From nobody Sun Feb 8 18:32:47 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 From nobody Sun Feb 8 18:32:47 2026 Received: from mail-yx1-f98.google.com (mail-yx1-f98.google.com [74.125.224.98]) (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 3FACE3B2AA for ; Thu, 8 Jan 2026 09:11:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.98 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767863498; cv=none; b=TOwZdfd9MPVUbSyCyDGvZMiPoXS/aigVU2Vj7ae+Ob5UuyJmOCMC2MHrjgJEKuIcPay7Uvbufu+GhhJHtD1VMiV376cHqDtdswxGhOOxGmp4NQ+xUuo4iwVKZogJhXl+v98q1tmSW/NY8JQvPZb2f72X1W6ZQmmZ/pkCEX0JITE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767863498; c=relaxed/simple; bh=HQp3oovGDQbXP4Dt+ZR8z/jnBwW7VqtTMHkFskxW8Gw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QwdE2AzEopUDWX1MRH5dMhnzkksE3CqNk2ZdRioMHaUxQiZgyCGvkOu8fPtSnfQGRmty7Pyw4+/wowZiZfTv9SuOA0IfmnTTIijy9+CVDbZR5DLCNqhb4s71GXajZgQo5FdwbsUUBCw+ITIVYNlDLUaRYRWafP2lg+XqTwzZgls= 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=HC3mo+ep; arc=none smtp.client-ip=74.125.224.98 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="HC3mo+ep" Received: by mail-yx1-f98.google.com with SMTP id 956f58d0204a3-646fe7f70e2so2162934d50.0 for ; Thu, 08 Jan 2026 01:11:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767863487; x=1768468287; 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=ZIZ8jaVgH+Lp5oUnSioszXqfXxvQ8K6hRpZqt1TpuX4=; b=ZDTesgBv1z5BTYt03kxSC1LLWFBnM0CO8dopFG1QNo9+TYxXvRIrBbgEkax7l3i4BE AAYrv2B9ZKyNiEC5GGQEgEblwSe2+WcnNtuCjxpdTMXSBJUbiaR3UZd2nysopSW5hZ5U VxO2DThA5gUM2HQv8VdOqgg/QtwDg3gWHGkoUWWxKXTyHBkLBDwtc1jh+6aaCNKGVxbo cev4Ulas/TmHr7GkOjAnJwrgytIm01PTq2yHzCVvVPvGJUkUxjLDFtXrFcqG6rKPDdXe OEs1/XznZxf4tjjpmIE088Ad7gf7EsahBZ5119PjlZEAoaZsAXpGuLYOrJ3vPXmEQmG3 A/qg== X-Forwarded-Encrypted: i=1; AJvYcCVSs+tZjlmAJNx5TQbE0lG85sITq0Y2dBBV+0x8ZaIldNiq+eoncMpBUtYVUyc8bk4y24T2Dsos8u6wLRM=@vger.kernel.org X-Gm-Message-State: AOJu0YziFN6huxR+niXdDmmWvVqv20LKvPtANXKwZre423bHyGlV/ds0 6c0gW13DIlvc6eMF6kyGR7vbfbVfCfyPv+DVksWubxCa8Xl6joqMdMwGlUDMAVwPdWkguVinPFy Eu7+Sd/xMwYluwFT+88gi8vzbgGv6YPe2WylU3MayLbS74ytCH8ytFW37DBXV9qVi3szoFsHU2J epCCeYRDmAxl0HWZEkh5McVBOCC7OXTCiGz7c20+MbQNHq6BmAiy0IECgbPCCZntusl4YbMqwxu md7H2yOGM/TPW4yTeRMOBk2gQ== X-Gm-Gg: AY/fxX7u3/uA2pqqJmJjGMmrDFmoGuOHwqYMhD+e9XunhLRBeLq78xINTjLB/no2mMW p7voS39xsE1Z3fwaF4VsDtgDZMPZ6u2Bmn7AJtl1PwXDQVPKkNUMz8pRdQs9hKzPKywSy2agaBL z2DAY0VN0R1d4405CDHRZdNAIpc5aDvRPai1KMPr1+oJkWAHzJ1VdjUGixKreGIWRUvA9V6br7L HeVK6yNKWXUI0iUKfHRf0G3YUnHqh7nNpEEQ5ueKd/CcydwwfFnfEiUh6sGjnvvKbJ8Ho2vpNVt SauBknt3KHFSkPVzbN/PxSgHSybFchz4ry1TFTE5S0KtFtI8yJ0pYEGz0SutBm9bUxBOpJ4SJDl WZJvLjtmZuMWF/SLkOUub88d5pUuS7n5EFUnCRW/blMmBnHD15t2vY/10qWc3/LWhwgLknzx3cw 6noPFxqzUQ/ADfaeHC0DjLIHZ1o2mre7eFDwgLIodTXvIRGiHm91c= X-Google-Smtp-Source: AGHT+IESKBsoirymr5sopNyuqK2KIYiZe8Y0RI/JZbRRorXk2QsQzZ3SV1jctOR0FQc5kTfJW8pATrEXn/La X-Received: by 2002:a05:690e:4298:20b0:644:6e20:da76 with SMTP id 956f58d0204a3-64716c7546cmr3854044d50.73.1767863487061; Thu, 08 Jan 2026 01:11:27 -0800 (PST) Received: from smtp-us-east1-p01-i01-si01.dlp.protect.broadcom.com (address-144-49-247-120.dlp.protect.broadcom.com. [144.49.247.120]) by smtp-relay.gmail.com with ESMTPS id 956f58d0204a3-6470d7233d2sm630158d50.0.2026.01.08.01.11.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jan 2026 01:11:27 -0800 (PST) X-Relaying-Domain: broadcom.com X-CFilter-Loop: Reflected Received: by mail-dl1-f71.google.com with SMTP id a92af1059eb24-11f3d181ef2so12148547c88.1 for ; Thu, 08 Jan 2026 01:11:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1767863486; x=1768468286; 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=ZIZ8jaVgH+Lp5oUnSioszXqfXxvQ8K6hRpZqt1TpuX4=; b=HC3mo+ep76S+GusBvsFX1GjWxRu5Knf0MdWuyy+p+GYHkIoOEnWE5I9UsiwHAVe5rJ XVeHrcpO6Z4EUURtrJArJfo2oJBMiMOx2sTgwvIV4C8P6BKIzOoUMEGQUVPRlV7ttM6o lARoBU/dhmn0XLdlO9ZW0jOl+obc31w1csXso= X-Forwarded-Encrypted: i=1; AJvYcCV5XAvtHgSYvzpn/XpWye9uDmeTv0jWpRQNT1VtFdATx2H3Cxlqvmro7JLYABWCGOGZTsCLwSyoiPsTSZI=@vger.kernel.org X-Received: by 2002:a05:7022:2522:b0:11e:354:32cb with SMTP id a92af1059eb24-121f8b75fcemr5874329c88.49.1767863485600; Thu, 08 Jan 2026 01:11:25 -0800 (PST) X-Received: by 2002:a05:7022:2522:b0:11e:354:32cb with SMTP id a92af1059eb24-121f8b75fcemr5874296c88.49.1767863484796; Thu, 08 Jan 2026 01:11:24 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 01:11:24 -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 v6.6] usb: xhci: Apply the link chain quirk on NEC isoc endpoints Date: Thu, 8 Jan 2026 00:50:21 -0800 Message-Id: <20260108085021.671854-3-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: 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 6.6.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 cbd8ef1c8db6..849a83e4013c 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1785,11 +1785,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