* [PATCH 3/5] drm/i915: Remove scratch page from shared
2013-01-18 20:30 ` [PATCH 2/5] drm/i915: Cut out the infamous ILK w/a from AGP layer Ben Widawsky
@ 2013-01-18 20:30 ` Ben Widawsky
2013-01-18 20:30 ` [PATCH 4/5] drm/i915: Needs_dmar, not Ben Widawsky
2013-01-18 20:30 ` [PATCH 5/5] agp/intel: Add gma_bus_addr Ben Widawsky
2 siblings, 0 replies; 7+ messages in thread
From: Ben Widawsky @ 2013-01-18 20:30 UTC (permalink / raw)
To: intel-gfx; +Cc: Ben Widawsky
We already had a mapping in both (minus the phys_addr in AGP).
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
drivers/char/agp/intel-gtt.c | 9 +++++----
drivers/gpu/drm/i915/i915_drv.h | 2 ++
drivers/gpu/drm/i915/i915_gem_gtt.c | 16 ++++++++--------
include/drm/intel-gtt.h | 3 ---
4 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 12c3102..7fcee5c 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -75,6 +75,7 @@ static struct _intel_private {
struct resource ifp_resource;
int resource_valid;
struct page *scratch_page;
+ phys_addr_t scratch_page_dma;
int refcount;
} intel_private;
@@ -297,9 +298,9 @@ static int intel_gtt_setup_scratch_page(void)
if (pci_dma_mapping_error(intel_private.pcidev, dma_addr))
return -EINVAL;
- intel_private.base.scratch_page_dma = dma_addr;
+ intel_private.scratch_page_dma = dma_addr;
} else
- intel_private.base.scratch_page_dma = page_to_phys(page);
+ intel_private.scratch_page_dma = page_to_phys(page);
intel_private.scratch_page = page;
@@ -546,7 +547,7 @@ static unsigned int intel_gtt_mappable_entries(void)
static void intel_gtt_teardown_scratch_page(void)
{
set_pages_wb(intel_private.scratch_page, 1);
- pci_unmap_page(intel_private.pcidev, intel_private.base.scratch_page_dma,
+ pci_unmap_page(intel_private.pcidev, intel_private.scratch_page_dma,
PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
put_page(intel_private.scratch_page);
__free_page(intel_private.scratch_page);
@@ -891,7 +892,7 @@ void intel_gtt_clear_range(unsigned int first_entry, unsigned int num_entries)
unsigned int i;
for (i = first_entry; i < (first_entry + num_entries); i++) {
- intel_private.driver->write_entry(intel_private.base.scratch_page_dma,
+ intel_private.driver->write_entry(intel_private.scratch_page_dma,
i, 0);
}
readl(intel_private.gtt+i-1);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 1cb8dad..ab2422a 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -383,6 +383,8 @@ struct i915_gtt {
void __iomem *gsm;
bool do_idle_maps;
+ dma_addr_t scratch_page_dma;
+ struct page *scratch_page;
};
#define I915_PPGTT_PD_ENTRIES 512
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 84c521f..3c1f66e 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -162,7 +162,7 @@ int i915_gem_init_aliasing_ppgtt(struct drm_device *dev)
}
}
- ppgtt->scratch_page_dma_addr = dev_priv->mm.gtt->scratch_page_dma;
+ ppgtt->scratch_page_dma_addr = dev_priv->gtt.scratch_page_dma;
i915_ppgtt_clear_range(ppgtt, 0,
ppgtt->num_pd_entries*I915_PPGTT_PT_ENTRIES);
@@ -396,7 +396,7 @@ static void i915_ggtt_clear_range(struct drm_device *dev,
first_entry, num_entries, max_entries))
num_entries = max_entries;
- scratch_pte = pte_encode(dev, dev_priv->mm.gtt->scratch_page_dma, I915_CACHE_LLC);
+ scratch_pte = pte_encode(dev, dev_priv->gtt.scratch_page_dma, I915_CACHE_LLC);
for (i = 0; i < num_entries; i++)
iowrite32(scratch_pte, >t_base[i]);
readl(gtt_base);
@@ -659,8 +659,8 @@ static int setup_scratch_page(struct drm_device *dev)
#else
dma_addr = page_to_phys(page);
#endif
- dev_priv->mm.gtt->scratch_page = page;
- dev_priv->mm.gtt->scratch_page_dma = dma_addr;
+ dev_priv->gtt.scratch_page = page;
+ dev_priv->gtt.scratch_page_dma = dma_addr;
return 0;
}
@@ -668,11 +668,11 @@ static int setup_scratch_page(struct drm_device *dev)
static void teardown_scratch_page(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;
- set_pages_wb(dev_priv->mm.gtt->scratch_page, 1);
- pci_unmap_page(dev->pdev, dev_priv->mm.gtt->scratch_page_dma,
+ set_pages_wb(dev_priv->gtt.scratch_page, 1);
+ pci_unmap_page(dev->pdev, dev_priv->gtt.scratch_page_dma,
PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
- put_page(dev_priv->mm.gtt->scratch_page);
- __free_page(dev_priv->mm.gtt->scratch_page);
+ put_page(dev_priv->gtt.scratch_page);
+ __free_page(dev_priv->gtt.scratch_page);
}
static inline unsigned int gen6_get_total_gtt_size(u16 snb_gmch_ctl)
diff --git a/include/drm/intel-gtt.h b/include/drm/intel-gtt.h
index 1747aa09..c787ee4 100644
--- a/include/drm/intel-gtt.h
+++ b/include/drm/intel-gtt.h
@@ -13,9 +13,6 @@ struct intel_gtt {
unsigned int gtt_mappable_entries;
/* Whether i915 needs to use the dmar apis or not. */
unsigned int needs_dmar : 1;
- /* Share the scratch page dma with ppgtts. */
- dma_addr_t scratch_page_dma;
- struct page *scratch_page;
/* needed for ioremap in drm/i915 */
phys_addr_t gma_bus_addr;
} *intel_gtt_get(void);
--
1.8.1.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 4/5] drm/i915: Needs_dmar, not
2013-01-18 20:30 ` [PATCH 2/5] drm/i915: Cut out the infamous ILK w/a from AGP layer Ben Widawsky
2013-01-18 20:30 ` [PATCH 3/5] drm/i915: Remove scratch page from shared Ben Widawsky
@ 2013-01-18 20:30 ` Ben Widawsky
2013-01-18 20:30 ` [PATCH 5/5] agp/intel: Add gma_bus_addr Ben Widawsky
2 siblings, 0 replies; 7+ messages in thread
From: Ben Widawsky @ 2013-01-18 20:30 UTC (permalink / raw)
To: intel-gfx; +Cc: Ben Widawsky
The reasoning behind our code taking two paths depending upon whether or
not we may have been configured for IOMMU isn't clear to me. It should
always be safe to use the pci mapping functions as they are designed to
abstract the decision we were handling in i915.
Aside from simpler code, removing another member for the intel_gtt
struct is a nice motivation.
I ran this by Chris, and he wasn't concerned about the extra kzalloc,
and memory references vs. page_to_phys calculation in the case without
IOMMU.
v2: Update commit message
v3: Remove needs_dmar addition from Zhenyu upstream
This reverts (and then other stuff)
commit 20652097dadd9a7fb4d652f25466299974bc78f9
Author: Zhenyu Wang <zhenyuw@linux.intel.com>
Date: Thu Dec 13 23:47:47 2012 +0800
drm/i915: Fix missed needs_dmar setting
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@gmail.com> (v2)
Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
drivers/char/agp/intel-gtt.c | 10 +++++----
drivers/gpu/drm/i915/i915_gem_gtt.c | 42 ++++++++++++-------------------------
include/drm/intel-gtt.h | 2 --
3 files changed, 19 insertions(+), 35 deletions(-)
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 7fcee5c..b452414 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -77,6 +77,8 @@ static struct _intel_private {
struct page *scratch_page;
phys_addr_t scratch_page_dma;
int refcount;
+ /* Whether i915 needs to use the dmar apis or not. */
+ unsigned int needs_dmar : 1;
} intel_private;
#define INTEL_GTT_GEN intel_private.driver->gen
@@ -292,7 +294,7 @@ static int intel_gtt_setup_scratch_page(void)
get_page(page);
set_pages_uc(page, 1);
- if (intel_private.base.needs_dmar) {
+ if (intel_private.needs_dmar) {
dma_addr = pci_map_page(intel_private.pcidev, page, 0,
PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
if (pci_dma_mapping_error(intel_private.pcidev, dma_addr))
@@ -608,7 +610,7 @@ static int intel_gtt_init(void)
intel_private.base.stolen_size = intel_gtt_stolen_size();
- intel_private.base.needs_dmar = USE_PCI_DMA_API && INTEL_GTT_GEN > 2;
+ intel_private.needs_dmar = USE_PCI_DMA_API && INTEL_GTT_GEN > 2;
ret = intel_gtt_setup_scratch_page();
if (ret != 0) {
@@ -866,7 +868,7 @@ static int intel_fake_agp_insert_entries(struct agp_memory *mem,
if (!mem->is_flushed)
global_cache_flush();
- if (intel_private.base.needs_dmar) {
+ if (intel_private.needs_dmar) {
struct sg_table st;
ret = intel_gtt_map_memory(mem->pages, mem->page_count, &st);
@@ -907,7 +909,7 @@ static int intel_fake_agp_remove_entries(struct agp_memory *mem,
intel_gtt_clear_range(pg_start, mem->page_count);
- if (intel_private.base.needs_dmar) {
+ if (intel_private.needs_dmar) {
intel_gtt_unmap_memory(mem->sg_list, mem->num_sg);
mem->sg_list = NULL;
mem->num_sg = 0;
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 3c1f66e..f8fb7e3 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -138,28 +138,23 @@ int i915_gem_init_aliasing_ppgtt(struct drm_device *dev)
goto err_pt_alloc;
}
- if (dev_priv->mm.gtt->needs_dmar) {
- ppgtt->pt_dma_addr = kzalloc(sizeof(dma_addr_t)
- *ppgtt->num_pd_entries,
- GFP_KERNEL);
- if (!ppgtt->pt_dma_addr)
- goto err_pt_alloc;
+ ppgtt->pt_dma_addr = kzalloc(sizeof(dma_addr_t) *ppgtt->num_pd_entries,
+ GFP_KERNEL);
+ if (!ppgtt->pt_dma_addr)
+ goto err_pt_alloc;
- for (i = 0; i < ppgtt->num_pd_entries; i++) {
- dma_addr_t pt_addr;
+ for (i = 0; i < ppgtt->num_pd_entries; i++) {
+ dma_addr_t pt_addr;
- pt_addr = pci_map_page(dev->pdev, ppgtt->pt_pages[i],
- 0, 4096,
- PCI_DMA_BIDIRECTIONAL);
+ pt_addr = pci_map_page(dev->pdev, ppgtt->pt_pages[i], 0, 4096,
+ PCI_DMA_BIDIRECTIONAL);
- if (pci_dma_mapping_error(dev->pdev,
- pt_addr)) {
- ret = -EIO;
- goto err_pd_pin;
+ if (pci_dma_mapping_error(dev->pdev, pt_addr)) {
+ ret = -EIO;
+ goto err_pd_pin;
- }
- ppgtt->pt_dma_addr[i] = pt_addr;
}
+ ppgtt->pt_dma_addr[i] = pt_addr;
}
ppgtt->scratch_page_dma_addr = dev_priv->gtt.scratch_page_dma;
@@ -294,11 +289,7 @@ void i915_gem_init_ppgtt(struct drm_device *dev)
for (i = 0; i < ppgtt->num_pd_entries; i++) {
dma_addr_t pt_addr;
- if (dev_priv->mm.gtt->needs_dmar)
- pt_addr = ppgtt->pt_dma_addr[i];
- else
- pt_addr = page_to_phys(ppgtt->pt_pages[i]);
-
+ pt_addr = ppgtt->pt_dma_addr[i];
pd_entry = GEN6_PDE_ADDR_ENCODE(pt_addr);
pd_entry |= GEN6_PDE_VALID;
@@ -734,13 +725,6 @@ int i915_gem_gtt_init(struct drm_device *dev)
if (!dev_priv->mm.gtt)
return -ENOMEM;
- if (!pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(40)))
- pci_set_consistent_dma_mask(dev->pdev, DMA_BIT_MASK(40));
-
-#ifdef CONFIG_INTEL_IOMMU
- dev_priv->mm.gtt->needs_dmar = 1;
-#endif
-
/* For GEN6+ the PTEs for the ggtt live at 2MB + BAR0 */
gtt_bus_addr = pci_resource_start(dev->pdev, 0) + (2<<20);
diff --git a/include/drm/intel-gtt.h b/include/drm/intel-gtt.h
index c787ee4..984105c 100644
--- a/include/drm/intel-gtt.h
+++ b/include/drm/intel-gtt.h
@@ -11,8 +11,6 @@ struct intel_gtt {
/* Part of the gtt that is mappable by the cpu, for those chips where
* this is not the full gtt. */
unsigned int gtt_mappable_entries;
- /* Whether i915 needs to use the dmar apis or not. */
- unsigned int needs_dmar : 1;
/* needed for ioremap in drm/i915 */
phys_addr_t gma_bus_addr;
} *intel_gtt_get(void);
--
1.8.1.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 5/5] agp/intel: Add gma_bus_addr
2013-01-18 20:30 ` [PATCH 2/5] drm/i915: Cut out the infamous ILK w/a from AGP layer Ben Widawsky
2013-01-18 20:30 ` [PATCH 3/5] drm/i915: Remove scratch page from shared Ben Widawsky
2013-01-18 20:30 ` [PATCH 4/5] drm/i915: Needs_dmar, not Ben Widawsky
@ 2013-01-18 20:30 ` Ben Widawsky
2013-01-18 21:18 ` Daniel Vetter
2 siblings, 1 reply; 7+ messages in thread
From: Ben Widawsky @ 2013-01-18 20:30 UTC (permalink / raw)
To: intel-gfx; +Cc: Ben Widawsky
It is no longer used in the i915 code, so isolate it from the shared
struct.
This was originally part of:
commit 0e275518f325418d559c05327775bff894b237f7
Author: Ben Widawsky <ben@bwidawsk.net>
Date: Mon Jan 14 13:35:33 2013 -0800
agp/intel: decouple more of the agp-i915 sharing
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
That commit had some other hunks which can't be used due to issues
Daniel found in previous commits.
Recommend to squash this in to:
commit 42389dbda7398dac0ceadef327d51dc5509f9399
Author: Ben Widawsky <ben@bwidawsk.net>
Date: Fri Jan 11 13:50:28 2013 -0800
drm/i915: Remove use on gma_bus_addr on gen6+
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
drivers/char/agp/intel-gtt.c | 5 +++--
include/drm/intel-gtt.h | 2 --
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index b452414..ff5f348 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -79,6 +79,7 @@ static struct _intel_private {
int refcount;
/* Whether i915 needs to use the dmar apis or not. */
unsigned int needs_dmar : 1;
+ phys_addr_t gma_bus_addr;
} intel_private;
#define INTEL_GTT_GEN intel_private.driver->gen
@@ -625,7 +626,7 @@ static int intel_gtt_init(void)
pci_read_config_dword(intel_private.pcidev, I915_GMADDR,
&gma_addr);
- intel_private.base.gma_bus_addr = (gma_addr & PCI_BASE_ADDRESS_MEM_MASK);
+ intel_private.gma_bus_addr = (gma_addr & PCI_BASE_ADDRESS_MEM_MASK);
return 0;
}
@@ -781,7 +782,7 @@ static int intel_fake_agp_configure(void)
return -EIO;
intel_private.clear_fake_agp = true;
- agp_bridge->gart_bus_addr = intel_private.base.gma_bus_addr;
+ agp_bridge->gart_bus_addr = intel_private.gma_bus_addr;
return 0;
}
diff --git a/include/drm/intel-gtt.h b/include/drm/intel-gtt.h
index 984105c..769b6c7 100644
--- a/include/drm/intel-gtt.h
+++ b/include/drm/intel-gtt.h
@@ -11,8 +11,6 @@ struct intel_gtt {
/* Part of the gtt that is mappable by the cpu, for those chips where
* this is not the full gtt. */
unsigned int gtt_mappable_entries;
- /* needed for ioremap in drm/i915 */
- phys_addr_t gma_bus_addr;
} *intel_gtt_get(void);
int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev,
--
1.8.1.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 5/5] agp/intel: Add gma_bus_addr
2013-01-18 20:30 ` [PATCH 5/5] agp/intel: Add gma_bus_addr Ben Widawsky
@ 2013-01-18 21:18 ` Daniel Vetter
2013-01-19 3:22 ` Ben Widawsky
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Vetter @ 2013-01-18 21:18 UTC (permalink / raw)
To: Ben Widawsky; +Cc: intel-gfx
On Fri, Jan 18, 2013 at 12:30:34PM -0800, Ben Widawsky wrote:
> It is no longer used in the i915 code, so isolate it from the shared
> struct.
>
> This was originally part of:
> commit 0e275518f325418d559c05327775bff894b237f7
> Author: Ben Widawsky <ben@bwidawsk.net>
> Date: Mon Jan 14 13:35:33 2013 -0800
>
> agp/intel: decouple more of the agp-i915 sharing
>
> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>
> Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
>
> That commit had some other hunks which can't be used due to issues
> Daniel found in previous commits.
>
> Recommend to squash this in to:
> commit 42389dbda7398dac0ceadef327d51dc5509f9399
> Author: Ben Widawsky <ben@bwidawsk.net>
> Date: Fri Jan 11 13:50:28 2013 -0800
>
> drm/i915: Remove use on gma_bus_addr on gen6+
>
> Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
All slurped into dinq, thanks for the patches.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 5/5] agp/intel: Add gma_bus_addr
2013-01-18 21:18 ` Daniel Vetter
@ 2013-01-19 3:22 ` Ben Widawsky
0 siblings, 0 replies; 7+ messages in thread
From: Ben Widawsky @ 2013-01-19 3:22 UTC (permalink / raw)
To: Daniel Vetter; +Cc: intel-gfx
On Fri, Jan 18, 2013 at 10:18:24PM +0100, Daniel Vetter wrote:
> On Fri, Jan 18, 2013 at 12:30:34PM -0800, Ben Widawsky wrote:
> > It is no longer used in the i915 code, so isolate it from the shared
> > struct.
> >
> > This was originally part of:
> > commit 0e275518f325418d559c05327775bff894b237f7
> > Author: Ben Widawsky <ben@bwidawsk.net>
> > Date: Mon Jan 14 13:35:33 2013 -0800
> >
> > agp/intel: decouple more of the agp-i915 sharing
> >
> > Reviewed-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>
> > Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
> >
> > That commit had some other hunks which can't be used due to issues
> > Daniel found in previous commits.
> >
> > Recommend to squash this in to:
> > commit 42389dbda7398dac0ceadef327d51dc5509f9399
> > Author: Ben Widawsky <ben@bwidawsk.net>
> > Date: Fri Jan 11 13:50:28 2013 -0800
> >
> > drm/i915: Remove use on gma_bus_addr on gen6+
> >
> > Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
>
> All slurped into dinq, thanks for the patches.
> -Daniel
It seems the accidentally dropped hunk you caught is indeed a problem on
my machine. I've submitted a patch to revert it.
Sorry.
--
Ben Widawsky, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 7+ messages in thread