Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1601056pxb; Thu, 4 Nov 2021 05:23:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqFKKUkZP5x/vNrEWRXMP/2Xiy9ZzP87kIHhxV1KTue9k/cLQQHBiK0zwy4/hhMzHCG2Le X-Received: by 2002:a17:907:1b0a:: with SMTP id mp10mr64084495ejc.29.1636028592556; Thu, 04 Nov 2021 05:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636028592; cv=none; d=google.com; s=arc-20160816; b=0CjH+CT+FaNujq3V9ixNxbUvLQ8NUXrDodWzK3yzMpNiD0TzDr9zzxglOhnIjId6m+ mBxnefXkHm7Ls0uncjag+5yKDGM1m5nJQ+wGWFObhSmxHV9v5dSpU+9xqhXSTEtYcfth IGMqqFjl6yr2WOwslvJcXARFpm5uktnEaK3bc46eqxzveOKm2JdzVJF+8UFvhrsEtuRK zo32L4pz1gqcFTronHWBijk2GUd9zIjA+HYqL+EotaTOweApceA98y9R++CTrcROEb0s 9FZ0RxBkb9XQ4mzPUKmbHOwhk/OhSJY0FI8821VD2FWclrHMFTaOUTtdWqRR0Omv1X2K tJzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=bn4Qu9/GY/iu6hJB7ys+4l6g1Nfofnm+bWrSasDLStM=; b=OIRDRm5EDzMs6aeXkI9cF0wSNH3m4SOppSuJWhv7UFTBIvVjk4QMu+x/EwuC/5dl+I P1lj6TJSYNY1XW9PsCWa2ywpCJQhO4MvXZSZ9CFnxnjccGQiqhtMH9uQxsbOJ1Avj+Z1 69kEc1Ix1IE6OS4DBGMBLlJ4sgAr6v59lEHyIL3B+w0wno1IkoTlNLTP0kC59hE3U0N/ LHH1PoCZPV7pzRKTus31w1KvPrsLOZyP6o6Lf54Qe2IHsnzSeyPBbZo1iCmHlqVW2R1z mBCjdhiOXKMriFh1oaZfIrNbY1NUW0Dxq6iUHp0JVlcRd7Qz0tHuUeDp5oh3p5kwHpCS Ec3g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m5si7603008edb.488.2021.11.04.05.22.46; Thu, 04 Nov 2021 05:23:12 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230509AbhKDMVP (ORCPT + 99 others); Thu, 4 Nov 2021 08:21:15 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:33270 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229843AbhKDMVO (ORCPT ); Thu, 4 Nov 2021 08:21:14 -0400 X-UUID: 731cec951b914e8b9b791b1b4e1d014f-20211104 X-UUID: 731cec951b914e8b9b791b1b4e1d014f-20211104 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1409694579; Thu, 04 Nov 2021 20:18:34 +0800 Received: from mtkmbs10n2.mediatek.inc (172.21.101.183) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Thu, 4 Nov 2021 20:18:33 +0800 Received: from mtksdccf07 (172.21.84.99) by mtkmbs10n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.3 via Frontend Transport; Thu, 4 Nov 2021 20:18:33 +0800 Message-ID: Subject: Re: [PATCH v2] dma-direct: improve DMA_ATTR_NO_KERNEL_MAPPING From: Walter Wu To: Christoph Hellwig CC: Marek Szyprowski , Robin Murphy , Matthias Brugger , "Ard Biesheuvel" , Andrew Morton , , , , wsd_upstream , Date: Thu, 4 Nov 2021 20:18:33 +0800 In-Reply-To: <20211104085336.GA24260@lst.de> References: <20211104023221.16391-1-walter-zh.wu@mediatek.com> <20211104085336.GA24260@lst.de> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2021-11-04 at 09:53 +0100, Christoph Hellwig wrote: > 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. > ok > > +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. > Would you think __kernel_map_page() is ok? Many arch support it, and only pass page and page number. but need to depend CONFIG_DEBUG_PAGEALLOC. Thanks. Walter > Not to mention the overly long line. Same on the free side.