[Intel-gfx] [PATCH 4/8] drm/i915: Check error return when setting DMA mask

Jani Nikula jani.nikula at linux.intel.com
Wed Apr 26 14:04:40 UTC 2017


On Wed, 26 Apr 2017, Imre Deak <imre.deak at intel.com> wrote:
> Even though an error from these functions isn't fatal we still want to
> have a diagnostic message about it.
>
> Signed-off-by: Imre Deak <imre.deak at intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem_gtt.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 8bab4ae..13bf099 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -2741,13 +2741,16 @@ static int gen8_gmch_probe(struct i915_ggtt *ggtt)
>  	struct pci_dev *pdev = dev_priv->drm.pdev;
>  	unsigned int size;
>  	u16 snb_gmch_ctl;
> +	int err;
>  
>  	/* TODO: We're not aware of mappable constraints on gen8 yet */
>  	ggtt->mappable_base = pci_resource_start(pdev, 2);
>  	ggtt->mappable_end = pci_resource_len(pdev, 2);
>  
> -	if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(39)))
> -		pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(39));
> +	if (!(err = pci_set_dma_mask(pdev, DMA_BIT_MASK(39))))

Please split out the assignment to a line of its own, in both places.

BR,
Jani.

> +		err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(39));
> +	if (err)
> +		DRM_ERROR("Can't set DMA mask/consistent mask (%d)\n", err);
>  
>  	pci_read_config_word(pdev, SNB_GMCH_CTRL, &snb_gmch_ctl);
>  
> @@ -2790,6 +2793,7 @@ static int gen6_gmch_probe(struct i915_ggtt *ggtt)
>  	struct pci_dev *pdev = dev_priv->drm.pdev;
>  	unsigned int size;
>  	u16 snb_gmch_ctl;
> +	int err;
>  
>  	ggtt->mappable_base = pci_resource_start(pdev, 2);
>  	ggtt->mappable_end = pci_resource_len(pdev, 2);
> @@ -2802,8 +2806,10 @@ static int gen6_gmch_probe(struct i915_ggtt *ggtt)
>  		return -ENXIO;
>  	}
>  
> -	if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(40)))
> -		pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(40));
> +	if (!(err = pci_set_dma_mask(pdev, DMA_BIT_MASK(40))))
> +		err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(40));
> +	if (err)
> +		DRM_ERROR("Can't set DMA mask/consistent mask (%d)\n", err);
>  	pci_read_config_word(pdev, SNB_GMCH_CTRL, &snb_gmch_ctl);
>  
>  	ggtt->stolen_size = gen6_get_stolen_size(snb_gmch_ctl);

-- 
Jani Nikula, Intel Open Source Technology Center


More information about the Intel-gfx mailing list