Update io-mapping.h in the LinuxKPI.
Add io_mapping_init_wc() and add a third (unused) parameter to io_mapping_map_wc(). Reviewed by: hselasky MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D11286
This commit is contained in:
parent
6589ee29df
commit
c73cdca2c4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=320196
@ -28,52 +28,85 @@
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
#ifndef _LINUX_IO_MAPPING_H_
|
||||
|
||||
#ifndef _LINUX_IO_MAPPING_H_
|
||||
#define _LINUX_IO_MAPPING_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <machine/vm.h>
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
struct io_mapping;
|
||||
struct io_mapping {
|
||||
unsigned long base;
|
||||
unsigned long size;
|
||||
void *mem;
|
||||
vm_memattr_t attr;
|
||||
};
|
||||
|
||||
static inline struct io_mapping *
|
||||
io_mapping_init_wc(struct io_mapping *mapping, resource_size_t base,
|
||||
unsigned long size)
|
||||
{
|
||||
|
||||
mapping->base = base;
|
||||
mapping->size = size;
|
||||
mapping->mem = ioremap_wc(base, size);
|
||||
mapping->attr = VM_MEMATTR_WRITE_COMBINING;
|
||||
return (mapping);
|
||||
}
|
||||
|
||||
static inline struct io_mapping *
|
||||
io_mapping_create_wc(resource_size_t base, unsigned long size)
|
||||
{
|
||||
struct io_mapping *mapping;
|
||||
|
||||
return ioremap_wc(base, size);
|
||||
mapping = kmalloc(sizeof(*mapping), GFP_KERNEL);
|
||||
if (mapping == NULL)
|
||||
return (NULL);
|
||||
return (io_mapping_init_wc(mapping, base, size));
|
||||
}
|
||||
|
||||
static inline void
|
||||
io_mapping_fini(struct io_mapping *mapping)
|
||||
{
|
||||
|
||||
iounmap(mapping->mem);
|
||||
}
|
||||
|
||||
static inline void
|
||||
io_mapping_free(struct io_mapping *mapping)
|
||||
{
|
||||
|
||||
iounmap(mapping);
|
||||
io_mapping_fini(mapping->mem);
|
||||
kfree(mapping);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset)
|
||||
{
|
||||
|
||||
return (((char *)mapping) + offset);
|
||||
return ((char *)mapping->mem + offset);
|
||||
}
|
||||
|
||||
static inline void
|
||||
io_mapping_unmap_atomic(void *vaddr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static inline void *
|
||||
io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset)
|
||||
io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset,
|
||||
unsigned long size)
|
||||
{
|
||||
|
||||
return (((char *) mapping) + offset);
|
||||
return ((char *)mapping->mem + offset);
|
||||
}
|
||||
|
||||
static inline void
|
||||
io_mapping_unmap(void *vaddr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif /* _LINUX_IO_MAPPING_H_ */
|
||||
#endif /* _LINUX_IO_MAPPING_H_ */
|
||||
|
@ -204,7 +204,7 @@ int mlx4_bf_alloc(struct mlx4_dev *dev, struct mlx4_bf *bf, int node)
|
||||
goto free_uar;
|
||||
}
|
||||
|
||||
uar->bf_map = io_mapping_map_wc(priv->bf_mapping, uar->index << PAGE_SHIFT);
|
||||
uar->bf_map = io_mapping_map_wc(priv->bf_mapping, uar->index << PAGE_SHIFT, PAGE_SIZE);
|
||||
if (!uar->bf_map) {
|
||||
err = -ENOMEM;
|
||||
goto unamp_uar;
|
||||
|
@ -189,7 +189,8 @@ int mlx5_alloc_map_uar(struct mlx5_core_dev *mdev, struct mlx5_uar *uar)
|
||||
|
||||
if (mdev->priv.bf_mapping)
|
||||
uar->bf_map = io_mapping_map_wc(mdev->priv.bf_mapping,
|
||||
uar->index << PAGE_SHIFT);
|
||||
uar->index << PAGE_SHIFT,
|
||||
PAGE_SIZE);
|
||||
|
||||
return 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user