Subject: kern/21440: wrong logic in pci_vpd_write
To: None <gnats-bugs@gnats.netbsd.org>
From: None <freza@psi.cz>
List: netbsd-bugs
Date: 05/03/2003 18:43:24
>Number:         21440
>Category:       kern
>Synopsis:       wrong logic in pci_vpd_write
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat May 03 16:44:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Jachym Holecek
>Release:        NetBSD-current as of Tue Apr 29 23:24:52 CEST 2003
>Organization:
>Environment:
System: NetBSD gloom 1.6 NetBSD 1.6 (GLOOM) #4: Mon Jan 27 14:40:31 CET 2003 jh@gloom:/usr/src/sys/arch/i386/compile/GLOOM i386
Architecture: i386
Machine: i386
>Description:
The pci_vpd_write(), from a patch I sent earlier, has wrong logic -- opflag
should be set to 1 and polled until it goes to 0 on VPD write. Sorry for
troubles.
>How-To-Repeat:
Try to write PLX9054 serial EEPROM (or any VPD data in general). The routine
allways succeeds, but nothings gets actually written as it does not wait
for operation to complete.
>Fix:

--- pci.c.orig	Sat May  3 18:30:19 2003
+++ pci.c.new	Sat May  3 18:31:31 2003
@@ -592,7 +592,7 @@
 		pci_conf_write(pc, tag, PCI_VPD_DATAREG(ofs), data[i]);
 
 		reg &= 0x0000ffff;
-		reg &= ~PCI_VPD_OPFLAG;
+		reg |= PCI_VPD_OPFLAG;
 		reg |= PCI_VPD_ADDRESS(offset);
 		pci_conf_write(pc, tag, ofs, reg);
 
@@ -606,7 +606,7 @@
 				return (1);
 			delay(1);
 			reg = pci_conf_read(pc, tag, ofs);
-		} while ((reg & PCI_VPD_OPFLAG) == 0);
+		} while (reg & PCI_VPD_OPFLAG);
 	}
 
 	return (0);
>Release-Note:
>Audit-Trail:
>Unformatted: