From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BD51C47089 for ; Thu, 27 May 2021 12:56:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DA25613CC for ; Thu, 27 May 2021 12:56:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235943AbhE0M5s (ORCPT ); Thu, 27 May 2021 08:57:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235986AbhE0M5l (ORCPT ); Thu, 27 May 2021 08:57:41 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C9F6C061763 for ; Thu, 27 May 2021 05:56:08 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id y202so512020pfc.6 for ; Thu, 27 May 2021 05:56:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=t9nQbEpq5kzp2vshpX/2KDY0MEdzNS47SlLJX4RAhzA=; b=XnDncQEfy0WK93TP5b5iaOvQy6p3tli5hK7U2lnqkRYfpimdp+9WScU0B/bVffV6lu KHvuv/cILlR7hwxjPwG4fSm8TLb0M0uiiQtfQGCy1lJiDeCNSlZdr9ro+4UoS7qK25VN Vwx6crrIG7NXb3xhmTS0AaKdDSprMjL64yAgA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=t9nQbEpq5kzp2vshpX/2KDY0MEdzNS47SlLJX4RAhzA=; b=Y6yIdQKUeByVC0YMjZEAihzApySJ4mF/gqjJZF2NufVYtXnaP69kWcxPEb61CQxAJP aMiPJbWliFmeO8KB9bARt6Mn+g+g9kh9aCv6wKW9TGEDonmYC9x++LFrja4CbsLbeIqh PIS+X3p0lykWa9etMTpWf6dSCjc4zSg7CiXKjQGrKPCaC4BmVYJfo6V8lXClaRc7vNp0 MvrGkBRWdykrprm2CZAWG8J+S3aHQUqmQxF+XB8OW3VESDjM2CCiigjTMYjWpXIGKFjR TXy76ey9D6b360S2qWzjuJ34I+s8wj1LNeOrL5kjNMiTzJUn0V1MZpC9gf+htjGEZHjy aYFQ== X-Gm-Message-State: AOAM5337TPbOA8bpF6zBUWhBFXTPBmp1UAxGhv5Aga2B8DJn0iCwvUME AcY1lx82HpeY/hsb7dAiZlyih1/nM9aXbQ== X-Google-Smtp-Source: ABdhPJwyhy8n1WGWvhoNqX3us1FMqir0idbssbwMh3j6mCmHBdwYDyc8aXj4CtYm9XmMLQ/zmZAc2A== X-Received: by 2002:a63:b545:: with SMTP id u5mr3572613pgo.261.1622120167355; Thu, 27 May 2021 05:56:07 -0700 (PDT) Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com. [209.85.210.179]) by smtp.gmail.com with ESMTPSA id q35sm1216580pja.56.2021.05.27.05.56.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 May 2021 05:56:07 -0700 (PDT) Received: by mail-pf1-f179.google.com with SMTP id d78so496848pfd.10 for ; Thu, 27 May 2021 05:56:06 -0700 (PDT) X-Received: by 2002:a92:2907:: with SMTP id l7mr2908573ilg.64.1622119750871; Thu, 27 May 2021 05:49:10 -0700 (PDT) MIME-Version: 1.0 References: <20210518064215.2856977-1-tientzu@chromium.org> <20210518064215.2856977-15-tientzu@chromium.org> <20210526121322.GA19313@willie-the-truck> <20210526155321.GA19633@willie-the-truck> <20210527113456.GA22019@willie-the-truck> In-Reply-To: <20210527113456.GA22019@willie-the-truck> From: Claire Chang Date: Thu, 27 May 2021 20:48:59 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v7 14/15] dt-bindings: of: Add restricted DMA pool To: Will Deacon 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Thu, May 27, 2021 at 7:35 PM Will Deacon wrote: > > 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? Sure. Let me add in the next version. > > Will