All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Logan Gunthorpe <logang@deltatee.com>,
	Christoph Hellwig <hch@infradead.org>
Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linaro-mm-sig@lists.linaro.org, amd-gfx@lists.freedesktop.org,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-media@vger.kernel.org
Subject: Re: [PATCH 2/8] PCI: Add pci_find_common_upstream_dev()
Date: Thu, 29 Mar 2018 20:15:33 +0200	[thread overview]
Message-ID: <e4d94265-e35e-316c-34ef-99ffaee8b657@amd.com> (raw)
In-Reply-To: <d2de0c2e-4c2d-9e46-1c26-bfa40ca662ff@deltatee.com>

Am 29.03.2018 um 18:25 schrieb Logan Gunthorpe:
>
> On 29/03/18 10:10 AM, Christian König wrote:
>> Why not? I mean the dma_map_resource() function is for P2P while other
>> dma_map_* functions are only for system memory.
> Oh, hmm, I wasn't aware dma_map_resource was exclusively for mapping
> P2P. Though it's a bit odd seeing we've been working under the
> assumption that PCI P2P is different as it has to translate the PCI bus
> address. Where as P2P for devices on other buses is a big unknown.

Yeah, completely agree. On my TODO list (but rather far down) is 
actually supporting P2P with USB devices.

And no, I don't have the slightest idea how to do this at the moment.

>>> And this is necessary to
>>> check if the DMA ops in use support it or not. We can't have the
>>> dma_map_X() functions do the wrong thing because they don't support it yet.
>> Well that sounds like we should just return an error from
>> dma_map_resources() when an architecture doesn't support P2P yet as Alex
>> suggested.
> Yes, well except in our patch-set we can't easily use
> dma_map_resources() as we either have SGLs to deal with or we need to
> create whole new interfaces to a number of subsystems.

Agree as well. I was also in clear favor of extending the SGLs to have a 
flag for this instead of the dma_map_resource() interface, but for some 
reason that didn't made it into the kernel.

>> You don't seem to understand the implications: The devices do have a
>> common upstream bridge! In other words your code would currently claim
>> that P2P is supported, but in practice it doesn't work.
> Do they? They don't on any of the Intel machines I'm looking at. The
> previous version of the patchset not only required a common upstream
> bridge but two layers of upstream bridges on both devices which would
> effectively limit transfers to PCIe switches only. But Bjorn did not
> like this.

At least to me that sounds like a good idea, it would at least disable 
(the incorrect) auto detection of P2P for such devices.

>> You need to include both drivers which participate in the P2P
>> transaction to make sure that both supports this and give them
>> opportunity to chicken out and in the case of AMD APUs even redirect the
>> request to another location (e.g. participate in the DMA translation).
> I don't think it's the drivers responsibility to reject P2P . The
> topology is what governs support or not. The discussions we had with
> Bjorn settled on if the devices are all behind the same bridge they can
> communicate with each other. This is essentially guaranteed by the PCI spec.

Well it is not only rejecting P2P, see the devices I need to worry about 
are essentially part of the CPU. Their resources looks like a PCI BAR to 
the BIOS and OS, but are actually backed by stolen system memory.

So as crazy as it sounds what you get is an operation which starts as 
P2P, but then the GPU drivers sees it and says: Hey please don't write 
that to my PCIe BAR, but rather system memory location X.

>> DMA-buf fortunately seems to handle all this already, that's why we
>> choose it as base for our implementation.
> Well, unfortunately DMA-buf doesn't help for the drivers we are working
> with as neither the block layer nor the RDMA subsystem have any
> interfaces for it.

A fact that gives me quite some sleepless nights as well. I think we 
sooner or later need to extend those interfaces to work with DMA-bufs as 
well.

I will try to give your patch set a review when I'm back from vacation 
and rebase my DMA-buf work on top of that.

Regards,
Christian.

>
> Logan

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: "Christian König" <christian.koenig@amd.com>
To: Logan Gunthorpe <logang@deltatee.com>,
	Christoph Hellwig <hch@infradead.org>
Cc: linaro-mm-sig@lists.linaro.org, amd-gfx@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-media@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>
Subject: Re: [PATCH 2/8] PCI: Add pci_find_common_upstream_dev()
Date: Thu, 29 Mar 2018 20:15:33 +0200	[thread overview]
Message-ID: <e4d94265-e35e-316c-34ef-99ffaee8b657@amd.com> (raw)
In-Reply-To: <d2de0c2e-4c2d-9e46-1c26-bfa40ca662ff@deltatee.com>

Am 29.03.2018 um 18:25 schrieb Logan Gunthorpe:
>
> On 29/03/18 10:10 AM, Christian König wrote:
>> Why not? I mean the dma_map_resource() function is for P2P while other
>> dma_map_* functions are only for system memory.
> Oh, hmm, I wasn't aware dma_map_resource was exclusively for mapping
> P2P. Though it's a bit odd seeing we've been working under the
> assumption that PCI P2P is different as it has to translate the PCI bus
> address. Where as P2P for devices on other buses is a big unknown.

Yeah, completely agree. On my TODO list (but rather far down) is 
actually supporting P2P with USB devices.

And no, I don't have the slightest idea how to do this at the moment.

>>> And this is necessary to
>>> check if the DMA ops in use support it or not. We can't have the
>>> dma_map_X() functions do the wrong thing because they don't support it yet.
>> Well that sounds like we should just return an error from
>> dma_map_resources() when an architecture doesn't support P2P yet as Alex
>> suggested.
> Yes, well except in our patch-set we can't easily use
> dma_map_resources() as we either have SGLs to deal with or we need to
> create whole new interfaces to a number of subsystems.

Agree as well. I was also in clear favor of extending the SGLs to have a 
flag for this instead of the dma_map_resource() interface, but for some 
reason that didn't made it into the kernel.

>> You don't seem to understand the implications: The devices do have a
>> common upstream bridge! In other words your code would currently claim
>> that P2P is supported, but in practice it doesn't work.
> Do they? They don't on any of the Intel machines I'm looking at. The
> previous version of the patchset not only required a common upstream
> bridge but two layers of upstream bridges on both devices which would
> effectively limit transfers to PCIe switches only. But Bjorn did not
> like this.

At least to me that sounds like a good idea, it would at least disable 
(the incorrect) auto detection of P2P for such devices.

>> You need to include both drivers which participate in the P2P
>> transaction to make sure that both supports this and give them
>> opportunity to chicken out and in the case of AMD APUs even redirect the
>> request to another location (e.g. participate in the DMA translation).
> I don't think it's the drivers responsibility to reject P2P . The
> topology is what governs support or not. The discussions we had with
> Bjorn settled on if the devices are all behind the same bridge they can
> communicate with each other. This is essentially guaranteed by the PCI spec.

Well it is not only rejecting P2P, see the devices I need to worry about 
are essentially part of the CPU. Their resources looks like a PCI BAR to 
the BIOS and OS, but are actually backed by stolen system memory.

So as crazy as it sounds what you get is an operation which starts as 
P2P, but then the GPU drivers sees it and says: Hey please don't write 
that to my PCIe BAR, but rather system memory location X.

>> DMA-buf fortunately seems to handle all this already, that's why we
>> choose it as base for our implementation.
> Well, unfortunately DMA-buf doesn't help for the drivers we are working
> with as neither the block layer nor the RDMA subsystem have any
> interfaces for it.

A fact that gives me quite some sleepless nights as well. I think we 
sooner or later need to extend those interfaces to work with DMA-bufs as 
well.

I will try to give your patch set a review when I'm back from vacation 
and rebase my DMA-buf work on top of that.

Regards,
Christian.

>
> Logan

  reply	other threads:[~2018-03-29 18:15 UTC|newest]

Thread overview: 161+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-25 10:59 [PATCH 1/8] lib/scatterlist: add sg_set_dma_addr() helper Christian König
2018-03-25 10:59 ` Christian König
     [not found] ` <20180325110000.2238-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-03-25 10:59   ` [PATCH 2/8] PCI: Add pci_find_common_upstream_dev() Christian König
2018-03-25 10:59     ` Christian König
2018-03-28 12:38     ` Christoph Hellwig
     [not found]       ` <20180328123830.GB25060-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2018-03-28 15:07         ` Christian König
2018-03-28 15:07           ` Christian König
2018-03-28 15:47           ` Logan Gunthorpe
2018-03-28 16:02             ` Christian König
2018-03-28 16:02               ` Christian König
2018-03-28 16:25               ` Logan Gunthorpe
     [not found]                 ` <16c7bef8-5f03-9e89-1f50-b62fb139a36f-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2018-03-28 18:28                   ` Christian König
2018-03-28 18:28                     ` Christian König
2018-03-28 18:57                     ` Logan Gunthorpe
     [not found]                       ` <e751cd28-f115-569f-5248-d24f30dee3cb-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2018-03-28 19:44                         ` Christian König
2018-03-28 19:44                           ` Christian König
2018-03-28 19:53                           ` Logan Gunthorpe
2018-03-29 11:44                             ` Christian König
2018-03-29 15:45                               ` Logan Gunthorpe
     [not found]                                 ` <98ce6cfd-bcf3-811e-a0f1-757b60da467a-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2018-03-29 16:10                                   ` Christian König
2018-03-29 16:10                                     ` Christian König
2018-03-29 16:25                                     ` Logan Gunthorpe
2018-03-29 18:15                                       ` Christian König [this message]
2018-03-29 18:15                                         ` Christian König
2018-03-30  1:58                                       ` Jerome Glisse
2018-03-30  1:58                                         ` Jerome Glisse
2018-03-30  6:33                                         ` Christoph Hellwig
2018-03-30  6:33                                           ` Christoph Hellwig
2018-03-30 15:25                                           ` Jerome Glisse
2018-03-30 18:46                                         ` Logan Gunthorpe
2018-03-30 19:45                                           ` Jerome Glisse
2018-03-30 19:45                                             ` Jerome Glisse
2018-04-02 17:02                                             ` Logan Gunthorpe
2018-04-02 17:20                                               ` Jerome Glisse
2018-04-02 17:20                                                 ` Jerome Glisse
2018-04-02 17:37                                                 ` Logan Gunthorpe
2018-04-02 19:16                                                   ` Jerome Glisse
2018-04-02 19:16                                                     ` Jerome Glisse
2018-04-02 19:32                                                     ` Logan Gunthorpe
2018-04-02 19:45                                                       ` Jerome Glisse
2018-04-02 19:45                                                         ` Jerome Glisse
     [not found]                             ` <CADnq5_P-z=Noos_jaME9_CERri3C-m2hPPvx2bArr36O=1FnrA@mail.gmail.com>
2018-03-29 14:37                               ` Alex Deucher
2018-03-29 14:37                                 ` Alex Deucher
2018-03-25 10:59   ` [PATCH 3/8] PCI: Add pci_peer_traffic_supported() Christian König
2018-03-25 10:59     ` Christian König
2018-03-25 10:59   ` [PATCH 5/8] drm/amdgpu: print DMA-buf status in debugfs Christian König
2018-03-25 10:59     ` Christian König
2018-03-25 10:59   ` [PATCH 6/8] drm/amdgpu: note that we can handle peer2peer DMA-buf Christian König
2018-03-25 10:59     ` Christian König
2018-03-25 10:59   ` [PATCH 7/8] drm/amdgpu: add amdgpu_gem_attach Christian König
2018-03-25 10:59     ` Christian König
2018-03-25 11:00   ` [PATCH 8/8] drm/amdgpu: add support for exporting VRAM using DMA-buf Christian König
2018-03-25 11:00     ` Christian König
2018-03-25 10:59 ` [PATCH 4/8] dma-buf: add peer2peer flag Christian König
2018-03-25 10:59   ` Christian König
     [not found]   ` <20180325110000.2238-4-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-03-29  6:57     ` Daniel Vetter
2018-03-29  6:57       ` Daniel Vetter
     [not found]       ` <20180329065753.GD3881-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-03-29 11:34         ` Christian König
2018-03-29 11:34           ` Christian König
     [not found]           ` <8b823458-8bdc-3217-572b-509a28aae742-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-04-03  9:09             ` Daniel Vetter
2018-04-03  9:09               ` Daniel Vetter
     [not found]               ` <20180403090909.GN3881-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-04-03 17:06                 ` Jerome Glisse
2018-04-03 17:06                   ` Jerome Glisse
     [not found]                   ` <20180403170645.GB5935-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-04-03 18:08                     ` Daniel Vetter
2018-04-03 18:08                       ` Daniel Vetter
2018-04-16 12:39                       ` Christoph Hellwig
2018-04-16 12:39                         ` Christoph Hellwig
     [not found]                         ` <20180416123937.GA9073-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2018-04-16 13:38                           ` Daniel Vetter
2018-04-16 13:38                             ` Daniel Vetter
2018-04-19  8:16                             ` Christoph Hellwig
2018-04-19  8:16                               ` Christoph Hellwig
     [not found]                               ` <20180419081657.GA16735-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2018-04-20  7:13                                 ` Daniel Vetter
2018-04-20  7:13                                   ` Daniel Vetter
     [not found]                                   ` <20180420071312.GF31310-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-04-20  8:58                                     ` Christian König
2018-04-20  8:58                                       ` Christian König
2018-04-20 10:17                                       ` Christoph Hellwig
2018-04-20 10:17                                         ` Christoph Hellwig
     [not found]                                         ` <20180420101755.GA11400-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2018-04-20 10:44                                           ` Christian König
2018-04-20 10:44                                             ` Christian König
2018-04-20 12:46                                             ` Christoph Hellwig
2018-04-20 15:21                                               ` [Linaro-mm-sig] " Daniel Vetter
2018-04-24 18:48                                                 ` Christoph Hellwig
2018-04-24 18:48                                                   ` Christoph Hellwig
2018-04-24 19:32                                                   ` Daniel Vetter
2018-04-24 19:32                                                     ` Daniel Vetter
2018-04-25  5:48                                                     ` Christoph Hellwig
2018-04-25  5:48                                                       ` Christoph Hellwig
     [not found]                                                       ` <20180425054855.GA17038-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2018-04-25  6:10                                                         ` Alex Deucher
2018-04-25  6:10                                                           ` Alex Deucher
2018-04-25  6:13                                                       ` Daniel Vetter
2018-04-25  6:13                                                         ` Daniel Vetter
2018-04-25  6:23                                                         ` Daniel Vetter
2018-04-25  6:23                                                           ` Daniel Vetter
2018-04-25  6:43                                                           ` Christoph Hellwig
2018-04-25  6:43                                                             ` Christoph Hellwig
     [not found]                                                             ` <20180425064335.GB28100-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2018-04-25  7:02                                                               ` Daniel Vetter
2018-04-25  7:02                                                                 ` Daniel Vetter
2018-04-25  7:09                                                                 ` Christoph Hellwig
2018-04-25  7:09                                                                   ` Christoph Hellwig
     [not found]                                                                   ` <20180425070905.GA24827-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2018-04-25  7:30                                                                     ` Daniel Vetter
2018-04-25  7:30                                                                       ` Daniel Vetter
2018-04-25  7:56                                                                       ` Thierry Reding
2018-04-25  7:56                                                                         ` Thierry Reding
2018-04-25  8:55                                                                         ` Christoph Hellwig
2018-04-25  8:55                                                                           ` Christoph Hellwig
2018-04-25  7:43                                                                   ` Thierry Reding
2018-04-25  7:43                                                                     ` Thierry Reding
2018-04-25  7:41                                                             ` Thierry Reding
2018-04-25  7:41                                                               ` Thierry Reding
2018-04-25  8:54                                                               ` noveau vs arm dma ops Christoph Hellwig
2018-04-25  8:54                                                                 ` Christoph Hellwig
2018-04-25  8:54                                                                 ` Christoph Hellwig
2018-04-25  9:25                                                                 ` Russell King - ARM Linux
2018-04-25  9:25                                                                   ` Russell King - ARM Linux
2018-04-25 10:04                                                                 ` Daniel Vetter
2018-04-25 10:04                                                                   ` Daniel Vetter
2018-04-25 10:04                                                                   ` Daniel Vetter
2018-04-25 15:33                                                                   ` Christoph Hellwig
2018-04-25 15:33                                                                     ` Christoph Hellwig
2018-04-25 15:33                                                                     ` Christoph Hellwig
     [not found]                                                                     ` <20180425153312.GD27076-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2018-04-25 21:35                                                                       ` Daniel Vetter
2018-04-25 21:35                                                                         ` Daniel Vetter
2018-04-25 21:35                                                                         ` Daniel Vetter
2018-04-25 23:26                                                                         ` Russell King - ARM Linux
2018-04-25 23:26                                                                           ` Russell King - ARM Linux
     [not found]                                                                           ` <20180425232646.GR16141-l+eeeJia6m9URfEZ8mYm6t73F7V6hmMc@public.gmane.org>
2018-04-26  9:17                                                                             ` Daniel Vetter
2018-04-26  9:17                                                                               ` Daniel Vetter
2018-04-26  9:17                                                                               ` Daniel Vetter
2018-04-26  9:09                                                                         ` Christoph Hellwig
2018-04-26  9:09                                                                           ` Christoph Hellwig
2018-04-26  9:09                                                                           ` Christoph Hellwig
     [not found]                                                                           ` <20180426090942.GA18811-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2018-04-26  9:45                                                                             ` Daniel Vetter
2018-04-26  9:45                                                                               ` Daniel Vetter
2018-04-26  9:45                                                                               ` Daniel Vetter
2018-04-26 11:12                                                                           ` Russell King - ARM Linux
2018-04-26 11:12                                                                             ` Russell King - ARM Linux
2018-04-25 22:54                                                                     ` Russell King - ARM Linux
2018-04-25 22:54                                                                       ` Russell King - ARM Linux
2018-04-26  9:13                                                                       ` Christoph Hellwig
2018-04-26  9:13                                                                         ` Christoph Hellwig
2018-04-26  9:13                                                                         ` Christoph Hellwig
2018-04-26  9:20                                                                       ` [Linaro-mm-sig] " Daniel Vetter
2018-04-26  9:20                                                                         ` Daniel Vetter
2018-04-26  9:20                                                                         ` Daniel Vetter
     [not found]                                                                         ` <CAKMK7uG9R6paoP4BmvqDVUP_4Db4Dz8MSXeLwUBMYaORa5-kVw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-04-26  9:24                                                                           ` Christoph Hellwig
2018-04-26  9:24                                                                             ` Christoph Hellwig
2018-04-26  9:24                                                                             ` Christoph Hellwig
2018-04-26  9:39                                                                             ` Daniel Vetter
2018-04-26  9:39                                                                               ` Daniel Vetter
2018-04-26  9:39                                                                               ` Daniel Vetter
     [not found]                                                         ` <CAKMK7uEFitkNQrD6cLX5Txe11XhVO=LC4YKJXH=VNdq+CY=DjQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-04-25  6:24                                                           ` [Linaro-mm-sig] [PATCH 4/8] dma-buf: add peer2peer flag Alex Deucher
2018-04-25  6:24                                                             ` Alex Deucher
2018-04-25  6:41                                                             ` Christoph Hellwig
2018-04-25  6:41                                                               ` Christoph Hellwig
     [not found]                                                               ` <20180425064118.GA28100-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2018-04-25 17:44                                                                 ` Alex Deucher
2018-04-25 17:44                                                                   ` Alex Deucher
2018-04-25 18:38                                                                   ` Dan Williams
2018-04-25 18:38                                                                     ` Dan Williams
2018-05-04 12:45                                                                   ` Lucas Stach
2018-03-28 12:37 ` [PATCH 1/8] lib/scatterlist: add sg_set_dma_addr() helper Christoph Hellwig
2018-03-28 12:37   ` Christoph Hellwig

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=e4d94265-e35e-316c-34ef-99ffaee8b657@amd.com \
    --to=christian.koenig@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=bhelgaas@google.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hch@infradead.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=logang@deltatee.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.