From nobody Fri Apr 10 01:06:05 2026 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (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 0BECD3DEAEA for ; Thu, 5 Mar 2026 17:03:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772730236; cv=none; b=fETzT9CYK6NERsZx3MD+FHbUmkV/c/agfmy6wlapw283+39xHkjUjjLw82dkxl6hz35fdEYKpqHFjMAKvBaNvMzHjpAC9MaVHG61ko8fS4lSLIDo19nxxK4qfDDihj1RGVBUj1BemvXdPnD+s9nsZT4I8NheVHQyFw8zth9FA58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772730236; c=relaxed/simple; bh=ehXww4EBP5o9XNrGQRSCbBb/4KpkUed7aGW0wp59lFw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=RPbKjmtWYkJfbMbt3phD54joXpXTIsslvQjhyCL2UnEQa0EYk1PH8R/xJOriTIwvd8xUj8ipH9bxIMFOYH8qRrhn+VXs47tC5Ssv6QqEziri95YWOembgqlIzd8ouK88wyI+j9fJd6FNYXK0T1N3eCJ/dDn6QXwnaTE0qi85L1k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--smostafa.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=FtUxYjBq; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--smostafa.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FtUxYjBq" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-4837246211bso106052565e9.0 for ; Thu, 05 Mar 2026 09:03:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772730233; x=1773335033; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=fS2TCdg+GqqKaNVQW4sApbDZr60XuAkM6k9PmxbMvJo=; b=FtUxYjBqVV8bTQgp7/1Y0EZcFW0hVRQyn3hAcjaJH9qVCieKXlLKVI+b00YO8NoTrJ 676j1xEMnSjiMIWQQ00mpv2jiEZUwU05uMqNwCxf8doNLzOtAzJWLCdfW5Ox6mMiMTna os0gcLmP+zONCMUAW7oOXd3KbEErBCkP19s5amoyR9p5bZ9PEgSC6TgNWExip63Sz9T7 KEGSg6vposU9c9tm61aqv95SRgehqVsr9ZsfKoRDMrlTlUxaGJApID2yore6S+2VH+uO lh7af1AVrd6PiFyB5dGK2csO7yr9+OdhD3LmaWZkF1Q3bBDYG0TxtIR2GterXmEa59Yy N/sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772730233; x=1773335033; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fS2TCdg+GqqKaNVQW4sApbDZr60XuAkM6k9PmxbMvJo=; b=xUvbL69RZWIF/lJnU953YOm2FZwz+Pbu/cq4tr7+eKlfwC2gU2luiTRkWxmy1hlcO0 vx1tvQoCHMMjboZ/wbcWsOtap97O64lPLUsC8DhaXt9tn7Nwe/gmr2tjMx/JKSGyAV6f GxXLxPoOTbjvL+bFwCMdaw/jtVI+nUGFT/gbYv+ioZX0/JeVERp/oInq5Zc4NTy+bYyB M2MxyaEtBP8wkxVq6hfgRdP17Ra80bX11cwsk3fOIfhcQM1ivYlX3Sd/L4IkBmAfRbjh l5FdjGkmsDXBR8JGksrEiBKcVkEMaVK3SvnlRRp9usgyRNtEhc0MOB6R5hhb5Cih/1r7 G2lA== X-Forwarded-Encrypted: i=1; AJvYcCW4Wrk/4bDXpzykRk0OwMzbUb8Zr5N2fdcdKZ1HUwsUUnyTCaSKSllxfZgDYk8JdQqmvkZqHqKMP927X+s=@vger.kernel.org X-Gm-Message-State: AOJu0YxqQUb7ijPyfskpC8oNWe9fu2bZrzxkVquBYKOZd6xIYM7+x2QJ loYkmcwEnadJ6FXBqI/GSLd14c780eWLH3yB4WqPPU0qKhIrpYUQHstBGUGY30+Ck+m59YQno1i rFB5fFjf/1IwIKg== X-Received: from wmbgy7.prod.google.com ([2002:a05:600c:8807:b0:483:6e65:5bb9]) (user=smostafa job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:6098:b0:483:71f7:2782 with SMTP id 5b1f17b1804b1-485235bc44emr2834755e9.12.1772730233280; Thu, 05 Mar 2026 09:03:53 -0800 (PST) Date: Thu, 5 Mar 2026 17:03:35 +0000 In-Reply-To: <20260305170335.963568-1-smostafa@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260305170335.963568-1-smostafa@google.com> X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog Message-ID: <20260305170335.963568-3-smostafa@google.com> Subject: [RFC PATCH 2/2] dma-mapping: Use the correct phys_to_dma() for DMA_RESTRICTED_POOL From: Mostafa Saleh To: iommu@lists.linux.dev, linux-kernel@vger.kernel.org Cc: robin.murphy@arm.com, m.szyprowski@samsung.com, will@kernel.org, maz@kernel.org, suzuki.poulose@arm.com, catalin.marinas@arm.com, Mostafa Saleh Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As restricted dma pools are always decrypted, in swiotlb.c it uses phys_to_dma_unencrypted() for address conversion. However, in DMA-direct, calls to phys_to_dma_direct() with force_dma_unencrypted() returning false, will fallback to phys_to_dma() which is inconsistent for memory allocated from restricted dma pools. Signed-off-by: Mostafa Saleh --- kernel/dma/direct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 27d804f0473f..1a402bb956d9 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -26,7 +26,7 @@ u64 zone_dma_limit __ro_after_init =3D DMA_BIT_MASK(24); static inline dma_addr_t phys_to_dma_direct(struct device *dev, phys_addr_t phys) { - if (force_dma_unencrypted(dev)) + if (force_dma_unencrypted(dev) || is_swiotlb_for_alloc(dev)) return phys_to_dma_unencrypted(dev, phys); return phys_to_dma(dev, phys); } --=20 2.53.0.473.g4a7958ca14-goog