From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD8A7C433EF for ; Thu, 17 Mar 2022 02:43:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240997AbiCQCo3 (ORCPT ); Wed, 16 Mar 2022 22:44:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236570AbiCQCo1 (ORCPT ); Wed, 16 Mar 2022 22:44:27 -0400 Received: from ZXSHCAS2.zhaoxin.com (ZXSHCAS2.zhaoxin.com [203.148.12.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F2D3DF96; Wed, 16 Mar 2022 19:43:10 -0700 (PDT) Received: from zxbjmbx1.zhaoxin.com (10.29.252.163) by ZXSHCAS2.zhaoxin.com (10.28.252.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Thu, 17 Mar 2022 10:43:07 +0800 Received: from [10.29.8.49] (10.29.8.49) by zxbjmbx1.zhaoxin.com (10.29.252.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Thu, 17 Mar 2022 10:43:05 +0800 Message-ID: Date: Thu, 17 Mar 2022 10:43:04 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] USB: Fix xhci ERDP update issue Content-Language: en-US To: Mathias Nyman , , , , , CC: , , , References: <3c576edf-89c3-ccf3-a43f-4ce2c1ced18d@zhaoxin.com> <261420fb-28b4-0def-a9e1-9c011bab7912@linux.intel.com> <1882dfc1-0f46-a594-d75b-b73d30f6d6db@zhaoxin.com> <6c11dc4f-4984-e7aa-9fc5-7026100b38e1@linux.intel.com> From: "WeitaoWang-oc@zhaoxin.com" In-Reply-To: <6c11dc4f-4984-e7aa-9fc5-7026100b38e1@linux.intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.29.8.49] X-ClientProxiedBy: ZXSHCAS1.zhaoxin.com (10.28.252.161) To zxbjmbx1.zhaoxin.com (10.29.252.163) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/3/16 21:20, Mathias Nyman wrote: > On 15.3.2022 14.44, WeitaoWang-oc@zhaoxin.com wrote: >> On 2022/3/15 下午4:08, Mathias Nyman wrote: >>> On 14.3.2022 9.25, WeitaoWang-oc@zhaoxin.com wrote: >>>> On some situations, software handles TRB events slower than adding TRBs, >>>> xhci_irq will not exit until all events are handled. If xhci_irq just >>>> handles 256 TRBs and exit, the temp variable(event_ring_deq) driver records in xhci irq is equal to driver current dequeue pointer. It will cause driver not update ERDP and software dequeue pointer lost sync with ERDP. On the next xhci_irq, the event ring is full but driver will not update ERDP as software dequeue pointer 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 >>>> >>>> Fixed this issue by update software record temp variable when handles 128 TRB events.> >>>> Signed-off-by: Weitao Wang >>> >>> Thanks >>> >>> Solution itself looks good but patch has some minor format issue: >>> >>> >>> It would also be interesting to know if the full event ring was triggered in a real >>> life usecase? >>> If that is the case I might need to look more into it. >>> >>> Bigger event ring, more rings, faster handler, avoid irqoff time... >>> >>> Thanks >>> Mathias >>> . >> Some performance test tools such as fio or iometer can be used to reproduce >>  this case, If tested with 4KB read or write. xHCI will generate a lost TRB >>  events fast than software consume on a certain period of time. Once the interrupt is entered, software may handle more than 128 TRBs at a time. >> While the software is processing, xHCI is still generating events. This may >> has problems caused by the ERDP update mechanism. If update software >>  record temp variable when handles 128 TRB events, event ring full will not >>  happen any more even though fio test with 4KB read or write. >> >> Thanks >> Weitao Wang >>> > > Thanks for the clarification. > > Could you resubmit this after fixing the minor patch format issue? > Also make sure patch passes checkpatch test > > Thanks > -Mathias All right, I'll resubmit this patch.Thanks for your help. Weitao Wang > .