From nobody Mon Sep 28 07:24:38 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 BAAEF309F08 for ; Tue, 25 Aug 2026 02:07:05 +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=1787623627; cv=none; b=F/VuM0sBd/M/33A8upaPiqTbkdd2QLOFIZ9p+HAR+wtowVjjjh/c3Frlj/vGNtg89yWBcYBxs87q1CWwfjeflL05XRix2wQGgNSWQM2MkoqIi2ZNUv7ImCn/k1ffWemhf/3SO5aZGRTu8VMkMLauJk3IrBmA5HmZyLrtCfQysWQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787623627; c=relaxed/simple; bh=IZhmY8lAjfPFB+VNxnCYr/qjCC7hbRpe/+XO+aXiA+U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SDEyhQTan4hOgvqDSsAcQ2bE6r+/GLwSYlgQk+pzaJcMm1hXvZsjAe4ckUzil4dWwwZb+n9joK4/aQICCahoafnljbT35THRVDsApdzgBxi2UHomzPphjMjpXHhfzKmK2KIHYnjCr/HYnTtSn63Wwdq6kyNyfHhq+EYyiu3VlTw= 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=AGUH3t3J; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=T3FsvbpE; 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="AGUH3t3J"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="T3FsvbpE" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67ONMaum107976 for ; Tue, 25 Aug 2026 02:07:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= q2iYO/r/HmJr9Cxtr5ffY+0uSqlQMOAULDrmT9AVeec=; b=AGUH3t3JO4IRoCDd RhORHKQ8HVzrWkXjMOgrHRC5fiafMpvT1M/G/A+udp3sVxCE6D/bSKEqr1xGDF8F 4kEiPNjuhJ0LlcWpbBXMODU0hXh0XxLS4T3sy1TRowb0DHxHOwp5VED5R7t8AVI6 YzYK05ywgCXCfxfoO2vQXINWfBMi/FGcw3pCpRqFC8BTHWjCrelbDNUoA/c77FQP YugnYqcddqNMEb1E3gxiwhRWQ/DlLQf1MgLJXJL2BUudA8c3trt3jfVbc8wcl43Q FkzyAxvE2vraP9fNGPiU+lL9SYgV01uyli+fdO1P2TUCKihQFSfK0Rgf6hOxEEPi a+R+fw== Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g8t1s1m21-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 25 Aug 2026 02:07:04 +0000 (GMT) Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-cbef1d25500so5205892a12.1 for ; Mon, 24 Aug 2026 19:07:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1787623622; x=1788228422; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=q2iYO/r/HmJr9Cxtr5ffY+0uSqlQMOAULDrmT9AVeec=; b=T3FsvbpE407LxbGwLrZ8yHGe28ZusyfVsQkPTiZnS6m4oY9OW8QBPKY61+XdpOI6DY EobcV5AFW3yFFVmy6VsDQaFmZ2AGpQGP+Lubq0LEdbIdeqiwvhxmJL3Hp8JZBKmrrcUG T6wSvfyFZiH+j6rT9P4CnTr2NcduBql/Oow8LILPRgBo5EtNVopiyGSOUnRXlk8VcPTc SeF9oHu+NIc+vFCrqEMuolxxWUfAYzvPN1BPqPguRlFqpCZ89tfDOCJ2ViaqXmC5TORZ a0NUU6L2PXJPynzUyYPFYGOYPv0zLIAWpO/Ilax1e9P89VBqk0OZe9IcgrK9PmrIBC5q oobQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787623622; x=1788228422; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=q2iYO/r/HmJr9Cxtr5ffY+0uSqlQMOAULDrmT9AVeec=; b=gvIfNO6noNoQH2Z+ORNbFf8hQHWtHfb62t/OxfESLxaSd93xzMPai+55kq/s/8FOGy hFFktQ+H8zlMKXmSCedrAhmtb4JHYIhHvD9yqKoUdNfi6nKUZ+ZZ861gHd0d9Co+oMnD zP/4OKtEwsfm3IF9chl55keY+U40TohVRk0EeTi3l8cwzz4NB1jcsQfAkQSdRvw7dGHJ xh0XJ4SqPMTSmweet0kTMkLI5e5u10D2uJUOOG4HrcIp3f86kCGRnmCjunpkbvAslBQw fVLBSu576bzJey2QGaEwz7zYojGlfZLE6hmU2lh+tgppeshjASyv1mNRoiE2N6hKqKCu 1i9w== X-Forwarded-Encrypted: i=1; AHgh+RoWxeaGJxMWzsdgyx8g5WuH0IoCUwBQDjxiqmdNdyZslvvZ6Iylq/oIo7BcNnSsiludr3oygsk8ObePGZo=@vger.kernel.org X-Gm-Message-State: AFuF++nreOHtJPtBbEKoOvCkMZWUCiHL3+Zpa9Rwz+7LHt0MvccKjbkm z9h7+zhOjuEHPbh2/Qa4F/CLqPOnOGNPSkONpWWnhKu0mO1jWMr7HvLV1LYtpLZGdJECchaPm+y iNAJVW0Wrcy384S6/oNDLNgYpsrulYUaOc1d79uDdeSCLmDxHaBbud2n8bOWqk4+Mhq0= X-Gm-Gg: AR+sD13eVP3XHmaGKdrTQDcAcc7ZqZIKGYWTzZHiqryWecNNQOfvvn/NaJrN2Bgpm87 lWKm5DYl4Fc6Ub3Zh4aZJhbfniZhgu9Y4DvDlndUkVOc4374plnn/2g9VUG1KNsq0iLjQ42VgpA RAHn3X4/P0CDx4zXnXTuBb8ituyyY6pyGeuocHsUc0IEyheKPzbjxR7GbsN8CSAagWZZx/wxkwW p8t21UKO7+EQLWON9YMgU3dg9rKinTgHshxpA5M1V4AvvrVggNp3+gmDPsi2h3a9ELAnCY3ULpT T438/w2w3YdwkgNLBszDhKu+Scuw9ILVCL2UwwwP4JULawnHhAx9V23o6wU8hQfGD2nTeUt7UcT W3twvRX1HBCImoGqDKxzrD0mhyBUVrZ66dGcO+z7usV2pkHwvyfC9 X-Received: by 2002:a05:6a20:6f8f:b0:3c3:a31b:3949 with SMTP id adf61e73a8af0-3cd911bf820mr6335033637.11.1787623622239; Mon, 24 Aug 2026 19:07:02 -0700 (PDT) X-Received: by 2002:a05:6a20:6f8f:b0:3c3:a31b:3949 with SMTP id adf61e73a8af0-3cd911bf820mr6334918637.11.1787623621734; Mon, 24 Aug 2026 19:07:01 -0700 (PDT) Received: from hu-wcheng-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-327f91d33dcsm39442376eec.18.2026.08.24.19.06.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2026 19:06:59 -0700 (PDT) From: Wesley Cheng Date: Mon, 24 Aug 2026 19:06:55 -0700 Subject: [PATCH 1/2] xhci: sideband: support page-aligned ring segment allocation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260824-16k_offload_v1_b4-v1-1-49a6be60ca30@oss.qualcomm.com> References: <20260824-16k_offload_v1_b4-v1-0-49a6be60ca30@oss.qualcomm.com> In-Reply-To: <20260824-16k_offload_v1_b4-v1-0-49a6be60ca30@oss.qualcomm.com> To: Mathias Nyman , Greg Kroah-Hartman , Jaroslav Kysela , Takashi Iwai Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org, Wesley Cheng X-Mailer: b4 0.15.2 X-Proofpoint-GUID: Jl2g2tgkvlWi3L0WG0PdrFL2ooXwxoaf X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODI1MDAxNiBTYWx0ZWRfX8WrDy6glaYLf Dw1RgNI3Mv2hTNGj3wA39QiPpUIWggouU41lvghX2PJ7IxrI6laJ+UHnRvo78b3iUsbrpnD9AM5 ZYJR/uTh3qu9iDK5xqj4QCttNvdEEmYkJ/huFFdEEGdLDZFOOwd0HokVz7lt816kYh61DQchKK0 nu+GrfmK3YJaycDkrBzetBdDsgSStN9uK2qf55GvwOggDtKlOkdOx/tIZtzNyBOnAg2SSlsGJkG BwTlEBiJU15nFqrg2/hJFztYQTi6TzouQ7JX8clJ881t80jNgVDsksF1lNNhHdUX7v+2+LfYxt7 iLUzwJ2DNiLZ/SGvNYGwsTIEGpVB58rfPOUqnqTv2ZZ6XNihzOJzGWtUuuzAq5s4T9x7jFC7e5n TMHdUPK6Qkuy/kbn12lExtkqEcQVmfFKHrK1zpPtuK0xV4es+Imfke4bO7ChLTRzIabieDmvLVv 6TrrOO1fIsq9WwfT54A== X-Proofpoint-Spam-Info: AW1haW4tMjYwODI1MDAxNiBTYWx0ZWRfX4o8OBR4KnqYI CmaMx6u0puagV+WqB3xJ0prVKnqQX7mI8tJ2mKxzaSpc6s4b2tBFG3YbSNGsDFpc7onkyL9PdUn HQbkCV5HR5jbQG3Dimt97uc05xMWDrA= X-Authority-Analysis: v=2.4 cv=L7ItheT8 c=1 sm=1 tr=0 ts=6a8cf8c8 cx=c_pps a=Oh5Dbbf/trHjhBongsHeRQ==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=RFEkg1aCLAsbH47RIloA:9 a=QEXdDO2ut3YA:10 a=_Vgx9l1VpLgwpw_dHYaR:22 X-Proofpoint-ORIG-GUID: Jl2g2tgkvlWi3L0WG0PdrFL2ooXwxoaf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-24_07,2026-08-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 impostorscore=0 spamscore=0 clxscore=1011 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608250016 Ring segments are normally allocated from a shared DMA pool sized and aligned to TRB_SEGMENT_SIZE (4096 bytes). On kernels built with a larger PAGE_SIZE (e.g. 16K or 64K page arches), a segment can end up at a non-page-aligned offset within its enclosing CPU page. A sideband client that maps a ring buffer directly via the IOMMU (which operates at page granularity) needs the ring to start at a page boundary and occupy whole pages, otherwise the IOVA it is given does not correspond to the actual start of the ring. Add an alignment_req parameter to the ring/segment allocation path (xhci_ring_alloc(), xhci_segment_alloc(), xhci_endpoint_init(), xhci_alloc_interrupter(), xhci_create_secondary_interrupter()) and to the sideband API (xhci_sideband_add_endpoint(), xhci_sideband_create_interrupter()) so a sideband client can request a specific alignment for its endpoint ring and interrupter event ring. When the requested alignment exceeds TRB_SEGMENT_SIZE, allocate the segment directly with dma_alloc_coherent() at that size instead of from the shared pool. Store the alignment requirement on struct xhci_ring so later segments added via ring expansion keep the same alignment for the life of the ring. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Wesley Cheng --- drivers/usb/host/xhci-mem.c | 70 ++++++++++++++++++++++++++++-------= ---- drivers/usb/host/xhci-sideband.c | 9 +++-- drivers/usb/host/xhci.h | 11 ++++-- include/linux/usb/xhci-sideband.h | 7 ++-- 4 files changed, 70 insertions(+), 27 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 7a21ac81f9c8..5f09b36c127b 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -15,6 +15,7 @@ #include #include #include +#include =20 #include "xhci.h" #include "xhci-trace.h" @@ -30,6 +31,7 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci, unsigned int max_packet, unsigned int num, + unsigned int alignment_req, gfp_t flags) { struct xhci_segment *seg; @@ -40,7 +42,14 @@ static struct xhci_segment *xhci_segment_alloc(struct xh= ci_hcd *xhci, if (!seg) return NULL; =20 - seg->trbs =3D dma_pool_zalloc(xhci->segment_pool, flags, &dma); + if (alignment_req > TRB_SEGMENT_SIZE) { + seg->trbs =3D dma_alloc_coherent(dev, alignment_req, &dma, flags); + if (seg->trbs) + seg->alloc_size =3D alignment_req; + } else { + seg->trbs =3D dma_pool_zalloc(xhci->segment_pool, flags, &dma); + } + if (!seg->trbs) { kfree(seg); return NULL; @@ -50,7 +59,10 @@ static struct xhci_segment *xhci_segment_alloc(struct xh= ci_hcd *xhci, seg->bounce_buf =3D kzalloc_node(max_packet, flags, dev_to_node(dev)); if (!seg->bounce_buf) { - dma_pool_free(xhci->segment_pool, seg->trbs, dma); + if (seg->alloc_size) + dma_free_coherent(dev, seg->alloc_size, seg->trbs, dma); + else + dma_pool_free(xhci->segment_pool, seg->trbs, dma); kfree(seg); return NULL; } @@ -65,7 +77,11 @@ static struct xhci_segment *xhci_segment_alloc(struct xh= ci_hcd *xhci, static void xhci_segment_free(struct xhci_hcd *xhci, struct xhci_segment *= seg) { if (seg->trbs) { - dma_pool_free(xhci->segment_pool, seg->trbs, seg->dma); + if (seg->alloc_size) + dma_free_coherent(xhci_to_hcd(xhci)->self.sysdev, + seg->alloc_size, seg->trbs, seg->dma); + else + dma_pool_free(xhci->segment_pool, seg->trbs, seg->dma); seg->trbs =3D NULL; } kfree(seg->bounce_buf); @@ -334,7 +350,7 @@ static int xhci_alloc_segments_for_ring(struct xhci_hcd= *xhci, struct xhci_ring struct xhci_segment *prev; unsigned int num =3D 0; =20 - prev =3D xhci_segment_alloc(xhci, ring->bounce_buf_len, num, flags); + prev =3D xhci_segment_alloc(xhci, ring->bounce_buf_len, num, ring->alignm= ent_req, flags); if (!prev) return -ENOMEM; num++; @@ -343,7 +359,8 @@ static int xhci_alloc_segments_for_ring(struct xhci_hcd= *xhci, struct xhci_ring while (num < ring->num_segs) { struct xhci_segment *next; =20 - next =3D xhci_segment_alloc(xhci, ring->bounce_buf_len, num, flags); + next =3D xhci_segment_alloc(xhci, ring->bounce_buf_len, num, + ring->alignment_req, flags); if (!next) goto free_segments; =20 @@ -370,7 +387,8 @@ static int xhci_alloc_segments_for_ring(struct xhci_hcd= *xhci, struct xhci_ring * See section 4.9.1 and figures 15 and 16. */ struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci, unsigned int num_= segs, - enum xhci_ring_type type, unsigned int max_packet, gfp_t flags) + enum xhci_ring_type type, unsigned int max_packet, + unsigned int alignment_req, gfp_t flags) { struct xhci_ring *ring; int ret; @@ -382,6 +400,7 @@ struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci= , unsigned int num_segs, =20 ring->num_segs =3D num_segs; ring->bounce_buf_len =3D max_packet; + ring->alignment_req =3D alignment_req; INIT_LIST_HEAD(&ring->td_list); ring->type =3D type; if (num_segs =3D=3D 0) @@ -421,6 +440,7 @@ int xhci_ring_expansion(struct xhci_hcd *xhci, struct x= hci_ring *ring, =20 new_ring.num_segs =3D num_new_segs; new_ring.bounce_buf_len =3D ring->bounce_buf_len; + new_ring.alignment_req =3D ring->alignment_req; new_ring.type =3D ring->type; ret =3D xhci_alloc_segments_for_ring(xhci, &new_ring, flags); if (ret) @@ -663,7 +683,7 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct = xhci_hcd *xhci, =20 for (cur_stream =3D 1; cur_stream < num_streams; cur_stream++) { stream_info->stream_rings[cur_stream] =3D - xhci_ring_alloc(xhci, 2, TYPE_STREAM, max_packet, mem_flags); + xhci_ring_alloc(xhci, 2, TYPE_STREAM, max_packet, 0, mem_flags); cur_ring =3D stream_info->stream_rings[cur_stream]; if (!cur_ring) goto cleanup_rings; @@ -1007,7 +1027,7 @@ int xhci_alloc_virt_device(struct xhci_hcd *xhci, int= slot_id, } =20 /* Allocate endpoint 0 ring */ - dev->eps[0].ring =3D xhci_ring_alloc(xhci, 2, TYPE_CTRL, 0, flags); + dev->eps[0].ring =3D xhci_ring_alloc(xhci, 2, TYPE_CTRL, 0, 0, flags); if (!dev->eps[0].ring) goto fail; =20 @@ -1486,11 +1506,20 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, if (usb_endpoint_xfer_control(&ep->desc) && xhci->hci_version >=3D 0x100) avg_trb_len =3D 8; =20 - /* Set up the endpoint ring */ - virt_dev->eps[ep_index].new_ring =3D - xhci_ring_alloc(xhci, 2, ring_type, max_packet, mem_flags); - if (!virt_dev->eps[ep_index].new_ring) - return -ENOMEM; + if (virt_dev->eps[ep_index].sideband && virt_dev->eps[ep_index].sideband-= >alignment_req) { + virt_dev->eps[ep_index].new_ring =3D + xhci_ring_alloc(xhci, 2, ring_type, max_packet, + virt_dev->eps[ep_index].sideband->alignment_req, + mem_flags); + if (!virt_dev->eps[ep_index].new_ring) + return -ENOMEM; + } else { + /* Set up the endpoint ring */ + virt_dev->eps[ep_index].new_ring =3D + xhci_ring_alloc(xhci, 2, ring_type, max_packet, 0, mem_flags); + if (!virt_dev->eps[ep_index].new_ring) + return -ENOMEM; + } =20 virt_dev->eps[ep_index].skip =3D false; virt_dev->eps[ep_index].next_uframe =3D -1; @@ -2291,7 +2320,8 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xh= ci, gfp_t flags) } =20 static struct xhci_interrupter * -xhci_alloc_interrupter(struct xhci_hcd *xhci, unsigned int segs, gfp_t fla= gs) +xhci_alloc_interrupter(struct xhci_hcd *xhci, unsigned int segs, + unsigned int alignment_req, gfp_t flags) { struct device *dev =3D xhci_to_hcd(xhci)->self.sysdev; struct xhci_interrupter *ir; @@ -2307,8 +2337,7 @@ xhci_alloc_interrupter(struct xhci_hcd *xhci, unsigne= d int segs, gfp_t flags) ir =3D kzalloc_node(sizeof(*ir), flags, dev_to_node(dev)); if (!ir) return NULL; - - ir->event_ring =3D xhci_ring_alloc(xhci, segs, TYPE_EVENT, 0, flags); + ir->event_ring =3D xhci_ring_alloc(xhci, segs, TYPE_EVENT, 0, alignment_r= eq, flags); if (!ir->event_ring) { xhci_warn(xhci, "Failed to allocate interrupter event ring\n"); kfree(ir); @@ -2356,7 +2385,8 @@ void xhci_add_interrupter(struct xhci_hcd *xhci, unsi= gned int intr_num) =20 struct xhci_interrupter * xhci_create_secondary_interrupter(struct usb_hcd *hcd, unsigned int segs, - u32 imod_interval, unsigned int intr_num) + u32 imod_interval, unsigned int intr_num, + unsigned int alignment_req) { struct xhci_hcd *xhci =3D hcd_to_xhci(hcd); struct xhci_interrupter *ir; @@ -2367,7 +2397,7 @@ xhci_create_secondary_interrupter(struct usb_hcd *hcd= , unsigned int segs, intr_num >=3D xhci->max_interrupters) return NULL; =20 - ir =3D xhci_alloc_interrupter(xhci, segs, GFP_KERNEL); + ir =3D xhci_alloc_interrupter(xhci, segs, alignment_req, GFP_KERNEL); if (!ir) return NULL; =20 @@ -2485,7 +2515,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) goto fail; =20 /* Set up the command ring to have one segments for now. */ - xhci->cmd_ring =3D xhci_ring_alloc(xhci, 1, TYPE_COMMAND, 0, flags); + xhci->cmd_ring =3D xhci_ring_alloc(xhci, 1, TYPE_COMMAND, 0, 0, flags); if (!xhci->cmd_ring) goto fail; =20 @@ -2498,7 +2528,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) if (!xhci->interrupters) goto fail; =20 - xhci->interrupters[0] =3D xhci_alloc_interrupter(xhci, 0, flags); + xhci->interrupters[0] =3D xhci_alloc_interrupter(xhci, 0, 0, flags); if (!xhci->interrupters[0]) goto fail; =20 diff --git a/drivers/usb/host/xhci-sideband.c b/drivers/usb/host/xhci-sideb= and.c index a5deeee4d5dc..471219d7d86d 100644 --- a/drivers/usb/host/xhci-sideband.c +++ b/drivers/usb/host/xhci-sideband.c @@ -144,7 +144,8 @@ EXPORT_SYMBOL_GPL(xhci_sideband_notify_ep_ring_free); */ int xhci_sideband_add_endpoint(struct xhci_sideband *sb, - struct usb_host_endpoint *host_ep) + struct usb_host_endpoint *host_ep, + unsigned int alignment_req) { struct xhci_virt_ep *ep; unsigned int ep_index; @@ -171,6 +172,7 @@ xhci_sideband_add_endpoint(struct xhci_sideband *sb, if (sb->eps[ep_index] || ep->sideband) return -EBUSY; =20 + sb->alignment_req =3D alignment_req; ep->sideband =3D sb; sb->eps[ep_index] =3D ep; =20 @@ -322,7 +324,8 @@ EXPORT_SYMBOL_GPL(xhci_sideband_check); */ int xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg, - bool ip_autoclear, u32 imod_interval, int intr_num) + bool ip_autoclear, u32 imod_interval, int intr_num, + unsigned int alignment_req) { if (!sb || !sb->xhci) return -ENODEV; @@ -337,7 +340,7 @@ xhci_sideband_create_interrupter(struct xhci_sideband *= sb, int num_seg, =20 sb->ir =3D xhci_create_secondary_interrupter(xhci_to_hcd(sb->xhci), num_seg, imod_interval, - intr_num); + intr_num, alignment_req); if (!sb->ir) return -ENOMEM; =20 diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index c7bfa7f028d3..e356405c6351 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1290,6 +1290,10 @@ struct xhci_segment { void *bounce_buf; unsigned int bounce_offs; unsigned int bounce_len; + /* nonzero if trbs was allocated via dma_alloc_coherent() at this size, + * instead of from xhci->segment_pool + */ + unsigned int alloc_size; }; =20 enum xhci_cancelled_td_status { @@ -1377,6 +1381,7 @@ struct xhci_ring { unsigned int stream_id; unsigned int num_segs; unsigned int bounce_buf_len; + unsigned int alignment_req; enum xhci_ring_type type; u32 old_trb_comp_code; struct radix_tree_root *trb_address_map; @@ -1823,7 +1828,8 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, struct = xhci_virt_device *virt_dev, struct usb_device *udev, struct usb_host_endpoint *ep, gfp_t mem_flags); struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci, unsigned int num_= segs, - enum xhci_ring_type type, unsigned int max_packet, gfp_t flags); + enum xhci_ring_type type, unsigned int max_packet, + unsigned int alignment_req, gfp_t flags); void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring); int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring, unsigned int num_trbs, gfp_t flags); @@ -1865,7 +1871,8 @@ void xhci_free_port_bw_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx); struct xhci_interrupter * xhci_create_secondary_interrupter(struct usb_hcd *hcd, unsigned int segs, - u32 imod_interval, unsigned int intr_num); + u32 imod_interval, unsigned int intr_num, + unsigned int alignment_req); void xhci_remove_secondary_interrupter(struct usb_hcd *hcd, struct xhci_interrupter *ir); void xhci_skip_sec_intr_events(struct xhci_hcd *xhci, diff --git a/include/linux/usb/xhci-sideband.h b/include/linux/usb/xhci-sid= eband.h index 005257085dcb..8ab4e1cb0fc6 100644 --- a/include/linux/usb/xhci-sideband.h +++ b/include/linux/usb/xhci-sideband.h @@ -62,6 +62,7 @@ struct xhci_sideband { struct usb_interface *intf; int (*notify_client)(struct usb_interface *intf, struct xhci_sideband_event *evt); + unsigned int alignment_req; }; =20 struct xhci_sideband * @@ -72,7 +73,8 @@ void xhci_sideband_unregister(struct xhci_sideband *sb); int xhci_sideband_add_endpoint(struct xhci_sideband *sb, - struct usb_host_endpoint *host_ep); + struct usb_host_endpoint *host_ep, + unsigned int alignment_req); int xhci_sideband_remove_endpoint(struct xhci_sideband *sb, struct usb_host_endpoint *host_ep); @@ -94,7 +96,8 @@ static inline bool xhci_sideband_check(struct usb_hcd *hc= d) =20 int xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg, - bool ip_autoclear, u32 imod_interval, int intr_num); + bool ip_autoclear, u32 imod_interval, int intr_num, + unsigned int alignment_req); void xhci_sideband_remove_interrupter(struct xhci_sideband *sb); int --=20 2.34.1 From nobody Mon Sep 28 07:24:38 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 899543093CB for ; Tue, 25 Aug 2026 02:07:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787623627; cv=none; b=j5z3jeGjKFQndEseLcOUO/q44N85wrEO5i0gjL61weYBYb02fdd7bJDabRucDSWaTtIGTWj/ZmwF4iEoutCD1NPzyrmYsLSg/eo2miYwFHOdGW+yYU5GvJA3E6NCNw5i1pn4AI3wvrn9+6nQjNlVvvrBvD9dw08S+zacRA7tkC4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787623627; c=relaxed/simple; bh=jZ9edC218ErYtuLBf01+Uq6fGVBYmGjOA1pWHaCCy+M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=S5PDTszZsSc99yepW9HeeHG7wG9EtzUR+LyeDZxSf1N7C7QiT/2C/HVvVMf3ppS/EjJb7Xy3tk+XY2uxbfi9pGGAT+Vr2dJlNJBEkdxYSPdrUiiJGnkCPicYsIoIYy93Tb7Lg2LnGiv9SAXcM0/XU9QhY80OsO/LIG6eRKDEV68= 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=SY/XCYXY; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Segfi6jb; arc=none smtp.client-ip=205.220.168.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="SY/XCYXY"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Segfi6jb" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67ONMFdp3931533 for ; Tue, 25 Aug 2026 02:07:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= YzF3hXZW0ytcWbA+isUMZBMZ3HrRdAr99GThHRzOSok=; b=SY/XCYXYw+5laH5/ wZbWHkILawpV/YQ16VNXFkz4xTjcjQd1BeMgBo+CcmltD9yg780ZTLCa2awzGZQ4 g7FdMzminkBYCfQripJxOXkrtahHTyD1g3rq/wawd0yUzQpmCQTkkqUcdkPt310C awNh4bqR6IR9sdJEueFAzqZWhvWKYnUTRBDXcKGguX2LAE3k4l4k4fOa88gAag31 V4Nyse8upSj35BG/V2YW6SxQbr3VSzUox5UfbyKOeuHkehN+Et6u898vz7eqhB+Q 1RpMNKbbhr2wLg9IdfbhPxVwQwbTRM/w0cZKwsO8eUa1pgBk1DryTEFPt6yZRiXO uvqHxA== Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g8rquj3uc-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 25 Aug 2026 02:07:04 +0000 (GMT) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-cbedf6e8a42so5070180a12.1 for ; Mon, 24 Aug 2026 19:07:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1787623624; x=1788228424; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YzF3hXZW0ytcWbA+isUMZBMZ3HrRdAr99GThHRzOSok=; b=Segfi6jbLBkNB22mDlCmv98jHOU+DKW464NgEYmVJiuveRmlODsMIH53uVuiE/+/yM MhWSsVNGFnx6hJ80aC4kZX9HJk7O/BgBvqrcKIOz3n0CxcXT5j8RYb51aPFoe1TA7gnz 1Cojtaq4ayNnDLkAgKf730WrAu8pfnXvDR2PD9IFVJOQszToxGRvTxObSuc86HM/Sd1Z lFB7P/3XEpqCUzjcRM6q2nFO9c5YKMZBxu/oVYqYIBQtEnBRPeyVdWTMSlhOu5shZNvm vAtCsLyM31IbBTJyHOrggPM1idi6tOjxOOWpyMT+inzv30hcXbSUVJGGKww3FD4RiKGV ej/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787623624; x=1788228424; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=YzF3hXZW0ytcWbA+isUMZBMZ3HrRdAr99GThHRzOSok=; b=OulJhrYxxi4FjldzsCv+xEftuHzKP0GenCR5oh2SdHDsFwBjYlplO3X41TgfKugR+l xeYphwLUIP1KKU43b07NayPQjGImzXhwjsTq0pMzBSFCMAcQNwSShdNzg1vriNchbzqG OuVdrUTEAuUChSOlIgeKkI528wZIvTUpCWW5A+jM0uFo/re8pLqGDKOsX+gQeb1ucfQA OTf5FPdEEl0x3Ds28YXYmgn4uPT3q+hSPRxnq5VrrXqbDB17ci+lpuYwEU1k+jOEBsDg V1UAiQvacuB/qJxMCmYVotsY2F1EUBL7/C0Svm45JSYtY3oqACYIYKmGTgCTQUiMWdz9 65MQ== X-Forwarded-Encrypted: i=1; AHgh+RpfBQq56koVTsunHgcqToRrIPPFokQ4rjksbeIMOH9J7oGcjc/0kCnNEzcYzGUGXnttNLxfKMSn7WoxpMg=@vger.kernel.org X-Gm-Message-State: AFuF++mdOIwv3uYW+pvPp6Vl/xwEGDM3abSdnOdPTb+F8IjbuSf7KEje XGl2OgIwMix/hMyQ+3Nn4ZZyBuEFxTOeLhHTZ1yBbUO2K6RvvyOn8a26MFb+DvIPhCDG60l3T3+ 3zU1DbA/s05pObX9aewebNvKcC0T41lkHObVGFMPqaLyh5X43WOxKKSyBxPEdguliZic= X-Gm-Gg: AR+sD10YZpFgADK18n5eyZ3E5/HTu3USBPh8j21ByzoY4B3i47G6KOazhOQVQMJJT3U j+FCIudCBR+PMV+0AxTHiI63LaoMulMztp4xlzJ11YkbtmXiJlvrVgVYHBf/CqDGcAeONGLPQZF HHha0Trmgy05gbmnJ65fbzcVCoOJGwYh+CO8sEqJXFpvwd2zW8TQIGoc7+XzCi0f9Xoz9jEuOEB RMWbdf9xV2AfFsHhCLDqts8Ao+6803jCmz3OeFn8DZBat6aAt9e14CUm9l7UT35OgE2d9Gw9Xrx y9Pv6rkHvCZ0YrucnnGLjXoDVMlh3MZ+TzaWXw/bfwZy9vY4wG+ly4kRknRTTvCq6DCSbf2qMLw ee4TX/jjGRfZdKep5SZNeLpwsR6loNiF4xBUpbf+NLq54WWQ3ix8+ X-Received: by 2002:a05:6a20:43ac:b0:3b4:8f18:33a with SMTP id adf61e73a8af0-3cd2fd8e233mr63445151637.1.1787623623715; Mon, 24 Aug 2026 19:07:03 -0700 (PDT) X-Received: by 2002:a05:6a20:43ac:b0:3b4:8f18:33a with SMTP id adf61e73a8af0-3cd2fd8e233mr63445049637.1.1787623623216; Mon, 24 Aug 2026 19:07:03 -0700 (PDT) Received: from hu-wcheng-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-327f91d33dcsm39442376eec.18.2026.08.24.19.07.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2026 19:07:02 -0700 (PDT) From: Wesley Cheng Date: Mon, 24 Aug 2026 19:06:56 -0700 Subject: [PATCH 2/2] ALSA: usb-audio: qcom: request page-aligned xHCI ring buffers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260824-16k_offload_v1_b4-v1-2-49a6be60ca30@oss.qualcomm.com> References: <20260824-16k_offload_v1_b4-v1-0-49a6be60ca30@oss.qualcomm.com> In-Reply-To: <20260824-16k_offload_v1_b4-v1-0-49a6be60ca30@oss.qualcomm.com> To: Mathias Nyman , Greg Kroah-Hartman , Jaroslav Kysela , Takashi Iwai Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org, Wesley Cheng X-Mailer: b4 0.15.2 X-Proofpoint-ORIG-GUID: 8xMpKDwuSj7clD1lwHb0IegoclPO2fhj X-Proofpoint-Spam-Info: AW1haW4tMjYwODI1MDAxNiBTYWx0ZWRfX/8tuua7vkjbD ZPcX0ARwcU50qM+l81QgRijghORjbKkLRfxq606Pl5lGxeBU3EW0a8gZv1DsZOVV9gUgs0jWhAY 9CB8dqn4cimZvzt5gw9izW+s6ygCvYE= X-Authority-Analysis: v=2.4 cv=CbQ4Irrl c=1 sm=1 tr=0 ts=6a8cf8c8 cx=c_pps a=Qgeoaf8Lrialg5Z894R3/Q==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=EUspDBNiAAAA:8 a=CbMfP9IJxQ5wjS32uxIA:9 a=QEXdDO2ut3YA:10 a=x9snwWr2DeNwDh03kgHS:22 X-Proofpoint-GUID: 8xMpKDwuSj7clD1lwHb0IegoclPO2fhj X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODI1MDAxNiBTYWx0ZWRfX3LTOyKa4MUKQ gTev5K6XUm+FvyZCtDroKhnWaIqCCPwu1r7mi04D2f2ApBVzq0xcjwwmPZmuJ9sP0acWwyx7Eux edmX4UYo3rnPo+dy2JyFNedfskbcYDlvEltnRUc3vtz4a2rFY8nlLAY+O3quaP4KGCRxCDFVtXf 00CKPVsb/HEKQuUqJCqt0Fp9O6smU+XHwU3Y8I4yKOk2qjIZEnCxQdeaozYSrYSTcggZWgVDRQ3 YKdlrPWC0vAI2Gu5M1xotWAGrCdM/LVctuOJnlmoQ7oZ29p112l8og4QfJ3btx5qLqt9ilaDv7Q znMw/dtg9FJxqWT0AKy1OjtnUmy2ziSbB/sKBhmloIoeUYOHzo54uKJsYFnbqXWxxm5HyzRS28H 6efZl/OHdD2zlecZw330Vr9vaDLeqJmOlnXEZEYKHnYoztrkVnv7Xm0033S7b1Dq3TQM2S/yNHB g6FGXdQKM28YpFI+kZg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-24_07,2026-08-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 suspectscore=0 impostorscore=0 malwarescore=0 spamscore=0 clxscore=1011 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608250016 Now that xhci sideband supports requesting a specific ring alignment, ask for PAGE_SIZE alignment when adding the data/sync endpoints to the sideband and when creating the interrupter's event ring, so the buffers reported to the ADSP over QMI always start at a page boundary and span a full page. xhci_sideband_add_endpoint() must run before the endpoint's transfer ring is first allocated (i.e. before snd_usb_endpoint_prepare() triggers xhci_endpoint_init()) for the alignment request to apply to that first allocation. Move the xhci_sideband_add_endpoint() calls out of uaudio_endpoint_setup() and into enable_audio_stream(), before snd_usb_endpoint_prepare() is called for the data and sync endpoints, and unwind them on the new error paths. At that point in the setup sequence dev->ep_in[]/ep_out[] are not yet populated, since the endpoint's altsetting has not been activated, so usb_pipe_endpoint() cannot be used to find the usb_host_endpoint. Add uaudio_find_host_endpoint(), which resolves it directly from the interface's altsetting descriptor table instead. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Wesley Cheng --- sound/usb/qcom/qc_audio_offload.c | 96 +++++++++++++++++++++++++++++++++--= ---- 1 file changed, 82 insertions(+), 14 deletions(-) diff --git a/sound/usb/qcom/qc_audio_offload.c b/sound/usb/qcom/qc_audio_of= fload.c index e4bfd43a2488..87e016104c3d 100644 --- a/sound/usb/qcom/qc_audio_offload.c +++ b/sound/usb/qcom/qc_audio_offload.c @@ -941,6 +941,45 @@ static void uaudio_dev_release(struct kref *kref) wake_up(&dev->disconnect_wq); } =20 +/** + * uaudio_find_host_endpoint() - look up usb_host_endpoint for a snd_usb_e= ndpoint + * @subs: usb substream owning the target snd_usb_endpoint + * @endpoint: sync or data snd_usb_endpoint to resolve + * + * usb_pipe_endpoint() resolves via dev->ep_in[]/ep_out[], which are only + * populated once usb_set_interface() has activated the endpoint's altsett= ing + * (i.e. after snd_usb_endpoint_prepare() has run for it). Looking that up + * beforehand returns NULL. + * + * Instead, look the endpoint up directly in the interface's altsetting + * descriptor table, which is populated once at enumeration time and stays + * valid regardless of which altsetting is currently active. + * + * Return: matching usb_host_endpoint, or NULL if not found. + */ +static struct usb_host_endpoint * +uaudio_find_host_endpoint(struct snd_usb_substream *subs, + struct snd_usb_endpoint *endpoint) +{ + struct usb_host_interface *alt; + struct usb_interface *iface; + int i; + + iface =3D usb_ifnum_to_if(subs->dev, endpoint->iface); + if (!iface) + return NULL; + + alt =3D usb_altnum_to_altsetting(iface, endpoint->altsetting); + if (!alt) + return NULL; + + for (i =3D 0; i < alt->desc.bNumEndpoints; i++) + if (alt->endpoint[i].desc.bEndpointAddress =3D=3D endpoint->ep_num) + return &alt->endpoint[i]; + + return NULL; +} + /** * enable_audio_stream() - enable usb snd endpoints * @subs: usb substream @@ -958,8 +997,9 @@ static void uaudio_dev_release(struct kref *kref) static int enable_audio_stream(struct snd_usb_substream *subs, snd_pcm_format_t pcm_format, unsigned int channels, unsigned int cur_rate, - int datainterval) + int datainterval, unsigned int card_num) { + struct usb_host_endpoint *data_ep =3D NULL, *sync_ep =3D NULL; struct snd_pcm_hw_params params; struct snd_usb_audio *chip; struct snd_interval *i; @@ -997,17 +1037,47 @@ static int enable_audio_stream(struct snd_usb_substr= eam *subs, goto detach_ep; } =20 + data_ep =3D uaudio_find_host_endpoint(subs, subs->data_endpoint); + if (!data_ep) { + dev_err(&subs->dev->dev, "data ep # %d not found\n", + subs->data_endpoint->ep_num); + ret =3D -ENODEV; + goto detach_ep; + } + + ret =3D xhci_sideband_add_endpoint(uadev[card_num].sb, data_ep, PAGE_SIZ= E); + if (ret < 0) { + dev_err(&subs->dev->dev, + "failed to add data ep to sec intr: %d\n", ret); + goto detach_ep; + } + if (subs->sync_endpoint) { + sync_ep =3D uaudio_find_host_endpoint(subs, subs->sync_endpoint); + if (!sync_ep) { + dev_err(&subs->dev->dev, "sync ep # %d not found\n", + subs->sync_endpoint->ep_num); + ret =3D -ENODEV; + goto remove_data_ep; + } + + ret =3D xhci_sideband_add_endpoint(uadev[card_num].sb, sync_ep, PAGE_SI= ZE); + if (ret < 0) { + dev_err(&subs->dev->dev, + "failed to add sync ep to sec intr: %d\n", ret); + goto remove_data_ep; + } + ret =3D snd_usb_endpoint_prepare(chip, subs->sync_endpoint); if (ret < 0) - goto detach_ep; + goto remove_sync_ep; } =20 ret =3D snd_usb_endpoint_prepare(chip, subs->data_endpoint); if (ret < 0) - goto detach_ep; + goto remove_sync_ep; =20 - dev_dbg(uaudio_qdev->data->dev, + dev_dbg(&subs->dev->dev, "selected %s iface:%d altsetting:%d datainterval:%dus\n", subs->direction ? "capture" : "playback", subs->cur_audiofmt->iface, subs->cur_audiofmt->altsetting, @@ -1019,6 +1089,11 @@ static int enable_audio_stream(struct snd_usb_substr= eam *subs, =20 return 0; =20 +remove_sync_ep: + if (sync_ep) + xhci_sideband_remove_endpoint(uadev[card_num].sb, sync_ep); +remove_data_ep: + xhci_sideband_remove_endpoint(uadev[card_num].sb, data_ep); detach_ep: snd_usb_hw_free(subs); =20 @@ -1140,14 +1215,6 @@ uaudio_endpoint_setup(struct snd_usb_substream *subs, =20 memcpy(ep_desc, &ep->desc, sizeof(ep->desc)); =20 - ret =3D xhci_sideband_add_endpoint(uadev[card_num].sb, ep); - if (ret < 0) { - dev_err(&subs->dev->dev, - "failed to add data ep to sec intr: %d\n", ret); - ret =3D -ENODEV; - goto exit; - } - sgt =3D xhci_sideband_get_endpoint_buffer(uadev[card_num].sb, ep); if (!sgt) { dev_err(&subs->dev->dev, @@ -1212,7 +1279,8 @@ static int uaudio_event_ring_setup(struct snd_usb_sub= stream *subs, =20 /* event ring */ ret =3D xhci_sideband_create_interrupter(uadev[card_num].sb, 1, false, - 0, uaudio_qdev->data->intr_num); + 0, uaudio_qdev->data->intr_num, + PAGE_SIZE); if (ret < 0) { dev_err(&subs->dev->dev, "failed to fetch interrupter\n"); goto put_offload; @@ -1637,7 +1705,7 @@ static void handle_uaudio_stream_req(struct qmi_handl= e *handle, ret =3D enable_audio_stream(subs, map_pcm_format(req_msg->audio_format), req_msg->number_of_ch, req_msg->bit_rate, - datainterval); + datainterval, pcm_card_num); =20 if (!ret) ret =3D prepare_qmi_response(subs, req_msg, &resp, --=20 2.34.1