From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796162944; b=TkGN2BaCaxQ+OhIANrLLjCllCs9ttQECHAfkwVjCnqKZxpvaffF5yJEdTzQN/uEUKm05 IzxERBoMeic4RTF06VfkfbAwM6KfdNor+1lFA/lJ4c/STffGf0bF9KClNejeEqikZoD5P S9LzcGJb79UW+Q2WljnucujkJG/swndVQyi1BK/B8WKDr2MsQeNmn1UkR8SaHORnR9odH exNwIujGndG/7NPl1uBMcPtbw9n5x1Gt8VMKHuCChcWyW2vMw7KBLJixBiE2af02ftvga AtdVAB21X6fv36AzlUydhInWyISB65MFgt80jW2BalZUAVnjzMqQl56p9YnRHwuU2+w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796162944; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:From: Subject:Date:Message-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:X-B4-Tracking:To:Cc:X-Mailer: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-ORIG-GUID: X-Proofpoint-Spam-Info:X-Proofpoint-GUID:X-Authority-Analysis: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=nr9DPu5m1Vwa6sYVw/gNcFA6LSo3OkUpvMEf3AfWsN0=; b=cIFlE3BzQy2rERGP4lUln9Atl8ivbCeXtNOr7CjWS0HcS7ECdg+GzJVAsz6q3rTbVWW5 knVJjgpaW3ZaNns3mVw40s0pHjCdSvHdWQYjUgQM+gBTUz/T7YtpBKgj2PB/jDA1cu4CS rKOoEM8r6DfdzTfjFryFNDJZRBZ3cevYaFzT8KWYQNsLeyuu6L9hcdrefgRFR11gjaN41 ImZUsGEQzdeO9zZ9Tqqs0rByqrM82NQBiIwLUdNaVDulp0oRGbazWK9Eoh1bOZfjRtiz/ EnzGMuOPhUTq7xOFGm+2zqX8NPK9AzC6zl+Myr0PZc1soxr/3ozhyOKWvJkNxhkiKCA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=XZnEHuCL; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b="irj7ngE/"; arc=none smtp.remote-ip=205.220.168.131 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 541F9606A31A for ; Tue, 1 Dec 2026 22:09:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 541F9606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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.a=rsa-sha256 header.s=qcppdkim1 header.b=XZnEHuCL; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=irj7ngE/ Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1J0xZu2540247 for ; Tue, 1 Dec 2026 22:09:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=nr9DPu5m1Vwa6sYVw/gNcF A6LSo3OkUpvMEf3AfWsN0=; b=XZnEHuCLPB8WOUs0VHg8zsPvvFGPQPpk4eTb5+ /6FqpHLnEGYqltBU/nQXmoWmq+1vZS5DIeJeOEqlqijrBjaXkU76ZXTE4qzriIp+ BYDOQ4aZN8K7I7Xob1lns0Ps2oqZaSVHk8MiJuGT93EgJCThMQcnrYi+R/fNFk3l 7iYHVXt06LPCFCC4X1U2ciKh7j5uPGjV9NXWUbILAYG2PgzSfOzxB0l6nIYnqhWR Bs/8i5hnor6PLqT3MWXTBYQdqq+OoWBDj67w6XLC37iePgC2osjUan+5HGyJc0QR fi23HejyaD8UQlFsHvpOM4/MmZ7nC5vqymoqeEsQhVB0JTqw== Received: from mail-dy1-f198.google.com (mail-dy1-f198.google.com [74.125.82.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ja29vh5rc-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 01 Dec 2026 22:09:03 +0000 (GMT) Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-386df943355so4084688eec.1 for ; Tue, 01 Dec 2026 14:09:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796162943; x=1796767743; darn=vger.kernel.org; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=nr9DPu5m1Vwa6sYVw/gNcFA6LSo3OkUpvMEf3AfWsN0=; b=irj7ngE/xsLPCMJVuP7OixsT8j0L82Hi9rNsQc3qvJcmR5EpHanMGG3weqrR9fL7l0 tbw6U9qONP5vXtQnWAJLYTq+piBeeHFv8D4MgwP/oFy7CvpZsWumrkjdKAXHxldB3tUh ActqKBIC9g/vPdkydFdKmF/Y9G4Djh/UGc6rkku4mA2Zt/MowjvrSmAxT/NGko0YqluI pL1dxwORNlXGmDeHjMasSMTCcynDgRJ1AK0dvPiKQU5hVDv/gKiBNFEK0ylIAKQcg0Ej gdNTZIHiHyL4UKs5tKh2bCY5sfZ0jieWOp0HdxTMVHQtLAp6v0TKfx/bkJaYxtrlHsov 874A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796162943; x=1796767743; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=nr9DPu5m1Vwa6sYVw/gNcFA6LSo3OkUpvMEf3AfWsN0=; b=YCKWaO07aVUY9nY3uJn26V9drlLK84TLvULSbDpqSaij+SNkwEIB2GBL/tUGbf3Irw 0T6zM1op/ZRY1WlU1Zvgg7ocdEkZbEYopuBKBG5B4YYjADsRLBpQPghDu6hV46hbgUpf 3LU7P1rAgcmB3YxF1JtdGrGfrwoHJtxbbm0JXnPMBXG6H8px4Rq/9Jkot5Y4mwGrCESe a+noHq0vW3pJFcKsgwHyIkjKAOYQwmJ/heSzxfdXlTi6kdgwSs6UVhIEfCgZVTlnbUeq w8HI6m7DAps35cNcl+CFrNaWNWZTkwFqYKEWIsNswjqN7lAYtIF+o1dYhrsrthk+jmMs ZiAw== X-Forwarded-Encrypted: i=1; AL+hErH3QIE+PcvKa+u+Wm1DvPn8xEG6v3TjvY7yRYkDg1fo+0CmUznxrWFN3GpCzMO3X3O9vTk97uyi4LYMwck=@vger.kernel.org X-Gm-Message-State: APuU4Z8UBXlN6OYhzXgc6rp2UXi8HUg8lA6VQvULhCb077YNj6EdEQR6 FvouDqpyAXLEwO2+KbnuFtv01w5RVGZnDq6Rjig+1eMZb4fOmXyD/fPdf7sjAUgmt+D2R+LZuMk 0vSnraCdZDV7Q5gMXaC2YYpizesORKs/z17Hfy2lIWI+pTBMT4ts3zC+0TOOK+dOb63w= X-Gm-Gg: AZFdTZdP1DpgcR4cu1qt4YGhvUjvBw4Oye17owa3DMLWIdXNFU+FHZCcgUdkaPflDM2 v4pOJ9cb20asQ94pbUvb2srXydxSwTX3EqlsZEJnOJZrh9NuYg9P0Y0GDV1sYW59nS9E2xCduac +Cx/3Ijx67HFKY6BNd/FaRH6euTIgEmcdfDBJ678uTCOsWK8dm8JvZIUeDD2OjXGLXNMh+f0Eky xCONqhiVKu3E/pTqGRyw7VMuRLgSFGwEXDQXmgM1FvR0pwGzCRlA5oCWOkhjWJjqS8+cI1PQeBU XXsEhEOnQQwTYN1uOZ88xqyP7niED3A09/RhQwpt93Gchd2/X7wcfBM77eV2YH0c0IC/VW53irr 7ktcyybsFu9lq34jrWQyPZN7cmRz0cx+vN47vJKa5viEHmc3Gd2gOE/5LTOn7uFyl7vic2/BLdQ Aw5ONeRxxeSDUFODV2WGsaf5UD X-Received: by 2002:a05:7301:d804:b0:386:b076:a940 with SMTP id 5a478bee46e88-386b076a9e4mr28750656eec.26.1796162942734; Tue, 01 Dec 2026 14:09:02 -0800 (PST) X-Received: by 2002:a05:7301:d804:b0:386:b076:a940 with SMTP id 5a478bee46e88-386b076a9e4mr28750631eec.26.1796162942176; Tue, 01 Dec 2026 14:09:02 -0800 (PST) Received: from hu-wcheng-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-386f6651e2asm38279881eec.27.2026.12.01.14.09.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 14:09:01 -0800 (PST) From: Wesley Cheng Subject: [PATCH v7 0/4] Add larger page size support for USB audio offload path Date: Tue, 01 Dec 2026 14:08:59 -0800 Message-Id: <20261201-16k_offload_v1_b4-v7-0-ad9ddad2530d@oss.qualcomm.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-B4-Tracking: v=1; b=H4sIAHtFD2sC/33QwU7DMAwG4FeZcqZTnDhOshPvgVCVpCkrbAs0W wWa+u6kQ4IdUi6Wfsn+bPnKchyHmNluc2VjnIY8pFMJ+mHDwt6dXmIzdCUzwQVxI7ABemtT3x+ S69oJWo+N7ACJI1daIytz72Psh8+b+fT8k/PFv8ZwXqClYz/kcxq/bksnWPr+8ydoeIPWkY/Eg 5P8MeW8/bi4Q0jH47YUtqyZxD1kapAokHFIkmz03tMKJP8gy2UNkgUCqawwXRDIzQqE95CtQVi gXqAzRKCV1SuQ+oUA6hepApEGgyAoWggrEN1D1Yto+ZEygSKPnOuuAs3z/A3gVE4tOAIAAA== To: Mathias Nyman , Greg Kroah-Hartman , Jaroslav Kysela , Takashi Iwai , Michal Pecio Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org, Wesley Cheng , Mathias Nyman X-Mailer: b4 0.13.0 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDA4OCBTYWx0ZWRfX4V/3dJlu5u3X SwdxLY8hmxsby+iSX3XBAxSgO1aMXoP43iQePtjbe59+eFtApR6NGCaTu3KcPtFvZSTWVAdRhX0 IxiQWFn86/vMT/1hSe7ruQhc5vepgdIfQ/v4fBy+Egup8NwXY/QeZSSZ2hWpIYk/ceUFTarqMZL 6Bex22ps5rEGdRd0WXivGBP/UZ+P3NyBqR5UyHy5OiSukCtJ1eGZPnjuhf/Bt3BzTMdaGsNN5dO jI3OFMn7oaTjtQ7liZHAcvFrKfvYYk27o+I7tCiFKT84QBjxpPw0yAuQQWTmFuAMbLFtbBQWGub 47AJ6iWGOv35WzhDVzgK8rmVdMlDYHtDThiBKkoQjPLlxR6/t/QvCQ8tDrgDHzknv8g/TIpMPn/ Kbu6XOSqCnMw9uwbhGDJX+VqSWYbRGgTRnhb0bi8t56GBOq4iN18XghDPZh+Sr4WEQJ1Ee6KFS4 OffbgI43OrSgCWK1sLw== X-Proofpoint-ORIG-GUID: bf_ydEi1JjBAHDGs1S9YZHJftzOB2Yxk X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDA4OCBTYWx0ZWRfXxFXRyMqzuDCS VhUjR45h4Y0q/PG5S3FU77iehSo/4ro3A7BjsSSDELHQx5EjIP8BuZ6ofV5Qdt8R8MsMDAQ8WrL CPJX6c4v7CN8QXaPlm2lbgW1wPCulXU= X-Proofpoint-GUID: bf_ydEi1JjBAHDGs1S9YZHJftzOB2Yxk X-Authority-Analysis: v=2.4 cv=JvFkP84C c=1 sm=1 tr=0 ts=6b0f457f cx=c_pps a=wEP8DlPgTf/vqF+yE6f9lg==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=bC-a23v3AAAA:8 a=QyXUC8HyAAAA:8 a=ag1SF4gXAAAA:8 a=iox4zFpeAAAA:8 a=p1Is3fgI91k69P5NFCwA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=bBxd6f-gb0O0v-kibOvt:22 a=FO4_E8m0qiDe52t0p3_H:22 a=Yupwre4RP9_Eg_Bd0iYG:22 a=WzC6qhA0u3u7Ye7llzcV:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-01_04,2026-12-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 adultscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 impostorscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612010088 On some environments, 16kB pages can be enabled from the Linux subsystem, which manages the IOMMU mappings for the audio DSP within the system. In the current design, the following assumptions break when 16k pages are utilized: 1. xHCI ring size is equal to PAGE_SIZE 2. Ring addresses start at the beginning of a page When the USB offload driver maps the rings (w/ the audio DSP SID), it is set with a 16k granular, which is a problem, as several xHCI rings could exist on the same page. This is because the rings are currently allocated from the segment_pool. Hence, potentially mapping non USB audio related rings into the region accessible by the audio DSP. To mitigate this, sideband rings are no longer allocated from the segment_pool. When PAGE_SIZE is larger than TRB_SEGMENT_SIZE, xHCI allocates the segments of sideband-tagged endpoint rings, and of the sideband secondary event ring, using dma_alloc_coherent(), which gives each segment a page of its own. Before the USB audio offload path is enabled, the USB audio data streams/endpoint are not active. Only when the class driver issues a usb_set_interface() call (done from snd_usb_endpoint_prepare()), will the xHCI allocate the transfer ring resources. The offload client driver therefore tags the endpoints with xhci_sideband_add_endpoint() before that point. The new ring allocation flow for sideband/offload clients will be as follows: handle_uaudio_stream_req() ▼ enable_audio_stream(subs, ..., pcm_card_num) ├─ data_ep = uaudio_find_host_endpoint(subs, subs->data_endpoint) ├─ xhci_sideband_add_endpoint(sb, data_ep) ← ep->sideband = sb; ep->no_pool_alloc = PAGE_SIZE > TRB_SEGMENT_SIZE ├─ snd_usb_endpoint_prepare(chip, sync_endpoint) ─┐ ├─ snd_usb_endpoint_prepare(chip, data_endpoint) ├─→ xhci_add_endpoint() │ ▼ │ xhci_endpoint_init(xhci, virt_dev, ep, ...) │ new_ring = __xhci_ring_alloc(..., ep->no_pool_alloc, ...) │ ▼ │ xhci_alloc_segments_for_ring(xhci, ring, flags) │ ▼ │ xhci_segment_alloc(xhci, max_packet, num, ring->no_pool_alloc, flags) │ seg->trbs = dma_alloc_coherent(dev, TRB_SEGMENT_SIZE, &dma, flags) ▼ xhci_sideband_get_endpoint_buffer(sb, data_ep) → xhci_ring_to_sgtable() Similar logic is added for the secondary interrupter path as well. The USB offload class driver calls xhci_sideband_create_interrupter(), which will be responsible for allocating the secondary event ring. xHCI core remains responsible for freeing these rings, once the endpoint has been dropped or the slot disabled. This also covers disconnecting the USB audio device while audio offload is active: usb_set_interface() returns early as the interface is unregistering, and the rings are freed later, when USB core drops the device's endpoints. As xhci_free_dev() frees the virt device with interrupts disabled, where dma_free_coherent() can't be called, those rings are freed after xhci->lock is released. This was confirmed to work on the SM8350 MTP platform, with the CONFIG_ARM64_16K_PAGES config enabled, alongside tinyaudio binaries: tinymix -D 0 set 513 1 (Enables USB_RX multimedia#1 path) tinyplay -D 0 -d 0.... (Routes PCM data to ASoC platform sound card) Signed-off-by: Wesley Cheng --- Changes in v7: - Rebased to Mathias' for-usb-linus branch - Added some fixes tag as suggested by sashiko - Link to v6: https://lore.kernel.org/r/20261109-16k_offload_v1_b4-v6-0-858c6e0e007d@oss.qualcomm.com Changes in v6: - Reordered patches so that offload works in between changes. Specifically patch#3 added a change in xHCI sideband to require the sideband ep add to happen before ring is assigned. - Fixed sashiko bot warning about the cleanup path in qc_audio_offload during error cases. - Link to v5: https://lore.kernel.org/r/20261103-16k_offload_v1_b4-v5-0-67184126e91c@oss.qualcomm.com Changes in v5: - Dropped the offload client owned segment pool, as suggested by Mathias. xHCI now allocates sideband ring segments with dma_alloc_coherent() when PAGE_SIZE is larger than TRB_SEGMENT_SIZE. - Free rings that are not allocated from the segment pool outside of xhci->lock in xhci_free_dev(). - Modified the xhci_ring_to_sgtable sequence to address an error from Sashiko where it questioned the safeness of virt_to_page. Leverage dma_get_sgtable, which will call the appropriate DMA mapping implementation. - Link to v4: https://patch.msgid.link/20260909-16k_offload_v1_b4-v4-0-f24a86617597@oss.qualcomm.com Changes in v4: - Split xHCI patches from xHCI core and xHCI sideband. - Make the dedicated offload segment pool optional for secondary interrupter creation. (xfer rings support this already in previous revs) - Fixed some inter-patch build/functionality failures in qc_audio_offload. Incremental builds between patches now work on 4k pages. (16k support at end) - Link to v3: https://patch.msgid.link/20260903-16k_offload_v1_b4-v3-0-135928dc2408@oss.qualcomm.com Changes in v3: - Moved sideband segment pool assignment to when a sideband endpoint is added. - Address an issue where during USB device disconnect (while offload active), where the offload client driver is freeing the DMA pool before xHCI core is able to free the dma allocations. - Update xhci_ring_to_sgtable to correctly allocate and fill the sg table which capture rings within page offsets. - Link to v2: https://patch.msgid.link/20260828-16k_offload_v1_b4-v2-0-8a46369ebbb6@oss.qualcomm.com Changes in v2: - Moved from using alignment_req to having the offload driver maintain its own segment pool. - Fixed OOB condition seen in xhci_ring_to_sgtable() and will capture page offsets properly. - Addressed inter-patch build failures. - Link to v1: https://patch.msgid.link/20260824-16k_offload_v1_b4-v1-0-49a6be60ca30@oss.qualcomm.com To: Mathias Nyman To: Greg Kroah-Hartman To: Jaroslav Kysela To: Takashi Iwai Cc: linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-sound@vger.kernel.org --- Wesley Cheng (4): usb: xhci: sideband: fix ring sg table for sub-page TRB segments usb: xhci: Allocate sideband ring segments with dma_alloc_coherent() ALSA: usb-audio: qcom: tag sideband endpoints before ring allocation ALSA: usb-audio: qcom: fix xfer ring IOMMU unmap on 16K+ page kernels b-audio: qcom: Free QMI handle | 258 ++++++++++++++++++++++++++++++++++++++ drivers/usb/host/xhci-mem.c | 63 +++++++--- drivers/usb/host/xhci-sideband.c | 93 ++++++++------ drivers/usb/host/xhci.c | 13 ++ drivers/usb/host/xhci.h | 5 +- sound/usb/qcom/qc_audio_offload.c | 203 +++++++++++++++++++++--------- 6 files changed, 524 insertions(+), 111 deletions(-) --- base-commit: 7599c0ca3e9e2b3676e83b17ab33f73dfae12ea6 change-id: 20260824-16k_offload_v1_b4-3d1460405774 Best regards, -- Wesley Cheng