Subject: kern/32220: I need this to get my AMD768 random no gen. working
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <murray@river-styx.org>
List: netbsd-bugs
Date: 12/03/2005 03:56:00
>Number:         32220
>Category:       kern
>Synopsis:       I need this to get my AMD768 random no gen. working
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 03 03:56:00 +0000 2005
>Originator:     Murray Armfield
>Release:        NetBSD-current
>Organization:
N/A
>Environment:
NetBSD ra.river-styx.org 3.99.13 NetBSD 3.99.13 (RA.MPACPI) #11: Sat Dec  3 14:31:53 EST 2005  admin@ra.river-styx.org:/usr/obj/sys/arch/i386/compile/RA.MPACPI i386
>Description:
The random number generator as found in the amdpm device is not by default enabled for me on my motherboard (ASUS A7M266-D motherboard utilizing AMD768 chipset) and hence does not come up. I would like it to be used for my randomness pool. Description and fix is below. Could someone please review and commit if acceptable. Thank you.
>How-To-Repeat:
Run a current kernel on an ASUS A7M266-D motherboard with amdpm added to config files. amdpm shows up fine but finds no RNG. I did actually write this driver myself until I got to sending it to you guys and found the amdpm driver already existed but is not mentioned in any kernel config files. Oh well, at least its there now. It was fun anyway.
>Fix:
Asset the RNG bit in general configuration register 1 of the system management registers as per AMD768 chipset documentation. Patch provided.

--- amdpm.c.old 2005-12-03 14:35:58.000000000 +1100
+++ amdpm.c
@@ -127,6 +127,8 @@ amdpm_attach(struct device *parent, stru
        }

        reg = pci_conf_read(pa->pa_pc, pa->pa_tag, AMDPM_CONFREG);
+       pci_conf_write(pa->pa_pc, pa->pa_tag, AMDPM_CONFREG, reg | AMDPM_RNGEN);+       reg = pci_conf_read(pa->pa_pc, pa->pa_tag, AMDPM_CONFREG);
        if (reg & AMDPM_RNGEN) {
                /* Check to see if we can read data from the RNG. */
                (void) bus_space_read_4(sc->sc_iot, sc->sc_ioh,