Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/jdolecek-ncq]: src/sys/dev two last forgotten on-stack xfers replaced wi...
details: https://anonhg.NetBSD.org/src/rev/430141f15eed
branches: jdolecek-ncq
changeset: 352685:430141f15eed
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Wed Jun 21 22:34:46 2017 +0000
description:
two last forgotten on-stack xfers replaced with using the queue xfer -
ata_get_params() and ata_set_mode()
fix wdc_atapi_get_params() to free the xfer used for soft reset before
calling ata_get_params() - it's now necessary, as ata_get_params() doesn't
invent a private xfer own any more
diffstat:
sys/dev/ata/ata.c | 77 +++++++++++++++++++++++++--------------------
sys/dev/scsipi/atapi_wdc.c | 12 ++++--
2 files changed, 51 insertions(+), 38 deletions(-)
diffs (209 lines):
diff -r c43f92c7c79f -r 430141f15eed sys/dev/ata/ata.c
--- a/sys/dev/ata/ata.c Wed Jun 21 19:38:42 2017 +0000
+++ b/sys/dev/ata/ata.c Wed Jun 21 22:34:46 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata.c,v 1.132.8.13 2017/06/21 19:38:43 jdolecek Exp $ */
+/* $NetBSD: ata.c,v 1.132.8.14 2017/06/21 22:34:46 jdolecek Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved.
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.132.8.13 2017/06/21 19:38:43 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.132.8.14 2017/06/21 22:34:46 jdolecek Exp $");
#include "opt_ata.h"
@@ -129,8 +129,6 @@
static bool atabus_suspend(device_t, const pmf_qual_t *);
static void atabusconfig_thread(void *);
-static void ata_xfer_init(struct ata_xfer *, bool);
-static void ata_xfer_destroy(struct ata_xfer *);
static void ata_channel_idle(struct ata_channel *);
/*
@@ -859,7 +857,7 @@
ata_get_params(struct ata_drive_datas *drvp, uint8_t flags,
struct ataparams *prms)
{
- struct ata_xfer xfer;
+ struct ata_xfer *xfer;
struct ata_channel *chp = drvp->chnl_softc;
struct atac_softc *atac = chp->ch_atac;
char *tb;
@@ -868,44 +866,50 @@
ATADEBUG_PRINT(("%s\n", __func__), DEBUG_FUNCS);
+ xfer = ata_get_xfer(chp);
+ if (xfer == NULL) {
+ ATADEBUG_PRINT(("%s: no xfer\n", __func__),
+ DEBUG_FUNCS|DEBUG_PROBE);
+ return CMD_AGAIN;
+ }
+
tb = kmem_zalloc(DEV_BSIZE, KM_SLEEP);
memset(prms, 0, sizeof(struct ataparams));
- ata_xfer_init(&xfer, true);
if (drvp->drive_type == ATA_DRIVET_ATA) {
- xfer.c_ata_c.r_command = WDCC_IDENTIFY;
- xfer.c_ata_c.r_st_bmask = WDCS_DRDY;
- xfer.c_ata_c.r_st_pmask = WDCS_DRQ;
- xfer.c_ata_c.timeout = 3000; /* 3s */
+ xfer->c_ata_c.r_command = WDCC_IDENTIFY;
+ xfer->c_ata_c.r_st_bmask = WDCS_DRDY;
+ xfer->c_ata_c.r_st_pmask = WDCS_DRQ;
+ xfer->c_ata_c.timeout = 3000; /* 3s */
} else if (drvp->drive_type == ATA_DRIVET_ATAPI) {
- xfer.c_ata_c.r_command = ATAPI_IDENTIFY_DEVICE;
- xfer.c_ata_c.r_st_bmask = 0;
- xfer.c_ata_c.r_st_pmask = WDCS_DRQ;
- xfer.c_ata_c.timeout = 10000; /* 10s */
+ xfer->c_ata_c.r_command = ATAPI_IDENTIFY_DEVICE;
+ xfer->c_ata_c.r_st_bmask = 0;
+ xfer->c_ata_c.r_st_pmask = WDCS_DRQ;
+ xfer->c_ata_c.timeout = 10000; /* 10s */
} else {
ATADEBUG_PRINT(("ata_get_parms: no disks\n"),
DEBUG_FUNCS|DEBUG_PROBE);
rv = CMD_ERR;
goto out;
}
- xfer.c_ata_c.flags = AT_READ | flags;
- xfer.c_ata_c.data = tb;
- xfer.c_ata_c.bcount = DEV_BSIZE;
+ xfer->c_ata_c.flags = AT_READ | flags;
+ xfer->c_ata_c.data = tb;
+ xfer->c_ata_c.bcount = DEV_BSIZE;
if ((*atac->atac_bustype_ata->ata_exec_command)(drvp,
- &xfer) != ATACMD_COMPLETE) {
+ xfer) != ATACMD_COMPLETE) {
ATADEBUG_PRINT(("ata_get_parms: wdc_exec_command failed\n"),
DEBUG_FUNCS|DEBUG_PROBE);
rv = CMD_AGAIN;
goto out;
}
- if (xfer.c_ata_c.flags & (AT_ERROR | AT_TIMEOU | AT_DF)) {
+ if (xfer->c_ata_c.flags & (AT_ERROR | AT_TIMEOU | AT_DF)) {
ATADEBUG_PRINT(("ata_get_parms: ata_c.flags=0x%x\n",
- xfer.c_ata_c.flags), DEBUG_FUNCS|DEBUG_PROBE);
+ xfer->c_ata_c.flags), DEBUG_FUNCS|DEBUG_PROBE);
rv = CMD_ERR;
goto out;
}
/* if we didn't read any data something is wrong */
- if ((xfer.c_ata_c.flags & AT_XFDONE) == 0) {
+ if ((xfer->c_ata_c.flags & AT_XFDONE) == 0) {
rv = CMD_ERR;
goto out;
}
@@ -953,35 +957,40 @@
rv = CMD_OK;
out:
kmem_free(tb, DEV_BSIZE);
- ata_xfer_destroy(&xfer);
+ ata_free_xfer(chp, xfer);
return rv;
}
int
ata_set_mode(struct ata_drive_datas *drvp, uint8_t mode, uint8_t flags)
{
- struct ata_xfer xfer;
+ struct ata_xfer *xfer;
int rv;
struct ata_channel *chp = drvp->chnl_softc;
struct atac_softc *atac = chp->ch_atac;
ATADEBUG_PRINT(("ata_set_mode=0x%x\n", mode), DEBUG_FUNCS);
- ata_xfer_init(&xfer, true);
+ xfer = ata_get_xfer(chp);
+ if (xfer == NULL) {
+ ATADEBUG_PRINT(("%s: no xfer\n", __func__),
+ DEBUG_FUNCS|DEBUG_PROBE);
+ return CMD_AGAIN;
+ }
- xfer.c_ata_c.r_command = SET_FEATURES;
- xfer.c_ata_c.r_st_bmask = 0;
- xfer.c_ata_c.r_st_pmask = 0;
- xfer.c_ata_c.r_features = WDSF_SET_MODE;
- xfer.c_ata_c.r_count = mode;
- xfer.c_ata_c.flags = flags;
- xfer.c_ata_c.timeout = 1000; /* 1s */
+ xfer->c_ata_c.r_command = SET_FEATURES;
+ xfer->c_ata_c.r_st_bmask = 0;
+ xfer->c_ata_c.r_st_pmask = 0;
+ xfer->c_ata_c.r_features = WDSF_SET_MODE;
+ xfer->c_ata_c.r_count = mode;
+ xfer->c_ata_c.flags = flags;
+ xfer->c_ata_c.timeout = 1000; /* 1s */
if ((*atac->atac_bustype_ata->ata_exec_command)(drvp,
- &xfer) != ATACMD_COMPLETE) {
+ xfer) != ATACMD_COMPLETE) {
rv = CMD_AGAIN;
goto out;
}
- if (xfer.c_ata_c.flags & (AT_ERROR | AT_TIMEOU | AT_DF)) {
+ if (xfer->c_ata_c.flags & (AT_ERROR | AT_TIMEOU | AT_DF)) {
rv = CMD_ERR;
goto out;
}
@@ -989,7 +998,7 @@
rv = CMD_OK;
out:
- ata_xfer_destroy(&xfer);
+ ata_free_xfer(chp, xfer);
return rv;
}
diff -r c43f92c7c79f -r 430141f15eed sys/dev/scsipi/atapi_wdc.c
--- a/sys/dev/scsipi/atapi_wdc.c Wed Jun 21 19:38:42 2017 +0000
+++ b/sys/dev/scsipi/atapi_wdc.c Wed Jun 21 22:34:46 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atapi_wdc.c,v 1.123.4.7 2017/06/20 20:58:23 jdolecek Exp $ */
+/* $NetBSD: atapi_wdc.c,v 1.123.4.8 2017/06/21 22:34:46 jdolecek Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer.
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.123.4.7 2017/06/20 20:58:23 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.123.4.8 2017/06/21 22:34:46 jdolecek Exp $");
#ifndef ATADEBUG
#define ATADEBUG
@@ -224,10 +224,12 @@
device_xname(atac->atac_dev), chp->ch_channel, drive,
xfer->c_ata_c.r_error), DEBUG_PROBE);
rv = -1;
- goto out;
+ goto out_xfer;
}
chp->ch_drive[drive].state = 0;
+ ata_free_xfer(chp, xfer);
+
(void)bus_space_read_1(wdr->cmd_iot, wdr->cmd_iohs[wd_status], 0);
/* Some ATAPI devices need a bit more time after software reset. */
@@ -241,8 +243,10 @@
goto out;
}
rv = 0;
+out:
+ return rv;
-out:
+out_xfer:
ata_free_xfer(chp, xfer);
return rv;
}
Home |
Main Index |
Thread Index |
Old Index