Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4781485iob; Mon, 9 May 2022 01:12:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQKKBlOlqaRCptNtIDHl9BWg3wQlt/h6TpG23hdSAilHr/EisOtmHhO/YCwQJuHV/wWZSZ X-Received: by 2002:a05:6e02:17ce:b0:2cf:9287:5a7f with SMTP id z14-20020a056e0217ce00b002cf92875a7fmr3884370ilu.216.1652083929391; Mon, 09 May 2022 01:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652083929; cv=none; d=google.com; s=arc-20160816; b=KVbFjMPoaSp3oWXPWbzQ3MKH9AMgb5Mc3PxRUB8yAdbVJP6Oe0F3hZmoCGBFVbS/zV OeqBT5RidVV3xGtvJIcjagrfU5SmRswOmmO7PG0yhADk/a8XbJ86/wV+fOPHAumm5jYD pTruQ5v2v72IUU2lGpFFCFgIYBl4VHm+ytCoJs+jbn7xDkTRsmPpcA9HLT2FnOz0Pi9+ 6Q2yQvrmdx/HQMq1A1w9WLPnUsEhNwj+eKeMT1fGm7cxdCUWMdvJ/g1HGvsJT0uS+4P7 5+Kq5usO+ogwJfscQVNI2/3jroAIT4l8ebMf6ytgO+k3tVvWF+0BiCWi2tsct9ZJlegF GHfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gXKgEnA7PQDf3PKk4J5eAyeSSY4ioQlZ+RPnw1zJfxA=; b=K7cwQZQju3UI7r3Z8mROR75gYv+Xtp6HUECvcE7oMesEdkfayxp5St6PSZZ7IaCRg3 vImjmIzVwD0689ZX10wFQ1pIeobFskaSREMiNx59K6QEhdbBmL3SDQJQORmsHDO+8jjp IlgQLyQnSqzMTmRsVf2gcaS1gPCHcMCMqYa6BqtfjVRnJjMwA+35rYpfB3/lBmMjPPQ3 ifY9Ez+rZqJZVEB5f5j+tF0E5pQ7f1fFmmMR8Cnb6FhdgDnhFO0kMFAs23cc4d/XLrmg ByerOx+DCXEnTV8BhbXk9NK/5ct/iJZQ51I7/PUTb1tI+pJvFYWxlXxoi2b+NOMWyAV2 1vlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pBTbZ71s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s7-20020a056e02216700b002cf5a82fd2bsi8158283ilv.7.2022.05.09.01.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 01:12:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pBTbZ71s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8B859121230; Mon, 9 May 2022 01:01:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357175AbiEDRXk (ORCPT + 99 others); Wed, 4 May 2022 13:23:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355741AbiEDREl (ORCPT ); Wed, 4 May 2022 13:04:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 427404F9C0; Wed, 4 May 2022 09:53:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DEEAFB8278E; Wed, 4 May 2022 16:53:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98893C385A5; Wed, 4 May 2022 16:53:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683197; bh=hmbtWVfyriMLSNG2cgnHPr6zR2rssfLG2hmu6gUSMOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pBTbZ71sdOk68ImgMCHiNWWhOLnMmX/Rkdp//H6//Z2Bp9PVLG/NmLu+Wlz0h8Ppr 7a4efWp15F/HL4J9nMcDGRYmW3CBxsX0fIVFF+Xfi06Pq69viEk+pDjfe/oxBEjUKd /fr7+0w1xqz/KxRRnNIJe5EvhjKf3nD0W8cqkRGI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Chen , Weitao Wang , Mathias Nyman , Sasha Levin Subject: [PATCH 5.15 054/177] USB: Fix xhci event ring dequeue pointer ERDP update issue Date: Wed, 4 May 2022 18:44:07 +0200 Message-Id: <20220504153057.854422954@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Weitao Wang [ Upstream commit e91ac20889d1a26d077cc511365cd7ff4346a6f3 ] In some situations software handles TRB events slower than adding TRBs. If the number of TRB events to be processed in a given interrupt is exactly the same as the event ring size 256, then the local variable "event_ring_deq" that holds the initial dequeue position is equal to software_dequeue after handling all 256 interrupts. It will cause driver to not update ERDP to hardware, Software dequeue pointer is out of sync with ERDP on interrupt exit. On the next interrupt, the event ring may full but driver will not update ERDP as software_dequeue is equal to ERDP. [ 536.377115] xhci_hcd 0000:00:12.0: ERROR unknown event type 37 [ 566.933173] sd 8:0:0:0: [sdb] tag#27 uas_eh_abort_handler 0 uas-tag 7 inflight: CMD OUT [ 566.933181] sd 8:0:0:0: [sdb] tag#27 CDB: Write(10) 2a 00 17 71 e6 78 00 00 08 00 [ 572.041186] xhci_hcd On some situataions,the0000:00:12.0: xHCI host not responding to stop endpoint command. [ 572.057193] xhci_hcd 0000:00:12.0: Host halt failed, -110 [ 572.057196] xhci_hcd 0000:00:12.0: xHCI host controller not responding, assume dead [ 572.057236] sd 8:0:0:0: [sdb] tag#26 uas_eh_abort_handler 0 uas-tag 6 inflight: CMD [ 572.057240] sd 8:0:0:0: [sdb] tag#26 CDB: Write(10) 2a 00 38 eb cc d8 00 00 08 00 [ 572.057244] sd 8:0:0:0: [sdb] tag#25 uas_eh_abort_handler 0 uas-tag 5 inflight: CMD Hardware ERDP is updated mid event handling if there are more than 128 events in an interrupt (half of ring size). Fix this by updating the software local variable at the same time as hardware ERDP. [commit message rewording -Mathias] Fixes: dc0ffbea5729 ("usb: host: xhci: update event ring dequeue pointer on purpose") Reviewed-by: Peter Chen Signed-off-by: Weitao Wang Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20220408134823.2527272-2-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/xhci-ring.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index d0b6806275e0..f9707997969d 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -3141,6 +3141,7 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd) if (event_loop++ < TRBS_PER_SEGMENT / 2) continue; xhci_update_erst_dequeue(xhci, event_ring_deq); + event_ring_deq = xhci->event_ring->dequeue; /* ring is half-full, force isoc trbs to interrupt more often */ if (xhci->isoc_bei_interval > AVOID_BEI_INTERVAL_MIN) -- 2.35.1