All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: xhci Portsc register issue
       [not found] <CALuomMuUD4xSaCUT6MZn3ZV2gjXnuBUhkz78PgXZ6XgV4e-NvA@mail.gmail.com>
@ 2012-10-25 15:36 ` Sarah Sharp
  2012-10-25 16:45   ` Bjorn Helgaas
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Sarah Sharp @ 2012-10-25 15:36 UTC (permalink / raw)
  To: shashank chaturvedi; +Cc: linux-usb, linux-pci

On Thu, Oct 25, 2012 at 12:31:09PM +0530, shashank chaturvedi wrote:
> Hi sarah,
>              I am using Ubuntu 11.04 OS and NEC USB3.0 Host controller.
> I want to write the PLS [8:5] field in the PORTSC register through C
> program ,as per xhci spec first we have to write the LWS field
> I am doing that also,  But its unable to write above fields.
> Can you help me for how to write these field of PORTSC register?
> I am sending you the code below.  Please provide me the solution for
> writing the PLS field of PORTSC register

Why would you want to do that?  For link power management?  What is the
xHCI kernel driver not providing you such that you have to write a
userspace program?

If you're trying to write the PLS register from userspace while the xHCI
driver is loaded, I don't think that will work.  The PCI registers have
already been mapped by the xHCI driver, and I don't think another
program would be able to map them again.

But I'm not sure, since I've never attempted to memory map PCI registers
from userspace.  I was under the impression that you just can't do that.

Sarah Sharp

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

* Re: xhci Portsc register issue
  2012-10-25 15:36 ` xhci Portsc register issue Sarah Sharp
@ 2012-10-25 16:45   ` Bjorn Helgaas
  2012-10-25 22:37   ` Peter Stuge
  2012-10-26  7:12   ` Gerd Hoffmann
  2 siblings, 0 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2012-10-25 16:45 UTC (permalink / raw)
  To: Sarah Sharp; +Cc: shashank chaturvedi, linux-usb, linux-pci

On Thu, Oct 25, 2012 at 9:36 AM, Sarah Sharp
<sarah.a.sharp@linux.intel.com> wrote:
> On Thu, Oct 25, 2012 at 12:31:09PM +0530, shashank chaturvedi wrote:
>> Hi sarah,
>>              I am using Ubuntu 11.04 OS and NEC USB3.0 Host controller.
>> I want to write the PLS [8:5] field in the PORTSC register through C
>> program ,as per xhci spec first we have to write the LWS field
>> I am doing that also,  But its unable to write above fields.
>> Can you help me for how to write these field of PORTSC register?
>> I am sending you the code below.  Please provide me the solution for
>> writing the PLS field of PORTSC register
>
> Why would you want to do that?  For link power management?  What is the
> xHCI kernel driver not providing you such that you have to write a
> userspace program?
>
> If you're trying to write the PLS register from userspace while the xHCI
> driver is loaded, I don't think that will work.  The PCI registers have
> already been mapped by the xHCI driver, and I don't think another
> program would be able to map them again.
>
> But I'm not sure, since I've never attempted to memory map PCI registers
> from userspace.  I was under the impression that you just can't do that.

PORTSC looks like an xHCI-specific register that would be inside one
of the BARs (xHCI spec sec 5.4.8).  This would typically be mapped by
the driver.  Writing it from userspace behind the driver's back is
asking for trouble because the driver owns the device, and it won't be
aware of what you're doing.

PCI config space isn't mapped by drivers in the same way PCI BARs are,
and you can change things there with "setpci".  But again, this is
asking for trouble because those registers are really owned by the PCI
core, and things will go wrong if you change things behind its back.

Bjorn

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

* Re: xhci Portsc register issue
  2012-10-25 15:36 ` xhci Portsc register issue Sarah Sharp
  2012-10-25 16:45   ` Bjorn Helgaas
@ 2012-10-25 22:37   ` Peter Stuge
       [not found]     ` <CALuomMs-Z_PH3KpEPDgjBr5oy86Go2G2PAxu_k2yxgzWwRhJYQ@mail.gmail.com>
  2012-10-26  7:12   ` Gerd Hoffmann
  2 siblings, 1 reply; 5+ messages in thread
From: Peter Stuge @ 2012-10-25 22:37 UTC (permalink / raw)
  To: Sarah Sharp; +Cc: shashank chaturvedi, linux-usb, linux-pci

Sarah Sharp wrote:
> I'm not sure, since I've never attempted to memory map PCI registers
> from userspace.  I was under the impression that you just can't do that.

Need root, and the kernel still gets a say, but yes, you can just do that.

http://stuge.se/physrd.c


//Peter

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

* Re: xhci Portsc register issue
  2012-10-25 15:36 ` xhci Portsc register issue Sarah Sharp
  2012-10-25 16:45   ` Bjorn Helgaas
  2012-10-25 22:37   ` Peter Stuge
@ 2012-10-26  7:12   ` Gerd Hoffmann
  2 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2012-10-26  7:12 UTC (permalink / raw)
  To: Sarah Sharp; +Cc: shashank chaturvedi, linux-usb, linux-pci


  Hi,

> But I'm not sure, since I've never attempted to memory map PCI registers
> from userspace.  I was under the impression that you just can't do that.

You can mmap /sys/bus/pci/devices(${device}/resource0.  Just hacked up a
tool which dumps the capability registers this way:

http://www.kraxel.org/cgit/usb-tools/tree/usb-print-caps.c

cheers,
  Gerd


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

* Re: xhci Portsc register issue
       [not found]     ` <CALuomMs-Z_PH3KpEPDgjBr5oy86Go2G2PAxu_k2yxgzWwRhJYQ@mail.gmail.com>
@ 2012-10-26 17:17       ` Sarah Sharp
  0 siblings, 0 replies; 5+ messages in thread
From: Sarah Sharp @ 2012-10-26 17:17 UTC (permalink / raw)
  To: shashank chaturvedi; +Cc: linux-usb, linux-pci

On Fri, Oct 26, 2012 at 10:32:05AM +0530, shashank chaturvedi wrote:
> >Why would you want to do that?  For link power management?  What is the
> >xHCI kernel driver not providing you such that you have to write a
> >userspace program?
> 
> I want to do this for link power managment.But i am able to read & write
> the PORTPMSC register (as per xhci spec 5.4.9) from userspace program.Why
> not the PORTSC regsiter?

Do NOT do this from userspace!  You need to modify the xHCI kernel
driver to support link PM for your host controller.  The USB core has
specific times it disables link PM (e.g. before a device is reset) and
some drivers may require link PM to be disabled.  You are circumventing
kernel policy by writing the link PM registers from userspace.  Do NOT
do this!

Sarah Sharp

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

end of thread, other threads:[~2012-10-26 17:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CALuomMuUD4xSaCUT6MZn3ZV2gjXnuBUhkz78PgXZ6XgV4e-NvA@mail.gmail.com>
2012-10-25 15:36 ` xhci Portsc register issue Sarah Sharp
2012-10-25 16:45   ` Bjorn Helgaas
2012-10-25 22:37   ` Peter Stuge
     [not found]     ` <CALuomMs-Z_PH3KpEPDgjBr5oy86Go2G2PAxu_k2yxgzWwRhJYQ@mail.gmail.com>
2012-10-26 17:17       ` Sarah Sharp
2012-10-26  7:12   ` Gerd Hoffmann

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.