Allow forcing non-posted memory on arm64

To allow for debugging after changing the arm64 VM_MEMATTR_DEVICE
memory type add a new set of tunables to tell the kernel to use
non-posted memory.

This adds the following tunables:
 - kern.force_nonposted: When set to non-zero the kernel will use
   non-posted memory for all device allocations.
 - hint.<dev>.<unit>.force_nonposted: As above, however only forces
   non-posted memory on the named device.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D38944
This commit is contained in:
Andrew Turner 2023-03-16 15:35:59 +00:00
parent bc10894757
commit f7acb7ed41

View File

@ -83,6 +83,10 @@ struct nexus_device {
struct resource_list nx_resources;
};
static int force_np;
SYSCTL_INT(_kern, OID_AUTO, force_nonposted, CTLFLAG_RDTUN, &force_np, 0,
"Force all devices to use non-posted device memory");
#define DEVTONX(dev) ((struct nexus_device *)device_get_ivars(dev))
static struct rman mem_rman;
@ -373,7 +377,7 @@ nexus_activate_resource_flags(device_t bus, device_t child, int type, int rid,
{
struct resource_map_request args;
struct resource_map map;
int err;
int err, use_np;
if ((err = rman_activate_resource(r)) != 0)
return (err);
@ -386,7 +390,13 @@ nexus_activate_resource_flags(device_t bus, device_t child, int type, int rid,
case SYS_RES_MEMORY:
if ((rman_get_flags(r) & RF_UNMAPPED) == 0) {
resource_init_map_request(&args);
if ((flags & BUS_SPACE_MAP_NONPOSTED) != 0)
use_np = (flags & BUS_SPACE_MAP_NONPOSTED) != 0 ||
force_np;
if (!use_np)
resource_int_value(device_get_name(child),
device_get_unit(child), "force_nonposted",
&use_np);
if (use_np)
args.memattr = VM_MEMATTR_DEVICE_NP;
err = nexus_map_resource(bus, child, type, r, &args,
&map);