Re: [PATCH 1/2] usb: host: xhci: dynamically allocate devs array

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

 



Hi,

Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx> writes:
> On 24.11.2016 15:33, Felipe Balbi wrote:
>> Instead of always defaulting to a 256-entry array,
>> we can dynamically allocate devs based on what HW
>> tells us it supports.
>>
>> Note that we can't, yet, purge MAX_HC_SLOTS
>> completely because of struct
>> xhci_device_context_array reliance on it.
>>
>> Signed-off-by: Felipe Balbi <felipe.balbi@xxxxxxxxxxxxxxx>
>> ---
>>   drivers/usb/host/xhci-hub.c  |  2 +-
>>   drivers/usb/host/xhci-mem.c  |  4 ++--
>>   drivers/usb/host/xhci-ring.c |  2 +-
>>   drivers/usb/host/xhci.c      | 19 +++++++++++++++----
>>   drivers/usb/host/xhci.h      |  2 +-
>>   5 files changed, 20 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
>> index 0ef16900efed..7b1b58ad6aac 100644
>> --- a/drivers/usb/host/xhci-hub.c
>> +++ b/drivers/usb/host/xhci-hub.c
>> @@ -356,7 +356,7 @@ int xhci_find_slot_id_by_port(struct usb_hcd *hcd, struct xhci_hcd *xhci,
>>   	enum usb_device_speed speed;
>>
>>   	slot_id = 0;
>> -	for (i = 0; i < MAX_HC_SLOTS; i++) {
>> +	for (i = 0; i < HCS_MAX_SLOTS(xhci->hcs_params1); i++) {
>
> Normally that is what it should look like, but as we in xhci driver don't use
> xhci->devs[0], and xhci->devs[HCS_MAX_SLOTS(xhci->hcs_params1)] can be a valid
> virt_device it needs a +1.

Should HCS_MAX_SLOTS() already handle that, then?

> Same goes for everywhere else (also when allocating)
>
> This is probably originally due to that xhci hw returns a slot_id 0 for failure, and
> 1 to, including HCD_MAX_SLOTS[hcs_params1) for successful enable device command.
>
> the virt_dev is then straight allocated to xhci->devs[slot_id] = kzalloc(..)
>     
> -Mathias

-- 
balbi

Attachment: signature.asc
Description: PGP signature


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

  Powered by Linux