From nobody Sun Feb 8 20:34:14 2026 Received: from mail-pj1-f97.google.com (mail-pj1-f97.google.com [209.85.216.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9FDE40756B for ; Thu, 8 Jan 2026 09:10:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.97 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767863444; cv=none; b=RJqiwuTUzkwrHQVQWBD7uPra4UZ/PtYkV3NzOhHvY9VIvnGHMOVdpF0tNR/AEsLF9o7Y/WtjwXDElzlW8zRb9uP6eoqXLCzs0Pko1Rt0tdA9r+ALuhqA7/ABrKhNzGnjQyT1eB12AzyshBfgmHCIv9EPW6T1OYuPMn2+7sG0WEg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767863444; c=relaxed/simple; bh=uq93U9o8JB9zbSTVh+vQQdETnho1x8xCHUG4yBJ991Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q46ysp3N6jEDclNywKDNr7gdRogFdgzakNIxcrjluCDtrAnk9t8UD/azWTG2EUzLLwYs4nGdxBS0QwoLwDIfqjIEbQAAVnrdyhUX4YUvN/oEepcBMp8brM4oM4maHHn1j3e7QybpKqhzWrR8/21hwjKYGQD0wA/wcyhq4EFPSRI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=ax4a+ip4; arc=none smtp.client-ip=209.85.216.97 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="ax4a+ip4" Received: by mail-pj1-f97.google.com with SMTP id 98e67ed59e1d1-34be2be4b7cso1653983a91.3 for ; Thu, 08 Jan 2026 01:10:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767863432; x=1768468232; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=l1wGe4AzuWmLwc2h4fqRv3J8yQzipzJ9zvQmyQ9uhA4=; b=uFH8CWgQBqdeHR3UHX3suC0tD0FEWCUSKNKCApoWHR8NY0vAh8ppd1jT6KFLgNARhj aCFFAQjtgG2+wXuMNeX/2cud5XnSdvjzyeMr8Be5dh8/JoM6Wb8KASytMhum76mQB+7x zb8aqk7YTcz2xlyY5iHqpwt97TNMMW2C5q6OhXdsLnoGnl7oAuTizS7rmRmr8obapdGd uSyTthU7bwuSGidZTwZ3FrRkqTVvJJLyLuLxl0ABl6/HY1PLQdCaZ5AQh88RUOpxHEC1 kVD6oIrDBkFS7OBKf8iu8qVM2jyyvu5GKZnfyblDgzGPCTWd76DfLz1vBACJIVksFsDd OprA== X-Forwarded-Encrypted: i=1; AJvYcCV3O7qfZdWjrh46YQXvxQSBUoeb1TkbSpNyB+aC31sBW/D6/yZyJeNz3PP3c5mRmzoCnsrJTMqy+afh4Wc=@vger.kernel.org X-Gm-Message-State: AOJu0Ywmue+YNIF0Jmz6wEwWjl6HB9ulr/uivdipKXAzAdBb6/UOInWI 7LR8v9u+sEwh9myeirykq6qfG8UbUr8TLU/m3cticiIr5QVd3G5MB3s9vO6t0jo40o5z6cNzWQL lh719oKtLjF+3scKuuS/d8Xgfd3d+WSww2P1kIeWBN3dNJ7KNzSbMOw9czFkaATljyp5NN63RqC Yn/P/XjT0adkBXv+ovqXkSkZ6LKuyzE7o9tTy87EeQaarLMvJox7R76iGeGlE+PtZKF3HrvE/mo e/eRsCifpe9Yk/npsKK3Y+Exg== X-Gm-Gg: AY/fxX54V5xaDNZJ+SbDC0Q//d1lCHnolYqkeuvFdbDiFaP+JvqFetovDh8Z9zye+fd VcDVPvJIAN/3K40INp2cWPq40pg51KvmvvWrDoKysibEzo8vBy164tLvCteLLoidW3AlRyyTrF5 hjPAos+NDNKlYwWnEb7hDYOMX3tIdMxELYl/SwsqASvtNVdJTw6SLWLAGGmTxcjvwQq2ZOtf78t M9IHk+FXcSZXFUpUc/7ExBlm1Y9uKFhN2iBYfTG/nWD3UqF54puv0tLxKcLakFVTVpoHQNh/6YY DAM8nCOjn1xoxNUKo47OTZUPcgjfIMhJu3mVuGk0Ka8eNu7SJIYipECA8EbkPAW1HKLfqsXuojW QDdTws9YBVrKp2X7JGZeoLh7ltpC1sP4PuKUhuHFl7PLmmFwzmYvW6Tju6RYTp+Sb+OkU6yf4rB cymZBPuQnRonDsK2+eGLGAOzxDYBOksWoYZQDIsg0VMMlVnA== X-Google-Smtp-Source: AGHT+IEF8IbWboquAYZ2Yo2ohdGcrZI5mjndAOMgmy5ZzUd0mXs+qW+ssLwqTpNFEH4AQi+jw8K7KuKqN+Xy X-Received: by 2002:a17:90b:5630:b0:34c:2db6:57a7 with SMTP id 98e67ed59e1d1-34f68b4dff7mr4973869a91.8.1767863431620; Thu, 08 Jan 2026 01:10:31 -0800 (PST) Received: from smtp-us-east1-p01-i01-si01.dlp.protect.broadcom.com (address-144-49-247-2.dlp.protect.broadcom.com. [144.49.247.2]) by smtp-relay.gmail.com with ESMTPS id 41be03b00d2f7-c4cbf0a02e0sm700619a12.2.2026.01.08.01.10.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jan 2026 01:10:31 -0800 (PST) X-Relaying-Domain: broadcom.com X-CFilter-Loop: Reflected Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-2b0530846d3so2202158eec.0 for ; Thu, 08 Jan 2026 01:10:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1767863430; x=1768468230; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=l1wGe4AzuWmLwc2h4fqRv3J8yQzipzJ9zvQmyQ9uhA4=; b=ax4a+ip4g4l4yfvuTcnabIcsykVjSS/IuuWmKcOm82Qu28E1W4qW5hGJlWkigY+Yn/ rDGQ7r8ZzlF5zJi845R4vFZJi5aMwkRNg4r+cJWxPDMBZ5dI+39p9jAgdoZrGrhzcX+t TzZAQO1s0fVYDA9qU91IcIlFkhWQ1P80l7Yfc= X-Forwarded-Encrypted: i=1; AJvYcCUIe48mWCP8yCP2ZbOSDREiUA54z64pnKn+Yuln2Umf+sCZ3VyNT31ZyLJXQzFnUxqhH3Cq8ygbc8SwlRE=@vger.kernel.org X-Received: by 2002:a05:7022:3c10:b0:119:e56b:98c0 with SMTP id a92af1059eb24-121f8b8bd9cmr3172455c88.39.1767863429608; Thu, 08 Jan 2026 01:10:29 -0800 (PST) X-Received: by 2002:a05:7022:3c10:b0:119:e56b:98c0 with SMTP id a92af1059eb24-121f8b8bd9cmr3172435c88.39.1767863428998; Thu, 08 Jan 2026 01:10:28 -0800 (PST) Received: from shivania.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-121f24985d1sm13267619c88.16.2026.01.08.01.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 01:10:28 -0800 (PST) From: Shivani Agarwal To: stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: mathias.nyman@intel.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ajay.kaher@broadcom.com, alexey.makhalov@broadcom.com, vamsi-krishna.brahmajosyula@broadcom.com, yin.ding@broadcom.com, tapas.kundu@broadcom.com, Niklas Neronin , Mathias Nyman , Shivani Agarwal Subject: [PATCH 1/2 v5.10-v6.1] usb: xhci: move link chain bit quirk checks into one helper function. Date: Thu, 8 Jan 2026 00:49:26 -0800 Message-Id: <20260108084927.671785-2-shivani.agarwal@broadcom.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260108084927.671785-1-shivani.agarwal@broadcom.com> References: <20260108084927.671785-1-shivani.agarwal@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-DetectorID-Processed: b00c1d49-9d2e-4205-b15f-d015386d3d5e Content-Type: text/plain; charset="utf-8" From: Niklas Neronin commit 7476a2215c07703db5e95efaa3fc5b9f957b9417 upstream. Older 0.95 xHCI hosts and some other specific newer hosts require the chain bit to be set for Link TRBs even if the link TRB is not in the middle of a transfer descriptor (TD). move the checks for all those cases into one xhci_link_chain_quirk() function to clean up and avoid code duplication. No functional changes. [skip renaming chain_links flag, reword commit message -Mathias] Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20240626124835.1023046-10-mathias.nyman@lin= ux.intel.com Signed-off-by: Greg Kroah-Hartman [Shivani: Modified to apply on v5.10.y-v6.1.y] Signed-off-by: Shivani Agarwal --- drivers/usb/host/xhci-mem.c | 10 ++-------- drivers/usb/host/xhci-ring.c | 8 ++------ drivers/usb/host/xhci.h | 7 +++++-- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 57f739f93321..42c12b382e9f 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -133,10 +133,7 @@ static void xhci_link_rings(struct xhci_hcd *xhci, str= uct xhci_ring *ring, if (!ring || !first || !last) return; =20 - /* Set chain bit for 0.95 hosts, and for isoc rings on AMD 0.96 host */ - chain_links =3D !!(xhci_link_trb_quirk(xhci) || - (ring->type =3D=3D TYPE_ISOC && - (xhci->quirks & XHCI_AMD_0x96_HOST))); + chain_links =3D xhci_link_chain_quirk(xhci, ring->type); =20 next =3D ring->enq_seg->next; xhci_link_segments(ring->enq_seg, first, ring->type, chain_links); @@ -326,10 +323,7 @@ static int xhci_alloc_segments_for_ring(struct xhci_hc= d *xhci, struct xhci_segment *prev; bool chain_links; =20 - /* Set chain bit for 0.95 hosts, and for isoc rings on AMD 0.96 host */ - chain_links =3D !!(xhci_link_trb_quirk(xhci) || - (type =3D=3D TYPE_ISOC && - (xhci->quirks & XHCI_AMD_0x96_HOST))); + chain_links =3D xhci_link_chain_quirk(xhci, type); =20 prev =3D xhci_segment_alloc(xhci, cycle_state, max_packet, flags); if (!prev) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index cb0bf8b6e017..1f047f38ef46 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -250,9 +250,7 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_= ring *ring, * AMD 0.96 host, carry over the chain bit of the previous TRB * (which may mean the chain bit is cleared). */ - if (!(ring->type =3D=3D TYPE_ISOC && - (xhci->quirks & XHCI_AMD_0x96_HOST)) && - !xhci_link_trb_quirk(xhci)) { + if (!xhci_link_chain_quirk(xhci, ring->type)) { next->link.control &=3D cpu_to_le32(~TRB_CHAIN); next->link.control |=3D cpu_to_le32(chain); } @@ -3355,9 +3353,7 @@ static int prepare_ring(struct xhci_hcd *xhci, struct= xhci_ring *ep_ring, /* If we're not dealing with 0.95 hardware or isoc rings * on AMD 0.96 host, clear the chain bit. */ - if (!xhci_link_trb_quirk(xhci) && - !(ep_ring->type =3D=3D TYPE_ISOC && - (xhci->quirks & XHCI_AMD_0x96_HOST))) + if (!xhci_link_chain_quirk(xhci, ep_ring->type)) ep_ring->enqueue->link.control &=3D cpu_to_le32(~TRB_CHAIN); else diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index fd095ff9fc8b..07591a498b5e 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1788,9 +1788,12 @@ static inline void xhci_write_64(struct xhci_hcd *xh= ci, lo_hi_writeq(val, regs); } =20 -static inline int xhci_link_trb_quirk(struct xhci_hcd *xhci) + +/* Link TRB chain should always be set on 0.95 hosts, and AMD 0.96 ISOC ri= ngs */ +static inline bool xhci_link_chain_quirk(struct xhci_hcd *xhci, enum xhci_= ring_type type) { - return xhci->quirks & XHCI_LINK_TRB_QUIRK; + return (xhci->quirks & XHCI_LINK_TRB_QUIRK) || + (type =3D=3D TYPE_ISOC && (xhci->quirks & XHCI_AMD_0x96_HOST)); } =20 /* xHCI debugging */ --=20 2.43.7 From nobody Sun Feb 8 20:34:14 2026 Received: from mail-vk1-f228.google.com (mail-vk1-f228.google.com [209.85.221.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DADE940756D for ; Thu, 8 Jan 2026 09:10:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.228 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767863444; cv=none; b=jPXsIOMveI6UpvPAn1e+KWAmW+yLNyJFETxRlgF/ro2SlxeuIq86/8j1LauJsVeqBaYQItYtRy2gu+0vp6cQjRFPQadGScFQ0CUIjGZIQR713zq/hr7dY5M5FZuACthcaLK7EFJuOVQDVEHMih0If5nHJqi9MU7dkVNNn/76NxI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767863444; c=relaxed/simple; bh=oMOgFSwY0RAP2ZDnrjutIY7BiKOu+6XtN7G/uaCAPag=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZrSJzM09wj0No92vNZwkjoqqF4hCJgpfTyd9NsmxY/9eXDHYcjwfcUk/6wiDsgU5TSrdSOWAniAdwZQsRI8TrwoStnEW+MzJpfDI4HfjAwZEGOMv1YAN7h5mtejGyV8CxB7URsQ9qs4qMEu49cqOA48Pl/hb+vYUl8KnC4396mY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=LTc4sRBn; arc=none smtp.client-ip=209.85.221.228 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="LTc4sRBn" Received: by mail-vk1-f228.google.com with SMTP id 71dfb90a1353d-55b302b8369so1978955e0c.0 for ; Thu, 08 Jan 2026 01:10:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767863433; x=1768468233; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=c9fHKbor+4yAlWDOSfn8eCqOO4MCtVL+l7N/J/f2X+c=; b=jBi/JlSDRfpRvnp50k0sd7nntXw2KuYESepsMP2sGe9ipOhgG3HrioyWy2gt8l+pGE UovFIiScq+ebg8a6xCYAymnjtG5uk49x6ugjmSnv7HIzGWbjZx2V0vz4HOG4hCcWaN2j 4Y6MY4I+DG+qNVqmdw2F9L6i8rL0udtojN4hm/3vXzRimYChLJLJqDTTOMcG6yyus1UT wsCgYxryPL9QfQzUhQCfVx0hj0X5bx/uZeNhwwllBuslyps/KiHuwdQcX+EbUUHQBD0j H18/49ahXybSNCZZ6DYszD/Z4veYKKySx9/JnGgSUw8Flj7fP1G/4HRd7SfNRh1ohfYk bK+Q== X-Forwarded-Encrypted: i=1; AJvYcCWzV7jY5NqEXht8HePc21A+vANorNpvY0ETjVvS7gSOT+XC2FR7vsYwgAY6zJtWNKS8y7d6yfQy4Ucyev4=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1X69lNkKhZZY3gKZTJqdbpWIMh+AIGgPzmuJdaw7cNsR1vsEE RNpNaIfv7Bt4ZZOg6wNkqXkPnM0qUG3z0BxswDC5iUJvDw427+C7EP6hYCYKedoproQ/4nABTS0 iIkZChp5oSgBviHHrBMq+X99jHxhVxYM6XPoUb0KKi8MMXDi5Erbto1LiisaX+3INrqPx3b0qzZ QrRITPoUPjNxnf9zHTIoYpFbrnY81r/lBHAMIArJjyn+m1EiU1b3xkiaCjF33VYdwp4JBpuak8p 0l3Srlj11wm3OeqiICWKik6Mg== X-Gm-Gg: AY/fxX4ty7ES4h55yjo/AJWrFIuUbZJQxgo0WWAzvVERuBDfQlaOWsfTEC0DJVwFBgL V0gXz5/n4trk/qKo6FM6UCVo1rT5D89PmOgggyHUC8DWVIYQduNCjlHEBXfCnrwINhj/pewUvQI +tUCZCB+mXlNcQI1nmNc3cpE2+aFROhbNCMJFnTRHcIPrYnyXOWqIIxEwDYPMEm0bdAfWi9uopm qoWQ29sTrGIEhzv4q8vMYoKZvKt9pFDWV4SkEKvVUwDQNGYT843mjHXz85vqM9PmFOYOuUOL6+o PAE0zG+81+gRQEKQ3vIrWr7uBNk5FEe/2dqqAPUp64641N3de0tPrqUZGU8wMSwc8a3T9G++gUH GigChI4sZZhtiF9bVsN1LPfzWEyXEfe1ogMFej+BHlTrLp1QB8wd87PThxLmdRYaL5YfKEtNN13 iGGcc48QnsphketFoyGNJ6ps7ds4EXGzv3Wbvhz9AYgM3Pmg== X-Google-Smtp-Source: AGHT+IG99rAM/9ULOC3zSGTXtiIuDpvOlWOWxZsX2Dl4V1Bl8pDV7ydHIyefw5aT8hwSkXRH8NavSuucJQO0 X-Received: by 2002:a05:6122:4593:b0:54a:9fe8:171e with SMTP id 71dfb90a1353d-56347d8330amr2034787e0c.7.1767863433253; Thu, 08 Jan 2026 01:10:33 -0800 (PST) Received: from smtp-us-east1-p01-i01-si01.dlp.protect.broadcom.com (address-144-49-247-1.dlp.protect.broadcom.com. [144.49.247.1]) by smtp-relay.gmail.com with ESMTPS id 71dfb90a1353d-5633a3d7c91sm799801e0c.5.2026.01.08.01.10.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jan 2026 01:10:33 -0800 (PST) X-Relaying-Domain: broadcom.com X-CFilter-Loop: Reflected Received: by mail-dl1-f69.google.com with SMTP id a92af1059eb24-11dd10b03d9so3077627c88.0 for ; Thu, 08 Jan 2026 01:10:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1767863432; x=1768468232; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c9fHKbor+4yAlWDOSfn8eCqOO4MCtVL+l7N/J/f2X+c=; b=LTc4sRBnTtZ9yqk7JM0Y7eRYHYfbFDOglaOv9zKuY+khG7l+8dG0skbYkvqOaYKs9e Xp42MEH0vOWnuKZnOWNl+yIhNTify25qqOu1REg+7GpCe0nkKJA/gKWXyyLbL1ShVnfp Nbi6KS4Y2vy9Dsk52Sop/4E4gl0i4LyWg1eLk= X-Forwarded-Encrypted: i=1; AJvYcCWE12/79/2Y3iKIIVQVsCMZEHy1uba1xs28UU4QYualKF3jIv2P3KqGAIBb/wVychCd36F4+B+cs8wHZNQ=@vger.kernel.org X-Received: by 2002:a05:7022:6187:b0:122:1e3:535d with SMTP id a92af1059eb24-12201e3552dmr268018c88.26.1767863432114; Thu, 08 Jan 2026 01:10:32 -0800 (PST) X-Received: by 2002:a05:7022:6187:b0:122:1e3:535d with SMTP id a92af1059eb24-12201e3552dmr267999c88.26.1767863431466; Thu, 08 Jan 2026 01:10:31 -0800 (PST) Received: from shivania.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-121f24985d1sm13267619c88.16.2026.01.08.01.10.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 01:10:30 -0800 (PST) From: Shivani Agarwal To: stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: mathias.nyman@intel.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ajay.kaher@broadcom.com, alexey.makhalov@broadcom.com, vamsi-krishna.brahmajosyula@broadcom.com, yin.ding@broadcom.com, tapas.kundu@broadcom.com, Michal Pecio , Mathias Nyman , Shivani Agarwal Subject: [PATCH 2/2 v5.10-v6.1] usb: xhci: Apply the link chain quirk on NEC isoc endpoints Date: Thu, 8 Jan 2026 00:49:27 -0800 Message-Id: <20260108084927.671785-3-shivani.agarwal@broadcom.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260108084927.671785-1-shivani.agarwal@broadcom.com> References: <20260108084927.671785-1-shivani.agarwal@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-DetectorID-Processed: b00c1d49-9d2e-4205-b15f-d015386d3d5e Content-Type: text/plain; charset="utf-8" From: Michal Pecio commit bb0ba4cb1065e87f9cc75db1fa454e56d0894d01 upstream. Two clearly different specimens of NEC uPD720200 (one with start/stop bug, one without) were seen to cause IOMMU faults after some Missed Service Errors. Faulting address is immediately after a transfer ring segment and patched dynamic debug messages revealed that the MSE was received when waiting for a TD near the end of that segment: [ 1.041954] xhci_hcd: Miss service interval error for slot 1 ep 2 expected = TD DMA ffa08fe0 [ 1.042120] xhci_hcd: AMD-Vi: Event logged [IO_PAGE_FAULT domain=3D0x0005 a= ddress=3D0xffa09000 flags=3D0x0000] [ 1.042146] xhci_hcd: AMD-Vi: Event logged [IO_PAGE_FAULT domain=3D0x0005 a= ddress=3D0xffa09040 flags=3D0x0000] It gets even funnier if the next page is a ring segment accessible to the HC. Below, it reports MSE in segment at ff1e8000, plows through a zero-filled page at ff1e9000 and starts reporting events for TRBs in page at ff1ea000 every microframe, instead of jumping to seg ff1e6000. [ 7.041671] xhci_hcd: Miss service interval error for slot 1 ep 2 expected = TD DMA ff1e8fe0 [ 7.041999] xhci_hcd: Miss service interval error for slot 1 ep 2 expected = TD DMA ff1e8fe0 [ 7.042011] xhci_hcd: WARN: buffer overrun event for slot 1 ep 2 on endpoint [ 7.042028] xhci_hcd: All TDs skipped for slot 1 ep 2. Clear skip flag. [ 7.042134] xhci_hcd: WARN: buffer overrun event for slot 1 ep 2 on endpoint [ 7.042138] xhci_hcd: ERROR Transfer event TRB DMA ptr not part of current = TD ep_index 2 comp_code 31 [ 7.042144] xhci_hcd: Looking for event-dma 00000000ff1ea040 trb-start 0000= 0000ff1e6820 trb-end 00000000ff1e6820 [ 7.042259] xhci_hcd: WARN: buffer overrun event for slot 1 ep 2 on endpoint [ 7.042262] xhci_hcd: ERROR Transfer event TRB DMA ptr not part of current = TD ep_index 2 comp_code 31 [ 7.042266] xhci_hcd: Looking for event-dma 00000000ff1ea050 trb-start 0000= 0000ff1e6820 trb-end 00000000ff1e6820 At some point completion events change from Isoch Buffer Overrun to Short Packet and the HC finally finds cycle bit mismatch in ff1ec000. [ 7.098130] xhci_hcd: ERROR Transfer event TRB DMA ptr not part of current = TD ep_index 2 comp_code 13 [ 7.098132] xhci_hcd: Looking for event-dma 00000000ff1ecc50 trb-start 0000= 0000ff1e6820 trb-end 00000000ff1e6820 [ 7.098254] xhci_hcd: ERROR Transfer event TRB DMA ptr not part of current = TD ep_index 2 comp_code 13 [ 7.098256] xhci_hcd: Looking for event-dma 00000000ff1ecc60 trb-start 0000= 0000ff1e6820 trb-end 00000000ff1e6820 [ 7.098379] xhci_hcd: Overrun event on slot 1 ep 2 It's possible that data from the isochronous device were written to random buffers of pending TDs on other endpoints (either IN or OUT), other devices or even other HCs in the same IOMMU domain. Lastly, an error from a different USB device on another HC. Was it caused by the above? I don't know, but it may have been. The disk was working without any other issues and generated PCIe traffic to starve the NEC of upstream BW and trigger those MSEs. The two HCs shared one x1 slot by means of a commercial "PCIe splitter" board. [ 7.162604] usb 10-2: reset SuperSpeed USB device number 3 using xhci_hcd [ 7.178990] sd 9:0:0:0: [sdb] tag#0 UNKNOWN(0x2003) Result: hostbyte=3D0x07= driverbyte=3DDRIVER_OK cmd_age=3D0s [ 7.179001] sd 9:0:0:0: [sdb] tag#0 CDB: opcode=3D0x28 28 00 04 02 ae 00 00= 02 00 00 [ 7.179004] I/O error, dev sdb, sector 67284480 op 0x0:(READ) flags 0x80700= phys_seg 5 prio class 0 Fortunately, it appears that this ridiculous bug is avoided by setting the chain bit of Link TRBs on isochronous rings. Other ancient HCs are known which also expect the bit to be set and they ignore Link TRBs if it's not. Reportedly, 0.95 spec guaranteed that the bit is set. The bandwidth-starved NEC HC running a 32KB/uframe UVC endpoint reports tens of MSEs per second and runs into the bug within seconds. Chaining Link TRBs allows the same workload to run for many minutes, many times. No negative side effects seen in UVC recording and UAC playback with a few devices at full speed, high speed and SuperSpeed. The problem doesn't reproduce on the newer Renesas uPD720201/uPD720202 and on old Etron EJ168 and VIA VL805 (but the VL805 has other bug). [shorten line length of log snippets in commit messge -Mathias] Signed-off-by: Michal Pecio Cc: stable@vger.kernel.org Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20250306144954.3507700-14-mathias.nyman@lin= ux.intel.com Signed-off-by: Greg Kroah-Hartman [Shivani: Modified to apply on v5.10.y-v6.1.y] Signed-off-by: Shivani Agarwal --- drivers/usb/host/xhci.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 07591a498b5e..b43e88102200 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1789,11 +1789,20 @@ static inline void xhci_write_64(struct xhci_hcd *x= hci, } =20 =20 -/* Link TRB chain should always be set on 0.95 hosts, and AMD 0.96 ISOC ri= ngs */ +/* + * Reportedly, some chapters of v0.95 spec said that Link TRB always has i= ts chain bit set. + * Other chapters and later specs say that it should only be set if the li= nk is inside a TD + * which continues from the end of one segment to the next segment. + * + * Some 0.95 hardware was found to misbehave if any link TRB doesn't have = the chain bit set. + * + * 0.96 hardware from AMD and NEC was found to ignore unchained isochronou= s link TRBs when + * "resynchronizing the pipe" after a Missed Service Error. + */ static inline bool xhci_link_chain_quirk(struct xhci_hcd *xhci, enum xhci_= ring_type type) { return (xhci->quirks & XHCI_LINK_TRB_QUIRK) || - (type =3D=3D TYPE_ISOC && (xhci->quirks & XHCI_AMD_0x96_HOST)); + (type =3D=3D TYPE_ISOC && (xhci->quirks & (XHCI_AMD_0x96_HOST | XH= CI_NEC_HOST))); } =20 /* xHCI debugging */ --=20 2.43.7