Skip to contentSkip to conversation

PCI: brcmstb: variable is missing proper initialization

PATCH Applied Jim Quinlan 5 participants 7 messages Nov 2, 2020 – Nov 20, 2020

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

PATCH 1/1 PCI: brcmstb: variable is missing proper initialization

The variable 'tmp' is used multiple times in the brcm_pcie_setup() function. One such usage did not initialize 'tmp' to the current value of the target register. By luck the mistake does not currently affect behavior; regardless 'tmp' is now initialized properly.

Fixes c0452137034b ("PCI: brcmstb: Add Broadcom STB PCIe host controller driver")
---
 drivers/pci/controller/pcie-brcmstb.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/controller/pcie-brcmstb.c +1 -0
index bea86899bd5d..9c3d2982248d 100644
@@ -893,6 +893,7 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
 		burst = 0x2; /* 512 bytes */
 
 	/* Set SCB_MAX_BURST_SIZE, CFG_READ_UR_MODE, SCB_ACCESS_EN */
+	tmp = readl(base + PCIE_MISC_MISC_CTRL);
 	u32p_replace_bits(&tmp, 1, PCIE_MISC_MISC_CTRL_SCB_ACCESS_EN_MASK);
 	u32p_replace_bits(&tmp, 1, PCIE_MISC_MISC_CTRL_CFG_READ_UR_MODE_MASK);
 	u32p_replace_bits(&tmp, burst, PCIE_MISC_MISC_CTRL_MAX_BURST_SIZE_MASK);
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Jim Quinlan

The variable 'tmp' is used multiple times in the brcm_pcie_setup() function. One such usage did not initialize 'tmp' to the current value of the target register. By luck the mistake does not currently affect behavior; regardless 'tmp' is now initialized properly.

Fixes c0452137034b ("PCI: brcmstb: Add Broadcom STB PCIe host controller driver")
Signature · 1 line
Florian
#2 lore raw
Quoted 10 lines · Florian Fainelli
Quoted 8 lines · Jim Quinlan

The variable 'tmp' is used multiple times in the brcm_pcie_setup() function. One such usage did not initialize 'tmp' to the current value of the target register. By luck the mistake does not currently affect behavior; regardless 'tmp' is now initialized properly.

Fixes c0452137034b ("PCI: brcmstb: Add Broadcom STB PCIe host controller driver")
#3 lore raw
In reply to Jim Quinlan
Quoted 4 lines · Jim Quinlan

The variable 'tmp' is used multiple times in the brcm_pcie_setup() function. One such usage did not initialize 'tmp' to the current value of the target register. By luck the mistake does not currently affect behavior; regardless 'tmp' is now initialized properly.

This is so trivial that there's probably no reason to post this again, but if you post a v2 for some reason, please update the subject to match the convention ("PCI: brcmstb: Verb ..."), e.g.,

PCI: brcmstb: Initialize "tmp" before use

The commit log does not say what the patch does, leaving it to the reader to infer it.

Lorenzo will likely fix this up when he applies it.

Incidental curiosity: where should I look to see what u32p_replace_bits() does? "git grep u32p_replace_bits" shows several calls, but no definitions.

Quoted 22 lines
Fixes c0452137034b ("PCI: brcmstb: Add Broadcom STB PCIe host controller driver")
---
 drivers/pci/controller/pcie-brcmstb.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/controller/pcie-brcmstb.c +1 -0
index bea86899bd5d..9c3d2982248d 100644
@@ -893,6 +893,7 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
 		burst = 0x2; /* 512 bytes */
 
 	/* Set SCB_MAX_BURST_SIZE, CFG_READ_UR_MODE, SCB_ACCESS_EN */
+	tmp = readl(base + PCIE_MISC_MISC_CTRL);
 	u32p_replace_bits(&tmp, 1, PCIE_MISC_MISC_CTRL_SCB_ACCESS_EN_MASK);
 	u32p_replace_bits(&tmp, 1, PCIE_MISC_MISC_CTRL_CFG_READ_UR_MODE_MASK);
 	u32p_replace_bits(&tmp, burst, PCIE_MISC_MISC_CTRL_MAX_BURST_SIZE_MASK);
Signature · 1 line
2.17.1
#4 lore raw
Quoted 12 lines · Bjorn Helgaas
Quoted 4 lines · Jim Quinlan

The variable 'tmp' is used multiple times in the brcm_pcie_setup() function. One such usage did not initialize 'tmp' to the current value of the target register. By luck the mistake does not currently affect behavior; regardless 'tmp' is now initialized properly.

This is so trivial that there's probably no reason to post this again, but if you post a v2 for some reason, please update the subject to match the convention ("PCI: brcmstb: Verb ..."), e.g.,

PCI: brcmstb: Initialize "tmp" before use

Quoted 8 lines

The commit log does not say what the patch does, leaving it to the reader to infer it.

Lorenzo will likely fix this up when he applies it.

Incidental curiosity: where should I look to see what u32p_replace_bits() does? "git grep u32p_replace_bits" shows several calls, but no definitions.

It's a bunch if defines in 'include/linux/bitfield.h'

Regards,
Nicolas

#5 lore raw
In reply to Bjorn Helgaas
Quoted 7 lines · Bjorn Helgaas
Quoted 4 lines · Jim Quinlan

The variable 'tmp' is used multiple times in the brcm_pcie_setup() function. One such usage did not initialize 'tmp' to the current value of the target register. By luck the mistake does not currently affect behavior; regardless 'tmp' is now initialized properly.

Quoted 8 lines

This is so trivial that there's probably no reason to post this again, but if you post a v2 for some reason, please update the subject to match the convention ("PCI: brcmstb: Verb ..."), e.g.,

PCI: brcmstb: Initialize "tmp" before use

The commit log does not say what the patch does, leaving it to the reader to infer it.

Got it.
Thanks,
Jim Quinlan
Broadcom STB

Quoted 34 lines

Lorenzo will likely fix this up when he applies it.

Incidental curiosity: where should I look to see what u32p_replace_bits() does? "git grep u32p_replace_bits" shows several calls, but no definitions.

Quoted 22 lines
Fixes c0452137034b ("PCI: brcmstb: Add Broadcom STB PCIe host controller driver")
---
 drivers/pci/controller/pcie-brcmstb.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/controller/pcie-brcmstb.c +1 -1
index bea86899bd5d..9c3d2982248d 100644
@@ -893,6 +893,7 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
              burst = 0x2; /* 512 bytes */
 
      /* Set SCB_MAX_BURST_SIZE, CFG_READ_UR_MODE, SCB_ACCESS_EN */
+     tmp = readl(base + PCIE_MISC_MISC_CTRL);
      u32p_replace_bits(&tmp, 1, PCIE_MISC_MISC_CTRL_SCB_ACCESS_EN_MASK);
      u32p_replace_bits(&tmp, 1, PCIE_MISC_MISC_CTRL_CFG_READ_UR_MODE_MASK);
      u32p_replace_bits(&tmp, burst, PCIE_MISC_MISC_CTRL_MAX_BURST_SIZE_MASK);
--

2.17.1

#6 lore raw
In reply to Jim Quinlan
Quoted 4 lines · Jim Quinlan

The variable 'tmp' is used multiple times in the brcm_pcie_setup() function. One such usage did not initialize 'tmp' to the current value of the target register. By luck the mistake does not currently affect behavior; regardless 'tmp' is now initialized properly.

Applied to pci/brcmstb, thanks!

[1/1] PCI: brcmstb: Initialize "tmp" before use
https://git.kernel.org/lpieralisi/pci/c/ddaff0af65

Thanks,
Lorenzo