[PATCH 2/2] drm/etnaviv: print MMU exception cause

Lucas Stach l.stach at pengutronix.de
Fri Sep 6 10:55:35 UTC 2019


On Fr, 2019-09-06 at 12:03 +0200, Christian Gmeiner wrote:
> Might be useful when debugging MMU exceptions.
> 
> Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 26
> ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> index d47d1a8e0219..aa878dd05860 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> @@ -1364,10 +1364,36 @@ static void dump_mmu_fault(struct etnaviv_gpu
> *gpu)
>  
>  	for (i = 0; i < 4; i++) {
>  		u32 address_reg;
> +		const char *error;
>  
>  		if (!(status & (VIVS_MMUv2_STATUS_EXCEPTION0__MASK <<
> (i * 4))))
>  			continue;
>  
> +		switch (status) {
> +		case MMU_EXCEPTION_SLAVE_NOT_PRESENT:
> +			error = "slave not present";
> +			break;
> +		case MMU_EXCEPTION_PAGE_NOT_PRESENT:
> +			error = "page not present";
> +			break;
> +		case MMU_EXCEPTION_WRITE_VIOLATION:
> +			error = "write violation";
> +			break;
> +		case MMU_EXCEPTION_OUT_OF_BOUND:
> +			error = "out of bound";
> +			break;
> +		case MMU_EXCEPTION_READ_SECURITY_VIOLATION:
> +			error = "read security violation";
> +			break;
> +		case MMU_EXCEPTION_WRITE_SECURITY_VIOLATION:
> +			error = "write security violation";
> +			break;
> +		default:
> +			error = "unknown state";
> +			break;
> +		}

As the exception status is a nice contiguous set of bits, I think this
could be simplified into a static array of strings. The error message
could then just use the bit position to index into the array.

Regards,
Lucas

> +		dev_err_ratelimited(gpu->dev, "MMU %d %s\n", i, error);
> +
>  		if (gpu->sec_mode == ETNA_SEC_NONE)
>  			address_reg = VIVS_MMUv2_EXCEPTION_ADDR(i);
>  		else



More information about the etnaviv mailing list