From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751062AbdJCHHz (ORCPT ); Tue, 3 Oct 2017 03:07:55 -0400 Received: from verein.lst.de ([213.95.11.211]:42001 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750720AbdJCHHy (ORCPT ); Tue, 3 Oct 2017 03:07:54 -0400 Date: Tue, 3 Oct 2017 09:07:52 +0200 From: Christoph Hellwig To: Miles Chen Cc: Christoph Hellwig , Robin Murphy , Marek Szyprowski , Andrew Morton , wsd_upstream@mediatek.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH v3] dma-debug: fix incorrect pfn calculation Message-ID: <20171003070752.GA18928@lst.de> References: <1506484087-1177-1-git-send-email-miles.chen@mediatek.com> <273077fd-c5ad-82c8-60aa-cde89355e5e8@arm.com> <20171001080449.GB11843@lst.de> <1506940241.28397.36.camel@mtkswgap22> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1506940241.28397.36.camel@mtkswgap22> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 02, 2017 at 06:30:41PM +0800, Miles Chen wrote: > ARCHs like metag and xtensa define their mappings (non-vmalloc and > non-linear) for dma allocation. metag basically is a reimplementation of the vmalloc map mechanism that should be easy to consolidate into the common one :( xtensa has a weird remapping into a different segment, something that I vaguely remember mips used to support as well. > These mapping types are architecture-dependent and should not be used > outside arch folders. So it is hard to check the mappings and convert > a virtual address to a correct pfn in lib/dam-debug.c > > How about recording only vmalloc (by is_vmalloc_addr()) and linear > address (by virt_addr_valid()) in lib/dma-debug? Since current > implementation is not correct for those ARCHs. > > if (!is_vmalloc_addr(addr) && !virt_addr_valid(addr)) > return; > > or This looks like a good start, although I'm not sure I'd trust virt_addr_valid on every little arch. In the worse case we'll have to exclude offenders from supporting dma debug, so let's go with that version. > > > > + entry->pfn = is_vmalloc_addr(virt) ? vmalloc_to_pfn(virt) : > > > > + page_to_pfn(virt_to_page(virt)); > > > > Please use normal if/else conditionsals: > > Is this for better readability? I'll send another patch for this. Yes.