From nobody Sun Feb 8 13:45:07 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D09A432573B for ; Mon, 5 Jan 2026 08:48:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767602902; cv=none; b=o8xrmVqG3e1U4RxoFdbQk3GHiSDxW4/ZcEF4FakEI+LCr+BYGTRI2Yzb5d4S6jwXFdSWPqq6ET3QP5QheYyASWcfAUe4kI8TBTlkUM7YHMoTn8th5FZhVTqxdNiMytZPCI3oNbiN9NTE2OwIIOadulVTXU+fLthIV9ucCn35I5Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767602902; c=relaxed/simple; bh=zSTwg8qA91/I1Dq2HwiHZvJEu2KQuog15x4W3HyOd1E=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=r/wqKA/VKDKbsO0b/3McpON1LcpC4C8nkVnuPrjnQDSbjJof8ejSwOMw/+AUE3ngC6bBhWE2Yqpyf7wL6LdsTTTtMQeUBEDnJPzHZKoPySY8cbm1qqWb2C/xIQHX6Proa5R3o70R5D7lnef9VbbYd0+VqShRizomPOomQLCJ95o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=ZjsXP3Mh; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=RSjq1ltf; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="ZjsXP3Mh"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="RSjq1ltf" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 60585CGi978934 for ; Mon, 5 Jan 2026 08:48:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=qcppdkim1; bh=yO7BgBaXQEF6PSstmQOsG5C9hyOl6q9hlWY COPYPjoE=; b=ZjsXP3MhwgqFt/lGEsor/IZ3j9o/jx75Ey9ZX0ArQa3Uh0dGF7P EJxItw+CmITowemeKHqDq57KM3gAtXAg2EhjMFZDdO+jUNwBnfoY7v1l1TFWikWq Glw+iW2R0GJFWO3QdVWEJSBZLMaBkjYLrIRYRfFTSd+vMqWmpDuNXxCagmXv+tHM G7EUeLUQwYuUR9nsbWFJlUUQNpeCJPO3SpCI1mti7VV7BJJAgICr3gYVLGhw/rkH sm1kBQFtRm9Hyv2UlvI3oq4uWtaFd2zAqSNEtpq/KNIGtUkvwPN1J0W5GprbySl3 JnG1R62B5Ilge14lgWRT1K/kvTdU5EWUSyQ== Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4bg9ftg5hc-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 05 Jan 2026 08:48:14 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-34c7d0c5ed2so14303677a91.0 for ; Mon, 05 Jan 2026 00:48:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1767602893; x=1768207693; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=yO7BgBaXQEF6PSstmQOsG5C9hyOl6q9hlWYCOPYPjoE=; b=RSjq1ltfzmd9XC4tiZBwrqwcz7WABNhOj6cc4adhyvdGRzSBGxe0saAJW3cG8Av5TK jwoj+mVxD5J8/+a2o8kDRtGVi5OoSTJl6rC1sq8JjHTtmbQ2Dux4tLEaFKhXZThYmgg3 B9sdQK2TyT55E0Q71KFAv7LhEbtrSyqWuNmQJwRRVVEYsnbFIQySHREEfuhh6grHoBag vlf7kWYGO7gHUXT//jh8kjJz4+Y4GmPnNOYlUyDo0vrCeTQGWHQ67ZYnBbXFup3GEcQm p005kaC0zXEaprnOO1+ZPAeukQFwOvEHAFl7pSQjz+GghcjPXl9sSWFXdFjQi3WBen8M tyHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767602893; x=1768207693; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=yO7BgBaXQEF6PSstmQOsG5C9hyOl6q9hlWYCOPYPjoE=; b=e41ubG7JzHcGY17UQ76tRmIgX4xOK9BaZO22+YdGoBN89FiHeUjAJrtmCUwtRR2SMC N2+ssskf7Ls/DuUcvhyb1R2U9owaDrqzEVG2NJQYGwTaKZrLGdYo/uAHZquBMxpTFRSK uX2r26P/f9ewsJ5RtUHNkUfpea84F7gPnn2hgnugkQ0sj8ti9VXXFVIw7yhtuW/iFfGb 2QqziYcNQeK5eA0xng72ZgF8Mgu37/T0XsAj/o2h/0ZsK2jhJrVAmMTHMBeqLiDxvuzC bMqWAgELu1VpZHq851xytJHywdFXtim3+rO/BwLNIdoz531qpoq/ta0y1lczrlvf34ub OBjw== X-Forwarded-Encrypted: i=1; AJvYcCX8d9UgicKuo4KBbv5ozV0Mn9DbU5/I6/2fDSe5WOHEJ9AQ3J5wIe0YEj/hbQKXsgIku4LevcF5pKXQvJg=@vger.kernel.org X-Gm-Message-State: AOJu0YyrfIkKNrD7dN1ChU1tReKtJZoXqkkf0z/Bh/8Aahl/uMFqjL2H ktiSqPaauxCek+hdzzrRb/TYfiOJdHwlbN+Kf4tOnu9k08tgAPwy9NopwgvVa+m4kOk7+aOC0F+ MojpxP7J/RmA9JE3M/SrPyxdhjqbtYdcEC4WDHsSc8JqHfFoRFIWXjZcwyT3LXimu+JEDGvwbga U= X-Gm-Gg: AY/fxX4Uub6jMFt5riTR25+W9q7V6f4BdzY5uyF+s/vYwrU52/RL55bKhEUTl1F3L8X ZpES261chqBkB1jtm4+D/dPXaj+wsGevfDbDnsYzGBsnxghtAbQ8FOpBw5qg9aSFXAKpbuolTIH +3tUesmdIC62fy/lLLJYVhnI2CkcZsOHWn5P14N916J9OJPtRsgkmnYKmdx2US8FOt+ZoR5EZFc ieZj7qmYzF00kLjWYcI/rP6BaRtX/pCRocim/rBFTIMrZW50VO3qs+Fzr7EA5UDOpbrYQ3m7i7L ppSicT9lmSy97EkJ6WQHwko4GFPHN1Y2HKrfXSJlZmC1XwJKka2lT9xj+mCdgt0hABJ7EYVT8oF 3K0/kkKuuvq5d47/U4IQ/dR61W9Dwk51iw/5uMKYLNhyd X-Received: by 2002:a05:6a21:3290:b0:35e:3d4b:4cfe with SMTP id adf61e73a8af0-376a94c773bmr40219125637.39.1767602893296; Mon, 05 Jan 2026 00:48:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IG0NhfaQgKrz3M/gb7XsmHegNMy8uvUWE/KObeykAa3rW1Vt9SzjPRq4FvPXRSv3Wxtl83GDQ== X-Received: by 2002:a05:6a21:3290:b0:35e:3d4b:4cfe with SMTP id adf61e73a8af0-376a94c773bmr40219108637.39.1767602892757; Mon, 05 Jan 2026 00:48:12 -0800 (PST) Received: from hu-ugoswami-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34f47520505sm5518163a91.0.2026.01.05.00.48.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jan 2026 00:48:12 -0800 (PST) From: Udipto Goswami To: Greg Kroah-Hartman , Mathias Nyman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Udipto Goswami Subject: [RFC PATCH] usb: xhci: Skip configure EP for disabled slots during teardown Date: Mon, 5 Jan 2026 14:18:05 +0530 Message-Id: <20260105084805.2155251-1-udipto.goswami@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 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-Proofpoint-GUID: eoOG0NXQfCforSSiUQfspOMDEuJp5ZqS X-Authority-Analysis: v=2.4 cv=GboaXAXL c=1 sm=1 tr=0 ts=695b7ace cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=vUbySO9Y5rIA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=zaS1wXQRRR3QRWluEX4A:9 a=rl5im9kqc5Lf4LNbBjHf:22 X-Proofpoint-ORIG-GUID: eoOG0NXQfCforSSiUQfspOMDEuJp5ZqS X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTA1MDA3OCBTYWx0ZWRfXzKAb2uoeUcEb 1UNPPHvaoVBONV9hZx3vd0rjEEJVHy9XBrM2iTz9IRGTIm+2ZRSF/0M8KOaYxeyRkmZrSwTlKeO UM4aTKPY93TM6p5PXiljLr+8IdxFNtMPFULA6b+ZBY10qKf0/YssYMw3P0U1TbhhdvZKZNVBOwJ mHE81jiEiuMDMtZ/06G6he4FMgXU7dz4SLNWRDILkbTNuRqHirqAhs+rwqatPk9qAj4RBZmPir7 KwHFTuU1Uac1yQsujnmeDRB8SP/MljbK2X2cbW0KpXQKPhuqw+A5QA6YXwL51+H62YIwbwrgJ/6 bWfWuUIWGD0BQsSbn9cYdDj8wC3fQCYL+khVMIGXN9s9MZX4mN6xaN/nhEMSfSTfSEGAjfpumMo zNRGYoviW8OY/93m4yYKKHCtuZ/JwMsV9SZVV8CeRIKKvAnRkmtYTD0WPZVxduHchAk6znLcX+K dp7hSXdac0KpKue/r/A== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2026-01-05_01,2025-12-31_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 impostorscore=0 spamscore=0 malwarescore=0 clxscore=1011 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2512120000 definitions=main-2601050078 Content-Type: text/plain; charset="utf-8" Consider a scenario when a HS headset fails resume and the hub performs a logical disconnect, the USB core tears down endpoints and calls hcd->check_bandwidth() on the way out, which with xHCI translates to a drop-only Configure Endpoint command (add_flags =3D=3D SLOT_FLAG, drop_flags !=3D 0). If the slot is already disabled (slot_id =3D=3D 0) or the virtual device has been freed, issuing this Configure Endpoint command is pointless and may appear stuck until event handling catches up, causing unnecessary delays during disconnect teardown. Fix this by adding a check in xhci_check_bandwidth(), return success immediately if slot_id =3D=3D 0 or vdev is missing, preventing the Configure Endpoint command from being queued at all. Additionally, in xhci_configure_endpoint() for drop-only Configure Endpoint operations, return success early if slot_id =3D=3D 0 or vdev is already freed, avoiding spurious command waits. Signed-off-by: Udipto Goswami --- drivers/usb/host/xhci.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 02c9bfe21ae2..bc92edbad468 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -2958,6 +2958,7 @@ static int xhci_configure_endpoint(struct xhci_hcd *x= hci, struct xhci_input_control_ctx *ctrl_ctx; struct xhci_virt_device *virt_dev; struct xhci_slot_ctx *slot_ctx; + u32 add_flags, drop_flags; =20 if (!command) return -EINVAL; @@ -2979,6 +2980,19 @@ static int xhci_configure_endpoint(struct xhci_hcd *= xhci, return -ENOMEM; } =20 + /* + * For drop-only Configure Endpoint (add_flags =3D=3D SLOT_FLAG + * and drop_flags !=3D 0), if vdev is already gone, there is no hardware + * to configure. Return success early to avoid issuing pointless commands. + */ + add_flags =3D le32_to_cpu(ctrl_ctx->add_flags); + drop_flags =3D le32_to_cpu(ctrl_ctx->drop_flags); + if (!ctx_change && add_flags =3D=3D SLOT_FLAG && drop_flags !=3D 0 && !vi= rt_dev) { + spin_unlock_irqrestore(&xhci->lock, flags); + xhci_dbg(xhci, "skip drop-only Configure EP; vdev already freed\n"); + return 0; + } + if ((xhci->quirks & XHCI_EP_LIMIT_QUIRK) && xhci_reserve_host_resources(xhci, ctrl_ctx)) { spin_unlock_irqrestore(&xhci->lock, flags); @@ -3082,12 +3096,27 @@ int xhci_check_bandwidth(struct usb_hcd *hcd, struc= t usb_device *udev) if (ret <=3D 0) return ret; xhci =3D hcd_to_xhci(hcd); + + /* + * If the slot is already disabled (slot_id =3D=3D 0) or the vdev is gone, + * we're in teardown. There's nothing to update in HW. Treat as success + * and skip issuing Configure Endpoint command. + */ + if (!udev->slot_id) { + xhci_dbg(xhci, "Slot already disabled for udev %p\n", udev); + return 0; + } + + virt_dev =3D xhci->devs[udev->slot_id]; + if (!virt_dev) { + xhci_dbg(xhci, "virt_dev already freed for slot %d\n", udev->slot_id); + return 0; + } if ((xhci->xhc_state & XHCI_STATE_DYING) || (xhci->xhc_state & XHCI_STATE_REMOVING)) return -ENODEV; =20 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev); - virt_dev =3D xhci->devs[udev->slot_id]; =20 command =3D xhci_alloc_command(xhci, true, GFP_KERNEL); if (!command) --=20 2.34.1