]> git.baikalelectronics.ru Git - kernel.git/commit
usb: dwc3: gadget: Fix event pending check
authorThinh Nguyen <Thinh.Nguyen@synopsys.com>
Tue, 28 Jun 2022 01:41:19 +0000 (18:41 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 21 Jul 2022 18:59:28 +0000 (20:59 +0200)
commit59e6792ebe001ff24143f1e050bc939dcc7327c3
tree8b3ccadd9061f90d84139e8dadab6a4bcfded98c
parent5ddf7f90871c6e2677f3ac92b601d9224780ceb9
usb: dwc3: gadget: Fix event pending check

commit 2c73c97ef2ec0ccf56a0c24eec7f10accefa6b6f upstream.

The DWC3_EVENT_PENDING flag is used to protect against invalid call to
top-half interrupt handler, which can occur when there's a delay in
software detection of the interrupt line deassertion.

However, the clearing of this flag was done prior to unmasking the
interrupt line, creating opportunity where the top-half handler can
come. This breaks the serialization and creates a race between the
top-half and bottom-half handler, resulting in losing synchronization
between the controller and the driver when processing events.

To fix this, make sure the clearing of the DWC3_EVENT_PENDING is done at
the end of the bottom-half handler.

Fixes: 0df5d259b1b7 ("usb: dwc3: gadget: Prevent losing events in event cache")
Cc: stable@vger.kernel.org
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://lore.kernel.org/r/8670aaf1cf52e7d1e6df2a827af2d77263b93b75.1656380429.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/gadget.c