From owner-freebsd-bugs Thu Jan 4 10:10:12 2001 From owner-freebsd-bugs@FreeBSD.ORG Thu Jan 4 10:10:02 2001 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 80D4237B402 for ; Thu, 4 Jan 2001 10:10:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f04IA1T72691; Thu, 4 Jan 2001 10:10:01 -0800 (PST) (envelope-from gnats) Resent-Date: Thu, 4 Jan 2001 10:10:01 -0800 (PST) Resent-Message-Id: <200101041810.f04IA1T72691@freefall.freebsd.org> Resent-From: gnats-admin@FreeBSD.org (GNATS Management) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: gnats-admin@FreeBSD.org, nms@FreeBSD.ORG Received: from otdel-1.org (Draculina.Otdel-1.ORG [195.230.65.30]) by hub.freebsd.org (Postfix) with ESMTP id C293937B400 for ; Thu, 4 Jan 2001 10:09:17 -0800 (PST) Received: by otdel-1.org (CommuniGate Pro PIPE 3.4b7) with PIPE id 670465; Thu, 04 Jan 2001 21:09:16 +0300 Message-Id: Date: Thu, 04 Jan 2001 21:09:16 +0300 From: nms@otdel-1.org Reply-To: nms@FreeBSD.ORG To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: kern/24073: oltr driver set work memory at wrong phase Resent-Sender: gnats@FreeBSD.org Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 24073 >Category: kern >Synopsis: oltr driver set work memory at wrong phase >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Jan 04 10:10:01 PST 2001 >Closed-Date: >Last-Modified: >Originator: Nikolai Saoukh >Release: FreeBSD 4.2-STABLE i386 >Organization: >Environment: >Description: oltr driver set work memory at wrong intialization phase. Actually this bug affects OC-3540 & OC-3129 cards only. >How-To-Repeat: >Fix: --- src/sys/contrib/dev/oltr/if_oltr.c.orig Tue Oct 10 04:47:12 2000 +++ src/sys/contrib/dev/oltr/if_oltr.c Mon Oct 23 20:49:53 2000 @@ -289,7 +289,7 @@ oltr_pci_attach(device_t dev) { int i, s, rc = 0, rid, - scratch_size, work_size; + scratch_size; int media = IFM_TOKEN|IFM_TOK_UTP16; u_long command; char PCIConfigHeader[64]; @@ -339,26 +339,6 @@ goto config_failed; } - switch(sc->config.type) { - case TRLLD_ADAPTER_PCI4: /* OC-3139 */ - work_size = 32 * 1024; - break; - case TRLLD_ADAPTER_PCI7: /* OC-3540 */ - work_size = 256; - break; - default: - work_size = 0; - } - - if (work_size) { - if ((sc->work_memory = malloc(work_size, M_DEVBUF, M_NOWAIT)) == NULL) { - device_printf(dev, "failed to allocate work memory.\n"); - } else { - TRlldAddMemory(sc->TRlldAdapter, sc->work_memory, - vtophys(sc->work_memory), work_size); - } - } - /* * Allocate RX/TX Pools */ @@ -545,7 +525,7 @@ static void oltr_pci_attach(pcici_t config_id, int unit) { - int i, s, rc = 0, scratch_size, work_size; + int i, s, rc = 0, scratch_size; int media = IFM_TOKEN|IFM_TOK_UTP16; u_long command; char PCIConfigHeader[64]; @@ -600,26 +580,6 @@ goto config_failed; } - switch(sc->config.type) { - case TRLLD_ADAPTER_PCI4: /* OC-3139 */ - work_size = 32 * 1024; - break; - case TRLLD_ADAPTER_PCI7: /* OC-3540 */ - work_size = 256; - break; - default: - work_size = 0; - } - - if (work_size) { - if ((sc->work_memory = malloc(work_size, M_DEVBUF, M_NOWAIT)) == NULL) { - printf("oltr%d: failed to allocate work memory.\n", unit); - } else { - TRlldAddMemory(sc->TRlldAdapter, sc->work_memory, - vtophys(sc->work_memory), work_size); - } - } - /* * Allocate RX/TX Pools */ @@ -843,6 +803,7 @@ struct ifnet *ifp = &sc->arpcom.ac_if; struct ifmedia *ifm = &sc->ifmedia; int poll = 0, i, rc = 0, s; + int work_size; /* * Check adapter state, don't allow multiple inits @@ -880,6 +841,26 @@ } sc->state = OL_INIT; + switch(sc->config.type) { + case TRLLD_ADAPTER_PCI4: /* OC-3139 */ + work_size = 32 * 1024; + break; + case TRLLD_ADAPTER_PCI7: /* OC-3540 */ + work_size = 256; + break; + default: + work_size = 0; + } + + if (work_size) { + if ((sc->work_memory = malloc(work_size, M_DEVBUF, M_NOWAIT)) == NULL) { + printf("oltr%d: failed to allocate work memory (%d octets).\n", sc->unit, work_size); + } else { + TRlldAddMemory(sc->TRlldAdapter, sc->work_memory, + vtophys(sc->work_memory), work_size); + } + } + switch(IFM_SUBTYPE(ifm->ifm_media)) { case IFM_AUTO: rc = TRlldSetSpeed(sc->TRlldAdapter, 0); /* TRLLD_SPEED_AUTO */ @@ -992,7 +973,7 @@ (void)splx(s); return; default: - printf("oltr%d: unkown open error (%d)\n", sc->unit, rc); + printf("oltr%d: unknown open error (%d)\n", sc->unit, rc); (void)splx(s); return; } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message