From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 1BF25262A6 for ; Wed, 1 Apr 2026 02:05:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775009110; cv=none; b=hLMbskJhwp0R3li37eKgnV1FjzpZMNPBo/dRiMzR6o96NRDTWnLMOvBxKQX5exgaW9D0M6bsyT+c8U6JlCVvh2OgGkwWwo49eq1XwWALelZo/fk+3t7uZ0Oabh1RwxdIcwm+DyZ9cjAknk1bx/Ze43LHPZAmKuT1Uu/vUIgB5Io= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775009110; c=relaxed/simple; bh=JbNc2o0u3C8QGaR7GHqDGQejtg7vpRmM1jVYQKHei4w=; h=From:To:Cc:Subject:In-Reply-To:Date:Message-ID:References: MIME-version:Content-type; b=o3bj1pDeVby7oLZQVwFS+zWNBhRsacZUr+6eXEeYjgqSRNCl/xajrpKfx0YpIOU8EBjd7WqOyjsCauItE1HUX3sDjG5vZASgI+jemDYO4AS4TwKxY6Ak3Av+AshMHl996JrHDQKsw6AV8pSMmlYGMa4H9lljlG+S9cMxeSMWQB0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BWIZr0AB; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BWIZr0AB" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2a7a9b8ed69so61414425ad.2 for ; Tue, 31 Mar 2026 19:05:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775009108; x=1775613908; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:message-id:date :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=SJMfA7CNqV0/pOxot929IT3yuZq+Zmc7WLvwY3fmaj4=; b=BWIZr0ABrwUAJKvRiSfbuK+QDMSCUFYaOi86uKqfLGwNUum8xRerBvwYmcRmvOlDVI BmtM/pDHQo4L+zIxY9eWoSXVi9pdmaapR9ld5wM2zNZ7b37LETxG4U3pv6kU+nRFI40+ CdCIOhGOZqA0EhD31pum1dz6/aWEbqBIjdIQr4Dl/muNcJ0J5wGU28taZkPXV9xUmQUb tcP55fgiihccR0AgTWfrqaEPDp3dQBQ/5U1FMqwWqiD0Ux/HRbt85IRP6Uq9Sm6HGOUb 17DlymuwHU+nxfYY0Tww4U7L1JJ3evgMDzIvXLlod9iDLUH58dFxyULFfbNijqqgaXaz zL1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775009108; x=1775613908; h=content-transfer-encoding:mime-version:references:message-id:date :in-reply-to:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=SJMfA7CNqV0/pOxot929IT3yuZq+Zmc7WLvwY3fmaj4=; b=KkUGYQ7APKKmNCjps6ptl8y1YV7sD7FeAGeM221EMiURRiyFzS9IyIx/Ad8SiH+Wi+ QbmN5srtn6Hm5jeqJw+nC3FUBC4iHZeEr5GVVACsNvzH8InpRhhMV5zrfEqq6bFGnnOK 5ydAnlVjZCuwEKtvX1G/nxwUp4kxeob+g45GIEXfrHVX4JIRvqX1KZ8AN1/SpcRvHOF5 5vE1Qu/iwxEJM0u9WnGT5Xm200c2hXnEXKm7rwwopTW1VUjsV/eac2gtDDmLNgg6Y4fj qmjZNLHDk9eyYBs+4q2sSnlKR7k6t0j+lDRU0OlmSIKaPe9ABFqNkcpDZQhXi3qm1C2D nh1w== X-Forwarded-Encrypted: i=1; AJvYcCURBwprBDQHXR8HoIyzjwBmXRpPtEhDl0aWl4FXfAFGRTw2ZzxZM8gt10vus6MCqnGDYa4UvtrXsMM721Y=@vger.kernel.org X-Gm-Message-State: AOJu0Yz2+EU684Y328RAeLMqObgMOSZndbwJ+JUtUTIB1uU4D9obiP8Y bOm9FJniAJIrBdv6s4JxrxLsOzX3ZRsmEAiMjLY9aqtQ/9/BzQNgt3JD X-Gm-Gg: ATEYQzx3KjYtDpBzTTM/B/LilN3wJjbZ2zgvlgR34ADKw+BcZl5e27pacXfc4o7cmar e8gxBVzjmmavoK5cXWqiRaqAWHRYBd5G2/i5SNscyzT7WHrbYsIC+KIlHUgNZtDAz6W6rLL3+4j 9087OVJGsJ4Hd+12nQD09W20F+PnLxrRinwJQqV7Wf30iNgaAWCvh8NuE+nLUyQ88rw9HCttCZq k/XElXYsI477rGcXHDW4dty2Xa2CIhy+TNjChm19BIyBiLCcIG7KmxzvTb4IKDv3siY0pVmNKvd 6ry/1Vzb6+srHHsNDeqgWxl/H3i/m/sRziUKNf/6ng16fSYK6x7PUBAKiWIsus1wUm5pQralewS LA/wnS18FQxxs8oG8RRhw4nHqgJEHw/NC0v/8lBTpapv4NsGHl6vIyyI44v/ZLqXzpT+hRpUi29 TNmS76yWSNMxXZaX2UamTrjg== X-Received: by 2002:a17:903:287:b0:2b2:4bf9:1766 with SMTP id d9443c01a7336-2b269d28734mr13881265ad.33.1775009108361; Tue, 31 Mar 2026 19:05:08 -0700 (PDT) Received: from pve-server ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b24268e7f5sm125994015ad.35.2026.03.31.19.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2026 19:05:07 -0700 (PDT) From: Ritesh Harjani (IBM) To: Gaurav Batra , linuxppc-dev@lists.ozlabs.org Cc: maddy@linux.ibm.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Gaurav Batra , Dan =?utf-8?Q?Hor=C3=A1k?= , Timothy Pearson , Shivaprasad G Bhat Subject: Re: [PATCH] powerpc/powernv/iommu: iommu incorrectly bypass DMA APIs In-Reply-To: <20260331223022.47488-1-gbatra@linux.ibm.com> Date: Wed, 01 Apr 2026 06:35:23 +0530 Message-ID: References: <20260331223022.47488-1-gbatra@linux.ibm.com> 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: 8bit ++CC few people who would be interested in this fix. Gaurav Batra writes: > In a PowerNV environment, for devices that supports DMA mask less than > 64 bit but larger than 32 bits, iommu is incorrectly bypassing DMA > APIs while allocating and mapping buffers for DMA operations. > > Devices are failing with ENOMEN during probe with the following messages > > amdgpu 0000:01:00.0: [drm] Detected VRAM RAM=4096M, BAR=4096M > amdgpu 0000:01:00.0: [drm] RAM width 128bits GDDR5 > amdgpu 0000:01:00.0: iommu: 64-bit OK but direct DMA is limited by 0 > amdgpu 0000:01:00.0: dma_iommu_get_required_mask: returning bypass mask 0xfffffffffffffff > amdgpu 0000:01:00.0: 4096M of VRAM memory ready > amdgpu 0000:01:00.0: 32570M of GTT memory ready. > amdgpu 0000:01:00.0: (-12) failed to allocate kernel bo > amdgpu 0000:01:00.0: [drm] Debug VRAM access will use slowpath MM access > amdgpu 0000:01:00.0: [drm] GART: num cpu pages 4096, num gpu pages 65536 > amdgpu 0000:01:00.0: [drm] PCIE GART of 256M enabled (table at 0x000000F4FFF80000). > amdgpu 0000:01:00.0: (-12) failed to allocate kernel bo > amdgpu 0000:01:00.0: (-12) create WB bo failed > amdgpu 0000:01:00.0: amdgpu_device_wb_init failed -12 > amdgpu 0000:01:00.0: amdgpu_device_ip_init failed > amdgpu 0000:01:00.0: Fatal error during GPU init > amdgpu 0000:01:00.0: finishing device. > amdgpu 0000:01:00.0: probe with driver amdgpu failed with error -12 > amdgpu 0000:01:00.0: ttm finalized > > Fixes: 1471c517cf7d ("powerpc/iommu: bypass DMA APIs for coherent allocations for pre-mapped memory") > Reported-by: Dan HorĂ¡k > Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/5039 We could even add the lore link so that in future people can find the discussion. Closes: https://lore.kernel.org/linuxppc-dev/20260313142351.609bc4c3efe1184f64ca5f44@danny.cz/ > Tested-by: Dan Horak > Signed-off-by: Ritesh Harjani Feel free to change this to the following, I mainly only suggested the fix :) Suggested-by: Ritesh Harjani (IBM) > Signed-off-by: Gaurav Batra > --- Generally this info... > I am working on testing the patch in an LPAR with AMDGPU. I will update the > results soon. ... goes below the three dashes in here ^^^ This is the same place where people also update the patch change log. But sure, thanks for updating. As for this patch, it looks good to me. So, feel free to add: Reviewed-by: Ritesh Harjani (IBM) > arch/powerpc/kernel/dma-iommu.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c > index 73e10bd4d56d..8b4de508d2eb 100644 > --- a/arch/powerpc/kernel/dma-iommu.c > +++ b/arch/powerpc/kernel/dma-iommu.c > @@ -67,7 +67,7 @@ bool arch_dma_unmap_sg_direct(struct device *dev, struct scatterlist *sg, > } > bool arch_dma_alloc_direct(struct device *dev) > { > - if (dev->dma_ops_bypass) > + if (dev->dma_ops_bypass && dev->bus_dma_limit) > return true; > > return false; > @@ -75,7 +75,7 @@ bool arch_dma_alloc_direct(struct device *dev) > > bool arch_dma_free_direct(struct device *dev, dma_addr_t dma_handle) > { > - if (!dev->dma_ops_bypass) > + if (!dev->dma_ops_bypass || !dev->bus_dma_limit) > return false; > > return is_direct_handle(dev, dma_handle); > -- > > I am working on testing the patch in an LPAR with AMDGPU. I will update the > results soon. This should go up, as mentioned above. -ritesh