Skip to content

Commit 1e6d5de

Browse files
committed
Merge tag 'dma-mapping-6.5-2023-06-28' of git://git.infradead.org/users/hch/dma-mapping
Pull dma-mapping updates from Christoph Hellwig: - swiotlb cleanups (Petr Tesarik) - use kvmalloc_array (gaoxu) - a small step towards removing is_swiotlb_active (Christoph Hellwig) - fix a Kconfig typo Sui Jingfeng) * tag 'dma-mapping-6.5-2023-06-28' of git://git.infradead.org/users/hch/dma-mapping: drm/nouveau: stop using is_swiotlb_active swiotlb: use the atomic counter of total used slabs if available swiotlb: remove unused field "used" from struct io_tlb_mem dma-remap: use kvmalloc_array/kvfree for larger dma memory remap dma-mapping: fix a Kconfig typo
2 parents 7ede5f7 + 0a2f637 commit 1e6d5de

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

drivers/gpu/drm/nouveau/nouveau_ttm.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
*/
2525

2626
#include <linux/limits.h>
27-
#include <linux/swiotlb.h>
2827

2928
#include <drm/ttm/ttm_range_manager.h>
29+
#include <drm/drm_cache.h>
3030

3131
#include "nouveau_drv.h"
3232
#include "nouveau_gem.h"
@@ -265,7 +265,6 @@ nouveau_ttm_init(struct nouveau_drm *drm)
265265
struct nvkm_pci *pci = device->pci;
266266
struct nvif_mmu *mmu = &drm->client.mmu;
267267
struct drm_device *dev = drm->dev;
268-
bool need_swiotlb = false;
269268
int typei, ret;
270269

271270
ret = nouveau_ttm_init_host(drm, 0);
@@ -300,13 +299,10 @@ nouveau_ttm_init(struct nouveau_drm *drm)
300299
drm->agp.cma = pci->agp.cma;
301300
}
302301

303-
#if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86)
304-
need_swiotlb = is_swiotlb_active(dev->dev);
305-
#endif
306-
307302
ret = ttm_device_init(&drm->ttm.bdev, &nouveau_bo_driver, drm->dev->dev,
308303
dev->anon_inode->i_mapping,
309-
dev->vma_offset_manager, need_swiotlb,
304+
dev->vma_offset_manager,
305+
drm_need_swiotlb(drm->client.mmu.dmabits),
310306
drm->client.mmu.dmabits <= 32);
311307
if (ret) {
312308
NV_ERROR(drm, "error initialising bo driver, %d\n", ret);

include/linux/swiotlb.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ dma_addr_t swiotlb_map(struct device *dev, phys_addr_t phys,
7676
* @nslabs: The number of IO TLB blocks (in groups of 64) between @start and
7777
* @end. For default swiotlb, this is command line adjustable via
7878
* setup_io_tlb_npages.
79-
* @used: The number of used IO TLB block.
8079
* @list: The free list describing the number of free entries available
8180
* from each index.
8281
* @orig_addr: The original address corresponding to a mapped entry.
@@ -98,7 +97,6 @@ struct io_tlb_mem {
9897
phys_addr_t end;
9998
void *vaddr;
10099
unsigned long nslabs;
101-
unsigned long used;
102100
struct dentry *debugfs;
103101
bool late_alloc;
104102
bool force_bounce;

kernel/dma/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ config ARCH_HAS_DMA_SET_MASK
4242
#
4343
# Select this option if the architecture needs special handling for
4444
# DMA_ATTR_WRITE_COMBINE. Normally the "uncached" mapping should be what
45-
# people thing of when saying write combine, so very few platforms should
45+
# people think of when saying write combine, so very few platforms should
4646
# need to enable this.
4747
#
4848
config ARCH_HAS_DMA_WRITE_COMBINE

kernel/dma/remap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ void *dma_common_contiguous_remap(struct page *page, size_t size,
4343
void *vaddr;
4444
int i;
4545

46-
pages = kmalloc_array(count, sizeof(struct page *), GFP_KERNEL);
46+
pages = kvmalloc_array(count, sizeof(struct page *), GFP_KERNEL);
4747
if (!pages)
4848
return NULL;
4949
for (i = 0; i < count; i++)
5050
pages[i] = nth_page(page, i);
5151
vaddr = vmap(pages, count, VM_DMA_COHERENT, prot);
52-
kfree(pages);
52+
kvfree(pages);
5353

5454
return vaddr;
5555
}

kernel/dma/swiotlb.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,15 @@ static int swiotlb_find_slots(struct device *dev, phys_addr_t orig_addr,
717717
return -1;
718718
}
719719

720+
#ifdef CONFIG_DEBUG_FS
721+
722+
static unsigned long mem_used(struct io_tlb_mem *mem)
723+
{
724+
return atomic_long_read(&mem->total_used);
725+
}
726+
727+
#else /* !CONFIG_DEBUG_FS */
728+
720729
static unsigned long mem_used(struct io_tlb_mem *mem)
721730
{
722731
int i;
@@ -727,6 +736,8 @@ static unsigned long mem_used(struct io_tlb_mem *mem)
727736
return used;
728737
}
729738

739+
#endif /* CONFIG_DEBUG_FS */
740+
730741
phys_addr_t swiotlb_tbl_map_single(struct device *dev, phys_addr_t orig_addr,
731742
size_t mapping_size, size_t alloc_size,
732743
unsigned int alloc_align_mask, enum dma_data_direction dir,

0 commit comments

Comments
 (0)