linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Requirement to get BAR pci_bus_address in user space
@ 2018-06-14 10:07 Srinath Mannam
  2018-06-14 10:20 ` Christoph Hellwig
  0 siblings, 1 reply; 10+ messages in thread
From: Srinath Mannam @ 2018-06-14 10:07 UTC (permalink / raw)
  To: Bjorn Helgaas, Christoph Hellwig, Abhishek Shah, Vikram Prakash
  Cc: linux-pci, linux-kernel, linux-nvme

Hi Bjorn,


We observed an issue in NVMe CMD cards in SPDK NVMe libraries.
Similar issue fixed with "nvme-pci: Use PCI bus address for
data/queues in CMB" commit in nvme kernel driver.
As per the fix, pci_bus_address of CMB bar is required to program to NVMe cards.

We need to implement similar fix for SPDK NVMe libraries also.

User space libraries get pci device resource information (resource phy
address, resource size) from resource file in sysfs.
But no mechanism available to get  pci_bus_address of corresponding
resource physical address in sysfs.

Please suggest me if any alternate mechanism available to get
pci_bus_address in user space.

Thank you.

Regards,
Srinath.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Requirement to get BAR pci_bus_address in user space
  2018-06-14 10:07 Requirement to get BAR pci_bus_address in user space Srinath Mannam
@ 2018-06-14 10:20 ` Christoph Hellwig
  2018-06-14 10:29   ` Srinath Mannam
  0 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2018-06-14 10:20 UTC (permalink / raw)
  To: Srinath Mannam
  Cc: Bjorn Helgaas, Christoph Hellwig, Abhishek Shah, Vikram Prakash,
	linux-pci, linux-kernel, linux-nvme

The only safe way to use PCI(e) devices in userspace is through vfio.
I think that is where you need to take your inquiries.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Requirement to get BAR pci_bus_address in user space
  2018-06-14 10:20 ` Christoph Hellwig
@ 2018-06-14 10:29   ` Srinath Mannam
  2018-06-14 10:33     ` okaya
  0 siblings, 1 reply; 10+ messages in thread
From: Srinath Mannam @ 2018-06-14 10:29 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Bjorn Helgaas, Abhishek Shah, Vikram Prakash, linux-pci,
	linux-kernel, linux-nvme, Alex Williamson, kvm

++ Alex Williamson, kvm,

Hi Christoph,

Thank you for quick reply.

If we want to add this in vfio then I think we need to do the same in
uio case also.

As I mentioned in previous mail, in the current implementation
resource information (address and size) is gathering from resource
named file created in /sys directory.
So I expect it would be better to have similar method as existing in sysfs.


Regards,
Srinath.

On Thu, Jun 14, 2018 at 3:50 PM, Christoph Hellwig <hch@lst.de> wrote:
> The only safe way to use PCI(e) devices in userspace is through vfio.
> I think that is where you need to take your inquiries.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Requirement to get BAR pci_bus_address in user space
  2018-06-14 10:29   ` Srinath Mannam
@ 2018-06-14 10:33     ` okaya
  2018-06-14 10:48       ` Srinath Mannam
  0 siblings, 1 reply; 10+ messages in thread
From: okaya @ 2018-06-14 10:33 UTC (permalink / raw)
  To: Srinath Mannam
  Cc: Christoph Hellwig, Bjorn Helgaas, Abhishek Shah, Vikram Prakash,
	linux-pci, linux-kernel, linux-nvme, Alex Williamson, kvm,
	linux-pci-owner

On 2018-06-14 06:29, Srinath Mannam wrote:
> ++ Alex Williamson, kvm,
> 
> Hi Christoph,
> 
> Thank you for quick reply.
> 
> If we want to add this in vfio then I think we need to do the same in
> uio case also.
> 
> As I mentioned in previous mail, in the current implementation
> resource information (address and size) is gathering from resource
> named file created in /sys directory.
> So I expect it would be better to have similar method as existing in 
> sysfs.
> 

Can you give some info on why you need the actual bar address value?

> 
> Regards,
> Srinath.
> 
> On Thu, Jun 14, 2018 at 3:50 PM, Christoph Hellwig <hch@lst.de> wrote:
>> The only safe way to use PCI(e) devices in userspace is through vfio.
>> I think that is where you need to take your inquiries.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Requirement to get BAR pci_bus_address in user space
  2018-06-14 10:33     ` okaya
@ 2018-06-14 10:48       ` Srinath Mannam
  2018-06-14 14:42         ` Keith Busch
  2018-06-14 14:50         ` Alex Williamson
  0 siblings, 2 replies; 10+ messages in thread
From: Srinath Mannam @ 2018-06-14 10:48 UTC (permalink / raw)
  To: Sinan Kaya
  Cc: Christoph Hellwig, Bjorn Helgaas, Abhishek Shah, Vikram Prakash,
	linux-pci, linux-kernel, linux-nvme, Alex Williamson, kvm,
	linux-pci-owner

Hi Sinan Kaya,

Here are the details,

The issue is, For CMB cards SQs are allocated inside device BAR memory
which is different from normal cards.
In Normal cards SQ memory allocated at host side.
In both the cases physical address of CQ memory is programmed in NVMe
controller register.
This method works for normal cards because CQ memory is at host side.
But in CMB cards pci bus address equivalent to CQ memory needs to program.

More details are in the patch: nvme-pci: Use PCI bus address for
data/queues in CMB.

With the above patch issue is fixed in the NVMe kernel driver, But
similar fix is required in SPDK library also.
So, We need a mechanism to get pci_bus_address in user space libraries
to address this issue.

Regards,
Srinath.


On Thu, Jun 14, 2018 at 4:03 PM,  <okaya@codeaurora.org> wrote:
> On 2018-06-14 06:29, Srinath Mannam wrote:
>>
>> ++ Alex Williamson, kvm,
>>
>> Hi Christoph,
>>
>> Thank you for quick reply.
>>
>> If we want to add this in vfio then I think we need to do the same in
>> uio case also.
>>
>> As I mentioned in previous mail, in the current implementation
>> resource information (address and size) is gathering from resource
>> named file created in /sys directory.
>> So I expect it would be better to have similar method as existing in
>> sysfs.
>>
>
> Can you give some info on why you need the actual bar address value?
>
>>
>> Regards,
>> Srinath.
>>
>> On Thu, Jun 14, 2018 at 3:50 PM, Christoph Hellwig <hch@lst.de> wrote:
>>>
>>> The only safe way to use PCI(e) devices in userspace is through vfio.
>>> I think that is where you need to take your inquiries.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Requirement to get BAR pci_bus_address in user space
  2018-06-14 10:48       ` Srinath Mannam
@ 2018-06-14 14:42         ` Keith Busch
  2018-06-14 14:50         ` Alex Williamson
  1 sibling, 0 replies; 10+ messages in thread
From: Keith Busch @ 2018-06-14 14:42 UTC (permalink / raw)
  To: Srinath Mannam
  Cc: Sinan Kaya, linux-pci-owner, Abhishek Shah, kvm, linux-pci,
	linux-kernel, linux-nvme, Vikram Prakash, Alex Williamson,
	Bjorn Helgaas, Christoph Hellwig

On Thu, Jun 14, 2018 at 04:18:15PM +0530, Srinath Mannam wrote:
> The issue is, For CMB cards SQs are allocated inside device BAR memory
> which is different from normal cards.
> In Normal cards SQ memory allocated at host side.
> In both the cases physical address of CQ memory is programmed in NVMe
> controller register.
> This method works for normal cards because CQ memory is at host side.
> But in CMB cards pci bus address equivalent to CQ memory needs to program.

How do you know if the address that you can see is even the real bus
address? You could be running against a direct assigned device in a
guest where you don't get to see the actual bus address.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Requirement to get BAR pci_bus_address in user space
  2018-06-14 10:48       ` Srinath Mannam
  2018-06-14 14:42         ` Keith Busch
@ 2018-06-14 14:50         ` Alex Williamson
  2018-06-14 14:59           ` Christoph Hellwig
  2018-06-14 20:04           ` Walker, Benjamin
  1 sibling, 2 replies; 10+ messages in thread
From: Alex Williamson @ 2018-06-14 14:50 UTC (permalink / raw)
  To: Srinath Mannam
  Cc: Sinan Kaya, Christoph Hellwig, Bjorn Helgaas, Abhishek Shah,
	Vikram Prakash, linux-pci, linux-kernel, linux-nvme, kvm,
	linux-pci-owner

On Thu, 14 Jun 2018 16:18:15 +0530
Srinath Mannam <srinath.mannam@broadcom.com> wrote:

> Hi Sinan Kaya,
> 
> Here are the details,
> 
> The issue is, For CMB cards SQs are allocated inside device BAR memory
> which is different from normal cards.
> In Normal cards SQ memory allocated at host side.
> In both the cases physical address of CQ memory is programmed in NVMe
> controller register.
> This method works for normal cards because CQ memory is at host side.
> But in CMB cards pci bus address equivalent to CQ memory needs to program.
> 
> More details are in the patch: nvme-pci: Use PCI bus address for
> data/queues in CMB.
> 
> With the above patch issue is fixed in the NVMe kernel driver, But
> similar fix is required in SPDK library also.
> So, We need a mechanism to get pci_bus_address in user space libraries
> to address this issue.

I don't understand the CQ vs CMB, but I think I gather that there's some
sort of buffer that's allocated from within the devices MMIO BAR and
some programming of the device needs to reference that buffer.
Wouldn't you therefore use the vfio type1 IOMMU MAP_DMA ioctl to map
the BAR into the IOVA address space and you can then use the IOVA +
offset into the BAR for the device to reference the buffer?  It seems
this is the same way we'd setup a peer-to-peer mapping, but we're using
it for the device to reference itself effectively.  Thanks,

Alex

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Requirement to get BAR pci_bus_address in user space
  2018-06-14 14:50         ` Alex Williamson
@ 2018-06-14 14:59           ` Christoph Hellwig
  2018-06-14 20:04           ` Walker, Benjamin
  1 sibling, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2018-06-14 14:59 UTC (permalink / raw)
  To: Alex Williamson
  Cc: Srinath Mannam, Sinan Kaya, Christoph Hellwig, Bjorn Helgaas,
	Abhishek Shah, Vikram Prakash, linux-pci, linux-kernel,
	linux-nvme, kvm, linux-pci-owner

On Thu, Jun 14, 2018 at 08:50:15AM -0600, Alex Williamson wrote:
> I don't understand the CQ vs CMB, but I think I gather that there's some
> sort of buffer that's allocated from within the devices MMIO BAR and
> some programming of the device needs to reference that buffer.
> Wouldn't you therefore use the vfio type1 IOMMU MAP_DMA ioctl to map
> the BAR into the IOVA address space and you can then use the IOVA +
> offset into the BAR for the device to reference the buffer?  It seems
> this is the same way we'd setup a peer-to-peer mapping, but we're using
> it for the device to reference itself effectively.  Thanks,

That's exactly what I meant..

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Requirement to get BAR pci_bus_address in user space
  2018-06-14 14:50         ` Alex Williamson
  2018-06-14 14:59           ` Christoph Hellwig
@ 2018-06-14 20:04           ` Walker, Benjamin
  2018-06-15  6:11             ` Srinath Mannam
  1 sibling, 1 reply; 10+ messages in thread
From: Walker, Benjamin @ 2018-06-14 20:04 UTC (permalink / raw)
  To: alex.williamson, srinath.mannam
  Cc: kvm, linux-kernel, vikram.prakash, okaya, hch, abhishek.shah,
	linux-nvme, linux-pci, linux-pci-owner, bhelgaas

On Thu, 2018-06-14 at 08:50 -0600, Alex Williamson wrote:
> On Thu, 14 Jun 2018 16:18:15 +0530
> Srinath Mannam <srinath.mannam@broadcom.com> wrote:
> 
> > Hi Sinan Kaya,
> > 
> > Here are the details,
> > 
> > The issue is, For CMB cards SQs are allocated inside device BAR memory
> > which is different from normal cards.
> > In Normal cards SQ memory allocated at host side.
> > In both the cases physical address of CQ memory is programmed in NVMe
> > controller register.
> > This method works for normal cards because CQ memory is at host side.
> > But in CMB cards pci bus address equivalent to CQ memory needs to program.
> > 
> > More details are in the patch: nvme-pci: Use PCI bus address for
> > data/queues in CMB.
> > 
> > With the above patch issue is fixed in the NVMe kernel driver, But
> > similar fix is required in SPDK library also.
> > So, We need a mechanism to get pci_bus_address in user space libraries
> > to address this issue.
> 
> I don't understand the CQ vs CMB, but I think I gather that there's some
> sort of buffer that's allocated from within the devices MMIO BAR and
> some programming of the device needs to reference that buffer.
> Wouldn't you therefore use the vfio type1 IOMMU MAP_DMA ioctl to map
> the BAR into the IOVA address space and you can then use the IOVA +
> offset into the BAR for the device to reference the buffer?  It seems
> this is the same way we'd setup a peer-to-peer mapping, but we're using
> it for the device to reference itself effectively.  Thanks,

SPDK already does this today. It's capable of placing submission and completion
queues in the device's controller memory buffer (CMB) and will do all of the
right things for both uio (look up physical address) and vfio (send
IOMMU_MAP_DMA ioctl to set a iova and use that). It additionally already
supports using the CMB as a target for peer-to-peer data transfers.

This was just confirmed to work on the most recent SPDK release. If you are not
on the most recent release, I recommend trying that first. If there is still
some issue, please do take it to the SPDK mailing list.

Thanks,
Ben

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Requirement to get BAR pci_bus_address in user space
  2018-06-14 20:04           ` Walker, Benjamin
@ 2018-06-15  6:11             ` Srinath Mannam
  0 siblings, 0 replies; 10+ messages in thread
From: Srinath Mannam @ 2018-06-15  6:11 UTC (permalink / raw)
  To: Walker, Benjamin
  Cc: alex.williamson, kvm, linux-kernel, vikram.prakash, okaya, hch,
	abhishek.shah, linux-nvme, linux-pci, linux-pci-owner, bhelgaas

Thank you very much Alex and Ben for all the details.

Please find my comments in lined..


On Fri, Jun 15, 2018 at 1:34 AM, Walker, Benjamin
<benjamin.walker@intel.com> wrote:
> On Thu, 2018-06-14 at 08:50 -0600, Alex Williamson wrote:
>> On Thu, 14 Jun 2018 16:18:15 +0530
>> Srinath Mannam <srinath.mannam@broadcom.com> wrote:
>>
>> > Hi Sinan Kaya,
>> >
>> > Here are the details,
>> >
>> > The issue is, For CMB cards SQs are allocated inside device BAR memory
>> > which is different from normal cards.
>> > In Normal cards SQ memory allocated at host side.
>> > In both the cases physical address of CQ memory is programmed in NVMe
>> > controller register.
>> > This method works for normal cards because CQ memory is at host side.
>> > But in CMB cards pci bus address equivalent to CQ memory needs to program.
>> >
>> > More details are in the patch: nvme-pci: Use PCI bus address for
>> > data/queues in CMB.
>> >
>> > With the above patch issue is fixed in the NVMe kernel driver, But
>> > similar fix is required in SPDK library also.
>> > So, We need a mechanism to get pci_bus_address in user space libraries
>> > to address this issue.
>>
>> I don't understand the CQ vs CMB, but I think I gather that there's some
Sorry, It was mistake, I meant SQ not CQ.
>> sort of buffer that's allocated from within the devices MMIO BAR and
>> some programming of the device needs to reference that buffer.
>> Wouldn't you therefore use the vfio type1 IOMMU MAP_DMA ioctl to map
>> the BAR into the IOVA address space and you can then use the IOVA +
>> offset into the BAR for the device to reference the buffer?  It seems
>> this is the same way we'd setup a peer-to-peer mapping, but we're using
>> it for the device to reference itself effectively.  Thanks,
>
> SPDK already does this today. It's capable of placing submission and completion
> queues in the device's controller memory buffer (CMB) and will do all of the
> right things for both uio (look up physical address) and vfio (send
> IOMMU_MAP_DMA ioctl to set a iova and use that). It additionally already
> supports using the CMB as a target for peer-to-peer data transfers.
>
> This was just confirmed to work on the most recent SPDK release. If you are not
> on the most recent release, I recommend trying that first. If there is still
> some issue, please do take it to the SPDK mailing list.
>
We are using SPDK version 18.04.
Is fix available in 18.04? Please point me to the patch with which fix
was added.

> Thanks,
> Ben

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-06-15  6:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-14 10:07 Requirement to get BAR pci_bus_address in user space Srinath Mannam
2018-06-14 10:20 ` Christoph Hellwig
2018-06-14 10:29   ` Srinath Mannam
2018-06-14 10:33     ` okaya
2018-06-14 10:48       ` Srinath Mannam
2018-06-14 14:42         ` Keith Busch
2018-06-14 14:50         ` Alex Williamson
2018-06-14 14:59           ` Christoph Hellwig
2018-06-14 20:04           ` Walker, Benjamin
2018-06-15  6:11             ` Srinath Mannam

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).