The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 1/1] MIPS: Routerboard 532: Fix vendor retry check code
@ 2024-05-08 12:07 Ilpo Järvinen
  2024-06-11 14:14 ` Thomas Bogendoerfer
  0 siblings, 1 reply; 2+ messages in thread
From: Ilpo Järvinen @ 2024-05-08 12:07 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Florian Fainelli, Ralf Baechle, Phil Sutter,
	linux-mips, linux-kernel
  Cc: Ilpo Järvinen

read_config_dword() contains strange condition checking ret for a
number of values. The ret variable, however, is always zero because
config_access() never returns anything else. Thus, the retry is always
taken until number of tries is exceeded.

The code looks like it wants to check *val instead of ret to see if the
read gave an error response.

Fixes: 73b4390fb234 ("[MIPS] Routerboard 532: Support for base system")
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
--

IMPORTANT NOTE TO MAINTAINER:

This change has potential of breaking something and I don't have HW to
test this with. I only came across it while going through all PCIBIOS_*
call chains. Clearly the current code non-sensical so something is not
right but whether this is the right way to solve the problem, I'm not
entirely sure because it will make small change into the behavior.
---
 arch/mips/pci/ops-rc32434.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/pci/ops-rc32434.c b/arch/mips/pci/ops-rc32434.c
index 874ed6df9768..34b9323bdabb 100644
--- a/arch/mips/pci/ops-rc32434.c
+++ b/arch/mips/pci/ops-rc32434.c
@@ -112,8 +112,8 @@ static int read_config_dword(struct pci_bus *bus, unsigned int devfn,
 	 * gives them time to settle
 	 */
 	if (where == PCI_VENDOR_ID) {
-		if (ret == 0xffffffff || ret == 0x00000000 ||
-		    ret == 0x0000ffff || ret == 0xffff0000) {
+		if (*val == 0xffffffff || *val == 0x00000000 ||
+		    *val == 0x0000ffff || *val == 0xffff0000) {
 			if (delay > 4)
 				return 0;
 			delay *= 2;
-- 
2.39.2


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

* Re: [PATCH 1/1] MIPS: Routerboard 532: Fix vendor retry check code
  2024-05-08 12:07 [PATCH 1/1] MIPS: Routerboard 532: Fix vendor retry check code Ilpo Järvinen
@ 2024-06-11 14:14 ` Thomas Bogendoerfer
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Bogendoerfer @ 2024-06-11 14:14 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Florian Fainelli, Ralf Baechle, Phil Sutter, linux-mips,
	linux-kernel

On Wed, May 08, 2024 at 03:07:00PM +0300, Ilpo Järvinen wrote:
> read_config_dword() contains strange condition checking ret for a
> number of values. The ret variable, however, is always zero because
> config_access() never returns anything else. Thus, the retry is always
> taken until number of tries is exceeded.
> 
> The code looks like it wants to check *val instead of ret to see if the
> read gave an error response.
> 
> Fixes: 73b4390fb234 ("[MIPS] Routerboard 532: Support for base system")
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> --
> 
> IMPORTANT NOTE TO MAINTAINER:
> 
> This change has potential of breaking something and I don't have HW to
> test this with. I only came across it while going through all PCIBIOS_*
> call chains. Clearly the current code non-sensical so something is not
> right but whether this is the right way to solve the problem, I'm not
> entirely sure because it will make small change into the behavior.

I have rework of this code sitting in one of my development branches
and I didn't spot the bug in the old code, but the new code does
what your fix is doing. So I'm pretty sure this change is correct.

> ---
>  arch/mips/pci/ops-rc32434.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

applied to mips-fixes.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

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

end of thread, other threads:[~2024-06-11 14:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-08 12:07 [PATCH 1/1] MIPS: Routerboard 532: Fix vendor retry check code Ilpo Järvinen
2024-06-11 14:14 ` Thomas Bogendoerfer

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