This replaces the hacky ->fault callback, which is currently directly called from common code through a hmm specific data structure as an exercise in layering violations.
Showing the changes to include/linux (3 of 6 files). Show all
Unified · Split
| @@ -692,11 +692,6 @@ struct hmm_devmem_ops { · 691 unmodified lines | |||
| 692 | * chunk, as an optimization. It must, however, prioritize the faulting address | 692 | * chunk, as an optimization. It must, however, prioritize the faulting address |
| 693 | * over all the others. | 693 | * over all the others. |
| 694 | */ | 694 | */ |
| 695 | typedef vm_fault_t (*dev_page_fault_t)(struct vm_area_struct *vma, | ||
| 696 | unsigned long addr, | ||
| 697 | const struct page *page, | ||
| 698 | unsigned int flags, | ||
| 699 | pmd_t *pmdp); | ||
| 700 | 695 | ||
| 701 | struct hmm_devmem { | 696 | struct hmm_devmem { |
| 702 | struct completion completion; | 697 | struct completion completion; |
| @@ -707,7 +702,6 @@ struct hmm_devmem { · 4 unmodified lines | |||
| 707 | struct dev_pagemap pagemap; | 702 | struct dev_pagemap pagemap; |
| 708 | const struct hmm_devmem_ops *ops; | 703 | const struct hmm_devmem_ops *ops; |
| 709 | struct percpu_ref ref; | 704 | struct percpu_ref ref; |
| 710 | dev_page_fault_t page_fault; | ||
| 711 | }; | 705 | }; |
| 712 | 706 | ||
| 713 | /* | 707 | /* |
| @@ -80,6 +80,12 @@ struct dev_pagemap_ops { · 79 unmodified lines | |||
| 80 | * Wait for refcount in struct dev_pagemap to be idle and reap it. | 80 | * Wait for refcount in struct dev_pagemap to be idle and reap it. |
| 81 | */ | 81 | */ |
| 82 | void (*cleanup)(struct dev_pagemap *pgmap); | 82 | void (*cleanup)(struct dev_pagemap *pgmap); |
| 83 | |||
| 84 | /* | ||
| 85 | * Used for private (un-addressable) device memory only. Must migrate | ||
| 86 | * the page back to a CPU accessible page. | ||
| 87 | */ | ||
| 88 | vm_fault_t (*migrate_to_ram)(struct vm_fault *vmf); | ||
| 83 | }; | 89 | }; |
| 84 | 90 | ||
| 85 | /** | 91 | /** |
| @@ -129,12 +129,6 @@ static inline struct page *device_private_entry_to_page(swp_entry_t entry) · 128 unmodified lines | |||
| 129 | { | 129 | { |
| 130 | return pfn_to_page(swp_offset(entry)); | 130 | return pfn_to_page(swp_offset(entry)); |
| 131 | } | 131 | } |
| 132 | |||
| 133 | vm_fault_t device_private_entry_fault(struct vm_area_struct *vma, | ||
| 134 | unsigned long addr, | ||
| 135 | swp_entry_t entry, | ||
| 136 | unsigned int flags, | ||
| 137 | pmd_t *pmdp); | ||
| 138 | #else /* CONFIG_DEVICE_PRIVATE */ | 132 | #else /* CONFIG_DEVICE_PRIVATE */ |
| 139 | static inline swp_entry_t make_device_private_entry(struct page *page, bool write) | 133 | static inline swp_entry_t make_device_private_entry(struct page *page, bool write) |
| 140 | { | 134 | { |
| @@ -164,15 +158,6 @@ static inline struct page *device_private_entry_to_page(swp_entry_t entry) · 23 unmodified lines | |||
| 164 | { | 158 | { |
| 165 | return NULL; | 159 | return NULL; |
| 166 | } | 160 | } |
| 167 | |||
| 168 | static inline vm_fault_t device_private_entry_fault(struct vm_area_struct *vma, | ||
| 169 | unsigned long addr, | ||
| 170 | swp_entry_t entry, | ||
| 171 | unsigned int flags, | ||
| 172 | pmd_t *pmdp) | ||
| 173 | { | ||
| 174 | return VM_FAULT_SIGBUS; | ||
| 175 | } | ||
| 176 | #endif /* CONFIG_DEVICE_PRIVATE */ | 161 | #endif /* CONFIG_DEVICE_PRIVATE */ |
| 177 | 162 | ||
| 178 | #ifdef CONFIG_MIGRATION | 163 | #ifdef CONFIG_MIGRATION |