[PATCH] drivers: net: fsl-mc: add a command which dumps the MC log

Ioana Ciornei ioana.ciornei at nxp.com
Thu Oct 7 10:09:56 CEST 2021


On Fri, Oct 01, 2021 at 12:01:07PM +0300, Cosmin-Florin Aluchenesei wrote:

> +static void mc_dump_log(void)
> +{
> +	struct mc_ccsr_registers __iomem *mc_ccsr_regs = MC_CCSR_BASE_ADDR;
> +	u64 high = in_le64(&mc_ccsr_regs->reg_mcfbahr) & MC_FW_ADDR_MASK_HIGH;
> +	u64 low = in_le64(&mc_ccsr_regs->reg_mcfbalr) & MC_FW_ADDR_MASK_LOW;
> +	u64 mc_addr = (high << 32) | low | MC_STRUCT_BUFFER_OFFSET;
> +	u32 buf_len, wrapped, last_byte, magic, buf_start;
> +	struct log_header *header;
> +	ssize_t size, bytes_end;
> +	const void *end_of_data;
> +	const void *map_addr;
> +	const void *end_addr;
> +	const void *cur_ptr;
> +	const void *buf;
> +
> +	map_addr = map_sysmem(mc_addr + MC_STRUCT_BUFFER_OFFSET,
> +			      MC_BUFFER_SIZE);


This does not work as it is.

You are adding the MC_STRUCT_BUFFER_OFFSET twice to the base address of
the MC - mc_addr. This means that the magic check below will fail
always.

A diff like the following fixes the issue.

--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -1799,7 +1799,7 @@ static void mc_dump_log(void)
        struct mc_ccsr_registers __iomem *mc_ccsr_regs = MC_CCSR_BASE_ADDR;
        u64 high = in_le64(&mc_ccsr_regs->reg_mcfbahr) & MC_FW_ADDR_MASK_HIGH;
        u64 low = in_le64(&mc_ccsr_regs->reg_mcfbalr) & MC_FW_ADDR_MASK_LOW;
-       u64 mc_addr = (high << 32) | low | MC_STRUCT_BUFFER_OFFSET;
+       u64 mc_addr = (high << 32) | low;
        u32 buf_len, wrapped, last_byte, magic, buf_start;
        struct log_header *header;
        ssize_t size, bytes_end;


Please fix this and send a v2.

Ioana


More information about the U-Boot mailing list