Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1421832pxb; Thu, 4 Nov 2021 01:55:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmqVgb/9dJC2B6sM+rZxvoNxTFWxGBqbvmZBhQt2Oo55nnZ7i40IsNfI35qoYp6nA6Njbh X-Received: by 2002:a6b:8e0c:: with SMTP id q12mr413320iod.187.1636016103467; Thu, 04 Nov 2021 01:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636016103; cv=none; d=google.com; s=arc-20160816; b=fFM5khyTZLR8ADMSunOzqCNyv1jozidndIbu1G81F9N79yOg6aR3NPqO845lhgsrOp HsAlcWIplBAjLX9ajUhUu+o9x/84+hKH90ccJHFV/CZj1rVOFgviHlhhgN+WMYYMBrwQ lFUysnFp9Q6NG2ZWp1at9fKYNqh/SuNO3PXdqLczOhZ7uC9AMKZYSQSdHt4Frb+nwJaJ 4lJY6yS9GWRkZcKBmAV2C8N+sCWdGyEDYZXGjsDWUDyYOs0w8IlAFVQ3VwJWT+PfO9l0 8LzihWNDQ4zUwMATr5dYxCsSQAOm6TfjwKVIgPYpTjtGwtQaZhjNDNH73HRtSGnnsmal ONsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=fRXR7pEfVihPg1PCMiQ0gjOxDihRz5GxFX7c4+oQyGE=; b=GFk8A0BPi4evQz0KiBLetTgnjlvYMuvIHBFr8QFKhnqE+Zj3ZW91ZnkR3v9pKgLdqC YuatabeKX8OuESCd4mucldb8dlGBkLycFRSbzIJu/dETgx/jonm40pgmId7kB/gLhK2H 8dbR/2UL/j8lesx/hGz7KqW5yg0T4H3E7nM7ouYB6onZkbvwBwkASrI+qD4gDB+fHtvN EQAJvP6Z6ZA/4BEmvzZXdR/4+fFsGamjCq67p8erXdHlG8Gt7KKcqR8kwz6yP+nTdy0l TWrGkyDQ6BHyMM9Tny4rhzJTjnAY/16HKVZo0OVLCGhaFWsrHOKLOPbouoAAijtnJJGo 2dyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q9si1503440jaj.121.2021.11.04.01.54.51; Thu, 04 Nov 2021 01:55:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230390AbhKDI4R (ORCPT + 99 others); Thu, 4 Nov 2021 04:56:17 -0400 Received: from verein.lst.de ([213.95.11.211]:34363 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230084AbhKDI4R (ORCPT ); Thu, 4 Nov 2021 04:56:17 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 89EB968AA6; Thu, 4 Nov 2021 09:53:36 +0100 (CET) Date: Thu, 4 Nov 2021 09:53:36 +0100 From: Christoph Hellwig To: Walter Wu Cc: Christoph Hellwig , Marek Szyprowski , Robin Murphy , Matthias Brugger , Ard Biesheuvel , Andrew Morton , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, wsd_upstream , linux-mediatek@lists.infradead.org Subject: Re: [PATCH v2] dma-direct: improve DMA_ATTR_NO_KERNEL_MAPPING Message-ID: <20211104085336.GA24260@lst.de> References: <20211104023221.16391-1-walter-zh.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211104023221.16391-1-walter-zh.wu@mediatek.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 04, 2021 at 10:32:21AM +0800, Walter Wu wrote: > diff --git a/include/linux/set_memory.h b/include/linux/set_memory.h > index f36be5166c19..6c7d1683339c 100644 > --- a/include/linux/set_memory.h > +++ b/include/linux/set_memory.h > @@ -7,11 +7,16 @@ > > #ifdef CONFIG_ARCH_HAS_SET_MEMORY > #include > + > +#ifndef CONFIG_RODATA_FULL_DEFAULT_ENABLED This is an arm64-specific symbol, and one that only controls a default. I don't think it is suitable to key off stubs in common code. > +static inline int set_memory_valid(unsigned long addr, int numpages, int enable) { return 0; } Pleae avoid overly long lines. > + if (IS_ENABLED(CONFIG_RODATA_FULL_DEFAULT_ENABLED)) { > + kaddr = (unsigned long)phys_to_virt(dma_to_phys(dev, *dma_handle)); This can just use page_address. > + /* page remove kernel mapping for arm64 */ > + set_memory_valid(kaddr, size >> PAGE_SHIFT, 0); > + } But more importantly: set_memory_valid only exists on arm64, this will break compile everywhere else. And this API is complete crap. Passing kernel virtual addresses as unsigned long just sucks, and passing an integer argument for valid/non-valid also is a horrible API. Not to mention the overly long line. Same on the free side.