diff mbox series

[6/6] mm/memremap: Set caching mode for PCI P2PDMA memory to WC

Message ID 20191209191346.5197-7-logang@deltatee.com (mailing list archive)
State Not Applicable
Headers show
Series Allow setting caching mode in arch_add_memory() for P2PDMA | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/merge (42159d2de18ffa66c2714d988a8c162db8b03956)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/next (7794b1d4185e2587af46435e3e2f6696dae314c7)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linus/master (e42617b825f8073569da76dc4510bfa019b1c35a)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/fixes (249fad734a25889a4f23ed014d43634af6798063)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linux-next (6cf8298daad041cd15dc514d8a4f93ca3636c84e)
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Logan Gunthorpe Dec. 9, 2019, 7:13 p.m. UTC
PCI BAR IO memory should never be mapped as WB, however prior to this
the PAT bits were set WB and it was typically overridden by MTRR
registers set by the firmware.

Set PCI P2PDMA memory to be WC (writecombining) as the only current
user (the NVMe CMB) was originally mapped WC before the P2PDMA code
replaced the mapping with devm_memremap_pages().

Future use-cases may need to generalize this by adding flags to
select the caching type, as some P2PDMA cases will not want WC.
However, those use-cases are not upstream yet and this can be changed
when they arrive.

Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
---
 mm/memremap.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/mm/memremap.c b/mm/memremap.c
index 4edcca074e15..ced32593e4a7 100644
--- a/mm/memremap.c
+++ b/mm/memremap.c
@@ -187,7 +187,10 @@  void *memremap_pages(struct dev_pagemap *pgmap, int nid)
 		}
 		break;
 	case MEMORY_DEVICE_DEVDAX:
+		need_devmap_managed = false;
+		break;
 	case MEMORY_DEVICE_PCI_P2PDMA:
+		pgprot = pgprot_writecombine(pgprot);
 		need_devmap_managed = false;
 		break;
 	default: