From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com ([192.55.52.120]:19433 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751323AbdAaP5K (ORCPT ); Tue, 31 Jan 2017 10:57:10 -0500 From: Felipe Balbi To: Krzysztof Opasiak , Linux USB Cc: stable@vger.kernel.org Subject: Re: [PATCH 2/2] usb: gadget: function: f_fs: pass companion descriptor along In-Reply-To: <19629578-9093-7087-067d-fc2619f974f0@samsung.com> References: <20170131130823.17237-1-felipe.balbi@linux.intel.com> <20170131130823.17237-2-felipe.balbi@linux.intel.com> <19629578-9093-7087-067d-fc2619f974f0@samsung.com> Date: Tue, 31 Jan 2017 17:56:31 +0200 Message-ID: <87y3xr5ikw.fsf@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: stable-owner@vger.kernel.org List-ID: Hi, Krzysztof Opasiak writes: > On 01/31/2017 02:08 PM, Felipe Balbi wrote: >> If we're dealing with SuperSpeed endpoints, we need >> to make sure to pass along the companion descriptor >> and initialize fields needed by the Gadget >> API. Eventually, f_fs.c should be converted to use >> config_ep_by_speed() like all other functions, >> though. >> >> Cc: >> Signed-off-by: Felipe Balbi >> --- >> >> Will be sent in a pull request during v4.11-rc >> >> drivers/usb/gadget/function/f_fs.c | 15 +++++++++++++-- >> 1 file changed, 13 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c >> index 87fccf611b69..86aba2ebb3ef 100644 >> --- a/drivers/usb/gadget/function/f_fs.c >> +++ b/drivers/usb/gadget/function/f_fs.c >> @@ -1833,11 +1833,14 @@ static int ffs_func_eps_enable(struct ffs_function *func) >> spin_lock_irqsave(&func->ffs->eps_lock, flags); >> while(count--) { >> struct usb_endpoint_descriptor *ds; >> + struct usb_ss_ep_comp_descriptor *comp_desc = NULL; >> + int needs_comp_desc = false; >> int desc_idx; >> >> - if (ffs->gadget->speed == USB_SPEED_SUPER) >> + if (ffs->gadget->speed == USB_SPEED_SUPER) { >> desc_idx = 2; >> - else if (ffs->gadget->speed == USB_SPEED_HIGH) >> + needs_comp_desc = true; >> + } else if (ffs->gadget->speed == USB_SPEED_HIGH) >> desc_idx = 1; >> else >> desc_idx = 0; >> @@ -1854,6 +1857,14 @@ static int ffs_func_eps_enable(struct ffs_function *func) >> >> ep->ep->driver_data = ep; >> ep->ep->desc = ds; >> + >> + comp_desc = (struct usb_ss_ep_comp_descriptor *)(ds + >> + USB_DT_ENDPOINT_SIZE); >> + ep->ep->maxburst = comp_desc->bMaxBurst + 1; >> + >> + if (needs_comp_desc) >> + ep->ep->comp_desc = comp_desc; >> + > > Please correct me if I'm wrong but wouldn't we read rubbish here if user > provided us SS ep descriptor without companion descriptor? companion desc is required for SS endpoints, it's also required that they follow EP desc. If user doesn't write it, don't they deserve the errors they'll have? -- balbi