Re: [RFC PATCH 2/2] USB: Set usb port's DevicerRemovable according acpi information in EHCI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2012年08月23日 22:10, Alan Stern wrote:
> On Thu, 23 Aug 2012, Lan Tianyu wrote:
> 
>>>>> Why not just update the ACPI information using the current hub
>>>>> descriptor?  You don't need to fetch the hub descriptor again.
>>>>>
>>>> You mean to set DeviceRemovable directly rather than via hub descriptor request
>>>> here, right?
>>>
>>> Right.  DeviceRemovable should be set in only one place, and this
>>> should be that place.
>>>
>> But if other places got hub descriptor, they can't get DeviceRemovable
>> value since we only set DeviceRemovable in the hub_configure().(e.g lsusb).
> 
> I don't understand.  lsusb will be able to see the DeviceRemovable 
> values in sysfs, won't it?
lsusb will issue get hub descriptor request in the usr space and print
DeviceRemovable.
e.g lsusb show on my machine.

Hub Descriptor:
  bLength               9
  bDescriptorType      41
  nNbrPorts             6
  wHubCharacteristic 0x0089
    Per-port power switching
    Per-port overcurrent protection
    TT think time 8 FS bits
    Port indicators
  bPwrOn2PwrGood       50 * 2 milli seconds
  bHubContrCurrent      0 milli Ampere
  DeviceRemovable    0x00	<====
  PortPwrCtrlMask    0xff
 Hub Port Status:
   Port 1: 0000.0303 lowspeed power enable connect
   Port 2: 0000.0100 power
   Port 3: 0000.0303 lowspeed power enable connect
   Port 4: 0000.0100 power
   Port 5: 0000.0100 power
   Port 6: 0000.0100 power

code in the usbutils/lsusb.c
do_hub()
{
	...
	ret = usb_control_msg(fd,
			LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS
			| LIBUSB_RECIPIENT_DEVICE,
			LIBUSB_REQUEST_GET_DESCRIPTOR,
			value << 8, 0,
			buf, sizeof buf, CTRL_TIMEOUT);
	...
	dump_hub("", buf, tt_type);
	...
}

dump_hub()
{
	...
	printf("%s  DeviceRemovable   ", prefix);
	...
}

So if we put setting DeviceRemovable in the hcd's hub descriptor request
routine, usr space could also get acpi information via getting hub
descriptor and we don't need to expose DeviceRemovable sysfs file.
> 
> Besides, there aren't any other places in the kernel that get the hub 
> descriptor.
Usr space may do this.

> 
>> Another problem is that some hcds will set DeviceRemovable themselves.
>> There will be a conflict between hcd and acpi information. Different
>> hcds may have different processes.
> 
> There is always the possibility of a conflict.  This remains true 
> whether you get the hub descriptor once or twice.
Yeah. how to deal with conflict
First time of getting the hub descriptor is to initialize hub and create
port devices. The second time is to update DeviceRemovable after
port devices create.

Another proposal is to set DeviceRemovable both in the hcd driver and
hub_configue() since hub probe maybe a special case. We have to get port
number first and then create port devices. Does this make sense?

> 
>>  So at first, I put setting
>> DeviceRemovable in the hcd's hub descriptor request routine.
> 
> But that is the wrong place to put it.  As you pointed out, when the 
> hub descriptor is requested we don't know how many ports there are and 
> so we can't set up the DeviceRemovable information.
This only works after the first hub descriptor request.

> 
> Alan Stern
> 


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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux