From nobody Mon Feb 9 23:15:38 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