From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.12 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796301129; b=tBviOB8o82srFcKw/92zQUvAqSGH1vn55bvVsjL26Mbk3sYE4loq1E62ls8AoIS/8Bvb E5f2FBCCaG+058MWBaKTHatRZ+joHSRvOTimwILF8raehMWrlHUAebkPH8ruttbHgqqqQ nnZDEHFcc/R3ZBWCDadbqmUxFFKSUjrVVAPk83mwHlJkOdXtkrSGrSOvBULvIIazW4yS8 NHopaOGFp0edYGKDncQMfuej1DARDt+jEs5Gjsd4BvtNACMEkt9d0D+mh6q0kg4bfzTCu Iwvbypkp5Dfy0NcF7wtWTGL+3MW+BKD5rsL4387DdO3gka1yV4aT/cU5HNYDIGnC3ag== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796301129; 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=6XhCN1BKBeA3QvzAA31GQ+WMQx0kunnSQfBKNu87he0=; b=fltsanCSf+QPKzWud32Ie9QeVEg3QVaFJgmseDOK3GSuIuxCBHjAN5BAdwGb1LLowyPs 7Rvhva+2zX46VgFj0tyw3ZJPcl2OdBohc70/xeadeyvQMybFiqlansMHeG1ZjCiqnkUzC E4gi/bZWcENDE0lIcM9HHmAVomKoTqpPkMeQtMjZN3RoheDIdMx2SY7P94lQQpx4EhvtL 90hVddLnlAU//AwDKs35b0vT/wKcEfLAHHUKjA1EnL+AOuWfBWXyjmpRnEBAIbvkPyvdM OJA97yRZ2YOpHwoKxWWx6djqqv2bdCb/WbcTAJo9l1r27MB7amKf7ywS65CFL+fzquQ== 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=ATWcu4ET; arc=none smtp.remote-ip=192.198.163.12 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 6E18E606A32F; Thu, 3 Dec 2026 12:32:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6E18E606A32F 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=ATWcu4ET DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796301128; x=1827837128; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=6XhCN1BKBeA3QvzAA31GQ+WMQx0kunnSQfBKNu87he0=; b=ATWcu4ETlXSOtkFWXyJy7BQyeh480wEgEC0nYyu+TLv9Q5qrzN3L9F3J k0CWJ7u3N9OsLfyR/svE2wpjhCKmLJddHTm7wTatw5hK4e7nalWmQuFPY uQ8NNWXB9XYEWFkCPPEBK91S4cCabw84uZAS7TaeeZo6mVrOY71xfizW+ KRL3FMSPyu9Vz9zhG+vZV+fU4kuR/9NY6tQIlnrdlqxUXsMtGprsi6m5A hEzfPJKVGPzZQE+jQl/GA4g/s3g4Iz99PnJGDP5FcujgOI5XRU0h2wVAQ I2igGRAjKuIfTIepZjID6V2nJnR7Ls+tSFELO27U+4YTc4wNT6657Jc1k g==; X-CSE-ConnectionGUID: V790D0u1Q6qAcXn7O4i/UA== X-CSE-MsgGUID: gDcEGTBwRDmiDBmWQF+flQ== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5162204" X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="5162204" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 04:32:08 -0800 X-CSE-ConnectionGUID: meh9aruxR52m2CJXMj0rlA== X-CSE-MsgGUID: MK8Y8xbxQmu4VHeCVlKjlQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="14308124" 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 04:32:07 -0800 Message-ID: Date: Thu, 3 Dec 2026 14:32:04 +0200 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] usb: xhci: dbc: advance transfer ring dequeue pointer on completion To: Michal Pecio Cc: matthew Boyle , Greg Kroah-Hartman , Niklas Neronin , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20261203120504.59ff2fca.michal.pecio@gmail.com> Content-Language: en-US From: Mathias Nyman In-Reply-To: <20261203120504.59ff2fca.michal.pecio@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/3/26 13:05, Michal Pecio wrote: > 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); Yes, that would be more future proof. Right now it doesn't matter as dbc uses one segment rings Checking return value =! NULL before assigning ring->dequeue would also be good Thanks Mathias