Add a way to map arm64 non-posted device memory
On arm64 we currently use a non-posted write for device memory, however we should move to use posted writes. This is expected to work on most hardware, however we will need to support a non-posted option for some broken hardware. Reviewed by: imp, manu, bcr (manpage) Differential Revision: https://reviews.freebsd.org/D29722
This commit is contained in:
parent
a6ca7519f8
commit
2abd4f8581
@ -52,7 +52,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd July 7, 2020
|
.Dd May 1, 2021
|
||||||
.Dt BUS_SPACE 9
|
.Dt BUS_SPACE 9
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -876,6 +876,11 @@ call should fail.
|
|||||||
If this
|
If this
|
||||||
flag is not specified, the system may map the space in whatever way is
|
flag is not specified, the system may map the space in whatever way is
|
||||||
most convenient.
|
most convenient.
|
||||||
|
.It Dv BUS_SPACE_MAP_NONPOSTED
|
||||||
|
Try to map the space using non-posted device memory.
|
||||||
|
This is to support buses and devices where mapping with posted device
|
||||||
|
memory is unsupported or broken.
|
||||||
|
This flag is currently only available on arm64.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
Not all combinations of flags make sense or are supported with all
|
Not all combinations of flags make sense or are supported with all
|
||||||
|
@ -99,9 +99,13 @@ static int
|
|||||||
generic_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags,
|
generic_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags,
|
||||||
bus_space_handle_t *bshp)
|
bus_space_handle_t *bshp)
|
||||||
{
|
{
|
||||||
|
vm_memattr_t ma;
|
||||||
void *va;
|
void *va;
|
||||||
|
|
||||||
va = pmap_mapdev(bpa, size);
|
ma = VM_MEMATTR_DEVICE;
|
||||||
|
if (flags == BUS_SPACE_MAP_NONPOSTED)
|
||||||
|
ma = VM_MEMATTR_DEVICE_NP;
|
||||||
|
va = pmap_mapdev_attr(bpa, size, ma);
|
||||||
if (va == NULL)
|
if (va == NULL)
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
*bshp = (bus_space_handle_t)va;
|
*bshp = (bus_space_handle_t)va;
|
||||||
|
@ -85,6 +85,7 @@
|
|||||||
#define BUS_SPACE_MAP_CACHEABLE 0x01
|
#define BUS_SPACE_MAP_CACHEABLE 0x01
|
||||||
#define BUS_SPACE_MAP_LINEAR 0x02
|
#define BUS_SPACE_MAP_LINEAR 0x02
|
||||||
#define BUS_SPACE_MAP_PREFETCHABLE 0x04
|
#define BUS_SPACE_MAP_PREFETCHABLE 0x04
|
||||||
|
#define BUS_SPACE_MAP_NONPOSTED 0x08
|
||||||
|
|
||||||
#define BUS_SPACE_UNRESTRICTED (~0)
|
#define BUS_SPACE_UNRESTRICTED (~0)
|
||||||
|
|
||||||
|
@ -36,7 +36,12 @@
|
|||||||
#define VM_MEMATTR_WRITE_THROUGH 3
|
#define VM_MEMATTR_WRITE_THROUGH 3
|
||||||
#define VM_MEMATTR_DEVICE_nGnRE 4
|
#define VM_MEMATTR_DEVICE_nGnRE 4
|
||||||
|
|
||||||
|
/*
|
||||||
|
* VM_MEMATTR_DEVICE can be changed to VM_MEMATTR_DEVICE_nGnRE when
|
||||||
|
* the PCI drivers use VM_MEMATTR_DEVICE_NP for their config space.
|
||||||
|
*/
|
||||||
#define VM_MEMATTR_DEVICE VM_MEMATTR_DEVICE_nGnRnE
|
#define VM_MEMATTR_DEVICE VM_MEMATTR_DEVICE_nGnRnE
|
||||||
|
#define VM_MEMATTR_DEVICE_NP VM_MEMATTR_DEVICE_nGnRnE
|
||||||
|
|
||||||
#ifdef _KERNEL
|
#ifdef _KERNEL
|
||||||
/* If defined vmstat will try to use both of these in a switch statement */
|
/* If defined vmstat will try to use both of these in a switch statement */
|
||||||
|
@ -1570,6 +1570,9 @@ display_object(struct kinfo_vmobject *kvo)
|
|||||||
#ifdef VM_MEMATTR_DEVICE
|
#ifdef VM_MEMATTR_DEVICE
|
||||||
MEMATTR_STR(VM_MEMATTR_DEVICE, "DEV")
|
MEMATTR_STR(VM_MEMATTR_DEVICE, "DEV")
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef VM_MEMATTR_DEVICE_NP
|
||||||
|
MEMATTR_STR(VM_MEMATTR_DEVICE, "NP")
|
||||||
|
#endif
|
||||||
#ifdef VM_MEMATTR_CACHEABLE
|
#ifdef VM_MEMATTR_CACHEABLE
|
||||||
MEMATTR_STR(VM_MEMATTR_CACHEABLE, "C")
|
MEMATTR_STR(VM_MEMATTR_CACHEABLE, "C")
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user