Re: xhci Portsc register issue

2012-10-26 Thread Gerd Hoffmann

  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

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: xhci Portsc register issue

2012-10-26 Thread Sarah Sharp
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
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: xhci Portsc register issue

2012-10-25 Thread Sarah Sharp
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
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: xhci Portsc register issue

2012-10-25 Thread Bjorn Helgaas
On Thu, Oct 25, 2012 at 9:36 AM, Sarah Sharp
sarah.a.sh...@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
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: xhci Portsc register issue

2012-10-25 Thread Peter Stuge
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
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html