linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Logan Gunthorpe <logang@deltatee.com>
To: "Koenig, Christian" <Christian.Koenig@amd.com>,
	Christoph Hellwig <hch@lst.de>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>
Subject: Re: [PATCH] PCI/P2PDMA: Root complex whitelist should not apply when an IOMMU is present
Date: Fri, 24 May 2019 10:06:26 -0600	[thread overview]
Message-ID: <60a2518c-b241-d7a3-28b4-da5b58f0d8d2@deltatee.com> (raw)
In-Reply-To: <c5b050f4-0584-8262-9285-f1c628ed4e27@amd.com>



On 2019-05-24 6:40 a.m., Koenig, Christian wrote:
> Am 23.05.19 um 17:59 schrieb Christoph Hellwig:
>> [CAUTION: External Email]
>>
>> On Thu, May 23, 2019 at 09:53:53AM -0600, Logan Gunthorpe wrote:
>>>> The problem shows up if pci_bus_address() returns a different address
>>>> than pci_resource_start(), should be easy to check if that happens.
>>>> IIRC it is something mostly seen on embedded SOCs.
>>>>
>>> I think it's a bit more complicated then that: If you're calling
>>> dma_map_resource() to program the IOMMU then I'm pretty sure you'd want
>>> to use the pci_resource_start() address as the phys_addr_t. If you're
>>> bypassing the root complex (like the current p2pdma code enforces), then
>>> you'd simply use a pci_bus_address() directly as the dma_addr and would
>>> not program the IOMMU at all seeing it's not involved (which is what is
>>> currently done).
>> True.  What we need is:
>>
>>   if (both device are behind the same root port (using a switch)) {
>>          use the current direct map + offset code
>>   } else {
>>          call ->map_resource()
>>   }
> 
> Sounds sane to me as well.
> 
> But since I don't have a struct pages backing my PCI BAR I won't be able 
> to use pci_p2pdma_map_sg.
> 
> How should we work around that?

I'd add something like:

int pci_p2pdma_map_resource(struct pci_dev *provider, struct device
*mapper, phys_addr_t addr, size_t size,  enum dma_data_direction dir,
unsigned long attrs);

But keep in mind we have to update pci_p2pdma_map_sg() as well before we
can enable the whitelist as there are existing users. The map_sg()
command should be able to get the provider device through the pgmap. And
that will be easier to do once Dan's patch[1] lands because he creates a
private pgmap struct.

Logan

[1]
https://lore.kernel.org/lkml/155727338646.292046.9922678317501435597.stgit@dwillia2-desk3.amr.corp.intel.com/T/#u

  parent reply	other threads:[~2019-05-24 16:06 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <a98bff67-a76e-4ddc-a317-96f2bdc9af72@email.android.com>
2019-05-22 20:41 ` [PATCH] PCI/P2PDMA: Root complex whitelist should not apply when an IOMMU is present Logan Gunthorpe
2019-05-23  8:12   ` Koenig, Christian
2019-05-23  9:43     ` Christoph Hellwig
2019-05-23  9:48       ` Koenig, Christian
2019-05-23  9:50         ` Christoph Hellwig
2019-05-23 10:06           ` Koenig, Christian
2019-05-23 10:26             ` Christoph Hellwig
2019-05-23 15:59               ` Logan Gunthorpe
2019-05-23 15:53           ` Logan Gunthorpe
2019-05-23 15:59             ` Christoph Hellwig
2019-05-24 12:40               ` Koenig, Christian
2019-05-24 14:12                 ` Christoph Hellwig
2019-05-24 16:18                   ` Logan Gunthorpe
2019-05-24 16:06                 ` Logan Gunthorpe [this message]
2019-05-23 16:14         ` Logan Gunthorpe
2019-05-23 15:47     ` Logan Gunthorpe
2019-05-22 20:12 Logan Gunthorpe
2019-06-18 20:40 ` Bjorn Helgaas
2019-06-18 20:51   ` Logan Gunthorpe
2019-06-18 23:50     ` Logan Gunthorpe
2019-06-19  9:26       ` Koenig, Christian
2019-06-19  9:29         ` Christoph Hellwig
2019-06-19  9:39           ` Koenig, Christian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60a2518c-b241-d7a3-28b4-da5b58f0d8d2@deltatee.com \
    --to=logang@deltatee.com \
    --cc=Christian.Koenig@amd.com \
    --cc=bhelgaas@google.com \
    --cc=hch@lst.de \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).