summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2016-05-01 17:48:43 +0000
committerkib <kib@FreeBSD.org>2016-05-01 17:48:43 +0000
commitcd5c613f44ed1120372f82d2e5e5dc1c68e16002 (patch)
treeb4653849e8bbf8df256d49bae9ce2a3b1fd49e76
parent52ea16e6badd453a497e167d8c0cdd71305dc75c (diff)
downloadFreeBSD-src-cd5c613f44ed1120372f82d2e5e5dc1c68e16002.zip
FreeBSD-src-cd5c613f44ed1120372f82d2e5e5dc1c68e16002.tar.gz
Avoid duplicated calls to pmap_page_get_memattr().
Avoid logging inconsistency for the /dev/mem device at all. The driver leaves memattr intact, and the corrective action in the device pager handles it right. In the logged warning, name the driver we blame, and show memory attributes values. Reported and tested by: pho Reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D6149
-rw-r--r--sys/vm/device_pager.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/sys/vm/device_pager.c b/sys/vm/device_pager.c
index a4f0d6e..2080fdf 100644
--- a/sys/vm/device_pager.c
+++ b/sys/vm/device_pager.c
@@ -299,7 +299,7 @@ old_dev_pager_fault(vm_object_t object, vm_ooffset_t offset, int prot,
struct cdevsw *csw;
struct file *fpop;
struct thread *td;
- vm_memattr_t memattr;
+ vm_memattr_t memattr, memattr1;
int ref, ret;
memattr = object->memattr;
@@ -327,10 +327,18 @@ old_dev_pager_fault(vm_object_t object, vm_ooffset_t offset, int prot,
/* If "paddr" is a real page, perform a sanity check on "memattr". */
if ((m_paddr = vm_phys_paddr_to_vm_page(paddr)) != NULL &&
- pmap_page_get_memattr(m_paddr) != memattr) {
- memattr = pmap_page_get_memattr(m_paddr);
- printf(
- "WARNING: A device driver has set \"memattr\" inconsistently.\n");
+ (memattr1 = pmap_page_get_memattr(m_paddr)) != memattr) {
+ /*
+ * For the /dev/mem d_mmap routine to return the
+ * correct memattr, pmap_page_get_memattr() needs to
+ * be called, which we do there.
+ */
+ if ((csw->d_flags & D_MEM) == 0) {
+ printf("WARNING: Device driver %s has set "
+ "\"memattr\" inconsistently (drv %u pmap %u).\n",
+ csw->d_name, memattr, memattr1);
+ }
+ memattr = memattr1;
}
if (((*mres)->flags & PG_FICTITIOUS) != 0) {
/*
OpenPOWER on IntegriCloud