Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Switch to kmem from malloc.
details: https://anonhg.NetBSD.org/src/rev/be8d0baecaae
branches: trunk
changeset: 759498:be8d0baecaae
user: matt <matt%NetBSD.org@localhost>
date: Sat Dec 11 18:21:14 2010 +0000
description:
Switch to kmem from malloc.
Don't actually set the PREFETCH64 base/limit registers unless they really are
in use.
diffstat:
sys/dev/pci/pciconf.c | 32 +++++++++++++++++---------------
1 files changed, 17 insertions(+), 15 deletions(-)
diffs (103 lines):
diff -r 5e4c8a82649b -r be8d0baecaae sys/dev/pci/pciconf.c
--- a/sys/dev/pci/pciconf.c Sat Dec 11 18:18:09 2010 +0000
+++ b/sys/dev/pci/pciconf.c Sat Dec 11 18:21:14 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pciconf.c,v 1.31 2009/08/02 11:25:50 gavan Exp $ */
+/* $NetBSD: pciconf.c,v 1.32 2010/12/11 18:21:14 matt Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pciconf.c,v 1.31 2009/08/02 11:25:50 gavan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pciconf.c,v 1.32 2010/12/11 18:21:14 matt Exp $");
#include "opt_pci.h"
@@ -74,6 +74,7 @@
#include <sys/queue.h>
#include <sys/systm.h>
#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pciconf.h>
@@ -320,7 +321,7 @@
pcireg_t io, pmem;
pciconf_win_t *pi, *pm;
- pb = malloc (sizeof (pciconf_bus_t), M_DEVBUF, M_NOWAIT);
+ pb = kmem_zalloc(sizeof (pciconf_bus_t), KM_NOSLEEP);
if (!pb)
panic("Unable to allocate memory for PCI configuration.");
@@ -419,7 +420,7 @@
return pb;
err:
- free(pb, M_DEVBUF);
+ kmem_free(pb, sizeof(*pb));
return NULL;
}
@@ -441,8 +442,10 @@
class = pci_conf_read(pb->pc, tag, PCI_CLASS_REG);
cmd = pci_conf_read(pb->pc, tag, PCI_COMMAND_STATUS_REG);
+ bhlc = pci_conf_read(pb->pc, tag, PCI_BHLC_REG);
- if (PCI_CLASS(class) != PCI_CLASS_BRIDGE) {
+ if (PCI_CLASS(class) != PCI_CLASS_BRIDGE
+ && PCI_HDRTYPE_TYPE(bhlc) != PCI_HDRTYPE_PPB) {
cmd &= ~(PCI_COMMAND_MASTER_ENABLE |
PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE);
pci_conf_write(pb->pc, tag, PCI_COMMAND_STATUS_REG, cmd);
@@ -457,7 +460,6 @@
if ((cmd & PCI_STATUS_66MHZ_SUPPORT) == 0)
pb->freq_66 = 0;
- bhlc = pci_conf_read(pb->pc, tag, PCI_BHLC_REG);
switch (PCI_HDRTYPE_TYPE(bhlc)) {
case PCI_HDRTYPE_DEVICE:
reg_start = PCI_MAPREG_START;
@@ -919,14 +921,14 @@
/*
* XXX -- 64-bit systems need a lot more than just this...
*/
- if (sizeof(u_long) > 4) {
- mem_base = (int64_t) mem_base >> 32;
- mem_limit = (int64_t) mem_limit >> 32;
+ if (PCI_BRIDGE_PREFETCHMEM_64BITS(mem)) {
+ mem_base = (uint64_t) mem_base >> 32;
+ mem_limit = (uint64_t) mem_limit >> 32;
+ pci_conf_write(pb->pc, pd->tag, PCI_BRIDGE_PREFETCHBASE32_REG,
+ mem_base & 0xffffffff);
+ pci_conf_write(pb->pc, pd->tag, PCI_BRIDGE_PREFETCHLIMIT32_REG,
+ mem_limit & 0xffffffff);
}
- pci_conf_write(pb->pc, pd->tag, PCI_BRIDGE_PREFETCHBASE32_REG,
- mem_base & 0xffffffff);
- pci_conf_write(pb->pc, pd->tag, PCI_BRIDGE_PREFETCHLIMIT32_REG,
- mem_limit & 0xffffffff);
rv = configure_bus(pb);
@@ -1100,7 +1102,7 @@
pciconf_bus_t *pb;
int rv;
- pb = malloc (sizeof (pciconf_bus_t), M_DEVBUF, M_NOWAIT);
+ pb = kmem_zalloc(sizeof (pciconf_bus_t), KM_NOSLEEP);
pb->busno = firstbus;
pb->next_busno = pb->busno + 1;
pb->last_busno = 255;
@@ -1128,6 +1130,6 @@
/*
* All done!
*/
- free(pb, M_DEVBUF);
+ kmem_free(pb, sizeof(*pb));
return rv;
}
Home |
Main Index |
Thread Index |
Old Index