From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796295904; b=HAbIjPz8Ugi+gNkAMSE6S5jQPMyc/fNbdbLxUpy2UPgrX/BrSiVH6zk8pGNNjhRqFd6P fc2b3AuCAdlVaFFp/JsTWNU8XyYzNexpprua5ky86EkM90UtuAIRwcpClbV0PEZO5jl4U louJ0adIjd4y9+macw3xdRhgrDRrL+3QLoTJHoWG0htx4egXFGutKPV9hM+psNQ8GiwPo ZuavmBnOsJUe3wLnKAlPwSJG04I8g9INBOgy3nzSIOCxauRhTUWF5fYGfzhGcEJJUm+5H xt4bGzSzQPfox8fvszP3AK3OAX9Lx6QR+KEjSnLe0IsFm9i9Tuin6EL/TNzF746yvxg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796295904; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=Zuqn66/ASYPi1NMVcP61CLtWRlPgSuHFChqgZJ7Afe4=; b=hO+Oti/EZw3Y8/a77hyjfNuLceVjLceLDhCvblbA/G9MfD/anta3L0Q2yQz9ypAeBcyJ 4FDHKODtK911l29FepIxjuTbqBRPHK6ST4U50KyGJ+VE49fa+y4n7exJ+dH5lcw5qoDx4 HfGBsPSBhkATCHV8oT/lu6uMJJ5YIsjSVcQ/TDHD4p60FVwFjwYs2MUtqrjnm/0wcBCr0 0yuLg3Z80lFuScqUED2+JD8EcEHwd96fk15nWrO2T3VWGtkxRIzBJsuM4BBQG3tRfiQ4l lhevDKzEieNm1Hl6cKe20twZMZJ9BvOr3IlJ7hbSkhtM52a2XOAWypFYM5g/bvIUHUQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=psAbt0zS; arc=none smtp.remote-ip=209.85.128.48 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4399E606A32F for ; Thu, 3 Dec 2026 11:05:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4399E606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=psAbt0zS Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4bbd2c5931bso23015385e9.2 for ; Thu, 03 Dec 2026 03:05:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796295902; x=1796900702; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Zuqn66/ASYPi1NMVcP61CLtWRlPgSuHFChqgZJ7Afe4=; b=psAbt0zSEgX+Qjvvp6bBtiCcJB89v8o8Sx0nf00agNpXcKRmBhhLvkfHoExWsDWHX/ /TGeFIkhKYSmy+Y2YRsVPHfjxn7SKwr9XfJ4ang98dWLqN6lcR8Tx0YxFWkrng6ltHEn D5HUz4bD+uKLeqJcyht6lUb7fZAr787QO52tR5bNAFq2z1uDla4xci28qQMr19ykSfDl cZf2deq3f0jMK4bMPswrLhRBOKjixYeRpoi6AkF5ymY90yXID/MEFDBH5ezQO5E8w0Vv VJNQD2TC//fT7LxlkA58YwQVJoFdsLKlFyJ0gR/CgToMIywx1E3kt3xgRNekVdCK0fm8 jpKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796295902; x=1796900702; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Zuqn66/ASYPi1NMVcP61CLtWRlPgSuHFChqgZJ7Afe4=; b=m/+eIXPk+hdxh3ROaHEfewVZQRbqK2vUR2bFYflqlKDvh8kE+rmLSOvJ1F8w1DZNIR b9dCnVEwfjRcPmWzYFUXHnm7J7FwEaE9mvkSvPOZFIT2v4SMtYZVceEFyIlmgOI9kVIm eI6uummv8+u15MXdLWMQd3+CrQYa69OICMZb9GB2shaTremQtENUp1ZWXrwN+GXT0si4 ZSlKu42B3BLdLemmNFA3UcA3RVReQcZIi1paVGvDR9ShrKheR3AyJVSKC29/NeUSOciz gMzX84O8SO4pOd8mZIId934FoZhsCrSxQEEeUk3TXy87oxNFLoFSx6k/AfotNosQjbzK 78JQ== X-Forwarded-Encrypted: i=1; AL+hErF//XN7nRnexdnJSJAjlt/Rtm2kjMh2ic7lXai2d0FyUmuxCcuJR2UU8fi/Z5zJxRHsDGUCx26HmNLsD+A=@vger.kernel.org X-Gm-Message-State: APuU4Z98aUVOb/l+mq7MBx9c//7u0l8lvxcn+0kdT51MGhOwY94GVU+o 52Ti6br5Cb3iXmqhGqzOU0T41STVaoexbWeIwxIcstsf1Prxwh3KImAw X-Gm-Gg: AZFdTZdykdb6lkXDmtiTpHvy+wc12lRWSvkOQz9oDW6ylBqOM9TulwPY2Qs33tIiFYI CuJnmon1vxDCIf79DulYU/Z+ufP/Hoj7g35TjovI4yGqw6FYH7m4AGNqggnRUP3aV3qGs/vQ3f1 FowBL8sUfHNTApWCFMaSB0yqOb3exNE0ZZR1JyI1iX1I00cd+NCYcNAojz5T948SMOm0FGued1J XXCqehFFgmN8S0u9R5muIIk8V+4dvWFrxDlqv+B2dwngwqVETUX08mR8nbr0DSq3aYZCXd39Qbj 9tVSslmOxdso25BOffDu2LlkD6F5saLxaGw9bgs+D22Ysy62hLCzNB5r2OtQPqBHOI516wXBJQ6 gKiw7g4ByTHUOm4ph9mSHNRfIBVh8zyUV2oJtmEiWfPxOQeRiu6svWI9G253iQODiYu7R81zl9s RQuOIWV43immHnsHGD4r6OoRffmOHWvCzNJqLVuvobkMFQhjPLDNH9L94NgmrJCOL0DWfnAUHDT GQnpVKvnc2PAf3OEVs6Bk0wkcGHqNaXRPx6C6wpp+ZQmRVXWeQbLcFEV3+SQ2L/Zsp3Ng9cB0xv q2fc5aD9jUDOAUTnrW7dR5d01MYTrC8VLCW/ X-Received: by 2002:a05:600c:3b0e:b0:4a1:efba:511 with SMTP id 5b1f17b1804b1-4bb8882508emr896715525e9.35.1796295901574; Thu, 03 Dec 2026 03:05:01 -0800 (PST) Received: from foxbook (bfj60.neoplus.adsl.tpnet.pl. [83.28.47.60]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbdff50723sm100752235e9.0.2026.12.03.03.05.00 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 03 Dec 2026 03:05:01 -0800 (PST) Date: Thu, 3 Dec 2026 12:05:04 +0100 From: Michal Pecio To: Mathias Nyman Cc: matthew Boyle , Greg Kroah-Hartman , Niklas Neronin , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] usb: xhci: dbc: advance transfer ring dequeue pointer on completion Message-ID: <20261203120504.59ff2fca.michal.pecio@gmail.com> In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 3 Dec 2026 12:48:55 +0200, Mathias Nyman wrote: > On 12/2/26 18:32, matthew Boyle wrote: > > Good Morning, > > Commit 7ee645963075 ("usb: xhci: remove legacy 'num_trbs_free' > > tracking") removed ring->num_trbs_free and switched > > xhci_dbc_queue_bulk_tx() to xhci_num_trbs_free(ring), which computes > > free space from ring->enqueue and ring->dequeue. > > > > However, DbC transfer rings never updated ring->dequeue on transfer > > completion; previously only ring->num_trbs_free was incremented in > > dbc_handle_xfer_event(). As a result, ring->dequeue remains stuck at > > the start of the single-segment ring while ring->enqueue advances. > > After exactly 254 TRBs (254 * 1024 B = 260,096 B on a 256-TRB segment > > with one link TRB and the xhci_num_trbs_free(ring) <= num_trbs guard), > > xhci_num_trbs_free() drops to 1 and every subsequent bulk transfer > > fails permanently with -EBUSY ("failed to queue trbs"). > > nice catch, thanks > > > > > Add a dbc_inc_deq() helper mirroring xhci_dbc_queue_trb()'s link-TRB > > wraparound and call it in dbc_handle_xfer_event() before giving back > > completed and stale stalled requests (while dbc->lock is still held, > > before completion callbacks can re-queue new TRBs). > > The transfer event contains the dequeue TRB DMA address, how about setting > the ring->dequeue directly based on it instead. > > Does this work for you: > > diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c > index 48ee6a4f9e1c..a9c011194cd8 100644 > --- a/drivers/usb/host/xhci-dbgcap.c > +++ b/drivers/usb/host/xhci-dbgcap.c > @@ -835,6 +835,7 @@ static void dbc_handle_xfer_event(struct xhci_dbc *dbc, union xhci_trb *event) > /* Match the pending request: */ > list_for_each_entry(r, &dep->list_pending, list_pending) { > if (r->trb_dma == event->trans_event.buffer) { > + ring->dequeue = xhci_dma_to_trb(ring->deq_seg, r->trb_dma, NULL); > req = r; > break; > } Not familiar with DBC, but I suspect you actually want: ring->dequeue = xhci_dma_to_trb(ring->deq_seg, r->trb_dma, &ring->deq_seg); Regards, Michal