From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796294940; b=iqYJehpZflADW5FT59vp7JayvbGoTTpXDD7dFLC2Wfv+ZsbaKfKGouginSf+ZkYP0/vJ 0skzuXACZOU3+p7+mFLRa4antJ5n19m6qHdrr3or7E38u4I/Kbr1dkE1uWnxs0F4sPrSc g14f9fzZ6MJKmK4kHO+e/bBiSghDrbUYB89l/fmYrUhNIKo7Wi5VMZmrd0oEQ5s1E/0IS NypQMSx6JgfVNYx5TbHSt7eYqeL09cU4MZgNu8F1VhvBgqCv6EaYLGA8bV19P7cqop5F7 p+WZb2pf2DneN7T+HbIh/JB9eYKSUUT17xe5r4qY95WUZ6pmPQlnKVC96IiwUsNOUvw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796294940; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=sR2adctQbMOSgAMqvCzeC7vNGczwokSdrTupNOrimx0=; b=p9CZM3+W4WoR/8zP+o6h/f5no2IXzCcav1k2nznq3oduBWqUx7bt5oCB/Mp5Ab9HDXi2 QfQVbjh4trs4gMsVxXI8NxLNzNm2v+FX2fC/kGEFmfCnsDXM+U0RBug6frtzSfsTYA6kh PCBNLRBQjxgmQtyOmaZ2IbURov7eQBfNU2M7wvJskYN+JoI9OYglsZS/61VzDvBUYdQ82 RmOuxMTlctBJeQbMi6KDMpAlqf4WVIZAkfy1BPLGDXNmMGM0Xib8Vvnlu8dZ7fZGclOZT IXcbrcQhPg82VNOlGL9c9iRCvfdvrRxeSrMefTVrfcsRPNidalGufddJsQDYOOViOjA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=f4oK2X7c; arc=none smtp.remote-ip=198.175.65.11 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15358606A32C; Thu, 3 Dec 2026 10:48:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 15358606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=f4oK2X7c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796294941; x=1827830941; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=sR2adctQbMOSgAMqvCzeC7vNGczwokSdrTupNOrimx0=; b=f4oK2X7ctJAcCK3LaBq9zj/pwZEkbRyQ6AAdmGyixLhPUwonER8aegEZ GDkf7H+6loCiKpoN5lBSKw6zGmYVle09rlg4C5EgpeFT+klqWgNqhpZks 1ZDzGLAiJ1Etlw52OoQyJ/C4mTkhK87Cc0zvMQlA0x/liM6cs7XwZvUFM 1O/Y1RJD3Nsw7yYoy1HBX5bl8Jx1qO9Z3PLmtMOSOrwg7fwl4W4Ir4zJd AgGeskCOVoX87SrhHQDxgGY3KdG31YQDPigmuFGdR2Ge+SWhZsRUNhZK0 Ib4tpuFxlqN/u/zh96u/pjJmjlZiSzFrdoo2x7AV1HQdA/qwUhpfIHsA/ A==; X-CSE-ConnectionGUID: 5wuEheyLTT2v1PyxuMoEyA== X-CSE-MsgGUID: iLP1KvqLRASNh3qkZB5y6Q== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5149495" X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="5149495" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 02:49:00 -0800 X-CSE-ConnectionGUID: VazRgu4AQ6mquRXCrJjuVA== X-CSE-MsgGUID: FiJAKyFOSjqwn5MxTED1fg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="13915171" Received: from klitkey1-mobl1.ger.corp.intel.com (HELO [10.245.244.95]) ([10.245.244.95]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 02:48:57 -0800 Message-ID: Date: Thu, 3 Dec 2026 12:48:55 +0200 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Fwd: [PATCH] usb: xhci: dbc: advance transfer ring dequeue pointer on completion To: matthew Boyle , Greg Kroah-Hartman , Niklas Neronin Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Michal Pecio References: Content-Language: en-US From: Mathias Nyman In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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; } diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 7ccd89a4b995..bc9a162617dd 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -85,7 +85,7 @@ dma_addr_t xhci_trb_virt_to_dma(struct xhci_segment *seg, return seg->dma + (segment_offset * sizeof(*trb)); } -static union xhci_trb *xhci_dma_to_trb(struct xhci_segment *start_seg, +union xhci_trb *xhci_dma_to_trb(struct xhci_segment *start_seg, dma_addr_t dma, struct xhci_segment **match_seg) { diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 6201b6b24252..42cc7e592ccd 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1963,6 +1963,8 @@ void xhci_cleanup_command_queue(struct xhci_hcd *xhci); void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring); unsigned int count_trbs(u64 addr, u64 len); unsigned int xhci_num_trbs_free(struct xhci_ring *ring); +union xhci_trb *xhci_dma_to_trb(struct xhci_segment *start_seg, dma_addr_t dma, + struct xhci_segment **match_seg); void xhci_process_cancelled_tds(struct xhci_hcd *xhci, struct xhci_virt_ep *ep); void xhci_update_erst_dequeue(struct xhci_hcd *xhci, struct xhci_interrupter *ir, Thanks Mathias