• Pawel Laszczak's avatar
    usb: gadget: Fix issue with config_ep_by_speed function · 5d363120
    Pawel Laszczak authored
    This patch adds new config_ep_by_speed_and_alt function which
    extends the config_ep_by_speed about alt parameter.
    This additional parameter allows to find proper usb_ss_ep_comp_descriptor.
    
    Problem has appeared during testing f_tcm (BOT/UAS) driver function.
    
    f_tcm function for SS use array of headers for both  BOT/UAS alternate
    setting:
    
    static struct usb_descriptor_header *uasp_ss_function_desc[] = {
            (struct usb_descriptor_header *) &bot_intf_desc,
            (struct usb_descriptor_header *) &uasp_ss_bi_desc,
            (struct usb_descriptor_header *) &bot_bi_ep_comp_desc,
            (struct usb_descriptor_header *) &uasp_ss_bo_desc,
            (struct usb_descriptor_header *) &bot_bo_ep_comp_desc,
    
            (struct usb_descriptor_header *) &uasp_intf_desc,
            (struct usb_descriptor_header *) &uasp_ss_bi_desc,
            (struct usb_descriptor_header *) &uasp_bi_ep_comp_desc,
            (struct usb_descriptor_header *) &uasp_bi_pipe_desc,
            (struct usb_descriptor_header *) &uasp_ss_bo_desc,
            (struct usb_descriptor_header *) &uasp_bo_ep_comp_desc,
            (struct usb_descriptor_header *) &uasp_bo_pipe_desc,
            (struct usb_descriptor_header *) &uasp_ss_status_desc,
            (struct usb_descriptor_header *) &uasp_status_in_ep_comp_desc,
            (struct usb_descriptor_header *) &uasp_status_pipe_desc,
            (struct usb_descriptor_header *) &uasp_ss_cmd_desc,
            (struct usb_descriptor_header *) &uasp_cmd_comp_desc,
            (struct usb_descriptor_header *) &uasp_cmd_pipe_desc,
            NULL,
    };
    
    The first 5 descriptors are associated with BOT alternate setting,
    and others are associated with UAS.
    
    During handling UAS alternate setting f_tcm driver invokes
    config_ep_by_speed and this function sets incorrect companion endpoint
    descriptor in usb_ep object.
    
    Instead setting ep->comp_desc to uasp_bi_ep_comp_desc function in this
    case set ep->comp_desc to uasp_ss_bi_desc.
    
    This is due to the fact that it searches endpoint based on endpoint
    address:
    
            for_each_ep_desc(speed_desc, d_spd) {
                    chosen_desc = (struct usb_endpoint_descriptor *)*d_spd;
                    if (chosen_desc->bEndpoitAddress == _ep->address)
                            goto ep_found;
            }
    
    And in result it uses the descriptor from BOT alternate setting
    instead UAS.
    
    Finally, it causes that controller driver during enabling endpoints
    detect that just enabled endpoint for bot.
    Signed-off-by: default avatarJayshri Pawar <jpawar@cadence.com>
    Signed-off-by: default avatarPawel Laszczak <pawell@cadence.com>
    Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
    5d363120
composite.c 66.3 KB