From nobody Fri Oct 31 23:21:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=actia.se Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1746186087366412.53083826504576; Fri, 2 May 2025 04:41:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.974588.1362404 (Exim 4.92) (envelope-from ) id 1uAolH-0004Gu-L3; Fri, 02 May 2025 11:40:59 +0000 Received: by outflank-mailman (output) from mailman id 974588.1362404; Fri, 02 May 2025 11:40:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uAolH-0004G9-Fd; Fri, 02 May 2025 11:40:59 +0000 Received: by outflank-mailman (input) for mailman id 974588; Fri, 02 May 2025 11:40:58 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uAolG-0004Db-K0 for xen-devel@lists.xenproject.org; Fri, 02 May 2025 11:40:58 +0000 Received: from mail.actia.se (mail.actia.se [212.181.117.226]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4ff52dca-274a-11f0-9eb4-5ba50f476ded; Fri, 02 May 2025 13:40:57 +0200 (CEST) Received: from S036ANL.actianordic.se (10.12.31.117) by S035ANL.actianordic.se (10.12.31.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 2 May 2025 13:40:56 +0200 Received: from S036ANL.actianordic.se ([fe80::e13e:1feb:4ea6:ec69]) by S036ANL.actianordic.se ([fe80::e13e:1feb:4ea6:ec69%3]) with mapi id 15.01.2507.039; Fri, 2 May 2025 13:40:56 +0200 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4ff52dca-274a-11f0-9eb4-5ba50f476ded From: John Ernberg To: Juergen Gross , Stefano Stabellini CC: Oleksandr Tyshchenko , Catalin Marinas , Andrew Morton , "xen-devel@lists.xenproject.org" , "iommu@lists.linux.dev" , "linux-kernel@vger.kernel.org" , "imx@lists.linux.dev" , John Ernberg , "stable@kernel.org" Subject: [PATCH 1/2] xen: swiotlb: Use swiotlb bouncing if kmalloc allocation demands it Thread-Topic: [PATCH 1/2] xen: swiotlb: Use swiotlb bouncing if kmalloc allocation demands it Thread-Index: AQHbu1cQNcuPrbmRHEK42QDjG7hf6w== Date: Fri, 2 May 2025 11:40:55 +0000 Message-ID: <20250502114043.1968976-2-john.ernberg@actia.se> References: <20250502114043.1968976-1-john.ernberg@actia.se> In-Reply-To: <20250502114043.1968976-1-john.ernberg@actia.se> Accept-Language: en-US, sv-SE Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.49.0 x-originating-ip: [10.12.12.35] x-esetresult: clean, is OK x-esetid: 37303A2956B14453667460 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-ZM-MESSAGEID: 1746186088423019000 Content-Type: text/plain; charset="utf-8" Xen swiotlb support was missed when the patch set starting with 4ab5f8ec7d71 ("mm/slab: decouple ARCH_KMALLOC_MINALIGN from ARCH_DMA_MINALIGN") was merged. When running Xen on iMX8QXP, a SoC without IOMMU, the effect was that USB transfers ended up corrupted when there was more than one URB inflight at the same time. Add a call to dma_kmalloc_needs_bounce() to make sure that allocations too small for DMA get bounced via swiotlb. Closes: https://lore.kernel.org/linux-usb/ab2776f0-b838-4cf6-a12a-c208eb6aa= d59@actia.se/ Fixes: 4ab5f8ec7d71 ("mm/slab: decouple ARCH_KMALLOC_MINALIGN from ARCH_DMA= _MINALIGN") Cc: stable@kernel.org # v6.5+ Signed-off-by: John Ernberg Reviewed-by: Catalin Marinas Reviewed-by: Stefano Stabellini --- It's impossible to pick an exact fixes tag since this driver was missed in the flagged patch set. I picked one I felt gave a decent enough picture for someone coming across this later. --- drivers/xen/swiotlb-xen.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index 1f65795cf5d7..ef56a2500ed6 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c @@ -217,6 +217,7 @@ static dma_addr_t xen_swiotlb_map_page(struct device *d= ev, struct page *page, * buffering it. */ if (dma_capable(dev, dev_addr, size, true) && + !dma_kmalloc_needs_bounce(dev, size, dir) && !range_straddles_page_boundary(phys, size) && !xen_arch_need_swiotlb(dev, phys, dev_addr) && !is_swiotlb_force_bounce(dev)) --=20 2.49.0