From owner-svn-src-stable-7@FreeBSD.ORG Tue May 19 15:47:42 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 99D4E106566C; Tue, 19 May 2009 15:47:42 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 872438FC18; Tue, 19 May 2009 15:47:42 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4JFlgqI002276; Tue, 19 May 2009 15:47:42 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4JFlgcT002274; Tue, 19 May 2009 15:47:42 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200905191547.n4JFlgcT002274@svn.freebsd.org> From: John Baldwin Date: Tue, 19 May 2009 15:47:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192387 - in stable/7/sys: . contrib/pf dev/ata dev/ath/ath_hal dev/cxgb X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2009 15:47:43 -0000 Author: jhb Date: Tue May 19 15:47:42 2009 New Revision: 192387 URL: http://svn.freebsd.org/changeset/base/192387 Log: MFC: - Add a void pointer to the ata-pci controller softc to allow chipset-specific code to attach chipset-specific data. - Use chipset-specific data in the acard and promise chipsets rather than changing the ivars of ATA PCI devices. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ata/ata-chipset.c stable/7/sys/dev/ata/ata-pci.h stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/dev/ata/ata-chipset.c ============================================================================== --- stable/7/sys/dev/ata/ata-chipset.c Tue May 19 15:33:41 2009 (r192386) +++ stable/7/sys/dev/ata/ata-chipset.c Tue May 19 15:47:42 2009 (r192387) @@ -50,6 +50,12 @@ __FBSDID("$FreeBSD$"); #include #include +struct ata_serialize { + struct mtx locked_mtx; + int locked_ch; + int restart_ch; +}; + /* local prototypes */ /* ata-chipset.c */ static int ata_generic_chipinit(device_t dev); @@ -186,6 +192,7 @@ static struct ata_chip_id *ata_match_chi static struct ata_chip_id *ata_find_chip(device_t dev, struct ata_chip_id *index, int slot); static int ata_setup_interrupt(device_t dev); static int ata_serialize(device_t dev, int flags); +static void ata_serialize_init(struct ata_serialize *serial); static void ata_print_cable(device_t dev, u_int8_t *who); static int ata_atapi(device_t dev); static int ata_check_80pin(device_t dev, int mode); @@ -919,6 +926,7 @@ static int ata_acard_chipinit(device_t dev) { struct ata_pci_controller *ctlr = device_get_softc(dev); + struct ata_serialize *serial; if (ata_setup_interrupt(dev)) return ENXIO; @@ -927,6 +935,10 @@ ata_acard_chipinit(device_t dev) if (ctlr->chip->cfg1 == ATPOLD) { ctlr->setmode = ata_acard_850_setmode; ctlr->locking = ata_serialize; + serial = malloc(sizeof(struct ata_serialize), + M_TEMP, M_WAITOK | M_ZERO); + ata_serialize_init(serial); + ctlr->chipset_data = serial; } else ctlr->setmode = ata_acard_86X_setmode; @@ -3461,7 +3473,7 @@ ata_promise_chipinit(device_t dev) mtx_init(&hpkt->mtx, "ATA promise HPKT lock", NULL, MTX_DEF); TAILQ_INIT(&hpkt->queue); hpkt->busy = 0; - device_set_ivars(dev, hpkt); + ctlr->chipset_data = hpkt; ctlr->allocate = ata_promise_mio_allocate; ctlr->reset = ata_promise_mio_reset; ctlr->dmainit = ata_promise_mio_dmainit; @@ -3908,7 +3920,7 @@ ata_promise_mio_reset(device_t dev) case PRSX4X: /* softreset channel ATA module */ - hpktp = device_get_ivars(ctlr->dev); + hpktp = ctlr->chipset_data; ATA_OUTL(ctlr->r_res2, 0xc0260 + (ch->unit << 7), ch->unit + 1); ata_udelay(1000); ATA_OUTL(ctlr->r_res2, 0xc0260 + (ch->unit << 7), @@ -4247,7 +4259,7 @@ ata_promise_apkt(u_int8_t *bytep, struct static void ata_promise_queue_hpkt(struct ata_pci_controller *ctlr, u_int32_t hpkt) { - struct ata_promise_sx4 *hpktp = device_get_ivars(ctlr->dev); + struct ata_promise_sx4 *hpktp = ctlr->chipset_data; mtx_lock(&hpktp->mtx); if (hpktp->busy) { @@ -4266,7 +4278,7 @@ ata_promise_queue_hpkt(struct ata_pci_co static void ata_promise_next_hpkt(struct ata_pci_controller *ctlr) { - struct ata_promise_sx4 *hpktp = device_get_ivars(ctlr->dev); + struct ata_promise_sx4 *hpktp = ctlr->chipset_data; struct host_packet *hp; mtx_lock(&hpktp->mtx); @@ -5841,11 +5853,14 @@ ata_setup_interrupt(device_t dev) return 0; } -struct ata_serialize { - struct mtx locked_mtx; - int locked_ch; - int restart_ch; -}; +static void +ata_serialize_init(struct ata_serialize *serial) +{ + + mtx_init(&serial->locked_mtx, "ATA serialize lock", NULL, MTX_DEF); + serial->locked_ch = -1; + serial->restart_ch = -1; +} static int ata_serialize(device_t dev, int flags) @@ -5853,20 +5868,9 @@ ata_serialize(device_t dev, int flags) struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); struct ata_channel *ch = device_get_softc(dev); struct ata_serialize *serial; - static int inited = 0; int res; - if (!inited) { - serial = malloc(sizeof(struct ata_serialize), - M_TEMP, M_NOWAIT | M_ZERO); - mtx_init(&serial->locked_mtx, "ATA serialize lock", NULL, MTX_DEF); - serial->locked_ch = -1; - serial->restart_ch = -1; - device_set_ivars(ctlr->dev, serial); - inited = 1; - } - else - serial = device_get_ivars(ctlr->dev); + serial = ctlr->chipset_data; mtx_lock(&serial->locked_mtx); switch (flags) { Modified: stable/7/sys/dev/ata/ata-pci.h ============================================================================== --- stable/7/sys/dev/ata/ata-pci.h Tue May 19 15:33:41 2009 (r192386) +++ stable/7/sys/dev/ata/ata-pci.h Tue May 19 15:47:42 2009 (r192387) @@ -59,6 +59,7 @@ struct ata_pci_controller { void (*function)(void *); void *argument; } interrupt[8]; /* XXX SOS max ch# for now */ + void *chipset_data; }; /* structure for SATA connection update hotplug/hotswap support */