From nobody Mon Feb 9 14:38:33 2026 Received: from mail-yw1-f225.google.com (mail-yw1-f225.google.com [209.85.128.225]) (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 7584B409FC2 for ; Thu, 8 Jan 2026 09:11:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.225 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767863496; cv=none; b=QHHWblIxQUTaJodEQzlAkO7EJ0kxL3t0dF1tc8M9OCBV28hMCv5ALUh4r9eZ50kA3iUxR2NXCvB6A66BpIExbr33J8iXOlZu07rrG19vTOf+gajOeHcAQhnrLm5Wl6xnJZt3xzS1X9db4SdU81U3JbrUQD/eTmn9v4swLRF8bB8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767863496; c=relaxed/simple; bh=B931oHIimqmsO10uO8Y+IrukZdrFt4h8LI0GgPLSxV4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tLoog39ks/iycbXSobP1M0cAgTnuMrRQnblfPbjk+VDnC/PObrFS+UGug/bWkGvCZqN4msfjnhk7wx9tDCJYMS6flTXOeIpA7xhyZsEjR+6lv+bnBNczjVQadiq1QQ9QRyHRWx1AeQZ/wniq8ylLxe3FMOzviYN0iWJ3J4ipnl0= 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=fLDMWLYI; arc=none smtp.client-ip=209.85.128.225 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="fLDMWLYI" Received: by mail-yw1-f225.google.com with SMTP id 00721157ae682-790992528f6so28340317b3.1 for ; Thu, 08 Jan 2026 01:11:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767863484; x=1768468284; 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=afDNHqE+O/jMQ8GoDcichOsLE/NDeo2/4CdPT3q2YIY=; b=KX5ua7X9ZllPKXpF3QrUO4GsItbO/MiRpXQtRq8N5oSpwQ+gyp9XD0AL0AWbxInrkd WjtthNLXmhoX74xtJefwz5i06KcxwCuI96ae9LL8IMBY3kOJsWBMcr20S+i5uhbGV/bK Np1u/JOQLCKuQYXYUHZgtHmX0MmYjSsf2FlL4I8DMf5KA+qIcgn6QqlKhfVmwW2OLaRU dj04eiYNL2mhmE6xMjki6FXI/iudnCDgMhQ1UOep7xXw+6MWGx2jbJmpsh2qa3fRQrCx aVcEiab4bjmfot1AC1G+6ID8/2aipHRvlUjEQGi9jHWnDFf2+17Rj0DYfhymt2lI50Qr aKXA== X-Forwarded-Encrypted: i=1; AJvYcCX/kJQp0BrbYa5dRENOvJe3KGmQffFlrcEEDYWEK7uBc4aqFJFVS1VxWXplv2t1yH5cMgCHvNpd2cABO8I=@vger.kernel.org X-Gm-Message-State: AOJu0YwZFZ1RbQ1qj5WQwPlOrxhMxGFX8heQn2yGYbQPNeCg7xfyUoD+ w/xIi935ERk+1o/ogzFJ8odEM9DZaPpi6g2Itx+5lUGEvMbVwpkJA+/vmsBNhB0lreeiyvfEp1a Dj4+iodakPk5fNI5TOw5aZW+M5Eh0vI3eJRQMh+Re3ZqTGyzQWDixhVV5sGF3v7+r4zKG2U9LvO cebzYH8MebkKprU4wGwv8satiC51Lm4S9+jY8kUycJ8Wa6cSLLIvMGgmHcPld0F2D/Y7sjvTT2v /IvtkSv5f8nfCs+b5NnbftDyg== X-Gm-Gg: AY/fxX727lGMgo1o0pyX0YvmIyzzltAiwMnXws1ADIqsS0o8kWOHYIy/DwXtcF9W74N Tjg7w7J39aAmCpodx3cxkrRNVQowpYo764iJIzz9WUiif42xkeF5ugnLsKxI6DZ3Vq24UtzasjC JpUqUZk+7sLGqLGcNj9uq7t4mLV2ZAFs5A6nSGpg4nLx/z4UsFPKu975zNNfr38N+OD0C0nlhPQ EJW3jjxIZumhZGHCPJkO9XdONmQBS/W620gFpNiTh2hNvVmzwlqUi28qXcqbeXpgV0ySdIMvkn9 IJfsUASPLQy6JM49gkCPIC9Vfl2G9jU0zfnXgxFV7cEnU4k/MFluJXXZ2mflQmtPH285kGCxtZ3 QZp/+UEirWIHqDWXUHZljnSuOve+DM3TDRkOA09zx5m/YO7aNqVp6Q9+dl4VoTuvvlT+36PHPmE FjEv+1FxGPrAqSEQy+e0O05N0jzOEirfCD0G9q7v6xZouM/w== X-Google-Smtp-Source: AGHT+IE8OyqdCGfcfKBcI5QYdxRDJGcKVutJ9Rx4sV4jhMXZK+ZIDO78Dkb3SBhE/MOTj/eBdaCh8WimB8rD X-Received: by 2002:a05:690c:e3c5:b0:788:ee99:f0fb with SMTP id 00721157ae682-790b55db84fmr56182647b3.6.1767863483864; Thu, 08 Jan 2026 01:11:23 -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 00721157ae682-790aa563f21sm5521497b3.4.2026.01.08.01.11.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jan 2026 01:11:23 -0800 (PST) X-Relaying-Domain: broadcom.com X-CFilter-Loop: Reflected Received: by mail-dy1-f199.google.com with SMTP id 5a478bee46e88-2b0530846d3so2202892eec.0 for ; Thu, 08 Jan 2026 01:11:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1767863483; x=1768468283; 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=afDNHqE+O/jMQ8GoDcichOsLE/NDeo2/4CdPT3q2YIY=; b=fLDMWLYI51tengXQI/QbjJil1AUrnf1AW6lzkOfVgFVmkLumZfcby6vX/tsiemB28i jxs7SjcsdOJKT4fE5Ips4dJZ1kAW+kcFa80y2x0wCRP0NEuohaZ5KJHLN/F4dld+h/lf RGLGGlOCtVusNk3vbuSBHCeol55DY/pa9N3iE= X-Forwarded-Encrypted: i=1; AJvYcCWtDCLKG0JqVpUWlv8OqU0V1LfUqgWqzwIgKnn3t3tdyS+HAeJcJWlz41z1x8dUazlrA18KfxmcLOsFkk0=@vger.kernel.org X-Received: by 2002:a05:693c:4151:10b0:2a4:8576:abf5 with SMTP id 5a478bee46e88-2b17d2b0af0mr3151548eec.23.1767863482646; Thu, 08 Jan 2026 01:11:22 -0800 (PST) X-Received: by 2002:a05:693c:4151:10b0:2a4:8576:abf5 with SMTP id 5a478bee46e88-2b17d2b0af0mr3151533eec.23.1767863482047; Thu, 08 Jan 2026 01:11:22 -0800 (PST) Received: from shivania.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b1706c503csm10623374eec.15.2026.01.08.01.11.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 01:11:21 -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 v6.6] usb: xhci: move link chain bit quirk checks into one helper function. Date: Thu, 8 Jan 2026 00:50:20 -0800 Message-Id: <20260108085021.671854-2-shivani.agarwal@broadcom.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260108085021.671854-1-shivani.agarwal@broadcom.com> References: <20260108085021.671854-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 6.6.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 621f12c11cbc..264f8bbe8f9e 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -136,10 +136,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); @@ -330,10 +327,7 @@ static int xhci_alloc_segments_for_ring(struct xhci_hc= d *xhci, unsigned int num =3D 0; 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, num, flags); if (!prev) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 6443e11eaac0..cdb819e323b3 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -245,9 +245,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); } @@ -3381,9 +3379,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 808f2ee43b94..cbd8ef1c8db6 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1784,9 +1784,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