public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] common: spl: spl_dfu.c: Fix warning associated with PCI subclass_code
@ 2026-03-05 10:38 Siddharth Vadapalli
  2026-03-05 13:08 ` Mattijs Korpershoek
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Siddharth Vadapalli @ 2026-03-05 10:38 UTC (permalink / raw)
  To: trini, lukma, mkorpershoek; +Cc: u-boot, srk, s-vadapalli

The subclass_code member of the pci_ep_header structure is a 1-byte
field. The macro PCI_CLASS_MEMORY_RAM is a concetation of baseclass_code
and subclass_code as follows:
	PCI_BASE_CLASS_MEMORY: 0x05
	Subclass Code for RAM: 0x00
	PCI_CLASS_MEMORY_RAM:  0x0500
Hence, instead of extracting it via an implicity type conversion from int
to u8 which throws a warning, explicitly mask the bits to extract the
subclass_code.

Fixes: cde77583cf0b ("spl: Add support for Device Firmware Upgrade (DFU) over PCIe")
Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
---

Hello,

This patch is based on commit
f473a453b0c kbuild: Drop phandle from diff between base DT and U-Boot augmented DT if DEVICE_TREE_DEBUG=1of the master branch of U-Boot.

Regards,
Siddharth.

 common/spl/spl_dfu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c
index b09f82790c9..7d21bb4d16a 100644
--- a/common/spl/spl_dfu.c
+++ b/common/spl/spl_dfu.c
@@ -64,7 +64,7 @@ static int dfu_over_pcie(void)
 	hdr.deviceid = CONFIG_SPL_PCI_DFU_DEVICE_ID;
 	hdr.vendorid = CONFIG_SPL_PCI_DFU_VENDOR_ID;
 	hdr.baseclass_code = PCI_BASE_CLASS_MEMORY;
-	hdr.subclass_code = PCI_CLASS_MEMORY_RAM;
+	hdr.subclass_code = PCI_CLASS_MEMORY_RAM & 0xff;
 
 	ret = pci_ep_write_header(dev, fn, &hdr);
 	if (ret) {
-- 
2.51.1


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

* Re: [PATCH] common: spl: spl_dfu.c: Fix warning associated with PCI subclass_code
  2026-03-05 10:38 [PATCH] common: spl: spl_dfu.c: Fix warning associated with PCI subclass_code Siddharth Vadapalli
@ 2026-03-05 13:08 ` Mattijs Korpershoek
  2026-03-05 14:54   ` Siddharth Vadapalli
  2026-03-06  5:04 ` Anshul Dalal
  2026-03-12  8:59 ` Mattijs Korpershoek
  2 siblings, 1 reply; 6+ messages in thread
From: Mattijs Korpershoek @ 2026-03-05 13:08 UTC (permalink / raw)
  To: Siddharth Vadapalli, trini, lukma, mkorpershoek; +Cc: u-boot, srk, s-vadapalli

Hi Siddharth,

Thank you for the patch.

On Thu, Mar 05, 2026 at 16:08, Siddharth Vadapalli <s-vadapalli@ti.com> wrote:

> The subclass_code member of the pci_ep_header structure is a 1-byte
> field. The macro PCI_CLASS_MEMORY_RAM is a concetation of baseclass_code
> and subclass_code as follows:
> 	PCI_BASE_CLASS_MEMORY: 0x05
> 	Subclass Code for RAM: 0x00
> 	PCI_CLASS_MEMORY_RAM:  0x0500
> Hence, instead of extracting it via an implicity type conversion from int
> to u8 which throws a warning, explicitly mask the bits to extract the

What's the exact warning string? With which compiler version?

Is there an example defconfig that I can use to reproduce this?

Thanks
Mattijs

> subclass_code.
>
> Fixes: cde77583cf0b ("spl: Add support for Device Firmware Upgrade (DFU) over PCIe")
> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
> ---
>
> Hello,
>
> This patch is based on commit
> f473a453b0c kbuild: Drop phandle from diff between base DT and U-Boot augmented DT if DEVICE_TREE_DEBUG=1of the master branch of U-Boot.
>
> Regards,
> Siddharth.
>
>  common/spl/spl_dfu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c
> index b09f82790c9..7d21bb4d16a 100644
> --- a/common/spl/spl_dfu.c
> +++ b/common/spl/spl_dfu.c
> @@ -64,7 +64,7 @@ static int dfu_over_pcie(void)
>  	hdr.deviceid = CONFIG_SPL_PCI_DFU_DEVICE_ID;
>  	hdr.vendorid = CONFIG_SPL_PCI_DFU_VENDOR_ID;
>  	hdr.baseclass_code = PCI_BASE_CLASS_MEMORY;
> -	hdr.subclass_code = PCI_CLASS_MEMORY_RAM;
> +	hdr.subclass_code = PCI_CLASS_MEMORY_RAM & 0xff;
>  
>  	ret = pci_ep_write_header(dev, fn, &hdr);
>  	if (ret) {
> -- 
> 2.51.1

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

* Re: [PATCH] common: spl: spl_dfu.c: Fix warning associated with PCI subclass_code
  2026-03-05 13:08 ` Mattijs Korpershoek
@ 2026-03-05 14:54   ` Siddharth Vadapalli
  0 siblings, 0 replies; 6+ messages in thread
From: Siddharth Vadapalli @ 2026-03-05 14:54 UTC (permalink / raw)
  To: Mattijs Korpershoek; +Cc: trini, lukma, u-boot, srk, s-vadapalli

On 05/03/26 6:38 PM, Mattijs Korpershoek wrote:
> Hi Siddharth,
> 
> Thank you for the patch.
> 
> On Thu, Mar 05, 2026 at 16:08, Siddharth Vadapalli <s-vadapalli@ti.com> wrote:
> 
>> The subclass_code member of the pci_ep_header structure is a 1-byte
>> field. The macro PCI_CLASS_MEMORY_RAM is a concetation of baseclass_code
>> and subclass_code as follows:
>> 	PCI_BASE_CLASS_MEMORY: 0x05
>> 	Subclass Code for RAM: 0x00
>> 	PCI_CLASS_MEMORY_RAM:  0x0500
>> Hence, instead of extracting it via an implicity type conversion from int
>> to u8 which throws a warning, explicitly mask the bits to extract the
> 
> What's the exact warning string? With which compiler version?

u-boot/common/spl/spl_dfu.c: In function ‘dfu_over_pcie’:
u-boot/include/pci_ids.h:48:41: warning: unsigned conversion from ‘int’ 
to ‘u8’ {aka ‘unsigned char’} changes value from ‘1280’ to ‘0’ [-Woverflow]
    48 | #define PCI_CLASS_MEMORY_RAM            0x0500
       |                                         ^~~~~~
u-boot/common/spl/spl_dfu.c:67:29: note: in expansion of macro 
‘PCI_CLASS_MEMORY_RAM’
    67 |         hdr.subclass_code = PCI_CLASS_MEMORY_RAM;
       |                             ^~~~~~~~~~~~~~~~~~~~

> 
> Is there an example defconfig that I can use to reproduce this?

CONFIG_SPL_PCI_DFU needs to be enabled for the warning to be displayed 
and will be seen in the context of PCIe Boot.

Regards,
Siddharth.

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

* Re: [PATCH] common: spl: spl_dfu.c: Fix warning associated with PCI subclass_code
  2026-03-05 10:38 [PATCH] common: spl: spl_dfu.c: Fix warning associated with PCI subclass_code Siddharth Vadapalli
  2026-03-05 13:08 ` Mattijs Korpershoek
@ 2026-03-06  5:04 ` Anshul Dalal
  2026-03-12  8:58   ` Mattijs Korpershoek
  2026-03-12  8:59 ` Mattijs Korpershoek
  2 siblings, 1 reply; 6+ messages in thread
From: Anshul Dalal @ 2026-03-06  5:04 UTC (permalink / raw)
  To: Siddharth Vadapalli, trini, lukma, mkorpershoek; +Cc: u-boot, srk

On Thu Mar 5, 2026 at 4:08 PM IST, Siddharth Vadapalli wrote:
> The subclass_code member of the pci_ep_header structure is a 1-byte
> field. The macro PCI_CLASS_MEMORY_RAM is a concetation of baseclass_code
> and subclass_code as follows:
> 	PCI_BASE_CLASS_MEMORY: 0x05
> 	Subclass Code for RAM: 0x00
> 	PCI_CLASS_MEMORY_RAM:  0x0500
> Hence, instead of extracting it via an implicity type conversion from int
> to u8 which throws a warning, explicitly mask the bits to extract the
> subclass_code.
>
> Fixes: cde77583cf0b ("spl: Add support for Device Firmware Upgrade (DFU) over PCIe")
> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>

I was able to reproduce the issue on am62x_evm_a53_defconfig with the
following diff:

	diff --git a/arch/arm/mach-k3/include/mach/am62_spl.h b/arch/arm/mach-k3/include/mach/am62_spl.h
	index 2c9139d2cc0..07ae5e99e49 100644
	--- a/arch/arm/mach-k3/include/mach/am62_spl.h
	+++ b/arch/arm/mach-k3/include/mach/am62_spl.h
	@@ -12,6 +12,7 @@
	 #define BOOT_DEVICE_OSPI		0x01
	 #define BOOT_DEVICE_QSPI		0x02
	 #define BOOT_DEVICE_SPI			0x03
	+#define BOOT_DEVICE_PCIE			0x03
	 #define BOOT_DEVICE_CPGMAC		0x04
	 #define BOOT_DEVICE_ETHERNET_RGMII	0x04
	 #define BOOT_DEVICE_ETHERNET_RMII	0x05
	diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
	index 281fa3fea15..a828ad164f1 100644
	--- a/configs/am62x_evm_a53_defconfig
	+++ b/configs/am62x_evm_a53_defconfig
	@@ -1,4 +1,9 @@
	 CONFIG_ARM=y
	+CONFIG_SPL_PCI_DFU=y
	+CONFIG_SPL_PCI_ENDPOINT=y
	+CONFIG_SPL_PCI_DFU_SPL_LOAD_FIT_ADDRESS=0x0
	+CONFIG_SPL_PCI_DFU_VENDOR_ID=0x0
	+CONFIG_SPL_PCI_DFU_DEVICE_ID=0x0
	 CONFIG_ARCH_K3=y
	 CONFIG_SYS_MALLOC_F_LEN=0x8000
	 CONFIG_TI_COMMON_CMD_OPTIONS=y

The patch looks good to me and fixes the build warning :)

Tested-by: Anshul Dalal <anshuld@ti.com>

> ---
>
> Hello,
>
> This patch is based on commit
> f473a453b0c kbuild: Drop phandle from diff between base DT and U-Boot augmented DT if DEVICE_TREE_DEBUG=1of the master branch of U-Boot.
>
> Regards,
> Siddharth.
>
>  common/spl/spl_dfu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c
> index b09f82790c9..7d21bb4d16a 100644
> --- a/common/spl/spl_dfu.c
> +++ b/common/spl/spl_dfu.c
> @@ -64,7 +64,7 @@ static int dfu_over_pcie(void)
>  	hdr.deviceid = CONFIG_SPL_PCI_DFU_DEVICE_ID;
>  	hdr.vendorid = CONFIG_SPL_PCI_DFU_VENDOR_ID;
>  	hdr.baseclass_code = PCI_BASE_CLASS_MEMORY;
> -	hdr.subclass_code = PCI_CLASS_MEMORY_RAM;
> +	hdr.subclass_code = PCI_CLASS_MEMORY_RAM & 0xff;
>  
>  	ret = pci_ep_write_header(dev, fn, &hdr);
>  	if (ret) {


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

* Re: [PATCH] common: spl: spl_dfu.c: Fix warning associated with PCI subclass_code
  2026-03-06  5:04 ` Anshul Dalal
@ 2026-03-12  8:58   ` Mattijs Korpershoek
  0 siblings, 0 replies; 6+ messages in thread
From: Mattijs Korpershoek @ 2026-03-12  8:58 UTC (permalink / raw)
  To: Anshul Dalal, Siddharth Vadapalli, trini, lukma, mkorpershoek; +Cc: u-boot, srk

Hi Anshul,

On Fri, Mar 06, 2026 at 10:34, Anshul Dalal <anshuld@ti.com> wrote:

> On Thu Mar 5, 2026 at 4:08 PM IST, Siddharth Vadapalli wrote:
>> The subclass_code member of the pci_ep_header structure is a 1-byte
>> field. The macro PCI_CLASS_MEMORY_RAM is a concetation of baseclass_code
>> and subclass_code as follows:
>> 	PCI_BASE_CLASS_MEMORY: 0x05
>> 	Subclass Code for RAM: 0x00
>> 	PCI_CLASS_MEMORY_RAM:  0x0500
>> Hence, instead of extracting it via an implicity type conversion from int
>> to u8 which throws a warning, explicitly mask the bits to extract the
>> subclass_code.
>>
>> Fixes: cde77583cf0b ("spl: Add support for Device Firmware Upgrade (DFU) over PCIe")
>> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
>
> I was able to reproduce the issue on am62x_evm_a53_defconfig with the
> following diff:
>
> 	diff --git a/arch/arm/mach-k3/include/mach/am62_spl.h b/arch/arm/mach-k3/include/mach/am62_spl.h
> 	index 2c9139d2cc0..07ae5e99e49 100644
> 	--- a/arch/arm/mach-k3/include/mach/am62_spl.h
> 	+++ b/arch/arm/mach-k3/include/mach/am62_spl.h
> 	@@ -12,6 +12,7 @@
> 	 #define BOOT_DEVICE_OSPI		0x01
> 	 #define BOOT_DEVICE_QSPI		0x02
> 	 #define BOOT_DEVICE_SPI			0x03
> 	+#define BOOT_DEVICE_PCIE			0x03
> 	 #define BOOT_DEVICE_CPGMAC		0x04
> 	 #define BOOT_DEVICE_ETHERNET_RGMII	0x04
> 	 #define BOOT_DEVICE_ETHERNET_RMII	0x05
> 	diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
> 	index 281fa3fea15..a828ad164f1 100644
> 	--- a/configs/am62x_evm_a53_defconfig
> 	+++ b/configs/am62x_evm_a53_defconfig
> 	@@ -1,4 +1,9 @@
> 	 CONFIG_ARM=y
> 	+CONFIG_SPL_PCI_DFU=y
> 	+CONFIG_SPL_PCI_ENDPOINT=y
> 	+CONFIG_SPL_PCI_DFU_SPL_LOAD_FIT_ADDRESS=0x0
> 	+CONFIG_SPL_PCI_DFU_VENDOR_ID=0x0
> 	+CONFIG_SPL_PCI_DFU_DEVICE_ID=0x0
> 	 CONFIG_ARCH_K3=y
> 	 CONFIG_SYS_MALLOC_F_LEN=0x8000
> 	 CONFIG_TI_COMMON_CMD_OPTIONS=y
>
> The patch looks good to me and fixes the build warning :)

Thanks for the diff. This was very helpful to me.
I could reproduce using the default toolchains that are provided by
buildman [1] which is ~/.buildman-toolchains/gcc-14.2.0-nolibc

[1] https://docs.u-boot.org/en/latest/build/buildman.html

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
Tested-by: Mattijs Korpershoek <mkorpershoek@kernel.org> # am62x_evm_a53

Will apply for master.

>
> Tested-by: Anshul Dalal <anshuld@ti.com>
>
>> ---
>>
>> Hello,
>>
>> This patch is based on commit
>> f473a453b0c kbuild: Drop phandle from diff between base DT and U-Boot augmented DT if DEVICE_TREE_DEBUG=1of the master branch of U-Boot.
>>
>> Regards,
>> Siddharth.
>>
>>  common/spl/spl_dfu.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c
>> index b09f82790c9..7d21bb4d16a 100644
>> --- a/common/spl/spl_dfu.c
>> +++ b/common/spl/spl_dfu.c
>> @@ -64,7 +64,7 @@ static int dfu_over_pcie(void)
>>  	hdr.deviceid = CONFIG_SPL_PCI_DFU_DEVICE_ID;
>>  	hdr.vendorid = CONFIG_SPL_PCI_DFU_VENDOR_ID;
>>  	hdr.baseclass_code = PCI_BASE_CLASS_MEMORY;
>> -	hdr.subclass_code = PCI_CLASS_MEMORY_RAM;
>> +	hdr.subclass_code = PCI_CLASS_MEMORY_RAM & 0xff;
>>  
>>  	ret = pci_ep_write_header(dev, fn, &hdr);
>>  	if (ret) {

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

* Re: [PATCH] common: spl: spl_dfu.c: Fix warning associated with PCI subclass_code
  2026-03-05 10:38 [PATCH] common: spl: spl_dfu.c: Fix warning associated with PCI subclass_code Siddharth Vadapalli
  2026-03-05 13:08 ` Mattijs Korpershoek
  2026-03-06  5:04 ` Anshul Dalal
@ 2026-03-12  8:59 ` Mattijs Korpershoek
  2 siblings, 0 replies; 6+ messages in thread
From: Mattijs Korpershoek @ 2026-03-12  8:59 UTC (permalink / raw)
  To: trini, lukma, Siddharth Vadapalli; +Cc: u-boot, srk

Hi,

On Thu, 05 Mar 2026 16:08:14 +0530, Siddharth Vadapalli wrote:
> The subclass_code member of the pci_ep_header structure is a 1-byte
> field. The macro PCI_CLASS_MEMORY_RAM is a concetation of baseclass_code
> and subclass_code as follows:
> 	PCI_BASE_CLASS_MEMORY: 0x05
> 	Subclass Code for RAM: 0x00
> 	PCI_CLASS_MEMORY_RAM:  0x0500
> Hence, instead of extracting it via an implicity type conversion from int
> to u8 which throws a warning, explicitly mask the bits to extract the
> subclass_code.
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu (u-boot-dfu)

[1/1] common: spl: spl_dfu.c: Fix warning associated with PCI subclass_code
      https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/433a17aca15481cde866a9bc636b61584360fbb3

--
Mattijs

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

end of thread, other threads:[~2026-03-12  9:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05 10:38 [PATCH] common: spl: spl_dfu.c: Fix warning associated with PCI subclass_code Siddharth Vadapalli
2026-03-05 13:08 ` Mattijs Korpershoek
2026-03-05 14:54   ` Siddharth Vadapalli
2026-03-06  5:04 ` Anshul Dalal
2026-03-12  8:58   ` Mattijs Korpershoek
2026-03-12  8:59 ` Mattijs Korpershoek

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