[PATCH 2/2] firmware: imx: sm-misc: Dump syslog info

Peng Fan peng.fan at oss.nxp.com
Fri Sep 12 00:50:32 PDT 2025


Hi Frank,

On Wed, Sep 10, 2025 at 11:25:04AM -0400, Frank Li wrote:
>On Wed, Sep 10, 2025 at 10:28:18PM +0800, Peng Fan wrote:
[...]
>> +static int syslog_show(struct seq_file *file, void *priv)
>> +{
>> +	struct device *dev = file->private;
>> +	/* 4KB is large enough for syslog */
>> +	void *syslog __free(kfree) = kmalloc(SZ_4K, GFP_KERNEL);
>> +	/* syslog API use num words, not num bytes */
>> +	u16 size = SZ_4K / 4;
>> +	int ret;
>> +
>> +	if (!ph)
>> +		return -ENODEV;
>> +
>> +	ret = imx_misc_ctrl_ops->misc_syslog(ph, &size, syslog);
>> +	if (ret) {
>> +		if (size > SZ_4K / 4) {
>> +			dev_err(dev, "syslog size is larger than 4KB, please enlarge\n");
>> +			return ret;
>

size could be runtime updated with the returned syslog size.

>suppose it is never happen, you pass down size to misc_syslog, it should
>never write data more than size.

Right. But size could be updated even it not write data more than the input
size.

>
>I am not sure what means of misc_syslog() return value. Generally it should
>be how many data in pointer 'syslog' if return value > 0.
>
>So seq_hex_dump() should use ret value. Then only dump validate data,
>instead of the whole buffer.

size has been updated by misc_syslog, so it is not to dump whole buffer.

Thanks,
Peng

>
>Frank
>
>> +		}
>> +	}
>> +
>> +	seq_hex_dump(file, " ", DUMP_PREFIX_NONE, 16, sizeof(u32), syslog, size * 4, false);
>> +	seq_putc(file, '\n');
>> +
>> +	return 0;
>> +}
>> +DEFINE_SHOW_ATTRIBUTE(syslog);
>> +
>> +static void scmi_imx_misc_put(void *p)
>> +{
>> +	debugfs_remove((struct dentry *)p);
>> +}
>> +
>>  static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev)
>>  {
>>  	const struct scmi_handle *handle = sdev->handle;
>>  	struct device_node *np = sdev->dev.of_node;
>> +	struct dentry *scmi_imx_dentry;
>>  	u32 src_id, flags;
>>  	int ret, i, num;
>>
>> @@ -98,6 +134,12 @@ static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev)
>>  		}
>>  	}
>>
>> +	scmi_imx_dentry = debugfs_create_dir("scmi_imx", NULL);
>> +	if (!IS_ERR(scmi_imx_dentry))
>> +		debugfs_create_file("syslog", 0444, scmi_imx_dentry, &sdev->dev, &syslog_fops);
>> +
>> +	devm_add_action_or_reset(&sdev->dev, scmi_imx_misc_put, scmi_imx_dentry);
>> +
>>  	return 0;
>>  }
>>
>>
>> --
>> 2.37.1
>>



More information about the linux-arm-kernel mailing list