LKML Archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Juergen Gross <jgross@suse.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Ben Skeggs <bskeggs@redhat.com>,
	Karol Herbst <kherbst@redhat.com>, Lyude Paul <lyude@redhat.com>
Cc: xen-devel@lists.xenproject.org, iommu@lists.linux.dev,
	linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org
Subject: [PATCH 3/4] drm/nouveau: stop using is_swiotlb_active
Date: Thu, 18 May 2023 15:42:52 +0200	[thread overview]
Message-ID: <20230518134253.909623-4-hch@lst.de> (raw)
In-Reply-To: <20230518134253.909623-1-hch@lst.de>

Drivers have no business looking into dma-mapping internals and check
what backend is used.  Unfortunstely the DRM core is still broken and
tries to do plain page allocations instead of using DMA API allocators
by default and uses various bandaids on when to use dma_alloc_coherent.

Switch nouveau to use the same (broken) scheme as amdgpu and radeon
to remove the last driver user of is_swiotlb_active.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/gpu/drm/nouveau/nouveau_ttm.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 1469a88910e45d..486f39f31a38df 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -24,9 +24,9 @@
  */
 
 #include <linux/limits.h>
-#include <linux/swiotlb.h>
 
 #include <drm/ttm/ttm_range_manager.h>
+#include <drm/drm_cache.h>
 
 #include "nouveau_drv.h"
 #include "nouveau_gem.h"
@@ -265,7 +265,6 @@ nouveau_ttm_init(struct nouveau_drm *drm)
 	struct nvkm_pci *pci = device->pci;
 	struct nvif_mmu *mmu = &drm->client.mmu;
 	struct drm_device *dev = drm->dev;
-	bool need_swiotlb = false;
 	int typei, ret;
 
 	ret = nouveau_ttm_init_host(drm, 0);
@@ -300,13 +299,10 @@ nouveau_ttm_init(struct nouveau_drm *drm)
 		drm->agp.cma = pci->agp.cma;
 	}
 
-#if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86)
-	need_swiotlb = is_swiotlb_active(dev->dev);
-#endif
-
 	ret = ttm_device_init(&drm->ttm.bdev, &nouveau_bo_driver, drm->dev->dev,
 				  dev->anon_inode->i_mapping,
-				  dev->vma_offset_manager, need_swiotlb,
+				  dev->vma_offset_manager,
+				  drm_need_swiotlb(drm->client.mmu.dmabits),
 				  drm->client.mmu.dmabits <= 32);
 	if (ret) {
 		NV_ERROR(drm, "error initialising bo driver, %d\n", ret);
-- 
2.39.2


  parent reply	other threads:[~2023-05-18 13:43 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-18 13:42 unexport swiotlb_active Christoph Hellwig
2023-05-18 13:42 ` [PATCH 1/4] x86: move a check out of pci_xen_swiotlb_init Christoph Hellwig
2023-05-18 13:42 ` [PATCH 2/4] x86: always initialize xen-swiotlb when xen-pcifront is enabling Christoph Hellwig
2023-05-18 18:18   ` Marek Marczykowski-Górecki
2023-05-19  4:04     ` Christoph Hellwig
2023-05-19 10:10       ` Marek Marczykowski-Górecki
2023-05-19 12:41         ` Christoph Hellwig
2023-05-19 12:49           ` Andrew Cooper
2023-05-19 12:58             ` Christoph Hellwig
2023-05-20  6:21               ` Christoph Hellwig
2023-05-22  7:52                 ` Petr Tesařík
2023-05-22  7:54         ` Petr Tesařík
2023-05-22  8:37         ` Juergen Gross
2023-06-07 13:12           ` Christoph Hellwig
2023-06-09 15:38             ` Juergen Gross
2023-06-12  6:47               ` Christoph Hellwig
2023-06-12  8:08               ` Juergen Gross
2023-06-12  8:23                 ` Christoph Hellwig
2023-05-18 13:42 ` Christoph Hellwig [this message]
2023-05-18 20:30   ` [PATCH 3/4] drm/nouveau: stop using is_swiotlb_active Lyude Paul
2023-06-07 13:11     ` Christoph Hellwig
2023-05-18 13:42 ` [PATCH 4/4] swiotlb: unexport is_swiotlb_active Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230518134253.909623-4-hch@lst.de \
    --to=hch@lst.de \
    --cc=bp@alien8.de \
    --cc=bskeggs@redhat.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgross@suse.com \
    --cc=kherbst@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lyude@redhat.com \
    --cc=mingo@redhat.com \
    --cc=nouveau@lists.freedesktop.org \
    --cc=sstabellini@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).