Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp875133pxj; Thu, 27 May 2021 13:48:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEcu7da9tyzcHZlushqoxz54zjKvSrOyLhIvbWPSfLa4VbG+0HsJ54+2uBQZX360lY9xWb X-Received: by 2002:a02:7348:: with SMTP id a8mr5195675jae.116.1622148509437; Thu, 27 May 2021 13:48:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622148509; cv=none; d=google.com; s=arc-20160816; b=KJ2ITx3+gJeCzpxCXyAIH5BkA1X+4Qj5Jan3lkeM2hhsc7n1+TvjjR1NgXnJKSOyec 9vDGliZ1SluAo+uze8PWf/3OiyzsowkO7yHzVZfwIM0GiYHlrXs8N4IT6FfWSpAu+4I2 T1WA3sL9Qk6HeJh1v5UQtuK4r0Q37qRkr9XuMATH0Ao7T4sGdriSFwghxZZWN2l9Y9mo BvcYp6vzaE+ht9MdxtIDTTyhMUIc6wS896gLSumuMm4CkbcR6SzWTE0iYcsjvyil4Ner 2y0SHpEzINhFpTzCcGUGFUOx9dc1hL8YwL74IdRIfTM3zxDzOwK4mPOAZMCGL44ismqO Zcng== 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 :dkim-signature; bh=qkPGCIOS3wC/xKGqc8LDOx3z/wTUMkpZTQaIk/g2YsM=; b=jhFnFogv73fCSq5GOFIDb4KDtSO0YWYA1+w30puPacjNuHHs1WTeG32PiTbXKfyE3C SqzwIn+g9iFAKTMYYeTHgMXhiCdFWEQar60SUj11UwsNYvX0U7IB5tRlkocW0fAdCpRe MjFYNgb7ZzhFMidPTpJ5i4tdM49CbuRUa0J/Nb787k+MPUMEvXCQrXp959/8v1q6pSDf xMB0mJqvZS1NB3Y9ODJ/RizgT1hMBoB0V+nN0To78YBS5HtjEYtX9AYjf/C4MG31Nl72 QdtY33+qHsJzMGPPXHNcO0OtXBk2pKC46oIfknJlBWSq7VUUkiaCkVuOTf3d++HMzL82 7z/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p4bPfFCD; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h6si3226883ili.157.2021.05.27.13.48.14; Thu, 27 May 2021 13:48:29 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p4bPfFCD; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233800AbhE0Lgn (ORCPT + 99 others); Thu, 27 May 2021 07:36:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:45674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233646AbhE0Lgk (ORCPT ); Thu, 27 May 2021 07:36:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2886A6113B; Thu, 27 May 2021 11:35:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622115307; bh=awWFyuDtGzTSFYuKnqnAwD8I2u8LvxPLkIedgwXpacY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=p4bPfFCD5PrcmECQ/JmYfkoIQvGIdlvd3Xmt5WsLHiji5zjF5hUpY/7jV/AEVHJHW CB6f9oBS2X3aNGgQ3+WcdNwOGV1gPRmBycO/zJJUoapgziqu+7IL5STMx1dAhYz3+T 0bM7UEMZILv76zqCaWO+pWXqjNmfb4VQ6CH4Qz9dn7I0OepvY2P5/VxhAaiFsn1JPd ce1hSAg7oNQpoYW+JbRsJjBqIARt3uf0TgyQ8bjr7saHdzXTBfM/jxaDHBHbhfTQ4Z nDFzJaE8tdL5MVg6406RffF7r/1Of9XzA/MNxWJkmUtb6zscbeJZBFAuG32Qt3uWbG DCkceG/OoqRLg== Date: Thu, 27 May 2021 12:34:57 +0100 From: Will Deacon To: Claire Chang Cc: heikki.krogerus@linux.intel.com, thomas.hellstrom@linux.intel.com, peterz@infradead.org, benh@kernel.crashing.org, joonas.lahtinen@linux.intel.com, dri-devel@lists.freedesktop.org, chris@chris-wilson.co.uk, grant.likely@arm.com, paulus@samba.org, Frank Rowand , mingo@kernel.org, sstabellini@kernel.org, Saravana Kannan , mpe@ellerman.id.au, "Rafael J . Wysocki" , Christoph Hellwig , Bartosz Golaszewski , bskeggs@redhat.com, linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org, Thierry Reding , intel-gfx@lists.freedesktop.org, matthew.auld@intel.com, linux-devicetree , Jianxiong Gao , Daniel Vetter , Konrad Rzeszutek Wilk , maarten.lankhorst@linux.intel.com, airlied@linux.ie, Dan Williams , linuxppc-dev@lists.ozlabs.org, jani.nikula@linux.intel.com, Rob Herring , rodrigo.vivi@intel.com, Bjorn Helgaas , boris.ostrovsky@oracle.com, Andy Shevchenko , jgross@suse.com, Nicolas Boichat , Greg KH , Randy Dunlap , lkml , "list@263.net:IOMMU DRIVERS" , Jim Quinlan , xypron.glpk@gmx.de, Robin Murphy , bauerman@linux.ibm.com Subject: Re: [PATCH v7 14/15] dt-bindings: of: Add restricted DMA pool Message-ID: <20210527113456.GA22019@willie-the-truck> References: <20210518064215.2856977-1-tientzu@chromium.org> <20210518064215.2856977-15-tientzu@chromium.org> <20210526121322.GA19313@willie-the-truck> <20210526155321.GA19633@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 27, 2021 at 07:29:20PM +0800, Claire Chang wrote: > On Wed, May 26, 2021 at 11:53 PM Will Deacon wrote: > > > > On Wed, May 26, 2021 at 01:13:22PM +0100, Will Deacon wrote: > > > On Tue, May 18, 2021 at 02:42:14PM +0800, Claire Chang wrote: > > > > @@ -138,4 +160,9 @@ one for multimedia processing (named multimedia-memory@77000000, 64MiB). > > > > memory-region = <&multimedia_reserved>; > > > > /* ... */ > > > > }; > > > > + > > > > + pcie_device: pcie_device@0,0 { > > > > + memory-region = <&restricted_dma_mem_reserved>; > > > > + /* ... */ > > > > + }; > > > > > > I still don't understand how this works for individual PCIe devices -- how > > > is dev->of_node set to point at the node you have above? > > > > > > I tried adding the memory-region to the host controller instead, and then > > > I see it crop up in dmesg: > > > > > > | pci-host-generic 40000000.pci: assigned reserved memory node restricted_dma_mem_reserved > > > > > > but none of the actual PCI devices end up with 'dma_io_tlb_mem' set, and > > > so the restricted DMA area is not used. In fact, swiotlb isn't used at all. > > > > > > What am I missing to make this work with PCIe devices? > > > > Aha, looks like we're just missing the logic to inherit the DMA > > configuration. The diff below gets things working for me. > > I guess what was missing is the reg property in the pcie_device node. > Will update the example dts. Thanks. I still think something like my diff makes sense, if you wouldn't mind including it, as it allows restricted DMA to be used for situations where the PCIe topology is not static. Perhaps we should prefer dev->of_node if it exists, but then use the node of the host bridge's parent node otherwise? Will