Re: [Intel-gfx] [PATCH 01/12] drm/i915/bdw: Make pdp allocation more dynamic
On 3/3/2015 11:48 AM, akash goel wrote: On Fri, Feb 20, 2015 at 11:15 PM, Michel Thierry michel.thie...@intel.com wrote: From: Ben Widawskybenjamin.widaw...@intel.com This transitional patch doesn't do much for the existing code. However, it should make upcoming patches to use the full 48b address space a bit easier to swallow. The patch also introduces the PML4, ie. the new top level structure of the page tables. v2: Renamed pdp_free to be similar to pd/pt (unmap_and_free_pdp), To facilitate testing, 48b mode will be available on Broadwell, when i915.enable_ppgtt = 3. Signed-off-by: Ben Widawskyb...@bwidawsk.net Signed-off-by: Michel Thierrymichel.thie...@intel.com (v2) --- drivers/gpu/drm/i915/i915_drv.h | 7 ++- drivers/gpu/drm/i915/i915_gem_gtt.c | 108 +--- drivers/gpu/drm/i915/i915_gem_gtt.h | 41 +++--- 3 files changed, 126 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 2dedd43..af0d149 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2432,7 +2432,12 @@ struct drm_i915_cmd_table { #define HAS_HW_CONTEXTS(dev) (INTEL_INFO(dev)-gen = 6) #define HAS_LOGICAL_RING_CONTEXTS(dev) (INTEL_INFO(dev)-gen = 8) #define USES_PPGTT(dev)(i915.enable_ppgtt) -#define USES_FULL_PPGTT(dev) (i915.enable_ppgtt == 2) +#define USES_FULL_PPGTT(dev) (i915.enable_ppgtt = 2) +#ifdef CONFIG_64BIT +# define USES_FULL_48BIT_PPGTT(dev)(i915.enable_ppgtt == 3) +#else +# define USES_FULL_48BIT_PPGTT(dev)false +#endif #define HAS_OVERLAY(dev) (INTEL_INFO(dev)-has_overlay) #define OVERLAY_NEEDS_PHYSICAL(dev) (INTEL_INFO(dev)-overlay_needs_physical) diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index ff86501..489f8db 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -100,10 +100,17 @@ static int sanitize_enable_ppgtt(struct drm_device *dev, int enable_ppgtt) { bool has_aliasing_ppgtt; bool has_full_ppgtt; + bool has_full_64bit_ppgtt; has_aliasing_ppgtt = INTEL_INFO(dev)-gen = 6; has_full_ppgtt = INTEL_INFO(dev)-gen = 7; +#ifdef CONFIG_64BIT + has_full_64bit_ppgtt = IS_BROADWELL(dev) false; /* FIXME: 64b */ +#else + has_full_64bit_ppgtt = false; +#endif + if (intel_vgpu_active(dev)) has_full_ppgtt = false; /* emulation is too hard */ @@ -121,6 +128,9 @@ static int sanitize_enable_ppgtt(struct drm_device *dev, int enable_ppgtt) if (enable_ppgtt == 2 has_full_ppgtt) return 2; + if (enable_ppgtt == 3 has_full_64bit_ppgtt) + return 3; + #ifdef CONFIG_INTEL_IOMMU /* Disable ppgtt on SNB if VT-d is on. */ if (INTEL_INFO(dev)-gen == 6 intel_iommu_gfx_mapped) { @@ -462,6 +472,45 @@ free_pd: return ERR_PTR(ret); } +static void __pdp_fini(struct i915_page_directory_pointer_entry *pdp) +{ + kfree(pdp-used_pdpes); + kfree(pdp-page_directory); + /* HACK */ + pdp-page_directory = NULL; +} + +static void unmap_and_free_pdp(struct i915_page_directory_pointer_entry *pdp, + struct drm_device *dev) +{ + __pdp_fini(pdp); + if (USES_FULL_48BIT_PPGTT(dev)) + kfree(pdp); +} + +static int __pdp_init(struct i915_page_directory_pointer_entry *pdp, + struct drm_device *dev) +{ + size_t pdpes = I915_PDPES_PER_PDP(dev); + + pdp-used_pdpes = kcalloc(BITS_TO_LONGS(pdpes), + sizeof(unsigned long), + GFP_KERNEL); + if (!pdp-used_pdpes) + return -ENOMEM; + + pdp-page_directory = kcalloc(pdpes, sizeof(*pdp-page_directory), GFP_KERNEL); + if (!pdp-page_directory) { + kfree(pdp-used_pdpes); + /* the PDP might be the statically allocated top level. Keep it +* as clean as possible */ + pdp-used_pdpes = NULL; + return -ENOMEM; + } + + return 0; +} + /* Broadwell Page Directory Pointer Descriptors */ static int gen8_write_pdp(struct intel_engine_cs *ring, unsigned entry, @@ -491,7 +540,7 @@ static int gen8_mm_switch(struct i915_hw_ppgtt *ppgtt, { int i, ret; - for (i = GEN8_LEGACY_PDPES - 1; i = 0; i--) { + for (i = 3; i = 0; i--) { struct i915_page_directory_entry *pd = ppgtt-pdp.page_directory[i]; dma_addr_t pd_daddr = pd ? pd-daddr : ppgtt-scratch_pd-daddr; /* The page directory might be NULL, but we need to clear out @@ -580,9 +629,6 @@ static void gen8_ppgtt_insert_entries(struct i915_address_space *vm, pt_vaddr = NULL; for_each_sg_page(pages-sgl, sg_iter, pages-nents, 0) { -
Re: [Intel-gfx] [PATCH 01/12] drm/i915/bdw: Make pdp allocation more dynamic
On Fri, Feb 20, 2015 at 11:15 PM, Michel Thierry michel.thie...@intel.com wrote: From: Ben Widawsky benjamin.widaw...@intel.com This transitional patch doesn't do much for the existing code. However, it should make upcoming patches to use the full 48b address space a bit easier to swallow. The patch also introduces the PML4, ie. the new top level structure of the page tables. v2: Renamed pdp_free to be similar to pd/pt (unmap_and_free_pdp), To facilitate testing, 48b mode will be available on Broadwell, when i915.enable_ppgtt = 3. Signed-off-by: Ben Widawsky b...@bwidawsk.net Signed-off-by: Michel Thierry michel.thie...@intel.com (v2) --- drivers/gpu/drm/i915/i915_drv.h | 7 ++- drivers/gpu/drm/i915/i915_gem_gtt.c | 108 +--- drivers/gpu/drm/i915/i915_gem_gtt.h | 41 +++--- 3 files changed, 126 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 2dedd43..af0d149 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2432,7 +2432,12 @@ struct drm_i915_cmd_table { #define HAS_HW_CONTEXTS(dev) (INTEL_INFO(dev)-gen = 6) #define HAS_LOGICAL_RING_CONTEXTS(dev) (INTEL_INFO(dev)-gen = 8) #define USES_PPGTT(dev)(i915.enable_ppgtt) -#define USES_FULL_PPGTT(dev) (i915.enable_ppgtt == 2) +#define USES_FULL_PPGTT(dev) (i915.enable_ppgtt = 2) +#ifdef CONFIG_64BIT +# define USES_FULL_48BIT_PPGTT(dev)(i915.enable_ppgtt == 3) +#else +# define USES_FULL_48BIT_PPGTT(dev)false +#endif #define HAS_OVERLAY(dev) (INTEL_INFO(dev)-has_overlay) #define OVERLAY_NEEDS_PHYSICAL(dev) (INTEL_INFO(dev)-overlay_needs_physical) diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index ff86501..489f8db 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -100,10 +100,17 @@ static int sanitize_enable_ppgtt(struct drm_device *dev, int enable_ppgtt) { bool has_aliasing_ppgtt; bool has_full_ppgtt; + bool has_full_64bit_ppgtt; has_aliasing_ppgtt = INTEL_INFO(dev)-gen = 6; has_full_ppgtt = INTEL_INFO(dev)-gen = 7; +#ifdef CONFIG_64BIT + has_full_64bit_ppgtt = IS_BROADWELL(dev) false; /* FIXME: 64b */ +#else + has_full_64bit_ppgtt = false; +#endif + if (intel_vgpu_active(dev)) has_full_ppgtt = false; /* emulation is too hard */ @@ -121,6 +128,9 @@ static int sanitize_enable_ppgtt(struct drm_device *dev, int enable_ppgtt) if (enable_ppgtt == 2 has_full_ppgtt) return 2; + if (enable_ppgtt == 3 has_full_64bit_ppgtt) + return 3; + #ifdef CONFIG_INTEL_IOMMU /* Disable ppgtt on SNB if VT-d is on. */ if (INTEL_INFO(dev)-gen == 6 intel_iommu_gfx_mapped) { @@ -462,6 +472,45 @@ free_pd: return ERR_PTR(ret); } +static void __pdp_fini(struct i915_page_directory_pointer_entry *pdp) +{ + kfree(pdp-used_pdpes); + kfree(pdp-page_directory); + /* HACK */ + pdp-page_directory = NULL; +} + +static void unmap_and_free_pdp(struct i915_page_directory_pointer_entry *pdp, + struct drm_device *dev) +{ + __pdp_fini(pdp); + if (USES_FULL_48BIT_PPGTT(dev)) + kfree(pdp); +} + +static int __pdp_init(struct i915_page_directory_pointer_entry *pdp, + struct drm_device *dev) +{ + size_t pdpes = I915_PDPES_PER_PDP(dev); + + pdp-used_pdpes = kcalloc(BITS_TO_LONGS(pdpes), + sizeof(unsigned long), + GFP_KERNEL); + if (!pdp-used_pdpes) + return -ENOMEM; + + pdp-page_directory = kcalloc(pdpes, sizeof(*pdp-page_directory), GFP_KERNEL); + if (!pdp-page_directory) { + kfree(pdp-used_pdpes); + /* the PDP might be the statically allocated top level. Keep it +* as clean as possible */ + pdp-used_pdpes = NULL; + return -ENOMEM; + } + + return 0; +} + /* Broadwell Page Directory Pointer Descriptors */ static int gen8_write_pdp(struct intel_engine_cs *ring, unsigned entry, @@ -491,7 +540,7 @@ static int gen8_mm_switch(struct i915_hw_ppgtt *ppgtt, { int i, ret; - for (i = GEN8_LEGACY_PDPES - 1; i = 0; i--) { + for (i = 3; i = 0; i--) { struct i915_page_directory_entry *pd = ppgtt-pdp.page_directory[i]; dma_addr_t pd_daddr = pd ? pd-daddr : ppgtt-scratch_pd-daddr; /* The page directory might be NULL, but we need to clear out @@ -580,9 +629,6 @@ static void gen8_ppgtt_insert_entries(struct i915_address_space *vm, pt_vaddr = NULL;
[Intel-gfx] [PATCH 01/12] drm/i915/bdw: Make pdp allocation more dynamic
From: Ben Widawsky benjamin.widaw...@intel.com This transitional patch doesn't do much for the existing code. However, it should make upcoming patches to use the full 48b address space a bit easier to swallow. The patch also introduces the PML4, ie. the new top level structure of the page tables. v2: Renamed pdp_free to be similar to pd/pt (unmap_and_free_pdp), To facilitate testing, 48b mode will be available on Broadwell, when i915.enable_ppgtt = 3. Signed-off-by: Ben Widawsky b...@bwidawsk.net Signed-off-by: Michel Thierry michel.thie...@intel.com (v2) --- drivers/gpu/drm/i915/i915_drv.h | 7 ++- drivers/gpu/drm/i915/i915_gem_gtt.c | 108 +--- drivers/gpu/drm/i915/i915_gem_gtt.h | 41 +++--- 3 files changed, 126 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 2dedd43..af0d149 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2432,7 +2432,12 @@ struct drm_i915_cmd_table { #define HAS_HW_CONTEXTS(dev) (INTEL_INFO(dev)-gen = 6) #define HAS_LOGICAL_RING_CONTEXTS(dev) (INTEL_INFO(dev)-gen = 8) #define USES_PPGTT(dev)(i915.enable_ppgtt) -#define USES_FULL_PPGTT(dev) (i915.enable_ppgtt == 2) +#define USES_FULL_PPGTT(dev) (i915.enable_ppgtt = 2) +#ifdef CONFIG_64BIT +# define USES_FULL_48BIT_PPGTT(dev)(i915.enable_ppgtt == 3) +#else +# define USES_FULL_48BIT_PPGTT(dev)false +#endif #define HAS_OVERLAY(dev) (INTEL_INFO(dev)-has_overlay) #define OVERLAY_NEEDS_PHYSICAL(dev) (INTEL_INFO(dev)-overlay_needs_physical) diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index ff86501..489f8db 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -100,10 +100,17 @@ static int sanitize_enable_ppgtt(struct drm_device *dev, int enable_ppgtt) { bool has_aliasing_ppgtt; bool has_full_ppgtt; + bool has_full_64bit_ppgtt; has_aliasing_ppgtt = INTEL_INFO(dev)-gen = 6; has_full_ppgtt = INTEL_INFO(dev)-gen = 7; +#ifdef CONFIG_64BIT + has_full_64bit_ppgtt = IS_BROADWELL(dev) false; /* FIXME: 64b */ +#else + has_full_64bit_ppgtt = false; +#endif + if (intel_vgpu_active(dev)) has_full_ppgtt = false; /* emulation is too hard */ @@ -121,6 +128,9 @@ static int sanitize_enable_ppgtt(struct drm_device *dev, int enable_ppgtt) if (enable_ppgtt == 2 has_full_ppgtt) return 2; + if (enable_ppgtt == 3 has_full_64bit_ppgtt) + return 3; + #ifdef CONFIG_INTEL_IOMMU /* Disable ppgtt on SNB if VT-d is on. */ if (INTEL_INFO(dev)-gen == 6 intel_iommu_gfx_mapped) { @@ -462,6 +472,45 @@ free_pd: return ERR_PTR(ret); } +static void __pdp_fini(struct i915_page_directory_pointer_entry *pdp) +{ + kfree(pdp-used_pdpes); + kfree(pdp-page_directory); + /* HACK */ + pdp-page_directory = NULL; +} + +static void unmap_and_free_pdp(struct i915_page_directory_pointer_entry *pdp, + struct drm_device *dev) +{ + __pdp_fini(pdp); + if (USES_FULL_48BIT_PPGTT(dev)) + kfree(pdp); +} + +static int __pdp_init(struct i915_page_directory_pointer_entry *pdp, + struct drm_device *dev) +{ + size_t pdpes = I915_PDPES_PER_PDP(dev); + + pdp-used_pdpes = kcalloc(BITS_TO_LONGS(pdpes), + sizeof(unsigned long), + GFP_KERNEL); + if (!pdp-used_pdpes) + return -ENOMEM; + + pdp-page_directory = kcalloc(pdpes, sizeof(*pdp-page_directory), GFP_KERNEL); + if (!pdp-page_directory) { + kfree(pdp-used_pdpes); + /* the PDP might be the statically allocated top level. Keep it +* as clean as possible */ + pdp-used_pdpes = NULL; + return -ENOMEM; + } + + return 0; +} + /* Broadwell Page Directory Pointer Descriptors */ static int gen8_write_pdp(struct intel_engine_cs *ring, unsigned entry, @@ -491,7 +540,7 @@ static int gen8_mm_switch(struct i915_hw_ppgtt *ppgtt, { int i, ret; - for (i = GEN8_LEGACY_PDPES - 1; i = 0; i--) { + for (i = 3; i = 0; i--) { struct i915_page_directory_entry *pd = ppgtt-pdp.page_directory[i]; dma_addr_t pd_daddr = pd ? pd-daddr : ppgtt-scratch_pd-daddr; /* The page directory might be NULL, but we need to clear out @@ -580,9 +629,6 @@ static void gen8_ppgtt_insert_entries(struct i915_address_space *vm, pt_vaddr = NULL; for_each_sg_page(pages-sgl, sg_iter, pages-nents, 0) { - if (WARN_ON(pdpe = GEN8_LEGACY_PDPES)) - break; - if (pt_vaddr == NULL) { struct