From: Myeonghun Pak <mhun512@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Ijae Kim <ae878000@gmail.com>,
Vasileios Almpanis <vasilisalmpanis@gmail.com>
Subject: [PATCH 2/4] usb: gadget: pch_udc: initialize DMA before registering interrupt sources
Date: Wed, 14 Oct 2026 23:49:14 -0400 [thread overview]
Message-ID: <20261015034916.2773248-3-mhun512@gmail.com> (raw)
In-Reply-To: <20261015034916.2773248-1-mhun512@gmail.com>
VBUS GPIO work can reconnect the controller before probe has
allocated its EP0 descriptors. Initialize the lock, endpoint state
and DMA resources before registering either interrupt source.
Keep PCI bus mastering disabled until the PCI IRQ is registered.
This issue was identified as part of our ongoing research while
reviewing kernel code.
Fixes: 637b78eb31e0 ("usb: gadget: pch_udc: Detecting VBUS through GPIO with interrupt")
Assisted-by: LLM
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
Compile-tested only.
drivers/usb/gadget/udc/pch_udc.c | 28 +++++++++-------------------
1 file changed, 9 insertions(+), 19 deletions(-)
diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c
index 3b5c5c41c38c..c360bc556cdc 100644
--- a/drivers/usb/gadget/udc/pch_udc.c
+++ b/drivers/usb/gadget/udc/pch_udc.c
@@ -2819,25 +2819,14 @@ static void pch_udc_pcd_reinit(struct pch_udc_dev *dev)
/**
* pch_udc_pcd_init() - This API initializes the driver structure
* @dev: Reference to the driver structure
- *
- * Return codes:
- * 0: Success
- * -ERRNO: All kind of errors when retrieving VBUS GPIO
*/
-static int pch_udc_pcd_init(struct pch_udc_dev *dev)
+static void pch_udc_pcd_init(struct pch_udc_dev *dev)
{
- int ret;
-
pch_udc_init(dev);
pch_udc_pcd_reinit(dev);
INIT_WORK(&dev->vbus_gpio.irq_work_fall, pch_vbus_gpio_work_fall);
INIT_WORK(&dev->vbus_gpio.irq_work_rise, pch_vbus_gpio_work_rise);
-
- ret = pch_vbus_gpio_init(dev);
- if (ret)
- pch_udc_exit(dev);
- return ret;
}
/**
@@ -3082,10 +3071,15 @@ static int pch_udc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
dev->base_addr = pcim_iomap_table(pdev)[dev->bar];
+ spin_lock_init(&dev->lock);
+ dev->gadget.ops = &pch_udc_ops;
+
/* initialize the hardware */
- retval = pch_udc_pcd_init(dev);
+ pch_udc_pcd_init(dev);
+
+ retval = init_dma_pools(dev);
if (retval)
- return retval;
+ goto finished;
pci_enable_msi(pdev);
@@ -3102,11 +3096,7 @@ static int pch_udc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
pci_set_master(pdev);
pci_try_set_mwi(pdev);
- /* device struct setup */
- spin_lock_init(&dev->lock);
- dev->gadget.ops = &pch_udc_ops;
-
- retval = init_dma_pools(dev);
+ retval = pch_vbus_gpio_init(dev);
if (retval)
goto finished;
next prev parent reply other threads:[~2026-10-15 3:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 3:49 [PATCH 0/4] usb: gadget: pch_udc: order IRQ and descriptor lifetimes Myeonghun Pak
2026-10-15 3:49 ` [PATCH 1/4] usb: gadget: pch_udc: release IRQ handlers before DMA cleanup Myeonghun Pak
2026-10-15 3:49 ` Myeonghun Pak [this message]
2026-10-15 3:49 ` [PATCH 3/4] usb: gadget: pch_udc: track successful EP0 DMA mappings Myeonghun Pak
2026-10-15 3:49 ` [PATCH 4/4] usb: gadget: pch_udc: free the EP0 data descriptor to its owning pool Myeonghun Pak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261015034916.2773248-3-mhun512@gmail.com \
--to=mhun512@gmail.com \
--cc=ae878000@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=vasilisalmpanis@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®