[PATCH 1/2] drm/nouveau: tegra: Fix NULL pointer dereference

Lyude Paul lyude at redhat.com
Tue Sep 17 18:11:37 UTC 2019


Not sure I understand enough about why BAR2 is needed or what it's used for to
give a proper review on this one, probably better to wait for skeggsb to take
a look at this

On Mon, 2019-09-16 at 16:36 +0200, Thierry Reding wrote:
> From: Thierry Reding <treding at nvidia.com>
> 
> Fill in BAR2 callbacks for instance memory. There's no BAR2 on Tegra
> GPUs, but buffers are all in system memory anyway, so just return the
> plain address.
> 
> Signed-off-by: Thierry Reding <treding at nvidia.com>
> ---
>  .../drm/nouveau/nvkm/subdev/instmem/gk20a.c   | 30 +++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
> b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
> index 985f2990ab0d..b0493f8df1fe 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
> @@ -261,6 +261,34 @@ gk20a_instobj_release_iommu(struct nvkm_memory *memory)
>  	nvkm_ltc_invalidate(ltc);
>  }
>  
> +static u64
> +gk20a_instobj_bar2_dma(struct nvkm_memory *memory)
> +{
> +	struct gk20a_instobj_dma *iobj = gk20a_instobj_dma(memory);
> +	u64 addr = ~0ULL;
> +
> +	if (gk20a_instobj_acquire_dma(&iobj->base.memory))
> +		addr = gk20a_instobj_addr(&iobj->base.memory);
> +
> +	gk20a_instobj_release_dma(&iobj->base.memory);
> +
> +	return addr;
> +}
> +
> +static u64
> +gk20a_instobj_bar2_iommu(struct nvkm_memory *memory)
> +{
> +	struct gk20a_instobj_iommu *iobj = gk20a_instobj_iommu(memory);
> +	u64 addr = ~0ULL;
> +
> +	if (gk20a_instobj_acquire_iommu(&iobj->base.memory))
> +		addr = gk20a_instobj_addr(&iobj->base.memory);
> +
> +	gk20a_instobj_release_iommu(&iobj->base.memory);
> +
> +	return addr;
> +}
> +
>  static u32
>  gk20a_instobj_rd32(struct nvkm_memory *memory, u64 offset)
>  {
> @@ -353,6 +381,7 @@ static const struct nvkm_memory_func
>  gk20a_instobj_func_dma = {
>  	.dtor = gk20a_instobj_dtor_dma,
>  	.target = gk20a_instobj_target,
> +	.bar2 = gk20a_instobj_bar2_dma,
>  	.page = gk20a_instobj_page,
>  	.addr = gk20a_instobj_addr,
>  	.size = gk20a_instobj_size,
> @@ -365,6 +394,7 @@ static const struct nvkm_memory_func
>  gk20a_instobj_func_iommu = {
>  	.dtor = gk20a_instobj_dtor_iommu,
>  	.target = gk20a_instobj_target,
> +	.bar2 = gk20a_instobj_bar2_iommu,
>  	.page = gk20a_instobj_page,
>  	.addr = gk20a_instobj_addr,
>  	.size = gk20a_instobj_size,
-- 
Cheers,
	Lyude Paul



More information about the dri-devel mailing list