From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796507997; b=n070wXBq6HLCQwdedKlwoiJDOgTyOy/tS0IEI1CiH09C6lRdzP5uPQqlWL+vBNlKnUvV xDloeW+NmT6lxxOw1C7yCjP4iIMgornMlcGhKjerZqGekknv4F6i5FoDSKCpVPaAbs1dT fuBPgvNwGXAFg1EeW6MHds+rINKjiVN/oswK5uGz41eOvx1nO9Rcp57aE9ZlFBIABqEin 0ZOQawPWnChCIELdmEqJojaa840hmsHz3uPTTRtz36lLgI94AFilwdOhZmH4QcDazunbG nAz3aDVCMp5R9P4HNS4nbRLMRyIzQ0oSLeHa7Hyuu+hsDuXrfK4DvIeg44QwvkYVnSg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796507997; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=vo2JEKraNSkTwCjQMpuI65a4xQGsyJeym0kKR56WFmw=; b=wa9rgpSLAZCBc6Z3eQg47/SxnqTJKeyaKOoj367ZEMhWqHFwbxY8l+02i/6+I3MtmXfa zI/58p094LQFi2yWYGzsTm+jqTq0fvs/mL00qetb8V/f2s9XMCDqQKw2HNKwnCvNCgtN+ arGtrPZ3oKTWDyPFnHxJqP6heQ2o1UVuL0RyVJpNYWcz9xhskGpt0KFqo8UUavsmWthab wnO6IEDNKk1ALDlHkfL/+auQXdzHl3KRt7L2b5788MMPf/s1Sl1RFhhtHWvzp1b/XFAyj lWfV4cA4NqzUlyr/9VluKvL+q61mxs3xWYI1QmUtuI/qbgpOONsLhAe/cd2Z+JrIymg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HHu2kFHP; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 155F0606A31F; Sat, 5 Dec 2026 21:59:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HHu2kFHP Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEA1F1F00936; Sat, 5 Dec 2026 21:59:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796507996; bh=vo2JEKraNSkTwCjQMpuI65a4xQGsyJeym0kKR56WFmw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=HHu2kFHPx0HpoJVNKyuITB/vJ9syoMvJ3JWLdqI1V19XiDQjB4mP4F/RjKSGPL+Lj h9l7UWK0wu1vFUZnTMLvoiqowozaQEj78LoQJ4+xBj69jCUpuCMlAwqMufwtQsGPw7 Uifh3y8mjJwaT61GKgwjDHUFVZwtP8SdR/5jUJl/xVEsmOhLt1KT7ehA/R3ZlqBRkh T7ir+ANnJzSRbgsC2Q2/HoaianmuJ+gd3fiIFaXU14RJ7EdWgfEePyUyS01c3aFGGo ExVup6UIuyn0YUmFF9EHIQhbimuhwYE/+kVAi6+JUoFnA/MaxzQI3gXfEWNiMjWgaa AuJy6tM7iuBvQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH usb-next v3] usb: gadget: pxa27x_udc: fix locking in req_done() on PREEMPT_RT Reply-To: sashiko-reviews@lists.linux.dev To: "Xinsheng Zhu" , linux-usb@vger.kernel.org Cc: linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org In-Reply-To: <20261205214738.93588-1-xinsheng.zhu.ny@gmail.com> References: <20261205214738.93588-1-xinsheng.zhu.ny@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 21:59:56 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] usb: gadget: pxa27x_udc: conditional locked flag in req_done() and helpers -- commit b1b33eb4417e50b1d8e93191abd1644e0e2f2fb3 Author: Xinsheng Zhu usb: gadget: pxa27x_udc: fix locking in req_done() on PREEMPT_RT This commit replaces local_irq_save()/local_irq_restore() around usb_gadget_giveback_request() in req_done() with spin_unlock()/spin_lock(), keeps ep->lock held across request lookup and removal in pxa_ep_dequeue(), and replaces pflags with a boolean locked flag across req_done() and its completion helpers. > diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc= /pxa27x_udc.c > index 9fd079cb65c6b..219833e681657 100644 > --- a/drivers/usb/gadget/udc/pxa27x_udc.c > +++ b/drivers/usb/gadget/udc/pxa27x_udc.c [ ... ] > static void req_done(struct pxa_ep *ep, struct pxa27x_request *req, int = status, > - unsigned long *pflags) > + bool locked) > { > unsigned long flags; > =20 > + if (!locked) > + spin_lock_irqsave(&ep->lock, flags); > + > ep_del_request(ep, req); > if (likely(req->req.status =3D=3D -EINPROGRESS)) > req->req.status =3D status; > @@ -672,37 +677,36 @@ static void req_done(struct pxa_ep *ep, struct pxa2= 7x_request *req, int status, > &req->req, status, > req->req.actual, req->req.length); > =20 > - if (pflags) > - spin_unlock_irqrestore(&ep->lock, *pflags); > - local_irq_save(flags); > + spin_unlock(&ep->lock); > usb_gadget_giveback_request(&req->udc_usb_ep->usb_ep, &req->req); > - local_irq_restore(flags); > - if (pflags) > - spin_lock_irqsave(&ep->lock, *pflags); > + spin_lock(&ep->lock); > + > + if (!locked) > + spin_unlock_irqrestore(&ep->lock, flags); > } > =20 > /** > * ep_end_out_req - Ends endpoint OUT request > * @ep: physical endpoint > * @req: pxa request > - * @pflags: flags of previous spinlock_irq_save() or NULL if no lock held > + * @locked: whether the caller holds ep->lock with spin_lock_irqsave() > * > * Context: ep->lock held or released (see req_done()) > * > * Ends endpoint OUT request (completes usb request). > */ > static void ep_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req, > - unsigned long *pflags) > + bool locked) > { > inc_ep_stats_reqs(ep, !USB_DIR_IN); > - req_done(ep, req, 0, pflags); > + req_done(ep, req, 0, locked); > } [Severity: Low] Could req_done(), ep_end_in_req(), and ep_end_out_req() require ep->lock to be held unconditionally instead of threading bool locked through five helpers? Conditionally acquiring and releasing ep->lock in req_done() produces sparse context-imbalance warnings and prevents asserting the lock with lockdep_assert_held(). When locked is false, ep_end_in_req() and ep_end_out_req() also update ep->stats via inc_ep_stats_reqs() before req_done() acquires ep->lock. Both ep0_end_in_req() and ep0_end_out_req() are only ever called with locked set to false. Acquiring ep->lock in those two helpers and around the WAIT_ACK_SET_CONF_INTERF call to ep_end_in_req() in pxa_ep_queue() would drop the locked parameter, keep sparse happy, and protect ep->stats. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205214738.9358= 8-1-xinsheng.zhu.ny@gmail.com?part=3D1