Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
* [PATCH] soc: qcom: cmd-db: fix minor version decoding in debugfs output
@ 2026-03-29 19:11 Alok Tiwari
  2026-03-30  5:35 ` Sneh Mankad
  0 siblings, 1 reply; 5+ messages in thread
From: Alok Tiwari @ 2026-03-29 19:11 UTC (permalink / raw)
  To: andersson, konradybcio, linux-arm-msm; +Cc: alok.a.tiwarilinux, alok.a.tiwari

cmd-db encodes the version as major in the high byte and minor in the low
byte. cmd_db_debugfs_dump() prints the full 16 bit value as the minor
version, resulting in incorrect output.

Extract minor from the low byte using (version & 0xff).

Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
---
 drivers/soc/qcom/cmd-db.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
index 84a75d8c4b70..eed7013c7676 100644
--- a/drivers/soc/qcom/cmd-db.c
+++ b/drivers/soc/qcom/cmd-db.c
@@ -301,7 +301,7 @@ static int cmd_db_debugfs_dump(struct seq_file *seq, void *p)
 
 		version = le16_to_cpu(rsc->version);
 		major = version >> 8;
-		minor = version;
+		minor = version & 0xff;
 
 		seq_printf(seq, "Slave %s (v%u.%u)\n", name, major, minor);
 		seq_puts(seq, "-------------------------\n");
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] soc: qcom: cmd-db: fix minor version decoding in debugfs output
  2026-03-29 19:11 [PATCH] soc: qcom: cmd-db: fix minor version decoding in debugfs output Alok Tiwari
@ 2026-03-30  5:35 ` Sneh Mankad
  2026-03-30  6:03   ` ALOK TIWARI
  0 siblings, 1 reply; 5+ messages in thread
From: Sneh Mankad @ 2026-03-30  5:35 UTC (permalink / raw)
  To: Alok Tiwari, andersson, konradybcio, linux-arm-msm; +Cc: alok.a.tiwarilinux


On 30-Mar-26 12:41 AM, Alok Tiwari wrote:
> cmd-db encodes the version as major in the high byte and minor in the low
> byte. cmd_db_debugfs_dump() prints the full 16 bit value as the minor
> version, resulting in incorrect output.
>
> Extract minor from the low byte using (version & 0xff).
>
> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
There should be a "fixes:" tag added since this is a fix.
> ---
>   drivers/soc/qcom/cmd-db.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
> index 84a75d8c4b70..eed7013c7676 100644
> --- a/drivers/soc/qcom/cmd-db.c
> +++ b/drivers/soc/qcom/cmd-db.c
> @@ -301,7 +301,7 @@ static int cmd_db_debugfs_dump(struct seq_file *seq, void *p)
>   
>   		version = le16_to_cpu(rsc->version);
>   		major = version >> 8;
> -		minor = version;
> +		minor = version & 0xff;

Minor is already a u8 type, so assigning a u16 type version to u8 type 
will automatically truncate the higher 8 bits.

Its the same reason why version is right shifted by 8 before being 
assigned to major variable.

I do not think there would be any difference in output with or without 
the change, do you have any example?

Thanks,
Sneh Mankad

>   
>   		seq_printf(seq, "Slave %s (v%u.%u)\n", name, major, minor);
>   		seq_puts(seq, "-------------------------\n");

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] soc: qcom: cmd-db: fix minor version decoding in debugfs output
  2026-03-30  5:35 ` Sneh Mankad
@ 2026-03-30  6:03   ` ALOK TIWARI
  2026-03-30 11:12     ` Dmitry Baryshkov
  2026-03-30 13:18     ` Bjorn Andersson
  0 siblings, 2 replies; 5+ messages in thread
From: ALOK TIWARI @ 2026-03-30  6:03 UTC (permalink / raw)
  To: Sneh Mankad, andersson, konradybcio, linux-arm-msm; +Cc: alok.a.tiwarilinux



On 3/30/2026 11:05 AM, Sneh Mankad wrote:
>> cmd-db encodes the version as major in the high byte and minor in the low
>> byte. cmd_db_debugfs_dump() prints the full 16 bit value as the minor
>> version, resulting in incorrect output.
>>
>> Extract minor from the low byte using (version & 0xff).
>>
>> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
> There should be a "fixes:" tag added since this is a fix.
>> ---
>>   drivers/soc/qcom/cmd-db.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
>> index 84a75d8c4b70..eed7013c7676 100644
>> --- a/drivers/soc/qcom/cmd-db.c
>> +++ b/drivers/soc/qcom/cmd-db.c
>> @@ -301,7 +301,7 @@ static int cmd_db_debugfs_dump(struct seq_file 
>> *seq, void *p)
>>           version = le16_to_cpu(rsc->version);
>>           major = version >> 8;
>> -        minor = version;
>> +        minor = version & 0xff;
> 
> Minor is already a u8 type, so assigning a u16 type version to u8 type 
> will automatically truncate the higher 8 bits.
> 
> Its the same reason why version is right shifted by 8 before being 
> assigned to major variable.
> 
> I do not think there would be any difference in output with or without 
> the change, do you have any example?


Thanks for pointing this out.

You are right that if minor is of type u8, assigning a u16 value will
implicitly truncate the upper 8 bits.

However, the intention of the change is to explicitly extract the minor
version from the lower byte, since the encoding defines the version as 
major in the high byte and minor in the low byte.

Using version & 0xff makes the extraction explicit and consistent with 
how major is derived using version >> 8. It improves readability and 
avoids relying on implicit truncation.

Since this change does not alter functionality and is mainly for clarity 
and consistency I believe a Fixes: tag may not be appropriate.
I can also drop “fix” from the subject to avoid confusion.

Thanks,
Alok

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] soc: qcom: cmd-db: fix minor version decoding in debugfs output
  2026-03-30  6:03   ` ALOK TIWARI
@ 2026-03-30 11:12     ` Dmitry Baryshkov
  2026-03-30 13:18     ` Bjorn Andersson
  1 sibling, 0 replies; 5+ messages in thread
From: Dmitry Baryshkov @ 2026-03-30 11:12 UTC (permalink / raw)
  To: ALOK TIWARI
  Cc: Sneh Mankad, andersson, konradybcio, linux-arm-msm,
	alok.a.tiwarilinux

On Mon, Mar 30, 2026 at 11:33:13AM +0530, ALOK TIWARI wrote:
> 
> 
> On 3/30/2026 11:05 AM, Sneh Mankad wrote:
> > > cmd-db encodes the version as major in the high byte and minor in the low
> > > byte. cmd_db_debugfs_dump() prints the full 16 bit value as the minor
> > > version, resulting in incorrect output.
> > > 
> > > Extract minor from the low byte using (version & 0xff).
> > > 
> > > Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
> > There should be a "fixes:" tag added since this is a fix.
> > > ---
> > >   drivers/soc/qcom/cmd-db.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
> > > index 84a75d8c4b70..eed7013c7676 100644
> > > --- a/drivers/soc/qcom/cmd-db.c
> > > +++ b/drivers/soc/qcom/cmd-db.c
> > > @@ -301,7 +301,7 @@ static int cmd_db_debugfs_dump(struct seq_file
> > > *seq, void *p)
> > >           version = le16_to_cpu(rsc->version);
> > >           major = version >> 8;
> > > -        minor = version;
> > > +        minor = version & 0xff;
> > 
> > Minor is already a u8 type, so assigning a u16 type version to u8 type
> > will automatically truncate the higher 8 bits.
> > 
> > Its the same reason why version is right shifted by 8 before being
> > assigned to major variable.
> > 
> > I do not think there would be any difference in output with or without
> > the change, do you have any example?
> 
> 
> Thanks for pointing this out.
> 
> You are right that if minor is of type u8, assigning a u16 value will
> implicitly truncate the upper 8 bits.
> 
> However, the intention of the change is to explicitly extract the minor
> version from the lower byte, since the encoding defines the version as major
> in the high byte and minor in the low byte.
> 
> Using version & 0xff makes the extraction explicit and consistent with how
> major is derived using version >> 8. It improves readability and avoids
> relying on implicit truncation.
> 
> Since this change does not alter functionality and is mainly for clarity and
> consistency I believe a Fixes: tag may not be appropriate.
> I can also drop “fix” from the subject to avoid confusion.

I believe the whole patch is unnecessary, sorry. It's handled by the
compiler itself.

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] soc: qcom: cmd-db: fix minor version decoding in debugfs output
  2026-03-30  6:03   ` ALOK TIWARI
  2026-03-30 11:12     ` Dmitry Baryshkov
@ 2026-03-30 13:18     ` Bjorn Andersson
  1 sibling, 0 replies; 5+ messages in thread
From: Bjorn Andersson @ 2026-03-30 13:18 UTC (permalink / raw)
  To: ALOK TIWARI; +Cc: Sneh Mankad, konradybcio, linux-arm-msm, alok.a.tiwarilinux

On Mon, Mar 30, 2026 at 11:33:13AM +0530, ALOK TIWARI wrote:
> 
> 
> On 3/30/2026 11:05 AM, Sneh Mankad wrote:
> > > cmd-db encodes the version as major in the high byte and minor in the low
> > > byte. cmd_db_debugfs_dump() prints the full 16 bit value as the minor
> > > version, resulting in incorrect output.
> > > 
> > > Extract minor from the low byte using (version & 0xff).
> > > 
> > > Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
> > There should be a "fixes:" tag added since this is a fix.
> > > ---
> > >   drivers/soc/qcom/cmd-db.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
> > > index 84a75d8c4b70..eed7013c7676 100644
> > > --- a/drivers/soc/qcom/cmd-db.c
> > > +++ b/drivers/soc/qcom/cmd-db.c
> > > @@ -301,7 +301,7 @@ static int cmd_db_debugfs_dump(struct seq_file
> > > *seq, void *p)
> > >           version = le16_to_cpu(rsc->version);
> > >           major = version >> 8;
> > > -        minor = version;
> > > +        minor = version & 0xff;
> > 
> > Minor is already a u8 type, so assigning a u16 type version to u8 type
> > will automatically truncate the higher 8 bits.
> > 
> > Its the same reason why version is right shifted by 8 before being
> > assigned to major variable.
> > 
> > I do not think there would be any difference in output with or without
> > the change, do you have any example?
> 
> 
> Thanks for pointing this out.
> 
> You are right that if minor is of type u8, assigning a u16 value will
> implicitly truncate the upper 8 bits.
> 
> However, the intention of the change is to explicitly extract the minor
> version from the lower byte, since the encoding defines the version as major
> in the high byte and minor in the low byte.
> 

You should say this in your commit message. Don't try to sneak changes
in, describe the actual problem that you're fixing in your commit
messages.

> Using version & 0xff makes the extraction explicit and consistent with how
> major is derived using version >> 8. It improves readability and avoids
> relying on implicit truncation.
> 
> Since this change does not alter functionality and is mainly for clarity and
> consistency I believe a Fixes: tag may not be appropriate.
> I can also drop “fix” from the subject to avoid confusion.
> 

I agree, this isn't a Fixes, because there is no problem in the current
implementation. A change of this kind would merely make the code
somewhat easier to read - but there will be more of it to read...

Regards,
Bjorn

> Thanks,
> Alok

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-30 13:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-29 19:11 [PATCH] soc: qcom: cmd-db: fix minor version decoding in debugfs output Alok Tiwari
2026-03-30  5:35 ` Sneh Mankad
2026-03-30  6:03   ` ALOK TIWARI
2026-03-30 11:12     ` Dmitry Baryshkov
2026-03-30 13:18     ` Bjorn Andersson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox