Skip to contentSkip to conversation

PCI: rockchip-ep: Remove wrong mask on subsys_vendor_id

PATCH Applied Rick Wertenbroek 4 participants 6 messages Apr 3, 2024 – May 17, 2024

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: rockchip-ep: Remove wrong mask on subsys_vendor_id

Remove wrong mask on subsys_vendor_id. Both the Vendor ID and Subsystem Vendor ID are u16 variables and are written to a u32 register of the controller. The Subsystem Vendor ID was always 0 because the u16 value was masked incorrectly with GENMASK(31,16) resulting in all lower 16 bits being set to 0 prior to the shift.

Remove both masks as they are unnecessary and set the register correctly i.e., the lower 16-bits are the Vendor ID and the upper 16-bits are the Subsystem Vendor ID.

This is documented in the RK3399 TRM section 17.6.7.1.17

Fixes cf590b078391 ("PCI: rockchip: Add EP driver for Rockchip PCIe controller")
---
 drivers/pci/controller/pcie-rockchip-ep.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/pci/controller/pcie-rockchip-ep.c +3 -4
index c9046e97a1d2..37d4bcb8bd5b 100644
@@ -98,10 +98,9 @@ static int rockchip_pcie_ep_write_header(struct pci_epc *epc, u8 fn, u8 vfn,
 
 	/* All functions share the same vendor ID with function 0 */
 	if (fn == 0) {
-		u32 vid_regs = (hdr->vendorid & GENMASK(15, 0)) |
-			       (hdr->subsys_vendor_id & GENMASK(31, 16)) << 16;
-
-		rockchip_pcie_write(rockchip, vid_regs,
+		rockchip_pcie_write(rockchip,
+				    hdr->vendorid |
+				    hdr->subsys_vendor_id << 16,
 				    PCIE_CORE_CONFIG_VENDOR);
 	}
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 39 lines · Rick Wertenbroek

Remove wrong mask on subsys_vendor_id. Both the Vendor ID and Subsystem Vendor ID are u16 variables and are written to a u32 register of the controller. The Subsystem Vendor ID was always 0 because the u16 value was masked incorrectly with GENMASK(31,16) resulting in all lower 16 bits being set to 0 prior to the shift.

Remove both masks as they are unnecessary and set the register correctly i.e., the lower 16-bits are the Vendor ID and the upper 16-bits are the Subsystem Vendor ID.

This is documented in the RK3399 TRM section 17.6.7.1.17

Fixes cf590b078391 ("PCI: rockchip: Add EP driver for Rockchip PCIe controller")
---
 drivers/pci/controller/pcie-rockchip-ep.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/pci/controller/pcie-rockchip-ep.c +3 -5
index c9046e97a1d2..37d4bcb8bd5b 100644
@@ -98,10 +98,9 @@ static int rockchip_pcie_ep_write_header(struct pci_epc *epc, u8 fn, u8 vfn,
 
        /* All functions share the same vendor ID with function 0 */
        if (fn == 0) {
-               u32 vid_regs = (hdr->vendorid & GENMASK(15, 0)) |
-                              (hdr->subsys_vendor_id & GENMASK(31, 16)) << 16;
-
-               rockchip_pcie_write(rockchip, vid_regs,
+               rockchip_pcie_write(rockchip,
+                                   hdr->vendorid |
+                                   hdr->subsys_vendor_id << 16,
                                    PCIE_CORE_CONFIG_VENDOR);
        }
 
--
Quoted 2 lines

2.25.1

This patch was tested on linux next-20240403.

The PCI endpoint test function was used and an arbitrary value e.g., 0x1234
was written to /sys/kernel/config/pci_ep/functions/pci_epf_test/pci_epf_test.0/subsys_vendor_id

This value was then verified with lspci -x / lspci -v on a host computer acting as PCI root complex.

Cheers,
Rick

Reviewed-by on v1 1/1
#2 lore raw
In reply to Rick Wertenbroek
Quoted 10 lines · Rick Wertenbroek

Remove wrong mask on subsys_vendor_id. Both the Vendor ID and Subsystem Vendor ID are u16 variables and are written to a u32 register of the controller. The Subsystem Vendor ID was always 0 because the u16 value was masked incorrectly with GENMASK(31,16) resulting in all lower 16 bits being set to 0 prior to the shift.

Remove both masks as they are unnecessary and set the register correctly i.e., the lower 16-bits are the Vendor ID and the upper 16-bits are the Subsystem Vendor ID.

Quoted 5 lines

This is documented in the RK3399 TRM section 17.6.7.1.17

Fixes cf590b078391 ("PCI: rockchip: Add EP driver for Rockchip PCIe controller")
Quoted 22 lines
---
 drivers/pci/controller/pcie-rockchip-ep.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/pci/controller/pcie-rockchip-ep.c +3 -4
index c9046e97a1d2..37d4bcb8bd5b 100644
@@ -98,10 +98,9 @@ static int rockchip_pcie_ep_write_header(struct pci_epc *epc, u8 fn, u8 vfn,
 
 	/* All functions share the same vendor ID with function 0 */
 	if (fn == 0) {
-		u32 vid_regs = (hdr->vendorid & GENMASK(15, 0)) |
-			       (hdr->subsys_vendor_id & GENMASK(31, 16)) << 16;
-
-		rockchip_pcie_write(rockchip, vid_regs,
+		rockchip_pcie_write(rockchip,
+				    hdr->vendorid |
+				    hdr->subsys_vendor_id << 16,
 				    PCIE_CORE_CONFIG_VENDOR);
 	}
 
Signature · 2 lines
Damien Le Moal
Western Digital Research
#3 lore raw
In reply to Rick Wertenbroek
Quoted 10 lines · Rick Wertenbroek

Remove wrong mask on subsys_vendor_id. Both the Vendor ID and Subsystem Vendor ID are u16 variables and are written to a u32 register of the controller. The Subsystem Vendor ID was always 0 because the u16 value was masked incorrectly with GENMASK(31,16) resulting in all lower 16 bits being set to 0 prior to the shift.

Remove both masks as they are unnecessary and set the register correctly i.e., the lower 16-bits are the Vendor ID and the upper 16-bits are the Subsystem Vendor ID.

Quoted 5 lines

This is documented in the RK3399 TRM section 17.6.7.1.17

Fixes cf590b078391 ("PCI: rockchip: Add EP driver for Rockchip PCIe controller")

Applied to pci/controller/rockchip by Krzysztof, but his outgoing mail queue got stuck. I added Damien's Reviewed-by. Trying to squeeze into v6.9.

Quoted 25 lines
---
 drivers/pci/controller/pcie-rockchip-ep.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/pci/controller/pcie-rockchip-ep.c +3 -4
index c9046e97a1d2..37d4bcb8bd5b 100644
@@ -98,10 +98,9 @@ static int rockchip_pcie_ep_write_header(struct pci_epc *epc, u8 fn, u8 vfn,
 
 	/* All functions share the same vendor ID with function 0 */
 	if (fn == 0) {
-		u32 vid_regs = (hdr->vendorid & GENMASK(15, 0)) |
-			       (hdr->subsys_vendor_id & GENMASK(31, 16)) << 16;
-
-		rockchip_pcie_write(rockchip, vid_regs,
+		rockchip_pcie_write(rockchip,
+				    hdr->vendorid |
+				    hdr->subsys_vendor_id << 16,
 				    PCIE_CORE_CONFIG_VENDOR);
 	}
 
Signature · 1 line
2.25.1
#4 lore raw
Quoted 13 lines · Bjorn Helgaas
Quoted 12 lines · Rick Wertenbroek

Remove wrong mask on subsys_vendor_id. Both the Vendor ID and Subsystem Vendor ID are u16 variables and are written to a u32 register of the controller. The Subsystem Vendor ID was always 0 because the u16 value was masked incorrectly with GENMASK(31,16) resulting in all lower 16 bits being set to 0 prior to the shift.

Remove both masks as they are unnecessary and set the register correctly i.e., the lower 16-bits are the Vendor ID and the upper 16-bits are the Subsystem Vendor ID.

This is documented in the RK3399 TRM section 17.6.7.1.17

Quoted 7 lines
Quoted 3 lines
Fixes cf590b078391 ("PCI: rockchip: Add EP driver for Rockchip PCIe controller")

Applied to pci/controller/rockchip by Krzysztof, but his outgoing mail queue got stuck. I added Damien's Reviewed-by. Trying to squeeze into v6.9.

Sorry, I meant v6.10. v6.9 is already done.

Quoted 25 lines
Quoted 25 lines
---
 drivers/pci/controller/pcie-rockchip-ep.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/pci/controller/pcie-rockchip-ep.c +3 -4
index c9046e97a1d2..37d4bcb8bd5b 100644
@@ -98,10 +98,9 @@ static int rockchip_pcie_ep_write_header(struct pci_epc *epc, u8 fn, u8 vfn,
 
 	/* All functions share the same vendor ID with function 0 */
 	if (fn == 0) {
-		u32 vid_regs = (hdr->vendorid & GENMASK(15, 0)) |
-			       (hdr->subsys_vendor_id & GENMASK(31, 16)) << 16;
-
-		rockchip_pcie_write(rockchip, vid_regs,
+		rockchip_pcie_write(rockchip,
+				    hdr->vendorid |
+				    hdr->subsys_vendor_id << 16,
 				    PCIE_CORE_CONFIG_VENDOR);
 	}
 
Signature · 1 line
2.25.1
#5 lore raw
In reply to Rick Wertenbroek
Quoted 11 lines

Remove wrong mask on subsys_vendor_id. Both the Vendor ID and Subsystem Vendor ID are u16 variables and are written to a u32 register of the controller. The Subsystem Vendor ID was always 0 because the u16 value was masked incorrectly with GENMASK(31,16) resulting in all lower 16 bits being set to 0 prior to the shift.

Remove both masks as they are unnecessary and set the register correctly i.e., the lower 16-bits are the Vendor ID and the upper 16-bits are the Subsystem Vendor ID.

This is documented in the RK3399 TRM section 17.6.7.1.17

Applied to controller/rockchip, thank you!

[1/1] PCI: rockchip-ep: Remove wrong mask on subsys_vendor_id

      https://git.kernel.org/pci/pci/c/2f014bf195ae

	Krzysztof