* [PATCH] drm/i915: Propagate errors on failed PPGTT
@ 2013-12-03 22:43 Ben Widawsky
2013-12-04 1:27 ` [PATCH v2] " Ben Widawsky
0 siblings, 1 reply; 3+ messages in thread
From: Ben Widawsky @ 2013-12-03 22:43 UTC (permalink / raw)
To: Intel GFX; +Cc: Ben Widawsky, Ben Widawsky
Clean up the return values/error handling so it's obvious what is going
on. This was tripped over in the PPGTT branch where code was added to do
a ret = foo() near the top, and this ended up bypassing some error cases
later.
These errors shouldn't exist with today's code, but a future patch
will add a ret = ..., and this the value of ret needs to be set
explicitly.
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
drivers/gpu/drm/i915/i915_gem_gtt.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index e63ae52..8075af8 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -361,7 +361,7 @@ static void gen8_ppgtt_cleanup(struct i915_address_space *vm)
static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt, uint64_t size)
{
struct page *pt_pages;
- int i, j, ret = -ENOMEM;
+ int i, j, ret;
const int max_pdp = DIV_ROUND_UP(size, 1 << 30);
const int num_pt_pages = GEN8_PDES_PER_PAGE * max_pdp;
@@ -407,14 +407,17 @@ static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt, uint64_t size)
temp = pci_map_page(ppgtt->base.dev->pdev,
&ppgtt->pd_pages[i], 0,
PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
- if (pci_dma_mapping_error(ppgtt->base.dev->pdev, temp))
+ ret = pci_dma_mapping_error(ppgtt->base.dev->pdev, temp);
+ if (ret)
goto err_out;
ppgtt->pd_dma_addr[i] = temp;
ppgtt->gen8_pt_dma_addr[i] = kmalloc(sizeof(dma_addr_t) * GEN8_PDES_PER_PAGE, GFP_KERNEL);
- if (!ppgtt->gen8_pt_dma_addr[i])
+ if (!ppgtt->gen8_pt_dma_addr[i]) {
+ ret = -ENOMEM;
goto err_out;
+ }
for (j = 0; j < GEN8_PDES_PER_PAGE; j++) {
struct page *p = &pt_pages[i * GEN8_PDES_PER_PAGE + j];
@@ -422,7 +425,8 @@ static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt, uint64_t size)
p, 0, PAGE_SIZE,
PCI_DMA_BIDIRECTIONAL);
- if (pci_dma_mapping_error(ppgtt->base.dev->pdev, temp))
+ ret = pci_dma_mapping_error(ppgtt->base.dev->pdev, temp);
+ if (ret)
goto err_out;
ppgtt->gen8_pt_dma_addr[i][j] = temp;
@@ -849,7 +853,7 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt)
struct drm_device *dev = ppgtt->base.dev;
struct drm_i915_private *dev_priv = dev->dev_private;
bool retried = false;
- int i, ret = -ENOMEM;
+ int i, ret;
/* PPGTT PDEs reside in the GGTT and consists of 512 entries. The
* allocator works in address space sizes, so it's multiplied by page
@@ -910,8 +914,10 @@ alloc:
ppgtt->pt_dma_addr = kcalloc(ppgtt->num_pd_entries, sizeof(dma_addr_t),
GFP_KERNEL);
- if (!ppgtt->pt_dma_addr)
+ if (!ppgtt->pt_dma_addr) {
+ ret = -ENOMEM;
goto err_pt_alloc;
+ }
for (i = 0; i < ppgtt->num_pd_entries; i++) {
dma_addr_t pt_addr;
--
1.8.4.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH v2] drm/i915: Propagate errors on failed PPGTT
2013-12-03 22:43 [PATCH] drm/i915: Propagate errors on failed PPGTT Ben Widawsky
@ 2013-12-04 1:27 ` Ben Widawsky
2014-01-15 12:50 ` Rodrigo Vivi
0 siblings, 1 reply; 3+ messages in thread
From: Ben Widawsky @ 2013-12-04 1:27 UTC (permalink / raw)
To: Intel GFX; +Cc: Ben Widawsky, Ben Widawsky
Clean up the return values/error handling so it's obvious what is going
on. This was tripped over in the PPGTT branch where code was added to do
a ret = foo() near the top, and this ended up bypassing some error cases
later.
These errors shouldn't exist with today's code, but a future patch
will add a ret = ..., and this the value of ret needs to be set
explicitly.
v2: Missed an error in alloc_page for gen6
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
drivers/gpu/drm/i915/i915_gem_gtt.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index e63ae52..866b23e 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -361,7 +361,7 @@ static void gen8_ppgtt_cleanup(struct i915_address_space *vm)
static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt, uint64_t size)
{
struct page *pt_pages;
- int i, j, ret = -ENOMEM;
+ int i, j, ret;
const int max_pdp = DIV_ROUND_UP(size, 1 << 30);
const int num_pt_pages = GEN8_PDES_PER_PAGE * max_pdp;
@@ -407,14 +407,17 @@ static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt, uint64_t size)
temp = pci_map_page(ppgtt->base.dev->pdev,
&ppgtt->pd_pages[i], 0,
PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
- if (pci_dma_mapping_error(ppgtt->base.dev->pdev, temp))
+ ret = pci_dma_mapping_error(ppgtt->base.dev->pdev, temp);
+ if (ret)
goto err_out;
ppgtt->pd_dma_addr[i] = temp;
ppgtt->gen8_pt_dma_addr[i] = kmalloc(sizeof(dma_addr_t) * GEN8_PDES_PER_PAGE, GFP_KERNEL);
- if (!ppgtt->gen8_pt_dma_addr[i])
+ if (!ppgtt->gen8_pt_dma_addr[i]) {
+ ret = -ENOMEM;
goto err_out;
+ }
for (j = 0; j < GEN8_PDES_PER_PAGE; j++) {
struct page *p = &pt_pages[i * GEN8_PDES_PER_PAGE + j];
@@ -422,7 +425,8 @@ static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt, uint64_t size)
p, 0, PAGE_SIZE,
PCI_DMA_BIDIRECTIONAL);
- if (pci_dma_mapping_error(ppgtt->base.dev->pdev, temp))
+ ret = pci_dma_mapping_error(ppgtt->base.dev->pdev, temp);
+ if (ret)
goto err_out;
ppgtt->gen8_pt_dma_addr[i][j] = temp;
@@ -849,7 +853,7 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt)
struct drm_device *dev = ppgtt->base.dev;
struct drm_i915_private *dev_priv = dev->dev_private;
bool retried = false;
- int i, ret = -ENOMEM;
+ int i, ret;
/* PPGTT PDEs reside in the GGTT and consists of 512 entries. The
* allocator works in address space sizes, so it's multiplied by page
@@ -904,14 +908,18 @@ alloc:
for (i = 0; i < ppgtt->num_pd_entries; i++) {
ppgtt->pt_pages[i] = alloc_page(GFP_KERNEL);
- if (!ppgtt->pt_pages[i])
+ if (!ppgtt->pt_pages[i]) {
+ ret = -ENOMEM;
goto err_pt_alloc;
+ }
}
ppgtt->pt_dma_addr = kcalloc(ppgtt->num_pd_entries, sizeof(dma_addr_t),
GFP_KERNEL);
- if (!ppgtt->pt_dma_addr)
+ if (!ppgtt->pt_dma_addr) {
+ ret = -ENOMEM;
goto err_pt_alloc;
+ }
for (i = 0; i < ppgtt->num_pd_entries; i++) {
dma_addr_t pt_addr;
--
1.8.4.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] drm/i915: Propagate errors on failed PPGTT
2013-12-04 1:27 ` [PATCH v2] " Ben Widawsky
@ 2014-01-15 12:50 ` Rodrigo Vivi
0 siblings, 0 replies; 3+ messages in thread
From: Rodrigo Vivi @ 2014-01-15 12:50 UTC (permalink / raw)
To: Ben Widawsky; +Cc: Intel GFX, Ben Widawsky
fyi: I got a conflict here when trying to merge to -collector
seemed like it was partially applied already.
On Tue, Dec 3, 2013 at 11:27 PM, Ben Widawsky
<benjamin.widawsky@intel.com> wrote:
> Clean up the return values/error handling so it's obvious what is going
> on. This was tripped over in the PPGTT branch where code was added to do
> a ret = foo() near the top, and this ended up bypassing some error cases
> later.
>
> These errors shouldn't exist with today's code, but a future patch
> will add a ret = ..., and this the value of ret needs to be set
> explicitly.
>
> v2: Missed an error in alloc_page for gen6
>
> Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
> ---
> drivers/gpu/drm/i915/i915_gem_gtt.c | 22 +++++++++++++++-------
> 1 file changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index e63ae52..866b23e 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -361,7 +361,7 @@ static void gen8_ppgtt_cleanup(struct i915_address_space *vm)
> static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt, uint64_t size)
> {
> struct page *pt_pages;
> - int i, j, ret = -ENOMEM;
> + int i, j, ret;
> const int max_pdp = DIV_ROUND_UP(size, 1 << 30);
> const int num_pt_pages = GEN8_PDES_PER_PAGE * max_pdp;
>
> @@ -407,14 +407,17 @@ static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt, uint64_t size)
> temp = pci_map_page(ppgtt->base.dev->pdev,
> &ppgtt->pd_pages[i], 0,
> PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
> - if (pci_dma_mapping_error(ppgtt->base.dev->pdev, temp))
> + ret = pci_dma_mapping_error(ppgtt->base.dev->pdev, temp);
> + if (ret)
> goto err_out;
>
> ppgtt->pd_dma_addr[i] = temp;
>
> ppgtt->gen8_pt_dma_addr[i] = kmalloc(sizeof(dma_addr_t) * GEN8_PDES_PER_PAGE, GFP_KERNEL);
> - if (!ppgtt->gen8_pt_dma_addr[i])
> + if (!ppgtt->gen8_pt_dma_addr[i]) {
> + ret = -ENOMEM;
> goto err_out;
> + }
>
> for (j = 0; j < GEN8_PDES_PER_PAGE; j++) {
> struct page *p = &pt_pages[i * GEN8_PDES_PER_PAGE + j];
> @@ -422,7 +425,8 @@ static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt, uint64_t size)
> p, 0, PAGE_SIZE,
> PCI_DMA_BIDIRECTIONAL);
>
> - if (pci_dma_mapping_error(ppgtt->base.dev->pdev, temp))
> + ret = pci_dma_mapping_error(ppgtt->base.dev->pdev, temp);
> + if (ret)
> goto err_out;
>
> ppgtt->gen8_pt_dma_addr[i][j] = temp;
> @@ -849,7 +853,7 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt)
> struct drm_device *dev = ppgtt->base.dev;
> struct drm_i915_private *dev_priv = dev->dev_private;
> bool retried = false;
> - int i, ret = -ENOMEM;
> + int i, ret;
>
> /* PPGTT PDEs reside in the GGTT and consists of 512 entries. The
> * allocator works in address space sizes, so it's multiplied by page
> @@ -904,14 +908,18 @@ alloc:
>
> for (i = 0; i < ppgtt->num_pd_entries; i++) {
> ppgtt->pt_pages[i] = alloc_page(GFP_KERNEL);
> - if (!ppgtt->pt_pages[i])
> + if (!ppgtt->pt_pages[i]) {
> + ret = -ENOMEM;
> goto err_pt_alloc;
> + }
> }
>
> ppgtt->pt_dma_addr = kcalloc(ppgtt->num_pd_entries, sizeof(dma_addr_t),
> GFP_KERNEL);
> - if (!ppgtt->pt_dma_addr)
> + if (!ppgtt->pt_dma_addr) {
> + ret = -ENOMEM;
> goto err_pt_alloc;
> + }
>
> for (i = 0; i < ppgtt->num_pd_entries; i++) {
> dma_addr_t pt_addr;
> --
> 1.8.4.2
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Rodrigo Vivi
Blog: http://blog.vivi.eng.br
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-01-15 12:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-03 22:43 [PATCH] drm/i915: Propagate errors on failed PPGTT Ben Widawsky
2013-12-04 1:27 ` [PATCH v2] " Ben Widawsky
2014-01-15 12:50 ` Rodrigo Vivi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox