public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Question on using MSI in PCI driver
@ 2004-06-22  2:22 Roland Dreier
  2004-06-22  3:50 ` Jeff Garzik
  0 siblings, 1 reply; 12+ messages in thread
From: Roland Dreier @ 2004-06-22  2:22 UTC (permalink / raw)
  To: tom.l.nguyen, linux-kernel

I'm looking at implementing MSI/MSI-X support in a PCI device driver
I'm working on.  However, I've run into an issue with the MSI API that
I would like some clarification on.

When I call pci_enable_msi, since my device is MSI-X capable, the
kernel calls msix_capability_init, which works out the memory region
where vectors should be written and then calls request_region.  (In
fact it calls

             request_mem_region(phys_addr,
		dev_msi_cap * PCI_MSIX_ENTRY_SIZE,
		"MSI-X iomap Failure"))

which leads to a bizarre entry in /proc/iomem with the name "MSI-X
iomap Failure")

The problem is that if I follow the standard route in my driver and
call pci_request_regions() during init (since I want to claim my whole
device), the request_mem_region in msix_capability_init will fail.
Now, for my device, the MSI-X table happens to fall in the middle of a
BAR, and I need to access stuff on both sides of it in that BAR.  To
make things even worse for me, my device has two more BARs I want to claim.

So it seems I am forced to turn my nice clean pci_request_regions()
call into two calls to request_mem_region() (to get the beginning and
end of the BAR with the MSI-X table in it) and two more calls to
pci_request_region() (to get the other two BARs).

This isn't the end of the world but it feels suboptimal to me.  Anyone
have an idea for a better way to do this?  (I'm happy to write a patch
to the kernel if someone suggests how to change the MSI API)

Thanks,
  Roland

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

* Re: Question on using MSI in PCI driver
  2004-06-22  2:22 Roland Dreier
@ 2004-06-22  3:50 ` Jeff Garzik
  2004-06-22  3:54   ` Roland Dreier
  0 siblings, 1 reply; 12+ messages in thread
From: Jeff Garzik @ 2004-06-22  3:50 UTC (permalink / raw)
  To: Roland Dreier; +Cc: tom.l.nguyen, linux-kernel, Greg KH

Roland Dreier wrote:
> I'm looking at implementing MSI/MSI-X support in a PCI device driver
> I'm working on.  However, I've run into an issue with the MSI API that
> I would like some clarification on.
> 
> When I call pci_enable_msi, since my device is MSI-X capable, the
> kernel calls msix_capability_init, which works out the memory region
> where vectors should be written and then calls request_region.  (In
> fact it calls


Not answering your question directly, but...

You are breaking new ground by adding MSI support to a driver.  I thank 
you for this -- alot -- but you should realize there will probably be a 
little bit of PCI core work necessary in order to get things the way you 
want them.

Feel free to propose changes to the PCI core to accomodate your MSI driver.

	Jeff



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

* Re: Question on using MSI in PCI driver
  2004-06-22  3:50 ` Jeff Garzik
@ 2004-06-22  3:54   ` Roland Dreier
  2004-06-22  4:01     ` Jeff Garzik
  0 siblings, 1 reply; 12+ messages in thread
From: Roland Dreier @ 2004-06-22  3:54 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: tom.l.nguyen, linux-kernel, Greg KH

    Jeff> You are breaking new ground by adding MSI support to a
    Jeff> driver.  I thank you for this -- alot -- but you should
    Jeff> realize there will probably be a little bit of PCI core work
    Jeff> necessary in order to get things the way you want them.

Yes, I noticed only a couple of hotplug drivers seem to be using MSI,
and no one is using multiple vector support.  My motivation is
twofold.  First, because my device can generate interrupts for
different reasons, and I'm noticing that doing the MMIO read to the
cause register is taking a lot of time, so I'm wondering whether
avoiding this by having separate MSI-X messages will be a win.
Second, for the fun of trying it :)

    Jeff> Feel free to propose changes to the PCI core to accomodate
    Jeff> your MSI driver.

First patch coming up now :)

 - Roland



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

* Re: Question on using MSI in PCI driver
  2004-06-22  3:54   ` Roland Dreier
@ 2004-06-22  4:01     ` Jeff Garzik
  2004-06-22  4:04       ` Roland Dreier
  0 siblings, 1 reply; 12+ messages in thread
From: Jeff Garzik @ 2004-06-22  4:01 UTC (permalink / raw)
  To: Roland Dreier; +Cc: tom.l.nguyen, linux-kernel, Greg KH

Roland Dreier wrote:
>     Jeff> Feel free to propose changes to the PCI core to accomodate
>     Jeff> your MSI driver.
> 
> First patch coming up now :)


Cool.  If you are feeling generous or motivated, update 
Documentation/pci.txt too ;-)

Sharing your experiences will save time for others.

	Jeff



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

* Re: Question on using MSI in PCI driver
  2004-06-22  4:01     ` Jeff Garzik
@ 2004-06-22  4:04       ` Roland Dreier
  0 siblings, 0 replies; 12+ messages in thread
From: Roland Dreier @ 2004-06-22  4:04 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: tom.l.nguyen, linux-kernel, Greg KH

    Jeff> Cool.  If you are feeling generous or motivated, update
    Jeff> Documentation/pci.txt too ;-)

Will do, once I know what I'm doing :)

 - R.

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

* RE: Question on using MSI in PCI driver
@ 2004-06-22 15:24 Nguyen, Tom L
  2004-06-22 17:49 ` Roland Dreier
  0 siblings, 1 reply; 12+ messages in thread
From: Nguyen, Tom L @ 2004-06-22 15:24 UTC (permalink / raw)
  To: Roland Dreier, linux-kernel; +Cc: Nguyen, Tom L

On Monday, June 21, 2004 Roland Dreier wrote:

> The problem is that if I follow the standard route in my driver and
> call pci_request_regions() during init (since I want to claim my whole
> device), the request_mem_region in msix_capability_init will fail.
> Now, for my device, the MSI-X table happens to fall in the middle of a
> BAR, and I need to access stuff on both sides of it in that BAR.  To
> make things even worse for me, my device has two more BARs I want to
claim.
>
> So it seems I am forced to turn my nice clean pci_request_regions()
> call into two calls to request_mem_region() (to get the beginning and
> end of the BAR with the MSI-X table in it) and two more calls to
> pci_request_region() (to get the other two BARs).
>

The PCI 3.0 specification has implementation notes that MMIO address
space for a device's MSI-X structure should be isolated so that the 
software system can set different page for controlling accesses to 
the MSI-X structure. The implementation of MSI patch requires the PCI
subsystem, not a device driver, to maintain full control of the MSI-X
table/MSI-X PBA and MMIO address space of the MSI-X table/MSI-X PBA. 
A device driver is prohibited from requesting the MMIO address space 
of the MSI-X table/MSI-X PBA. Otherwise, the PCI subsystem will fail 
enabling MSI-X on its hardware device when it calls the function 
pci_enable_msi(). 

Thanks,
Long

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

* Re: Question on using MSI in PCI driver
  2004-06-22 15:24 Nguyen, Tom L
@ 2004-06-22 17:49 ` Roland Dreier
  0 siblings, 0 replies; 12+ messages in thread
From: Roland Dreier @ 2004-06-22 17:49 UTC (permalink / raw)
  To: Nguyen, Tom L; +Cc: linux-kernel

    Tom> The PCI 3.0 specification has implementation notes that MMIO
    Tom> address space for a device's MSI-X structure should be
    Tom> isolated so that the software system can set different page
    Tom> for controlling accesses to the MSI-X structure. The
    Tom> implementation of MSI patch requires the PCI subsystem, not a
    Tom> device driver, to maintain full control of the MSI-X
    Tom> table/MSI-X PBA and MMIO address space of the MSI-X
    Tom> table/MSI-X PBA. A device driver is prohibited from
    Tom> requesting the MMIO address space of the MSI-X table/MSI-X
    Tom> PBA. Otherwise, the PCI subsystem will fail enabling MSI-X on
    Tom> its hardware device when it calls the function
    Tom> pci_enable_msi().

Thanks.  I guess for the time being I will have to split up my request
region calls.

Do you think the msi subsystem should use a different name for the
MSI-X memory region ("MSI-X iomap Failure" seems very strange to me).

 - Roland

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

* RE: Question on using MSI in PCI driver
@ 2004-06-22 18:08 Nguyen, Tom L
  2004-06-22 18:26 ` Roland Dreier
  2004-06-22 19:51 ` Christoph Hellwig
  0 siblings, 2 replies; 12+ messages in thread
From: Nguyen, Tom L @ 2004-06-22 18:08 UTC (permalink / raw)
  To: Roland Dreier; +Cc: linux-kernel

On Tuesday, June 22, 2004 Roland Dreier wrote: 

>Do you think the msi subsystem should use a different name for the
>MSI-X memory region ("MSI-X iomap Failure" seems very strange to me).

What do you think of "Failure to request the MMIO address space of the
MSI-X PBA"?
Or what name do you suggest?

Thanks,
Long

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

* Re: Question on using MSI in PCI driver
  2004-06-22 18:08 Question on using MSI in PCI driver Nguyen, Tom L
@ 2004-06-22 18:26 ` Roland Dreier
  2004-06-22 19:51 ` Christoph Hellwig
  1 sibling, 0 replies; 12+ messages in thread
From: Roland Dreier @ 2004-06-22 18:26 UTC (permalink / raw)
  To: Nguyen, Tom L; +Cc: linux-kernel

    Tom> What do you think of "Failure to request the MMIO address
    Tom> space of the MSI-X PBA"?  Or what name do you suggest?

Unless I'm misunderstanding the code, nothing is failing, and it's not
the PBA being mapped.  You're ioremapping the the MSI-X vector table
so that the msi core can write vector values, etc.  So I would suggest
using a name of "MSI-X vector table" in the call to
request_mem_region.  (Remember that this name will be displayed in
/proc/iomem, and I don't think it makes sense to display "MSI-X iomap
Failure" to the user when MSI-X is set up and working).

 - Roland

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

* RE: Question on using MSI in PCI driver
@ 2004-06-22 18:43 Nguyen, Tom L
  0 siblings, 0 replies; 12+ messages in thread
From: Nguyen, Tom L @ 2004-06-22 18:43 UTC (permalink / raw)
  To: Roland Dreier; +Cc: linux-kernel

On Tuesday, June 22 Roland Dreier wrote:
> So I would suggest using a name of "MSI-X vector table" in the 
> call to request_mem_region.

Good!

Thanks,
Long



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

* Re: Question on using MSI in PCI driver
  2004-06-22 18:08 Question on using MSI in PCI driver Nguyen, Tom L
  2004-06-22 18:26 ` Roland Dreier
@ 2004-06-22 19:51 ` Christoph Hellwig
  2004-06-22 19:55   ` Roland Dreier
  1 sibling, 1 reply; 12+ messages in thread
From: Christoph Hellwig @ 2004-06-22 19:51 UTC (permalink / raw)
  To: Nguyen, Tom L; +Cc: Roland Dreier, linux-kernel

On Tue, Jun 22, 2004 at 11:08:04AM -0700, Nguyen, Tom L wrote:
> On Tuesday, June 22, 2004 Roland Dreier wrote: 
> 
> >Do you think the msi subsystem should use a different name for the
> >MSI-X memory region ("MSI-X iomap Failure" seems very strange to me).
> 
> What do you think of "Failure to request the MMIO address space of the
> MSI-X PBA"?
> Or what name do you suggest?

Why do you think you want "failure" in that string?   It's a name that
can be used to easily identify the MMIO region, and your sentence is a)
too long and b) doesn't make sense (at least to me, maybe I'm missing
something important).

Why not just "MSI-X PBA"?


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

* Re: Question on using MSI in PCI driver
  2004-06-22 19:51 ` Christoph Hellwig
@ 2004-06-22 19:55   ` Roland Dreier
  0 siblings, 0 replies; 12+ messages in thread
From: Roland Dreier @ 2004-06-22 19:55 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Nguyen, Tom L, linux-kernel

    Christoph> Why do you think you want "failure" in that string?
    Christoph> It's a name that can be used to easily identify the
    Christoph> MMIO region, and your sentence is a) too long and b)
    Christoph> doesn't make sense (at least to me, maybe I'm missing
    Christoph> something important).

Agreed (and I think Long agrees now too).

    Christoph> Why not just "MSI-X PBA"?

Just to be clear ... it's not actually the PBA, so I don't think
that's a good idea.  I believe my suggestion of "MSI-X vector table,"
which Long accepted, is the right name.

 - Roland

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

end of thread, other threads:[~2004-06-22 20:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-22 18:08 Question on using MSI in PCI driver Nguyen, Tom L
2004-06-22 18:26 ` Roland Dreier
2004-06-22 19:51 ` Christoph Hellwig
2004-06-22 19:55   ` Roland Dreier
  -- strict thread matches above, loose matches on Subject: below --
2004-06-22 18:43 Nguyen, Tom L
2004-06-22 15:24 Nguyen, Tom L
2004-06-22 17:49 ` Roland Dreier
2004-06-22  2:22 Roland Dreier
2004-06-22  3:50 ` Jeff Garzik
2004-06-22  3:54   ` Roland Dreier
2004-06-22  4:01     ` Jeff Garzik
2004-06-22  4:04       ` Roland Dreier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox