History

x86/io: add interface to reserve io memtype for a resource range. (v1.1)

A recent change to the mm code in: 87744ab3832b mm: fix cache mode tracking in vm_insert_mixed() started enforcing checking the memory type against the registered list for amixed pfn insertion mappings. It happens that the drm drivers for a number of gpus relied on this being broken. Currently the driver only inserted VRAM mappings into the tracking table when they came from the kernel, and userspace mappings never landed in the table. This led to a regression where all the mapping end up as UC instead of WC now. I've considered a number of solutions but since this needs to be fixed in fixes and not next, and some of the solutions were going to introduce overhead that hadn't been there before I didn't consider them viable at this stage. These mainly concerned hooking into the TTM io reserve APIs, but these API have a bunch of fast paths I didn't want to unwind to add this to. The solution I've decided on is to add a new API like the arch_phys_wc APIs (these would have worked but wc_del didn't take a range), and use them from the drivers to add a WC compatible mapping to the table for all VRAM on those GPUs. This means we can then create userspace mapping that won't get degraded to UC. v1.1: use CONFIG_X86_PAT + add some comments in io.h

Dave Airlie committed 10 years ago

Commit 8ef42271 parent 07d9a383 files · +42 −0Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/io.h+22−0
@@ -141,4 +141,26 @@ enum { · 140 unmodified lines
141141 void *memremap(resource_size_t offset, size_t size, unsigned long flags);
142142 void memunmap(void *addr);
143143
144+/*
145+ * On x86 PAT systems we have memory tracking that keeps track of
146+ * the allowed mappings on memory ranges. This tracking works for
147+ * all the in-kernel mapping APIs (ioremap*), but where the user
148+ * wishes to map a range from a physical device into user memory
149+ * the tracking won't be updated. This API is to be used by
150+ * drivers which remap physical device pages into userspace,
151+ * and wants to make sure they are mapped WC and not UC.
152+ */
153+#ifndef arch_io_reserve_memtype_wc
154+static inline int arch_io_reserve_memtype_wc(resource_size_t base,
155+ resource_size_t size)
156+{
157+ return 0;
158+}
159+
160+static inline void arch_io_free_memtype_wc(resource_size_t base,
161+ resource_size_t size)
162+{
163+}
164+#endif
165+
144166 #endif /* _LINUX_IO_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t