mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-22 04:03:58 +08:00
mm: simplify device private page handling in hmm_range_fault
Remove the HMM_PFN_DEVICE_PRIVATE flag, no driver has ever set this flag on input, and the only place that uses it on output can be trivially changed to use is_device_private_page(). This removes the ability to request that device_private pages are faulted back into system memory. Link: https://lore.kernel.org/r/20200316193216.920734-4-hch@lst.de Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
parent
800bb1c8dc
commit
17ffdc4829
@ -776,7 +776,6 @@ struct amdgpu_ttm_tt {
|
||||
static const uint64_t hmm_range_flags[HMM_PFN_FLAG_MAX] = {
|
||||
(1 << 0), /* HMM_PFN_VALID */
|
||||
(1 << 1), /* HMM_PFN_WRITE */
|
||||
0 /* HMM_PFN_DEVICE_PRIVATE */
|
||||
};
|
||||
|
||||
static const uint64_t hmm_range_values[HMM_PFN_VALUE_MAX] = {
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include <nvif/class.h>
|
||||
#include <nvif/object.h>
|
||||
#include <nvif/if000c.h>
|
||||
#include <nvif/if500b.h>
|
||||
#include <nvif/if900b.h>
|
||||
|
||||
@ -692,9 +693,8 @@ nouveau_dmem_convert_pfn(struct nouveau_drm *drm,
|
||||
if (page == NULL)
|
||||
continue;
|
||||
|
||||
if (!(range->pfns[i] & range->flags[HMM_PFN_DEVICE_PRIVATE])) {
|
||||
if (!is_device_private_page(page))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!nouveau_dmem_page(drm, page)) {
|
||||
WARN(1, "Some unknown device memory !\n");
|
||||
@ -705,5 +705,6 @@ nouveau_dmem_convert_pfn(struct nouveau_drm *drm,
|
||||
addr = nouveau_dmem_page_addr(page);
|
||||
range->pfns[i] &= ((1UL << range->pfn_shift) - 1);
|
||||
range->pfns[i] |= (addr >> PAGE_SHIFT) << range->pfn_shift;
|
||||
range->pfns[i] |= NVIF_VMM_PFNMAP_V0_VRAM;
|
||||
}
|
||||
}
|
||||
|
@ -367,7 +367,6 @@ static const u64
|
||||
nouveau_svm_pfn_flags[HMM_PFN_FLAG_MAX] = {
|
||||
[HMM_PFN_VALID ] = NVIF_VMM_PFNMAP_V0_V,
|
||||
[HMM_PFN_WRITE ] = NVIF_VMM_PFNMAP_V0_W,
|
||||
[HMM_PFN_DEVICE_PRIVATE] = NVIF_VMM_PFNMAP_V0_VRAM,
|
||||
};
|
||||
|
||||
static const u64
|
||||
|
@ -74,7 +74,6 @@
|
||||
* Flags:
|
||||
* HMM_PFN_VALID: pfn is valid. It has, at least, read permission.
|
||||
* HMM_PFN_WRITE: CPU page table has write permission set
|
||||
* HMM_PFN_DEVICE_PRIVATE: private device memory (ZONE_DEVICE)
|
||||
*
|
||||
* The driver provides a flags array for mapping page protections to device
|
||||
* PTE bits. If the driver valid bit for an entry is bit 3,
|
||||
@ -86,7 +85,6 @@
|
||||
enum hmm_pfn_flag_e {
|
||||
HMM_PFN_VALID = 0,
|
||||
HMM_PFN_WRITE,
|
||||
HMM_PFN_DEVICE_PRIVATE,
|
||||
HMM_PFN_FLAG_MAX
|
||||
};
|
||||
|
||||
|
25
mm/hmm.c
25
mm/hmm.c
@ -116,15 +116,6 @@ static inline void hmm_pte_need_fault(const struct hmm_vma_walk *hmm_vma_walk,
|
||||
/* We aren't ask to do anything ... */
|
||||
if (!(pfns & range->flags[HMM_PFN_VALID]))
|
||||
return;
|
||||
/* If this is device memory then only fault if explicitly requested */
|
||||
if ((cpu_flags & range->flags[HMM_PFN_DEVICE_PRIVATE])) {
|
||||
/* Do we fault on device memory ? */
|
||||
if (pfns & range->flags[HMM_PFN_DEVICE_PRIVATE]) {
|
||||
*write_fault = pfns & range->flags[HMM_PFN_WRITE];
|
||||
*fault = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* If CPU page table is not valid then we need to fault */
|
||||
*fault = !(cpu_flags & range->flags[HMM_PFN_VALID]);
|
||||
@ -262,21 +253,15 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr,
|
||||
swp_entry_t entry = pte_to_swp_entry(pte);
|
||||
|
||||
/*
|
||||
* This is a special swap entry, ignore migration, use
|
||||
* device and report anything else as error.
|
||||
* Never fault in device private pages pages, but just report
|
||||
* the PFN even if not present.
|
||||
*/
|
||||
if (is_device_private_entry(entry)) {
|
||||
cpu_flags = range->flags[HMM_PFN_VALID] |
|
||||
range->flags[HMM_PFN_DEVICE_PRIVATE];
|
||||
cpu_flags |= is_write_device_private_entry(entry) ?
|
||||
range->flags[HMM_PFN_WRITE] : 0;
|
||||
hmm_pte_need_fault(hmm_vma_walk, orig_pfn, cpu_flags,
|
||||
&fault, &write_fault);
|
||||
if (fault || write_fault)
|
||||
goto fault;
|
||||
*pfn = hmm_device_entry_from_pfn(range,
|
||||
swp_offset(entry));
|
||||
*pfn |= cpu_flags;
|
||||
*pfn |= range->flags[HMM_PFN_VALID];
|
||||
if (is_write_device_private_entry(entry))
|
||||
*pfn |= range->flags[HMM_PFN_WRITE];
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user