From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8511C1E8354 for ; Tue, 1 Apr 2025 07:43:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.33 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743493420; cv=none; b=lWWZPEQpYH2IMKfnTin/Gc+DeNlNJis7rdm/YXSOp+daeZ4eCFnNQ1AC4cFLUz/sxHj4ilBySaBe0rmNoLEqoXnfcV0JLmZHNVvHd1n8W4UJdZSLEBlOnfSdzjbRdB7S0MgZ502eyatYj1UtUdgkTpTKRGV/zPHOj4ZPrlUP+As= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743493420; c=relaxed/simple; bh=qr/8p1o91A5TlRegE4wC9I4CaxqpQPBlCpEyH0NznAI=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:In-Reply-To: Content-Type:References; b=gv1y4flmjZwjb5xm1bkNIEf4rEkjww3FMPxWy8mntd9GG/Led0nevKGL9giX/Ot9Af/HjTWw3p1ChsmsbK5KY7g1Jx8eDPKu+j31yaj8AefTzafoFlE8+mxtkOWGXBrYDZDj2BvgGranAsq6KMCA6zK24j8wv8EZMAK3zHSolCs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=QTE4g73O; arc=none smtp.client-ip=203.254.224.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="QTE4g73O" Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20250401074336epoutp037f1b9baa35354fc91588dae8573f6148~yIgZ3jzuY1671116711epoutp03M for ; Tue, 1 Apr 2025 07:43:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20250401074336epoutp037f1b9baa35354fc91588dae8573f6148~yIgZ3jzuY1671116711epoutp03M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1743493416; bh=GwjWeunkq1l/5B88bKkJLajuB8wNS63pQ2RF9huwFp4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=QTE4g73OXPu9KwnhufaowLlEVDu7/U5BcYe9r7NlzOX06rY8RnRQcR3QbOAKudqXw kj7atnF5IE4LrAcEJgkpGL/kobcolV5Qj2IFusnFaOoiM9QvfV6EAK/X6JQWxJ+SCX BSJGqgxYI2Rwdrp/6BloLvBkC06bRE1iTahBNrw4= Received: from epsnrtp01.localdomain (unknown [182.195.42.153]) by epcas2p2.samsung.com (KnoxPortal) with ESMTPS id 20250401074336epcas2p2f02591cd926c46cb5e4b13bf24739f54~yIgZboA4c0122401224epcas2p2h; Tue, 1 Apr 2025 07:43:36 +0000 (GMT) Received: from epsmgec2p1-new.samsung.com (unknown [182.195.36.100]) by epsnrtp01.localdomain (Postfix) with ESMTP id 4ZRg3W673Bz6B9mM; Tue, 1 Apr 2025 07:43:35 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmgec2p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 7E.B1.37303.7299BE76; Tue, 1 Apr 2025 16:43:35 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p4.samsung.com (KnoxPortal) with ESMTPA id 20250401074335epcas2p478e462b41a0091bb8c3b438427ba33f4~yIgYNQxQ_1848418484epcas2p4B; Tue, 1 Apr 2025 07:43:35 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20250401074335epsmtrp18995c1031bb6821b387f8bf0e83dfac3~yIgYMKBsG3035630356epsmtrp1a; Tue, 1 Apr 2025 07:43:35 +0000 (GMT) X-AuditID: b6c32a4d-541ff700000091b7-20-67eb99270135 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 62.6B.19478.6299BE76; Tue, 1 Apr 2025 16:43:35 +0900 (KST) Received: from ubuntu (unknown [10.229.95.128]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20250401074334epsmtip18f2d5902c32751d094e1bf2f9e18e927~yIgX8OJwM1407114071epsmtip1X; Tue, 1 Apr 2025 07:43:34 +0000 (GMT) Date: Tue, 1 Apr 2025 16:52:47 +0900 From: Jung Daehwan To: Puma Hsu Cc: Wesley Cheng , srinivas.kandagatla@linaro.org, mathias.nyman@intel.com, perex@perex.cz, conor+dt@kernel.org, dmitry.torokhov@gmail.com, corbet@lwn.net, broonie@kernel.org, lgirdwood@gmail.com, krzk+dt@kernel.org, pierre-louis.bossart@linux.intel.com, Thinh.Nguyen@synopsys.com, tiwai@suse.com, robh@kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-sound@vger.kernel.org, linux-input@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH v36 05/31] usb: host: xhci: Notify xHCI sideband on transfer ring free Message-ID: <20250401075247.GF98772@ubuntu> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Brightmail-Tracker: H4sIAAAAAAAAA02Te0xTdxT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IcLErivMo5nSlC AumJJanZqakFqUUwWSYOTqkGJvXM7TnWG52XLltfzV1rtmDG4aMsT7OLX62UO/+83H9tb/K2 BMF2n4scfPKeH9Uurq+wW9Bh/jq/vC7Tr2hH1/toOXlj122Ve5zS5WzvuVZcXmVyxUhjRbKd RW2o7qY5U09KVXZ++Ke2LiNQoD9qsZiVY7Ry47azDs8uWjVqZsWvjT6gvfOOXtK7Pk9xbiO+ 27Fcs+Z/Ls50Vbj46IDknswDT0691Oz45JCzTelMzP47f66qxS/pd3KslhL4pX5sT+jHzVkn rGVqny3l4H+//Uzj1CUm2mWfczqcT3yz6Yv+wBJ4g+vxtISin2ssbkbESRjsYY8OF+reGr1b bM9flj8sZ/0l7RcvKhLdJXpLiaU4I9FQi7moOBEAP5iQ/HgDAAA= X-CMS-MailID: 20250401074335epcas2p478e462b41a0091bb8c3b438427ba33f4 X-Msg-Generator: CA Content-Type: multipart/mixed; boundary="----BWvmtLGreXPtZv31XE49129YoyRr4_KGUd.k-ILdCyGA2LCZ=_6a960_" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20250328074643epcas2p4cee289bcb682528d34b5676770363e01 References: <20250319005141.312805-1-quic_wcheng@quicinc.com> <20250319005141.312805-6-quic_wcheng@quicinc.com> ------BWvmtLGreXPtZv31XE49129YoyRr4_KGUd.k-ILdCyGA2LCZ=_6a960_ Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Disposition: inline On Fri, Mar 28, 2025 at 03:45:00PM +0800, Puma Hsu wrote: > On Wed, Mar 19, 2025 at 8:52 AM Wesley Cheng wrote: > > > > In the case of handling a USB bus reset, the xhci_discover_or_reset_device > > can run without first notifying the xHCI sideband client driver to stop or > > prevent the use of the transfer ring. It was seen that when a bus reset > > situation happened, the USB offload driver was attempting to fetch the xHCI > > transfer ring information, which was already freed. > > > > Signed-off-by: Wesley Cheng > > Tested-by: Puma Hsu > Tested-by: Daehwan Jung > > --- > > drivers/usb/host/xhci-sideband.c | 29 ++++++++++++++++++++++++++++- > > drivers/usb/host/xhci.c | 3 +++ > > include/linux/usb/xhci-sideband.h | 30 +++++++++++++++++++++++++++++- > > 3 files changed, 60 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/usb/host/xhci-sideband.c b/drivers/usb/host/xhci-sideband.c > > index 742bbc6c2d9b..d49f9886dd84 100644 > > --- a/drivers/usb/host/xhci-sideband.c > > +++ b/drivers/usb/host/xhci-sideband.c > > @@ -88,6 +88,30 @@ __xhci_sideband_remove_endpoint(struct xhci_sideband *sb, struct xhci_virt_ep *e > > > > /* sideband api functions */ > > > > +/** > > + * xhci_sideband_notify_ep_ring_free - notify client of xfer ring free > > + * @sb: sideband instance for this usb device > > + * @ep_index: usb endpoint index > > + * > > + * Notifies the xHCI sideband client driver of a xHCI transfer ring free > > + * routine. This will allow for the client to ensure that all transfers > > + * are completed. > > + * > > + * The callback should be synchronous, as the ring free happens after. > > + */ > > +void xhci_sideband_notify_ep_ring_free(struct xhci_sideband *sb, > > + unsigned int ep_index) > > +{ > > + struct xhci_sideband_event evt; > > + > > + evt.type = XHCI_SIDEBAND_XFER_RING_FREE; > > + evt.evt_data = &ep_index; > > + > > + if (sb->notify_client) > > + sb->notify_client(sb->intf, &evt); > > +} > > +EXPORT_SYMBOL_GPL(xhci_sideband_notify_ep_ring_free); > > + > > /** > > * xhci_sideband_add_endpoint - add endpoint to sideband access list > > * @sb: sideband instance for this usb device > > @@ -342,7 +366,9 @@ EXPORT_SYMBOL_GPL(xhci_sideband_interrupter_id); > > * Return: pointer to a new xhci_sideband instance if successful. NULL otherwise. > > */ > > struct xhci_sideband * > > -xhci_sideband_register(struct usb_interface *intf, enum xhci_sideband_type type) > > +xhci_sideband_register(struct usb_interface *intf, enum xhci_sideband_type type, > > + int (*notify_client)(struct usb_interface *intf, > > + struct xhci_sideband_event *evt)) > > { > > struct usb_device *udev = interface_to_usbdev(intf); > > struct usb_hcd *hcd = bus_to_hcd(udev->bus); > > @@ -381,6 +407,7 @@ xhci_sideband_register(struct usb_interface *intf, enum xhci_sideband_type type) > > sb->vdev = vdev; > > sb->intf = intf; > > sb->type = type; > > + sb->notify_client = notify_client; > > vdev->sideband = sb; > > > > spin_unlock_irq(&xhci->lock); > > diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c > > index 61950a350432..91e2d6eac8b7 100644 > > --- a/drivers/usb/host/xhci.c > > +++ b/drivers/usb/host/xhci.c > > @@ -20,6 +20,7 @@ > > #include > > #include > > #include > > +#include > > > > #include "xhci.h" > > #include "xhci-trace.h" > > @@ -3919,6 +3920,8 @@ static int xhci_discover_or_reset_device(struct usb_hcd *hcd, > > } > > > > if (ep->ring) { > > + if (ep->sideband) > > + xhci_sideband_notify_ep_ring_free(ep->sideband, i); > > xhci_debugfs_remove_endpoint(xhci, virt_dev, i); > > xhci_free_endpoint_ring(xhci, virt_dev, i); > > } > > diff --git a/include/linux/usb/xhci-sideband.h b/include/linux/usb/xhci-sideband.h > > index f8722afb8a2d..45288c392f6e 100644 > > --- a/include/linux/usb/xhci-sideband.h > > +++ b/include/linux/usb/xhci-sideband.h > > @@ -21,6 +21,20 @@ enum xhci_sideband_type { > > XHCI_SIDEBAND_VENDOR, > > }; > > > > +enum xhci_sideband_notify_type { > > + XHCI_SIDEBAND_XFER_RING_FREE, > > +}; > > + > > +/** > > + * struct xhci_sideband_event - sideband event > > + * @type: notifier type > > + * @evt_data: event data > > + */ > > +struct xhci_sideband_event { > > + enum xhci_sideband_notify_type type; > > + void *evt_data; > > +}; > > + > > /** > > * struct xhci_sideband - representation of a sideband accessed usb device. > > * @xhci: The xhci host controller the usb device is connected to > > @@ -30,6 +44,7 @@ enum xhci_sideband_type { > > * @type: xHCI sideband type > > * @mutex: mutex for sideband operations > > * @intf: USB sideband client interface > > + * @notify_client: callback for xHCI sideband sequences > > * > > * FIXME usb device accessed via sideband Keeping track of sideband accessed usb devices. > > */ > > @@ -44,10 +59,14 @@ struct xhci_sideband { > > struct mutex mutex; > > > > struct usb_interface *intf; > > + int (*notify_client)(struct usb_interface *intf, > > + struct xhci_sideband_event *evt); > > }; > > > > struct xhci_sideband * > > -xhci_sideband_register(struct usb_interface *intf, enum xhci_sideband_type type); > > +xhci_sideband_register(struct usb_interface *intf, enum xhci_sideband_type type, > > + int (*notify_client)(struct usb_interface *intf, > > + struct xhci_sideband_event *evt)); > > void > > xhci_sideband_unregister(struct xhci_sideband *sb); > > int > > @@ -71,4 +90,13 @@ void > > xhci_sideband_remove_interrupter(struct xhci_sideband *sb); > > int > > xhci_sideband_interrupter_id(struct xhci_sideband *sb); > > + > > +#if IS_ENABLED(CONFIG_USB_XHCI_SIDEBAND) > > +void xhci_sideband_notify_ep_ring_free(struct xhci_sideband *sb, > > + unsigned int ep_index); > > +#else > > +static inline void xhci_sideband_notify_ep_ring_free(struct xhci_sideband *sb, > > + unsigned int ep_index) > > +{ } > > +#endif /* IS_ENABLED(CONFIG_USB_XHCI_SIDEBAND) */ > > #endif /* __LINUX_XHCI_SIDEBAND_H */ > > > > ------BWvmtLGreXPtZv31XE49129YoyRr4_KGUd.k-ILdCyGA2LCZ=_6a960_ Content-Type: text/plain; charset="utf-8" ------BWvmtLGreXPtZv31XE49129YoyRr4_KGUd.k-ILdCyGA2LCZ=_6a960_--