From 60aa19b6a784ffcbe7ae3faf83b0c65addb6d95e Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Fri, 28 Oct 2005 07:11:14 +0000 Subject: malloc(M_WAITOK) is bad in init code, M_DEVBUF is nicer than M_TEMP, and if the cpu gets stuck, don't spin too long. --- sys/arch/i386/i386/powernow-k7.c | 6 ++++-- sys/arch/i386/i386/powernow-k8.c | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sys/arch/i386/i386/powernow-k7.c b/sys/arch/i386/i386/powernow-k7.c index 15f4d52b91c..4833f174740 100644 --- a/sys/arch/i386/i386/powernow-k7.c +++ b/sys/arch/i386/i386/powernow-k7.c @@ -1,4 +1,4 @@ -/* $OpenBSD: powernow-k7.c,v 1.5 2005/10/28 07:03:41 tedu Exp $ */ +/* $OpenBSD: powernow-k7.c,v 1.6 2005/10/28 07:11:13 tedu Exp $ */ /* * Copyright (c) 2004 Martin Végiard. * All rights reserved. @@ -350,7 +350,9 @@ k7_powernow_init(void) char *techname = NULL; ci = curcpu(); - cstate = malloc(sizeof(struct k7pnow_cpu_state), M_TEMP, M_WAITOK); + cstate = malloc(sizeof(struct k7pnow_cpu_state), M_DEVBUF, M_NOWAIT); + if (!cstate) + return; cpuid(0x80000001, regs); if ((regs[0] & 0xfff) == 0x760) diff --git a/sys/arch/i386/i386/powernow-k8.c b/sys/arch/i386/i386/powernow-k8.c index 8724f5d593d..cfc2899d1cd 100644 --- a/sys/arch/i386/i386/powernow-k8.c +++ b/sys/arch/i386/i386/powernow-k8.c @@ -1,4 +1,4 @@ -/* $OpenBSD: powernow-k8.c,v 1.1 2005/10/28 07:03:41 tedu Exp $ */ +/* $OpenBSD: powernow-k8.c,v 1.2 2005/10/28 07:11:13 tedu Exp $ */ /* * Copyright (c) 2004 Martin Végiard. * All rights reserved. @@ -189,7 +189,7 @@ int k8pnow_read_pending_wait(uint64_t * status) { unsigned int i = 0; while(PN8_STA_PENDING(*status)) { i++; - if (i > 0x1000000) { + if (i > 1000) { printf("k8pnow_read_pending_wait: change pending stuck" ".\n"); return 1; @@ -400,7 +400,9 @@ k8_powernow_init(void) char * techname = NULL; ci = curcpu(); - cstate = malloc(sizeof(struct k8pnow_cpu_state), M_TEMP, M_WAITOK); + cstate = malloc(sizeof(struct k8pnow_cpu_state), M_DEVBUF, M_NOWAIT); + if (!cstate) + return; rate = pentium_mhz; status = rdmsr(MSR_AMDK7_FIDVID_STATUS); -- cgit v1.2.3