diff mbox series

[09/29] accel/ivpu: Add FW version debugfs entry

Message ID 20240924081754.209728-10-jacek.lawrynowicz@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series accel/ivpu: Fixes for 6.12-rc1 | expand

Commit Message

Jacek Lawrynowicz Sept. 24, 2024, 8:17 a.m. UTC
From: Karol Wachowski <karol.wachowski@intel.com>

Add debugfs that prints current firmware version string on read.

Signed-off-by: Karol Wachowski <karol.wachowski@intel.com>
Reviewed-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
---
 drivers/accel/ivpu/ivpu_debugfs.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Jeffrey Hugo Sept. 27, 2024, 8:55 p.m. UTC | #1
On 9/24/2024 2:17 AM, Jacek Lawrynowicz wrote:
> From: Karol Wachowski <karol.wachowski@intel.com>
> 
> Add debugfs that prints current firmware version string on read.
> 
> Signed-off-by: Karol Wachowski <karol.wachowski@intel.com>
> Reviewed-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
> Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
> ---
>   drivers/accel/ivpu/ivpu_debugfs.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/accel/ivpu/ivpu_debugfs.c b/drivers/accel/ivpu/ivpu_debugfs.c
> index cd3ac08f0409a..65245f45cc701 100644
> --- a/drivers/accel/ivpu/ivpu_debugfs.c
> +++ b/drivers/accel/ivpu/ivpu_debugfs.c
> @@ -4,6 +4,7 @@
>    */
>   
>   #include <linux/debugfs.h>
> +#include <linux/firmware.h>
>   
>   #include <drm/drm_debugfs.h>
>   #include <drm/drm_file.h>
> @@ -20,6 +21,8 @@
>   #include "ivpu_jsm_msg.h"
>   #include "ivpu_pm.h"
>   
> +#include "vpu_boot_api.h"
> +
>   static inline struct ivpu_device *seq_to_ivpu(struct seq_file *s)
>   {
>   	struct drm_debugfs_entry *entry = s->private;
> @@ -45,6 +48,14 @@ static int fw_name_show(struct seq_file *s, void *v)
>   	return 0;
>   }
>   
> +static int fw_version_show(struct seq_file *s, void *v)
> +{
> +	struct ivpu_device *vdev = seq_to_ivpu(s);
> +
> +	seq_printf(s, "%s\n", (const char *)vdev->fw->file->data + VPU_FW_HEADER_SIZE);

This FW file comes from userspace. Is there a check somewhere else that 
this string is properly NULL terminated as expected?
Jacek Lawrynowicz Sept. 30, 2024, 1:04 p.m. UTC | #2
On 9/27/2024 10:55 PM, Jeffrey Hugo wrote:
> On 9/24/2024 2:17 AM, Jacek Lawrynowicz wrote:
>> From: Karol Wachowski <karol.wachowski@intel.com>
>>
>> Add debugfs that prints current firmware version string on read.
>>
>> Signed-off-by: Karol Wachowski <karol.wachowski@intel.com>
>> Reviewed-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
>> Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
>> ---
>>   drivers/accel/ivpu/ivpu_debugfs.c | 12 ++++++++++++
>>   1 file changed, 12 insertions(+)
>>
>> diff --git a/drivers/accel/ivpu/ivpu_debugfs.c b/drivers/accel/ivpu/ivpu_debugfs.c
>> index cd3ac08f0409a..65245f45cc701 100644
>> --- a/drivers/accel/ivpu/ivpu_debugfs.c
>> +++ b/drivers/accel/ivpu/ivpu_debugfs.c
>> @@ -4,6 +4,7 @@
>>    */
>>     #include <linux/debugfs.h>
>> +#include <linux/firmware.h>
>>     #include <drm/drm_debugfs.h>
>>   #include <drm/drm_file.h>
>> @@ -20,6 +21,8 @@
>>   #include "ivpu_jsm_msg.h"
>>   #include "ivpu_pm.h"
>>   +#include "vpu_boot_api.h"
>> +
>>   static inline struct ivpu_device *seq_to_ivpu(struct seq_file *s)
>>   {
>>       struct drm_debugfs_entry *entry = s->private;
>> @@ -45,6 +48,14 @@ static int fw_name_show(struct seq_file *s, void *v)
>>       return 0;
>>   }
>>   +static int fw_version_show(struct seq_file *s, void *v)
>> +{
>> +    struct ivpu_device *vdev = seq_to_ivpu(s);
>> +
>> +    seq_printf(s, "%s\n", (const char *)vdev->fw->file->data + VPU_FW_HEADER_SIZE);
> 
> This FW file comes from userspace. Is there a check somewhere else that this string is properly NULL terminated as expected?
> 

Sadly there is no check. I will add limited and properly terminated string with version info.
diff mbox series

Patch

diff --git a/drivers/accel/ivpu/ivpu_debugfs.c b/drivers/accel/ivpu/ivpu_debugfs.c
index cd3ac08f0409a..65245f45cc701 100644
--- a/drivers/accel/ivpu/ivpu_debugfs.c
+++ b/drivers/accel/ivpu/ivpu_debugfs.c
@@ -4,6 +4,7 @@ 
  */
 
 #include <linux/debugfs.h>
+#include <linux/firmware.h>
 
 #include <drm/drm_debugfs.h>
 #include <drm/drm_file.h>
@@ -20,6 +21,8 @@ 
 #include "ivpu_jsm_msg.h"
 #include "ivpu_pm.h"
 
+#include "vpu_boot_api.h"
+
 static inline struct ivpu_device *seq_to_ivpu(struct seq_file *s)
 {
 	struct drm_debugfs_entry *entry = s->private;
@@ -45,6 +48,14 @@  static int fw_name_show(struct seq_file *s, void *v)
 	return 0;
 }
 
+static int fw_version_show(struct seq_file *s, void *v)
+{
+	struct ivpu_device *vdev = seq_to_ivpu(s);
+
+	seq_printf(s, "%s\n", (const char *)vdev->fw->file->data + VPU_FW_HEADER_SIZE);
+	return 0;
+}
+
 static int fw_trace_capability_show(struct seq_file *s, void *v)
 {
 	struct ivpu_device *vdev = seq_to_ivpu(s);
@@ -111,6 +122,7 @@  static int reset_pending_show(struct seq_file *s, void *v)
 static const struct drm_debugfs_info vdev_debugfs_list[] = {
 	{"bo_list", bo_list_show, 0},
 	{"fw_name", fw_name_show, 0},
+	{"fw_version", fw_version_show, 0},
 	{"fw_trace_capability", fw_trace_capability_show, 0},
 	{"fw_trace_config", fw_trace_config_show, 0},
 	{"last_bootmode", last_bootmode_show, 0},