LinuxKPI: Implement dma_map_resource/dma_unmap_resource functions

dma_map_resource() and dma_unmap_resource() functions are used to map
and unmap of memory-mapped IO resources so they can be accessed by
the device.

Required by drm-kmod v5.5 to be built.

While for drm-kmod 6.6-lts only amdgpu uses these in one place and
the code apparently has not been exercised a lot it has been around
like this for years.  With changing the underlying implementations
bring it into the tree; should we find errors with it they can also
be fixed here.

Bump __FreeBSD version to be able to detect this change.

Obtained from:	D30933 (by wulf)
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D49625
This commit is contained in:
Bjoern A. Zeeb 2025-04-01 14:51:03 +00:00
parent f99d393f7f
commit a02180cf60
3 changed files with 19 additions and 1 deletions

View file

@ -27,6 +27,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 15.x IS SLOW:
world, or to merely disable the most expensive debugging functionality
at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".)
20250603:
LinuxKPI dma-mapping.h were pulled into the tree from drm-kmod.
Bump _FreeBSD_version to 1500045 to be able to detect this change.
20250527:
The CAM target layer userland, i.e. ctld(8), ctladm(8) and ctlstat(8),
has moved to the new FreeBSD-ctl package. If you use pkgbase and you

View file

@ -214,6 +214,20 @@ dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
lkpi_dma_unmap(dev, dma_address, size, direction, 0);
}
static inline dma_addr_t
dma_map_resource(struct device *dev, phys_addr_t paddr, size_t size,
enum dma_data_direction direction, unsigned long attrs)
{
return (lkpi_dma_map_phys(dev, paddr, size, direction, attrs));
}
static inline void
dma_unmap_resource(struct device *dev, dma_addr_t dma, size_t size,
enum dma_data_direction direction, unsigned long attrs)
{
lkpi_dma_unmap(dev, dma, size, direction, attrs);
}
static inline void
dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma, size_t size,
enum dma_data_direction direction)

View file

@ -73,7 +73,7 @@
* cannot include sys/param.h and should only be updated here.
*/
#undef __FreeBSD_version
#define __FreeBSD_version 1500044
#define __FreeBSD_version 1500045
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,