Re: [patch] vhost/scsi: potential memory corruption
On Thu, 2015-02-05 at 10:37 +0300, Dan Carpenter wrote: This code in vhost_scsi_make_tpg() is confusing because we limit tpgt to UINT_MAX but the data type of tpg-tport_tpgt and that is a u16. I looked at the context and it turns out that in vhost_scsi_set_endpoint(), tpg-tport_tpgt is used as an offset into the vs_tpg[] array which has VHOST_SCSI_MAX_TARGET (256) elements so anything higher than 255 then it is invalid. I have made that the limit now. In vhost_scsi_send_evt() we mask away values higher than 255, but now that the limit has changed, we don't need the mask. Signed-off-by: Dan Carpenter dan.carpen...@oracle.com --- Compile tested only. diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 3e265ef..4339222 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -1278,7 +1278,7 @@ vhost_scsi_send_evt(struct vhost_scsi *vs, * lun[4-7] need to be zero according to virtio-scsi spec. */ evt-event.lun[0] = 0x01; - evt-event.lun[1] = tpg-tport_tpgt 0xFF; + evt-event.lun[1] = tpg-tport_tpgt; if (lun-unpacked_lun = 256) evt-event.lun[2] = lun-unpacked_lun 8 | 0x40 ; evt-event.lun[3] = lun-unpacked_lun 0xFF; @@ -2149,12 +2149,12 @@ vhost_scsi_make_tpg(struct se_wwn *wwn, struct vhost_scsi_tport, tport_wwn); struct vhost_scsi_tpg *tpg; - unsigned long tpgt; + u16 tpgt; int ret; if (strstr(name, tpgt_) != name) return ERR_PTR(-EINVAL); - if (kstrtoul(name + 5, 10, tpgt) || tpgt UINT_MAX) + if (kstrtou16(name + 5, 10, tpgt) || tpgt = VHOST_SCSI_MAX_TARGET) return ERR_PTR(-EINVAL); tpg = kzalloc(sizeof(struct vhost_scsi_tpg), GFP_KERNEL); Nice catch Dan. Applied to target-pending/for-next. --nab -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/4] SCSI-QLA4...: Less function calls in qla4xxx_sysfs_ddb_logout() after error detection
From: Markus Elfring elfr...@users.sourceforge.net Date: Fri, 6 Feb 2015 22:44:23 +0100 The vfree() function was called in three cases by the qla4xxx_sysfs_ddb_logout() function during error handling even if the passed variables flash_tddb and tmp_tddb contained still a null pointer. * This implementation detail could be improved by adjustments for jump labels. * Let us return immediately after the first failed function call according to the current Linux coding style convention. * Delete also an unnecessary check for the variable fw_ddb_entry there. Signed-off-by: Markus Elfring elfr...@users.sourceforge.net --- drivers/scsi/qla4xxx/ql4_os.c | 35 +-- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index e508bc9..802390b 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -7699,23 +7699,22 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess, { struct Scsi_Host *shost = iscsi_flash_session_to_shost(fnode_sess); struct scsi_qla_host *ha = to_qla_host(shost); - struct ql4_tuple_ddb *flash_tddb = NULL; - struct ql4_tuple_ddb *tmp_tddb = NULL; - struct dev_db_entry *fw_ddb_entry = NULL; - struct ddb_entry *ddb_entry = NULL; dma_addr_t fw_ddb_dma; uint32_t next_idx = 0; uint32_t state = 0, conn_err = 0; uint16_t conn_id = 0; int idx, index; int status, ret = 0; + struct ql4_tuple_ddb *flash_tddb; + struct ql4_tuple_ddb *tmp_tddb; + struct ddb_entry *ddb_entry; + struct dev_db_entry *fw_ddb_entry = dma_pool_alloc(ha-fw_ddb_dma_pool, + GFP_KERNEL, + fw_ddb_dma); - fw_ddb_entry = dma_pool_alloc(ha-fw_ddb_dma_pool, GFP_KERNEL, - fw_ddb_dma); - if (fw_ddb_entry == NULL) { + if (!fw_ddb_entry) { ql4_printk(KERN_ERR, ha, %s:Out of memory\n, __func__); - ret = -ENOMEM; - goto exit_ddb_logout; + return -ENOMEM; } flash_tddb = vzalloc(sizeof(*flash_tddb)); @@ -7723,7 +7722,7 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess, ql4_printk(KERN_WARNING, ha, %s:Memory Allocation failed.\n, __func__); ret = -ENOMEM; - goto exit_ddb_logout; + goto free_pool; } tmp_tddb = vzalloc(sizeof(*tmp_tddb)); @@ -7731,7 +7730,7 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess, ql4_printk(KERN_WARNING, ha, %s:Memory Allocation failed.\n, __func__); ret = -ENOMEM; - goto exit_ddb_logout; + goto free_flash; } if (!fnode_sess-targetname) { @@ -7739,7 +7738,7 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess, %s:Cannot logout from SendTarget entry\n, __func__); ret = -EPERM; - goto exit_ddb_logout; + goto free_tmp; } if (fnode_sess-is_boot_target) { @@ -7747,7 +7746,7 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess, %s: Logout from boot target entry is not permitted.\n, __func__); ret = -EPERM; - goto exit_ddb_logout; + goto free_tmp; } strlcpy(flash_tddb-iscsi_name, fnode_sess-targetname, @@ -7794,12 +7793,12 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess, if (idx == MAX_DDB_ENTRIES) ret = -ESRCH; -exit_ddb_logout: - vfree(flash_tddb); +free_tmp: vfree(tmp_tddb); - if (fw_ddb_entry) - dma_pool_free(ha-fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma); - +free_flash: + vfree(flash_tddb); +free_pool: + dma_pool_free(ha-fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma); return ret; } -- 2.2.2 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/4] SCSI-QLA4...: Deletion of unnecessary checks before three function calls
From: Markus Elfring elfr...@users.sourceforge.net Date: Fri, 6 Feb 2015 20:38:23 +0100 The following functions perform also input parameter validation. * iscsi_boot_destroy_kset * kfree * vfree Thus the test around their calls is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring elfr...@users.sourceforge.net --- drivers/scsi/qla4xxx/ql4_mbx.c | 2 +- drivers/scsi/qla4xxx/ql4_os.c | 31 ++- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c index c291fdf..2343c0f 100644 --- a/drivers/scsi/qla4xxx/ql4_mbx.c +++ b/drivers/scsi/qla4xxx/ql4_mbx.c @@ -2410,7 +2410,7 @@ exit_free_acb: dma_free_coherent(ha-pdev-dev, sizeof(struct addr_ctrl_blk), acb, acb_dma); exit_config_acb: - if ((acb_config == ACB_CONFIG_SET) ha-saved_acb) { + if (acb_config == ACB_CONFIG_SET) { kfree(ha-saved_acb); ha-saved_acb = NULL; } diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 6d25879..2a00fd3 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -4131,9 +4131,7 @@ static void qla4xxx_mem_free(struct scsi_qla_host *ha) dma_free_coherent(ha-pdev-dev, ha-queues_len, ha-queues, ha-queues_dma); -if (ha-fw_dump) - vfree(ha-fw_dump); - + vfree(ha-fw_dump); ha-queues_len = 0; ha-queues = NULL; ha-queues_dma = 0; @@ -4155,8 +4153,7 @@ static void qla4xxx_mem_free(struct scsi_qla_host *ha) if (ha-chap_dma_pool) dma_pool_destroy(ha-chap_dma_pool); - if (ha-chap_list) - vfree(ha-chap_list); + vfree(ha-chap_list); ha-chap_list = NULL; if (ha-fw_ddb_dma_pool) @@ -4175,9 +4172,7 @@ static void qla4xxx_mem_free(struct scsi_qla_host *ha) iounmap(ha-reg); } - if (ha-reset_tmplt.buff) - vfree(ha-reset_tmplt.buff); - + vfree(ha-reset_tmplt.buff); pci_release_regions(ha-pdev); } @@ -6370,10 +6365,8 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, } exit_check: - if (fw_tddb) - vfree(fw_tddb); - if (tmp_tddb) - vfree(tmp_tddb); + vfree(fw_tddb); + vfree(tmp_tddb); return ret; } @@ -6525,10 +6518,8 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha, } exit_check: - if (fw_tddb) - vfree(fw_tddb); - if (tmp_tddb) - vfree(tmp_tddb); + vfree(fw_tddb); + vfree(tmp_tddb); return ret; } @@ -7806,10 +7797,8 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess, ret = -ESRCH; exit_ddb_logout: - if (flash_tddb) - vfree(flash_tddb); - if (tmp_tddb) - vfree(tmp_tddb); + vfree(flash_tddb); + vfree(tmp_tddb); if (fw_ddb_entry) dma_pool_free(ha-fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma); @@ -9002,7 +8991,7 @@ static void qla4xxx_remove_adapter(struct pci_dev *pdev) /* destroy iface from sysfs */ qla4xxx_destroy_ifaces(ha); - if ((!ql4xdisablesysfsboot) ha-boot_kset) + if (!ql4xdisablesysfsboot) iscsi_boot_destroy_kset(ha-boot_kset); qla4xxx_destroy_fw_ddb_session(ha); -- 2.2.2 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 01/36] aha1542: Stop using scsi_module.c
Convert aha1542 to use scsi_add_host instead of scsi_module.c Use pnp_driver and isa_driver to manage cards. Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 300 +++- drivers/scsi/aha1542.h |2 +- 2 files changed, 169 insertions(+), 133 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 770c48d..b7a62da 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -35,7 +35,8 @@ #include linux/proc_fs.h #include linux/init.h #include linux/spinlock.h -#include linux/isapnp.h +#include linux/isa.h +#include linux/pnp.h #include linux/blkdev.h #include linux/slab.h @@ -71,7 +72,7 @@ /* Boards 3,4 slots are reserved for ISAPnP scans */ -static unsigned int bases[MAXBOARDS] __initdata = {0x330, 0x334, 0, 0}; +static unsigned int bases[MAXBOARDS] = {0x330, 0x334, 0, 0}; /* set by aha1542_setup according to the command line; they also may be marked __initdata, but require zero initializers then */ @@ -79,7 +80,7 @@ static unsigned int bases[MAXBOARDS] __initdata = {0x330, 0x334, 0, 0}; static int setup_called[MAXBOARDS]; static int setup_buson[MAXBOARDS]; static int setup_busoff[MAXBOARDS]; -static int setup_dmaspeed[MAXBOARDS] __initdata = { -1, -1, -1, -1 }; +static int setup_dmaspeed[MAXBOARDS] = { -1, -1, -1, -1 }; /* * LILO/Module params: aha1542=PORTBASE[,BUSON,BUSOFF[,DMASPEED]] @@ -103,18 +104,6 @@ static bool isapnp = 0; static int aha1542[] = {0x330, 11, 4, -1}; module_param_array(aha1542, int, NULL, 0); module_param(isapnp, bool, 0); - -static struct isapnp_device_id id_table[] __initdata = { - { - ISAPNP_ANY_ID, ISAPNP_ANY_ID, - ISAPNP_VENDOR('A', 'D', 'P'), ISAPNP_FUNCTION(0x1542), - 0 - }, - {0} -}; - -MODULE_DEVICE_TABLE(isapnp, id_table); - #else static int isapnp = 1; #endif @@ -221,7 +210,7 @@ fail: /* Only used at boot time, so we do not need to worry about latency as much here */ -static int __init aha1542_in(unsigned int base, unchar * cmdp, int len) +static int aha1542_in(unsigned int base, unchar *cmdp, int len) { unsigned long flags; @@ -242,7 +231,7 @@ fail: /* Similar to aha1542_in, except that we wait a very short period of time. We use this if we know the board is alive and awake, but we are not sure if the board will respond to the command we are about to send or not */ -static int __init aha1542_in1(unsigned int base, unchar * cmdp, int len) +static int aha1542_in1(unsigned int base, unchar *cmdp, int len) { unsigned long flags; @@ -314,7 +303,7 @@ static int makecode(unsigned hosterr, unsigned scsierr) return scsierr | (hosterr 16); } -static int __init aha1542_test_port(int bse, struct Scsi_Host *shpnt) +static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) { unchar inquiry_cmd[] = {CMD_INQUIRY}; unchar inquiry_result[4]; @@ -744,7 +733,7 @@ fail: aha1542_intr_reset(bse); } -static int __init aha1542_getconfig(int base_io, unsigned char *irq_level, unsigned char *dma_chan, unsigned char *scsi_id) +static int aha1542_getconfig(int base_io, unsigned char *irq_level, unsigned char *dma_chan, unsigned char *scsi_id) { unchar inquiry_cmd[] = {CMD_RETCONF}; unchar inquiry_result[3]; @@ -813,7 +802,7 @@ fail: /* This function should only be called for 1542C boards - we can detect the special firmware settings and unlock the board */ -static int __init aha1542_mbenable(int base) +static int aha1542_mbenable(int base) { static unchar mbenable_cmd[3]; static unchar mbenable_result[2]; @@ -848,7 +837,7 @@ fail: } /* Query the board to find out if it is a 1542 or a 1740, or whatever. */ -static int __init aha1542_query(int base_io, int *transl) +static int aha1542_query(int base_io, int *transl) { unchar inquiry_cmd[] = {CMD_INQUIRY}; unchar inquiry_result[4]; @@ -963,7 +952,7 @@ __setup(aha1542=,do_setup); #endif /* return non-zero on detection */ -static int __init aha1542_detect(struct scsi_host_template * tpnt) +static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct device *pdev, int indx) { unsigned char dma_chan; unsigned char irq_level; @@ -972,87 +961,18 @@ static int __init aha1542_detect(struct scsi_host_template * tpnt) unsigned int base_io; int trans; struct Scsi_Host *shpnt = NULL; - int count = 0; - int indx; DEB(printk(aha1542_detect: \n)); tpnt-proc_name = aha1542; -#ifdef MODULE - bases[0] = aha1542[0]; - setup_buson[0] = aha1542[1]; - setup_busoff[0] = aha1542[2]; - { - int atbt = -1; - switch (aha1542[3]) { - case 5: - atbt = 0x00; - break; - case 6: - atbt =
[PATCH 09/36] aha1542: Use BIT() macro
Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.h | 37 +++-- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/aha1542.h b/drivers/scsi/aha1542.h index f0b862b..1333a23 100644 --- a/drivers/scsi/aha1542.h +++ b/drivers/scsi/aha1542.h @@ -36,29 +36,30 @@ /* I/O Port interface 4.2 */ /* READ */ #define STATUS(base) base -#define STST 0x80/* Self Test in Progress */ -#define DIAGF 0x40/* Internal Diagnostic Failure */ -#define INIT 0x20/* Mailbox Initialization Required */ -#define IDLE 0x10/* SCSI Host Adapter Idle */ -#define CDF0x08/* Command/Data Out Port Full */ -#define DF 0x04/* Data In Port Full */ -#define INVDCMD0x01/* Invalid H A Command */ -#define STATMASK 0xfd /* 0x02 is reserved */ +#define STST BIT(7) /* Self Test in Progress */ +#define DIAGF BIT(6) /* Internal Diagnostic Failure */ +#define INIT BIT(5) /* Mailbox Initialization Required */ +#define IDLE BIT(4) /* SCSI Host Adapter Idle */ +#define CDFBIT(3) /* Command/Data Out Port Full */ +#define DF BIT(2) /* Data In Port Full */ +/* BIT(1) is reserved */ +#define INVDCMDBIT(0) /* Invalid H A Command */ +#define STATMASK (STST | DIAGF | INIT | IDLE | CDF | DF | INVDCMD) #define INTRFLAGS(base) (STATUS(base)+2) -#define ANYINTR0x80/* Any Interrupt */ -#define SCRD 0x08/* SCSI Reset Detected */ -#define HACC 0x04/* HA Command Complete */ -#define MBOA 0x02/* MBO Empty */ -#define MBIF 0x01/* MBI Full */ -#define INTRMASK 0x8f +#define ANYINTRBIT(7) /* Any Interrupt */ +#define SCRD BIT(3) /* SCSI Reset Detected */ +#define HACC BIT(2) /* HA Command Complete */ +#define MBOA BIT(1) /* MBO Empty */ +#define MBIF BIT(0) /* MBI Full */ +#define INTRMASK (ANYINTR | SCRD | HACC | MBOA | MBIF) /* WRITE */ #define CONTROL(base) STATUS(base) -#define HRST 0x80/* Hard Reset */ -#define SRST 0x40/* Soft Reset */ -#define IRST 0x20/* Interrupt Reset */ -#define SCRST 0x10/* SCSI Bus Reset */ +#define HRST BIT(7) /* Hard Reset */ +#define SRST BIT(6) /* Soft Reset */ +#define IRST BIT(5) /* Interrupt Reset */ +#define SCRST BIT(4) /* SCSI Bus Reset */ /* READ/WRITE */ #define DATA(base) (STATUS(base)+1) -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 02/36] aha1542: remove dead code
Remove dead code. Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 243 +--- drivers/scsi/aha1542.h |6 -- 2 files changed, 1 insertion(+), 248 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index b7a62da..506e33e 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -570,13 +570,6 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd * if (*cmd == REQUEST_SENSE) { /* Don't do the command - we have the sense data already */ -#if 0 - /* scsi_request_sense() provides a buffer of size 256, - so there is no reason to expect equality */ - if (bufflen != SCSI_SENSE_BUFFERSIZE) - printk(KERN_CRIT aha1542: Wrong buffer length supplied - for request sense (%d)\n, bufflen); -#endif SCpnt-result = 0; done(SCpnt); return 0; @@ -1095,24 +1088,14 @@ static int aha1542_restart(struct Scsi_Host *shost) { int i; int count = 0; -#if 0 - unchar ahacmd = CMD_START_SCSI; -#endif for (i = 0; i AHA1542_MAILBOXES; i++) if (HOSTDATA(shost)-SCint[i] !(HOSTDATA(shost)-SCint[i]-device-soft_reset)) { -#if 0 - HOSTDATA(shost)-mb[i].status = 1; /* Indicate ready to restart... */ -#endif count++; } printk(KERN_DEBUG Potential to restart %d stalled commands...\n, count); -#if 0 - /* start scsi command */ - if (count) - aha1542_out(shost-io_port, ahacmd, 1); -#endif + return 0; } @@ -1177,39 +1160,6 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt) Trying device reset for target\n); return SUCCESS; - - -#ifdef ERIC_neverdef - /* -* With the 1542 we apparently never get an interrupt to -* acknowledge a device reset being sent. Then again, Leonard -* says we are doing this wrong in the first place... -* -* Take a wait and see attitude. If we get spurious interrupts, -* then the device reset is doing something sane and useful, and -* we will wait for the interrupt to post completion. -*/ - printk(KERN_WARNING Sent BUS DEVICE RESET to target %d\n, SCpnt-target); - - /* -* Free the command block for all commands running on this -* target... -*/ - for (i = 0; i AHA1542_MAILBOXES; i++) { - if (HOSTDATA(SCpnt-host)-SCint[i] - HOSTDATA(SCpnt-host)-SCint[i]-target == SCpnt-target) { - Scsi_Cmnd *SCtmp; - SCtmp = HOSTDATA(SCpnt-host)-SCint[i]; - kfree(SCtmp-host_scribble); - SCtmp-host_scribble = NULL; - HOSTDATA(SCpnt-host)-SCint[i] = NULL; - HOSTDATA(SCpnt-host)-mb[i].status = 0; - } - } - return SUCCESS; - - return FAILED; -#endif /* ERIC_neverdef */ } static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) @@ -1344,197 +1294,6 @@ fail: return FAILED; } -#if 0 -/* - * These are the old error handling routines. They are only temporarily - * here while we play with the new error handling code. - */ -static int aha1542_old_abort(Scsi_Cmnd * SCpnt) -{ -#if 0 - unchar ahacmd = CMD_START_SCSI; - unsigned long flags; - struct mailbox *mb; - int mbi, mbo, i; - - printk(KERN_DEBUG In aha1542_abort: %x %x\n, - inb(STATUS(SCpnt-host-io_port)), - inb(INTRFLAGS(SCpnt-host-io_port))); - - spin_lock_irqsave(aha1542_lock, flags); - mb = HOSTDATA(SCpnt-host)-mb; - mbi = HOSTDATA(SCpnt-host)-aha1542_last_mbi_used + 1; - if (mbi = 2 * AHA1542_MAILBOXES) - mbi = AHA1542_MAILBOXES; - - do { - if (mb[mbi].status != 0) - break; - mbi++; - if (mbi = 2 * AHA1542_MAILBOXES) - mbi = AHA1542_MAILBOXES; - } while (mbi != HOSTDATA(SCpnt-host)-aha1542_last_mbi_used); - spin_unlock_irqrestore(aha1542_lock, flags); - - if (mb[mbi].status) { - printk(KERN_ERR Lost interrupt discovered on irq %d - attempting to recover\n, - SCpnt-host-irq); - aha1542_intr_handle(SCpnt-host, NULL); - return 0; - } - /* OK, no lost interrupt. Try looking to see how many pending commands - we think we have. */ - - for (i = 0; i AHA1542_MAILBOXES; i++) - if (HOSTDATA(SCpnt-host)-SCint[i]) { - if (HOSTDATA(SCpnt-host)-SCint[i] == SCpnt) { - printk(KERN_ERR Timed out command
[PATCH 07/36] aha1542: Reorder functions to remove forward declarations
Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 51 +++- drivers/scsi/aha1542.h | 12 2 files changed, 24 insertions(+), 39 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 8851719..af1e8fa 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -124,10 +124,6 @@ static DEFINE_SPINLOCK(aha1542_lock); #define WAITnexttimeout 300 -static void setup_mailboxes(int base_io, struct Scsi_Host *shpnt); -static int aha1542_restart(struct Scsi_Host *shost); -static void aha1542_intr_handle(struct Scsi_Host *shost); - static inline void aha1542_intr_reset(u16 base) { outb(IRST, CONTROL(base)); @@ -368,16 +364,20 @@ fail: return 0; /* 0 = not ok */ } -/* A quick wrapper for do_aha1542_intr_handle to grab the spin lock */ -static irqreturn_t do_aha1542_intr_handle(int dummy, void *dev_id) +static int aha1542_restart(struct Scsi_Host *shost) { - unsigned long flags; - struct Scsi_Host *shost = dev_id; + struct aha1542_hostdata *aha1542 = shost_priv(shost); + int i; + int count = 0; - spin_lock_irqsave(shost-host_lock, flags); - aha1542_intr_handle(shost); - spin_unlock_irqrestore(shost-host_lock, flags); - return IRQ_HANDLED; + for (i = 0; i AHA1542_MAILBOXES; i++) + if (aha1542-SCint[i] + !(aha1542-SCint[i]-device-soft_reset)) { + count++; + } + printk(KERN_DEBUG Potential to restart %d stalled commands...\n, count); + + return 0; } /* A high level interrupt handler */ @@ -539,6 +539,18 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) }; } +/* A quick wrapper for do_aha1542_intr_handle to grab the spin lock */ +static irqreturn_t do_aha1542_intr_handle(int dummy, void *dev_id) +{ + unsigned long flags; + struct Scsi_Host *shost = dev_id; + + spin_lock_irqsave(shost-host_lock, flags); + aha1542_intr_handle(shost); + spin_unlock_irqrestore(shost-host_lock, flags); + return IRQ_HANDLED; +} + static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) { struct aha1542_hostdata *aha1542 = shost_priv(SCpnt-device-host); @@ -1078,21 +1090,6 @@ static int aha1542_release(struct Scsi_Host *shost) return 0; } -static int aha1542_restart(struct Scsi_Host *shost) -{ - struct aha1542_hostdata *aha1542 = shost_priv(shost); - int i; - int count = 0; - - for (i = 0; i AHA1542_MAILBOXES; i++) - if (aha1542-SCint[i] - !(aha1542-SCint[i]-device-soft_reset)) { - count++; - } - printk(KERN_DEBUG Potential to restart %d stalled commands...\n, count); - - return 0; -} /* * This is a device reset. This is handled by sending a special command diff --git a/drivers/scsi/aha1542.h b/drivers/scsi/aha1542.h index 6b418bb..f0b862b 100644 --- a/drivers/scsi/aha1542.h +++ b/drivers/scsi/aha1542.h @@ -125,18 +125,6 @@ struct ccb { /* Command Control Block 5.3 */ /* REQUEST SENSE */ }; -static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct device *pdev, int indx); -static int aha1542_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); -static int aha1542_bus_reset(Scsi_Cmnd * SCpnt); -static int aha1542_dev_reset(Scsi_Cmnd * SCpnt); -static int aha1542_host_reset(Scsi_Cmnd * SCpnt); -#if 0 -static int aha1542_old_abort(Scsi_Cmnd * SCpnt); -static int aha1542_old_reset(Scsi_Cmnd *, unsigned int); -#endif -static int aha1542_biosparam(struct scsi_device *, struct block_device *, - sector_t, int *); - #define AHA1542_MAILBOXES 8 #endif -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 06/36] aha1542: Use u8 instead of unchar
Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 50 drivers/scsi/aha1542.h | 42 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 2a6308f..8851719 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -168,7 +168,7 @@ static void aha1542_stat(void) routine does not send something out while we are in the middle of this. Fortunately, it is only at boot time that multi-byte messages are ever sent. */ -static int aha1542_out(unsigned int base, unchar * cmdp, int len) +static int aha1542_out(unsigned int base, u8 *cmdp, int len) { unsigned long flags = 0; int got_lock; @@ -207,7 +207,7 @@ fail: /* Only used at boot time, so we do not need to worry about latency as much here */ -static int aha1542_in(unsigned int base, unchar *cmdp, int len) +static int aha1542_in(unsigned int base, u8 *cmdp, int len) { unsigned long flags; @@ -228,7 +228,7 @@ fail: /* Similar to aha1542_in, except that we wait a very short period of time. We use this if we know the board is alive and awake, but we are not sure if the board will respond to the command we are about to send or not */ -static int aha1542_in1(unsigned int base, unchar *cmdp, int len) +static int aha1542_in1(unsigned int base, u8 *cmdp, int len) { unsigned long flags; @@ -302,9 +302,9 @@ static int makecode(unsigned hosterr, unsigned scsierr) static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) { - unchar inquiry_cmd[] = {CMD_INQUIRY}; - unchar inquiry_result[4]; - unchar *cmdp; + u8 inquiry_cmd[] = {CMD_INQUIRY}; + u8 inquiry_result[4]; + u8 *cmdp; int len; volatile int debug = 0; @@ -542,11 +542,11 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) { struct aha1542_hostdata *aha1542 = shost_priv(SCpnt-device-host); - unchar ahacmd = CMD_START_SCSI; - unchar direction; - unchar *cmd = (unchar *) SCpnt-cmnd; - unchar target = SCpnt-device-id; - unchar lun = SCpnt-device-lun; + u8 ahacmd = CMD_START_SCSI; + u8 direction; + u8 *cmd = (u8 *) SCpnt-cmnd; + u8 target = SCpnt-device-id; + u8 lun = SCpnt-device-lun; unsigned long flags; int bufflen = scsi_bufflen(SCpnt); int mbo; @@ -674,7 +674,7 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd * int i; printk(KERN_DEBUG aha1542_command: sending.. ); for (i = 0; i sizeof(ccb[mbo]) - 10; i++) - printk(%02x , ((unchar *) ccb[mbo])[i]); + printk(%02x , ((u8 *) ccb[mbo])[i]); }; #endif @@ -701,7 +701,7 @@ static void setup_mailboxes(int bse, struct Scsi_Host *shpnt) struct mailbox *mb = aha1542-mb; struct ccb *ccb = aha1542-ccb; - unchar cmd[5] = { CMD_MBINIT, AHA1542_MAILBOXES, 0, 0, 0}; + u8 cmd[5] = { CMD_MBINIT, AHA1542_MAILBOXES, 0, 0, 0}; for (i = 0; i AHA1542_MAILBOXES; i++) { mb[i].status = mb[AHA1542_MAILBOXES + i].status = 0; @@ -720,8 +720,8 @@ fail: static int aha1542_getconfig(int base_io, unsigned char *irq_level, unsigned char *dma_chan, unsigned char *scsi_id) { - unchar inquiry_cmd[] = {CMD_RETCONF}; - unchar inquiry_result[3]; + u8 inquiry_cmd[] = {CMD_RETCONF}; + u8 inquiry_result[3]; int i; i = inb(STATUS(base_io)); if (i DF) { @@ -789,8 +789,8 @@ fail: static int aha1542_mbenable(int base) { - static unchar mbenable_cmd[3]; - static unchar mbenable_result[2]; + static u8 mbenable_cmd[3]; + static u8 mbenable_result[2]; int retval; retval = BIOS_TRANSLATION_6432; @@ -824,8 +824,8 @@ fail: /* Query the board to find out if it is a 1542 or a 1740, or whatever. */ static int aha1542_query(int base_io, int *transl) { - unchar inquiry_cmd[] = {CMD_INQUIRY}; - unchar inquiry_result[4]; + u8 inquiry_cmd[] = {CMD_INQUIRY}; + u8 inquiry_result[4]; int i; i = inb(STATUS(base_io)); if (i DF) { @@ -968,8 +968,8 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct /* Set the Bus on/off-times as not to ruin floppy performance */ { - unchar oncmd[] = {CMD_BUSON_TIME, 7}; - unchar offcmd[] = {CMD_BUSOFF_TIME, 5}; + u8 oncmd[] = {CMD_BUSON_TIME, 7}; + u8 offcmd[] = {CMD_BUSOFF_TIME, 5}; if (setup_called[indx]) {
[PATCH 0/4] SCSI-QLA4...: Deletion of some unnecessary checks
From: Markus Elfring elfr...@users.sourceforge.net Date: Fri, 6 Feb 2015 23:03:41 +0100 Further update suggestions were taken into account after a patch was applied from static source code analysis. Markus Elfring (4): Deletion of unnecessary checks before three function calls Less function calls in qla4xxx_is_session_exists() after error detection Less function calls in qla4xxx_is_flash_ddb_exists() after error detection Less function calls in qla4xxx_sysfs_ddb_logout() after error detection drivers/scsi/qla4xxx/ql4_mbx.c | 2 +- drivers/scsi/qla4xxx/ql4_os.c | 96 ++ 2 files changed, 42 insertions(+), 56 deletions(-) -- 2.2.2 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 03/36] aha1542: Remove SCSI_BUF_PA, SCSI_SG_PA, AHA1542_SCATTER and AHA1542_CMDLUN
Remove SCSI_BUF_PA, SCSI_SG_PA, AHA1542_SCATTER and AHA1542_CMDLUN macros Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 23 ++- drivers/scsi/aha1542.h |2 -- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 506e33e..197480d 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -46,10 +46,6 @@ #include scsi.h #include scsi/scsi_host.h #include aha1542.h - -#define SCSI_BUF_PA(address) isa_virt_to_bus(address) -#define SCSI_SG_PA(sgent) (isa_page_to_bus(sg_page((sgent))) + (sgent)-offset) - #include linux/stat.h #ifdef DEBUG @@ -463,7 +459,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) return; }; - mbo = (scsi2int(mb[mbi].ccbptr) - (SCSI_BUF_PA(ccb[0]))) / sizeof(struct ccb); + mbo = (scsi2int(mb[mbi].ccbptr) - (isa_virt_to_bus(ccb[0]))) / sizeof(struct ccb); mbistatus = mb[mbi].status; mb[mbi].status = 0; HOSTDATA(shost)-aha1542_last_mbi_used = mbi; @@ -622,7 +618,7 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd * printk(KERN_DEBUG Sending command (%d %x)..., mbo, done); #endif - any2scsi(mb[mbo].ccbptr, SCSI_BUF_PA(ccb[mbo])); /* This gets trashed for some reason */ + any2scsi(mb[mbo].ccbptr, isa_virt_to_bus(ccb[mbo])); /* This gets trashed for some reason */ memset(ccb[mbo], 0, sizeof(struct ccb)); @@ -653,11 +649,12 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd * return SCSI_MLQUEUE_HOST_BUSY; } scsi_for_each_sg(SCpnt, sg, sg_count, i) { - any2scsi(cptr[i].dataptr, SCSI_SG_PA(sg)); + any2scsi(cptr[i].dataptr, isa_page_to_bus(sg_page(sg)) + + sg-offset); any2scsi(cptr[i].datalen, sg-length); }; any2scsi(ccb[mbo].datalen, sg_count * sizeof(struct chain)); - any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(cptr)); + any2scsi(ccb[mbo].dataptr, isa_virt_to_bus(cptr)); #ifdef DEBUG printk(cptr %x: , cptr); ptr = (unsigned char *) cptr; @@ -713,10 +710,10 @@ static void setup_mailboxes(int bse, struct Scsi_Host *shpnt) for (i = 0; i AHA1542_MAILBOXES; i++) { mb[i].status = mb[AHA1542_MAILBOXES + i].status = 0; - any2scsi(mb[i].ccbptr, SCSI_BUF_PA(ccb[i])); + any2scsi(mb[i].ccbptr, isa_virt_to_bus(ccb[i])); }; aha1542_intr_reset(bse);/* reset interrupts, so they don't block */ - any2scsi((cmd + 2), SCSI_BUF_PA(mb)); + any2scsi((cmd + 2), isa_virt_to_bus(mb)); aha1542_out(bse, cmd, 5); WAIT(INTRFLAGS(bse), INTRMASK, HACC, 0); while (0) { @@ -1139,7 +1136,7 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt) HOSTDATA(SCpnt-device-host)-aha1542_last_mbo_used = mbo; spin_unlock_irqrestore(aha1542_lock, flags); - any2scsi(mb[mbo].ccbptr, SCSI_BUF_PA(ccb[mbo])); /* This gets trashed for some reason */ + any2scsi(mb[mbo].ccbptr, isa_virt_to_bus(ccb[mbo])); /* This gets trashed for some reason */ memset(ccb[mbo], 0, sizeof(struct ccb)); @@ -1328,8 +1325,8 @@ static struct scsi_host_template driver_template = { .bios_param = aha1542_biosparam, .can_queue = AHA1542_MAILBOXES, .this_id= 7, - .sg_tablesize = AHA1542_SCATTER, - .cmd_per_lun= AHA1542_CMDLUN, + .sg_tablesize = 16, + .cmd_per_lun= 1, .unchecked_isa_dma = 1, .use_clustering = ENABLE_CLUSTERING, }; diff --git a/drivers/scsi/aha1542.h b/drivers/scsi/aha1542.h index af91125..812a406 100644 --- a/drivers/scsi/aha1542.h +++ b/drivers/scsi/aha1542.h @@ -138,7 +138,5 @@ static int aha1542_biosparam(struct scsi_device *, struct block_device *, sector_t, int *); #define AHA1542_MAILBOXES 8 -#define AHA1542_SCATTER 16 -#define AHA1542_CMDLUN 1 #endif -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 04/36] aha1542: Remove HOSTDATA macro
Remove HOSTDATA macro and use shost_priv instead Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 114 +++- 1 file changed, 55 insertions(+), 59 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 197480d..ebf54b5 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -118,8 +118,6 @@ struct aha1542_hostdata { struct ccb ccb[AHA1542_MAILBOXES]; }; -#define HOSTDATA(host) ((struct aha1542_hostdata *) host-hostdata) - static DEFINE_SPINLOCK(aha1542_lock); @@ -382,6 +380,7 @@ static irqreturn_t do_aha1542_intr_handle(int dummy, void *dev_id) /* A high level interrupt handler */ static void aha1542_intr_handle(struct Scsi_Host *shost) { + struct aha1542_hostdata *aha1542 = shost_priv(shost); void (*my_done) (Scsi_Cmnd *) = NULL; int errstatus, mbi, mbo, mbistatus; int number_serviced; @@ -389,11 +388,8 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) Scsi_Cmnd *SCtmp; int flag; int needs_restart; - struct mailbox *mb; - struct ccb *ccb; - - mb = HOSTDATA(shost)-mb; - ccb = HOSTDATA(shost)-ccb; + struct mailbox *mb = aha1542-mb; + struct ccb *ccb = aha1542-ccb; #ifdef DEBUG { @@ -435,7 +431,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) aha1542_intr_reset(shost-io_port); spin_lock_irqsave(aha1542_lock, flags); - mbi = HOSTDATA(shost)-aha1542_last_mbi_used + 1; + mbi = aha1542-aha1542_last_mbi_used + 1; if (mbi = 2 * AHA1542_MAILBOXES) mbi = AHA1542_MAILBOXES; @@ -445,7 +441,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) mbi++; if (mbi = 2 * AHA1542_MAILBOXES) mbi = AHA1542_MAILBOXES; - } while (mbi != HOSTDATA(shost)-aha1542_last_mbi_used); + } while (mbi != aha1542-aha1542_last_mbi_used); if (mb[mbi].status == 0) { spin_unlock_irqrestore(aha1542_lock, flags); @@ -462,7 +458,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) mbo = (scsi2int(mb[mbi].ccbptr) - (isa_virt_to_bus(ccb[0]))) / sizeof(struct ccb); mbistatus = mb[mbi].status; mb[mbi].status = 0; - HOSTDATA(shost)-aha1542_last_mbi_used = mbi; + aha1542-aha1542_last_mbi_used = mbi; spin_unlock_irqrestore(aha1542_lock, flags); #ifdef DEBUG @@ -480,7 +476,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) printk(KERN_DEBUG ...done %d %d\n, mbo, mbi); #endif - SCtmp = HOSTDATA(shost)-SCint[mbo]; + SCtmp = aha1542-SCint[mbo]; if (!SCtmp || !SCtmp-scsi_done) { printk(KERN_WARNING aha1542_intr_handle: Unexpected interrupt\n); @@ -533,8 +529,8 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) } DEB(if (errstatus) printk(aha1542_intr_handle: returning %6x\n, errstatus)); SCtmp-result = errstatus; - HOSTDATA(shost)-SCint[mbo] = NULL; /* This effectively frees up the mailbox slot, as - far as queuecommand is concerned */ + aha1542-SCint[mbo] = NULL; /* This effectively frees up the mailbox slot, as + far as queuecommand is concerned */ my_done(SCtmp); number_serviced++; }; @@ -542,6 +538,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) { + struct aha1542_hostdata *aha1542 = shost_priv(SCpnt-device-host); unchar ahacmd = CMD_START_SCSI; unchar direction; unchar *cmd = (unchar *) SCpnt-cmnd; @@ -550,14 +547,11 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd * unsigned long flags; int bufflen = scsi_bufflen(SCpnt); int mbo; - struct mailbox *mb; - struct ccb *ccb; + struct mailbox *mb = aha1542-mb; + struct ccb *ccb = aha1542-ccb; DEB(int i); - mb = HOSTDATA(SCpnt-device-host)-mb; - ccb = HOSTDATA(SCpnt-device-host)-ccb; - DEB(if (target 1) { SCpnt-result = DID_TIME_OUT 16; done(SCpnt); return 0; @@ -593,25 +587,25 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd * is how the host adapter will scan for them */ spin_lock_irqsave(aha1542_lock, flags); - mbo = HOSTDATA(SCpnt-device-host)-aha1542_last_mbo_used + 1; + mbo = aha1542-aha1542_last_mbo_used + 1;
[PATCH 08/36] aha1542: remove empty aha1542_stat
Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 16 +--- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index af1e8fa..ebc5476 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -154,12 +154,6 @@ static inline void aha1542_intr_reset(u16 base) } \ } -static void aha1542_stat(void) -{ -/* int s = inb(STATUS), i = inb(INTRFLAGS); - printk(status=%x intrflags=%x\n, s, i, WAITnexttimeout-WAITtimeout); */ -} - /* This is a bit complicated, but we need to make sure that an interrupt routine does not send something out while we are in the middle of this. Fortunately, it is only at boot time that multi-byte messages @@ -196,7 +190,6 @@ fail: if (got_lock) spin_unlock_irqrestore(aha1542_lock, flags); printk(KERN_ERR aha1542_out failed(%d): , len + 1); - aha1542_stat(); return 1; } @@ -217,7 +210,6 @@ static int aha1542_in(unsigned int base, u8 *cmdp, int len) fail: spin_unlock_irqrestore(aha1542_lock, flags); printk(KERN_ERR aha1542_in failed(%d): , len + 1); - aha1542_stat(); return 1; } @@ -590,7 +582,6 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd * printk(KERN_DEBUG aha1542_queuecommand: dev %d cmd %02x pos %d len %d , target, *cmd, i, bufflen); else printk(KERN_DEBUG aha1542_command: dev %d cmd %02x pos %d len %d , target, *cmd, i, bufflen); - aha1542_stat(); printk(KERN_DEBUG aha1542_queuecommand: dumping scsi cmd:); for (i = 0; i SCpnt-cmd_len; i++) printk(%02x , cmd[i]); @@ -691,12 +682,10 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd * #endif if (done) { - DEB(printk(aha1542_queuecommand: now waiting for interrupt ); - aha1542_stat()); + DEB(printk(aha1542_queuecommand: now waiting for interrupt )); SCpnt-scsi_done = done; mb[mbo].status = 1; aha1542_out(SCpnt-device-host-io_port, ahacmd, 1); /* start scsi command */ - DEB(aha1542_stat()); } else printk(aha1542_queuecommand: done can't be NULL\n); @@ -1017,11 +1006,8 @@ fail: printk(, DMA priority %d, dma_chan); printk(\n); - DEB(aha1542_stat()); setup_mailboxes(base_io, shpnt); - DEB(aha1542_stat()); - DEB(printk(aha1542_detect: enable interrupt channel %d\n, irq_level)); spin_lock_irqsave(aha1542_lock, flags); if (request_irq(irq_level, do_aha1542_intr_handle, 0, -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 05/36] aha1542: Convert aha1542_intr_reset to function
Convert aha1542_intr_reset macro to inline function Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c |5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index ebf54b5..2a6308f 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -128,7 +128,10 @@ static void setup_mailboxes(int base_io, struct Scsi_Host *shpnt); static int aha1542_restart(struct Scsi_Host *shost); static void aha1542_intr_handle(struct Scsi_Host *shost); -#define aha1542_intr_reset(base) outb(IRST, CONTROL(base)) +static inline void aha1542_intr_reset(u16 base) +{ + outb(IRST, CONTROL(base)); +} #define WAIT(port, mask, allof, noneof) \ { register int WAITbits; \ -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/36] aha1542: Various improvements
Hello, this patch series updates aha1542 driver to not use deprecated initialization, removes dead code, ugly macros and simplifies the code. No major CodingStyle fixes yet. Tested on AHA-1542B. aha1542.c | 1687 +++--- aha1542.h | 136 +--- 2 files changed, 583 insertions(+), 1240 deletions(-) -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] hpsa: correct compiler warnings introduced by hpsa-add-local-workqueue patch
Correct compiler warning introduced by hpsa-add-local-workqueue patch 6636e7f455b33b957c5ee016daa6de46148026ab hpsa: Use local workqueues instead of system workqueues Suggested-by: Kees Cook keesc...@chromium.org Reviewed-by: Scott Teel scott.t...@pmcs.com Reviewed-by: Webb Scales web...@hp.com Signed-off-by: Don Brace don.br...@pmcs.com --- drivers/scsi/hpsa.c |4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 95d581c..a1cfbd3 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -6831,10 +6831,8 @@ static struct workqueue_struct *hpsa_create_controller_wq(struct ctlr_info *h, char *name) { struct workqueue_struct *wq = NULL; - char wq_name[20]; - snprintf(wq_name, sizeof(wq_name), %s_%d_hpsa, name, h-ctlr); - wq = alloc_ordered_workqueue(wq_name, 0); + wq = alloc_ordered_workqueue(%s_%d_hpsa, 0, name, h-ctlr); if (!wq) dev_err(h-pdev-dev, failed to create %s workqueue\n, name); -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/4] SCSI-QLA4...: Less function calls in qla4xxx_is_session_exists() after error detection
From: Markus Elfring elfr...@users.sourceforge.net Date: Fri, 6 Feb 2015 21:14:40 +0100 The vfree() function was called in two cases by the qla4xxx_is_session_exists() function during error handling even if the passed variables fw_tddb and tmp_tddb contained still a null pointer. * This implementation detail could be improved by adjustments for jump labels. * Let us return immediately after the first failed function call according to the current Linux coding style convention. Signed-off-by: Markus Elfring elfr...@users.sourceforge.net --- drivers/scsi/qla4xxx/ql4_os.c | 17 - 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 2a00fd3..a7ca479 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -6327,17 +6327,15 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, uint32_t *index) { struct ddb_entry *ddb_entry; - struct ql4_tuple_ddb *fw_tddb = NULL; - struct ql4_tuple_ddb *tmp_tddb = NULL; int idx; int ret = QLA_ERROR; + struct ql4_tuple_ddb *tmp_tddb; + struct ql4_tuple_ddb *fw_tddb = vzalloc(sizeof(*fw_tddb)); - fw_tddb = vzalloc(sizeof(*fw_tddb)); if (!fw_tddb) { DEBUG2(ql4_printk(KERN_WARNING, ha, Memory Allocation failed.\n)); - ret = QLA_SUCCESS; - goto exit_check; + return QLA_SUCCESS; } tmp_tddb = vzalloc(sizeof(*tmp_tddb)); @@ -6345,7 +6343,7 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, DEBUG2(ql4_printk(KERN_WARNING, ha, Memory Allocation failed.\n)); ret = QLA_SUCCESS; - goto exit_check; + goto free_fw; } qla4xxx_convert_param_ddb(fw_ddb_entry, fw_tddb, NULL); @@ -6360,13 +6358,14 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, ret = QLA_SUCCESS; /* found */ if (index != NULL) *index = idx; - goto exit_check; + goto free_tmp; } } -exit_check: - vfree(fw_tddb); +free_tmp: vfree(tmp_tddb); +free_fw: + vfree(fw_tddb); return ret; } -- 2.2.2 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 21/36] aha1542: Simplify aha1542_biosparam
Simplify aha1542_biosparam, use sector_div, remove unused BIOS_TRANSLATION_1632. Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 21 - 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index d151913..1615865 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -78,7 +78,6 @@ static int dma_speed[MAXBOARDS] = { -1, -1, -1, -1 }; module_param_array(dma_speed, int, NULL, 0); MODULE_PARM_DESC(dma_speed, DMA speed [MB/s] (5,6,7,8,10, default=-1 [by jumper])); -#define BIOS_TRANSLATION_1632 0/* Used by some old 1542A boards */ #define BIOS_TRANSLATION_6432 1/* Default case these days */ #define BIOS_TRANSLATION_25563 2 /* Big disk case */ @@ -1048,24 +1047,20 @@ static int aha1542_host_reset(Scsi_Cmnd *SCpnt) } static int aha1542_biosparam(struct scsi_device *sdev, - struct block_device *bdev, sector_t capacity, int *ip) + struct block_device *bdev, sector_t capacity, int geom[]) { struct aha1542_hostdata *aha1542 = shost_priv(sdev-host); - int translation_algorithm; - int size = capacity; - translation_algorithm = aha1542-bios_translation; - - if ((size 11) 1024 translation_algorithm == BIOS_TRANSLATION_25563) { + if (capacity = 0x20 + aha1542-bios_translation == BIOS_TRANSLATION_25563) { /* Please verify that this is the same as what DOS returns */ - ip[0] = 255; - ip[1] = 63; - ip[2] = size / 255 / 63; + geom[0] = 255; /* heads */ + geom[1] = 63; /* sectors */ } else { - ip[0] = 64; - ip[1] = 32; - ip[2] = size 11; + geom[0] = 64; /* heads */ + geom[1] = 32; /* sectors */ } + geom[2] = sector_div(capacity, geom[0] * geom[1]); /* cylinders */ return 0; } -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 14/36] aha1542: remove useless code from aha1542_test_port
Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 15 +-- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index af2c69e..29ddcc9 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -271,7 +271,6 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) u8 inquiry_result[4]; u8 *cmdp; int len; - volatile int debug = 0; /* Quick and dirty test for presence of the card. */ if (inb(STATUS(bse)) == 0xff) @@ -279,8 +278,6 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) /* Reset the adapter. I ought to make a hard reset, but it's not really necessary */ - /* DEB(printk(aha1542_test_port called \n)); */ - /* In case some other card was probing here, reset interrupts */ aha1542_intr_reset(bse);/* reset interrupts, so they don't block */ @@ -288,23 +285,19 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) mdelay(20); /* Wait a little bit for things to settle down. */ - debug = 1; /* Expect INIT and IDLE, any of the others are bad */ if (!wait_mask(STATUS(bse), STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) return 0; - debug = 2; /* Shouldn't have generated any interrupts during reset */ if (inb(INTRFLAGS(bse)) INTRMASK) return 0; - /* Perform a host adapter inquiry instead so we do not need to set up the mailboxes ahead of time */ aha1542_outb(bse, CMD_INQUIRY); - debug = 3; len = 4; cmdp = inquiry_result[0]; @@ -314,24 +307,18 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) *cmdp++ = inb(DATA(bse)); } - debug = 8; /* Reading port should reset DF */ if (inb(STATUS(bse)) DF) return 0; - debug = 9; /* When HACC, command is completed, and we're though testing */ if (!wait_mask(INTRFLAGS(bse), HACC, HACC, 0, 0)) return 0; - /* now initialize adapter */ - debug = 10; /* Clear interrupts */ outb(IRST, CONTROL(bse)); - debug = 11; - - return debug; /* 1 = ok */ + return 1; } static int aha1542_restart(struct Scsi_Host *shost) -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/4] SCSI-QLA4...: Less function calls in qla4xxx_is_flash_ddb_exists() after error detection
From: Markus Elfring elfr...@users.sourceforge.net Date: Fri, 6 Feb 2015 21:55:55 +0100 The vfree() function was called in two cases by the qla4xxx_is_flash_ddb_exists() function during error handling even if the passed variables fw_tddb and tmp_tddb contained still a null pointer. * This implementation detail could be improved by adjustments for jump labels. * Let us return immediately after the first failed function call according to the current Linux coding style convention. Signed-off-by: Markus Elfring elfr...@users.sourceforge.net --- drivers/scsi/qla4xxx/ql4_os.c | 19 +-- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index a7ca479..e508bc9 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -6470,16 +6470,14 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha, struct dev_db_entry *fw_ddb_entry) { struct qla_ddb_index *nt_ddb_idx, *nt_ddb_idx_tmp; - struct ql4_tuple_ddb *fw_tddb = NULL; - struct ql4_tuple_ddb *tmp_tddb = NULL; int rval, ret = QLA_ERROR; + struct ql4_tuple_ddb *tmp_tddb; + struct ql4_tuple_ddb *fw_tddb = vzalloc(sizeof(*fw_tddb)); - fw_tddb = vzalloc(sizeof(*fw_tddb)); if (!fw_tddb) { DEBUG2(ql4_printk(KERN_WARNING, ha, Memory Allocation failed.\n)); - ret = QLA_SUCCESS; - goto exit_check; + return QLA_SUCCESS; } tmp_tddb = vzalloc(sizeof(*tmp_tddb)); @@ -6487,7 +6485,7 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha, DEBUG2(ql4_printk(KERN_WARNING, ha, Memory Allocation failed.\n)); ret = QLA_SUCCESS; - goto exit_check; + goto vfree_fw; } qla4xxx_convert_param_ddb(fw_ddb_entry, fw_tddb, NULL); @@ -6498,7 +6496,7 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha, ret = qla4xxx_compare_tuple_ddb(ha, fw_tddb, tmp_tddb, true); /* found duplicate ddb */ if (ret == QLA_SUCCESS) - goto exit_check; + goto vfree_tmp; } list_for_each_entry_safe(nt_ddb_idx, nt_ddb_idx_tmp, list_nt, list) { @@ -6512,13 +6510,14 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha, else ret = QLA_SUCCESS; - goto exit_check; + goto vfree_tmp; } } -exit_check: - vfree(fw_tddb); +vfree_tmp: vfree(tmp_tddb); +vfree_fw: + vfree(fw_tddb); return ret; } -- 2.2.2 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] xen-scsiback: some modifications about code comment
From: Tao Chen boby.c...@huawei.com Signed-off-by: Tao Chen boby.c...@huawei.com --- drivers/xen/xen-scsiback.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index 3e32146..59f09fd 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c @@ -83,7 +83,7 @@ struct ids_tuple { struct v2p_entry { struct ids_tuple v; /* translate from */ - struct scsiback_tpg *tpg; /* translate to */ + struct scsiback_tpg *tpg; /* translate to */ unsigned int lun; struct kref kref; struct list_head l; @@ -525,7 +525,7 @@ static int scsiback_gnttab_data_map(struct vscsiif_request *ring_req, } } - /* free of (sgl) in fast_flush_area()*/ + /* free of (sgl) in fast_flush_area() */ pending_req-sgl = kmalloc_array(nr_segments, sizeof(struct scatterlist), GFP_KERNEL); if (!pending_req-sgl) @@ -1084,7 +1084,7 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op, } } break; - /*When it is necessary, processing is added here.*/ + /* When it is necessary, processing is added here. */ default: break; } @@ -1475,8 +1475,8 @@ static u32 scsiback_tpg_get_inst_index(struct se_portal_group *se_tpg) static int scsiback_check_stop_free(struct se_cmd *se_cmd) { /* -* Do not release struct se_cmd's containing a valid TMR -* pointer. These will be released directly in scsiback_device_action() +* Do not release struct se_cmd's containing a valid TMR pointer. +* These will be released directly in scsiback_device_action() * with transport_generic_free_cmd(). */ if (se_cmd-se_cmd_flags SCF_SCSI_TMR_CDB) @@ -1642,7 +1642,7 @@ static int scsiback_make_nexus(struct scsiback_tpg *tpg, return -ENOMEM; } /* -* Initialize the struct se_session pointer +* Initialize the struct se_session pointer */ tv_nexus-tvn_se_sess = transport_init_session(TARGET_PROT_NORMAL); if (IS_ERR(tv_nexus-tvn_se_sess)) { @@ -1759,7 +1759,7 @@ static ssize_t scsiback_tpg_store_nexus(struct se_portal_group *se_tpg, unsigned char i_port[VSCSI_NAMELEN], *ptr, *port_ptr; int ret; /* -* Shutdown the active I_T nexus if 'NULL' is passed.. +* Shutdown the active I_T nexus if 'NULL' is passed. */ if (!strncmp(page, NULL, 4)) { ret = scsiback_drop_nexus(tpg); @@ -1930,7 +1930,7 @@ static void scsiback_drop_tpg(struct se_portal_group *se_tpg) */ scsiback_drop_nexus(tpg); /* -* Deregister the se_tpg from TCM.. +* Deregister the se_tpg from TCM. */ core_tpg_deregister(se_tpg); kfree(tpg); -- 1.8.5 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 24/36] aha1542: Always name Scsi_Host variables sh
Make Scsi_Host variable names consistent - use sh everywhere. Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 98 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index dcc493d..7b06698 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -241,7 +241,7 @@ static int makecode(unsigned hosterr, unsigned scsierr) return scsierr | (hosterr 16); } -static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) +static int aha1542_test_port(int bse, struct Scsi_Host *sh) { u8 inquiry_result[4]; int i; @@ -293,9 +293,9 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) } /* A high level interrupt handler */ -static void aha1542_intr_handle(struct Scsi_Host *shost) +static void aha1542_intr_handle(struct Scsi_Host *sh) { - struct aha1542_hostdata *aha1542 = shost_priv(shost); + struct aha1542_hostdata *aha1542 = shost_priv(sh); void (*my_done)(struct scsi_cmnd *) = NULL; int errstatus, mbi, mbo, mbistatus; int number_serviced; @@ -307,7 +307,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) #ifdef DEBUG { - flag = inb(INTRFLAGS(shost-io_port)); + flag = inb(INTRFLAGS(sh-io_port)); printk(KERN_DEBUG aha1542_intr_handle: ); if (!(flag ANYINTR)) printk(no interrupt?); @@ -319,13 +319,13 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) printk(HACC ); if (flag SCRD) printk(SCRD ); - printk(status %02x\n, inb(STATUS(shost-io_port))); + printk(status %02x\n, inb(STATUS(sh-io_port))); }; #endif number_serviced = 0; while (1 == 1) { - flag = inb(INTRFLAGS(shost-io_port)); + flag = inb(INTRFLAGS(sh-io_port)); /* Check for unusual interrupts. If any of these happen, we should probably do something special, but for now just printing a message @@ -339,7 +339,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) if (flag SCRD) printk(SCRD ); } - aha1542_intr_reset(shost-io_port); + aha1542_intr_reset(sh-io_port); spin_lock_irqsave(aha1542_lock, flags); mbi = aha1542-aha1542_last_mbi_used + 1; @@ -447,11 +447,11 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) static irqreturn_t do_aha1542_intr_handle(int dummy, void *dev_id) { unsigned long flags; - struct Scsi_Host *shost = dev_id; + struct Scsi_Host *sh = dev_id; - spin_lock_irqsave(shost-host_lock, flags); - aha1542_intr_handle(shost); - spin_unlock_irqrestore(shost-host_lock, flags); + spin_lock_irqsave(sh-host_lock, flags); + aha1542_intr_handle(sh); + spin_unlock_irqrestore(sh-host_lock, flags); return IRQ_HANDLED; } @@ -605,9 +605,9 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct static DEF_SCSI_QCMD(aha1542_queuecommand) /* Initialize mailboxes */ -static void setup_mailboxes(int bse, struct Scsi_Host *shpnt) +static void setup_mailboxes(int bse, struct Scsi_Host *sh) { - struct aha1542_hostdata *aha1542 = shost_priv(shpnt); + struct aha1542_hostdata *aha1542 = shost_priv(sh); int i; struct mailbox *mb = aha1542-mb; struct ccb *ccb = aha1542-ccb; @@ -817,7 +817,7 @@ fail: static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct device *pdev, int indx) { unsigned int base_io = io[indx]; - struct Scsi_Host *shpnt; + struct Scsi_Host *sh; struct aha1542_hostdata *aha1542; if (base_io == 0) @@ -826,80 +826,80 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct if (!request_region(base_io, AHA1542_REGION_SIZE, aha1542)) return NULL; - shpnt = scsi_host_alloc(tpnt, sizeof(struct aha1542_hostdata)); - if (!shpnt) + sh = scsi_host_alloc(tpnt, sizeof(struct aha1542_hostdata)); + if (!sh) goto release; - aha1542 = shost_priv(shpnt); + aha1542 = shost_priv(sh); - if (!aha1542_test_port(base_io, shpnt)) + if (!aha1542_test_port(base_io, sh)) goto unregister; aha1542_set_bus_times(indx); if (aha1542_query(base_io, aha1542-bios_translation)) goto unregister; - if (aha1542_getconfig(base_io, shpnt-irq, shpnt-dma_channel, shpnt-this_id) == -1) + if (aha1542_getconfig(base_io, sh-irq, sh-dma_channel, sh-this_id) == -1) goto unregister; - printk(KERN_INFO Adaptec
[PATCH 31/36] aha1542: remove DEB macro and simplify debug code
Remove DEB macro and join ifdef DEBUG blocks Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 56 +++- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index d607f59..6d4532c 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -24,11 +24,6 @@ #include scsi/scsi_host.h #include aha1542.h -#ifdef DEBUG -#define DEB(x) x -#else -#define DEB(x) -#endif #define MAXBOARDS 4 static bool isapnp = 1; @@ -195,7 +190,9 @@ static int makecode(unsigned hosterr, unsigned scsierr) case 0x1a: /* Invalid CCB or Segment List Parameter-A segment list with a zero length segment or invalid segment list boundaries was received. A CCB parameter was invalid. */ - DEB(printk(Aha1542: %x %x\n, hosterr, scsierr)); +#ifdef DEBUG + printk(Aha1542: %x %x\n, hosterr, scsierr); +#endif hosterr = DID_ERROR;/* Couldn't find any better */ break; @@ -340,11 +337,9 @@ static void aha1542_intr_handle(struct Scsi_Host *sh) spin_unlock_irqrestore(aha1542_lock, flags); #ifdef DEBUG - { - if (ccb[mbo].tarstat | ccb[mbo].hastat) - shost_printk(KERN_DEBUG, sh, aha1542_command: returning %x (status %d)\n, - ccb[mbo].tarstat + ((int) ccb[mbo].hastat 16), mb[mbi].status); - }; + if (ccb[mbo].tarstat | ccb[mbo].hastat) + shost_printk(KERN_DEBUG, sh, aha1542_command: returning %x (status %d)\n, + ccb[mbo].tarstat + ((int) ccb[mbo].hastat 16), mb[mbi].status); #endif if (mbistatus == 3) @@ -386,26 +381,17 @@ static void aha1542_intr_handle(struct Scsi_Host *sh) if (errstatus) shost_printk(KERN_DEBUG, sh, (aha1542 error:%x %x %x) , errstatus, ccb[mbo].hastat, ccb[mbo].tarstat); -#endif - if (ccb[mbo].tarstat == 2) { -#ifdef DEBUG int i; -#endif - DEB(printk(aha1542_intr_handle: sense:)); -#ifdef DEBUG + + printk(aha1542_intr_handle: sense:); for (i = 0; i 12; i++) printk(%02x , ccb[mbo].cdb[ccb[mbo].cdblen + i]); printk(\n); -#endif - /* - DEB(printk(aha1542_intr_handle: buf:)); - for (i = 0; i bufflen; i++) - printk(%02x , ((unchar *)buff)[i]); - printk(\n); -*/ } - DEB(if (errstatus) printk(aha1542_intr_handle: returning %6x\n, errstatus)); + if (errstatus) + printk(aha1542_intr_handle: returning %6x\n, errstatus); +#endif tmp_cmd-result = errstatus; aha1542-int_cmds[mbo] = NULL; /* This effectively frees up the mailbox slot, as far as queuecommand is concerned */ @@ -438,15 +424,15 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct int mbo; struct mailbox *mb = aha1542-mb; struct ccb *ccb = aha1542-ccb; +#ifdef DEBUG + int i; - DEB(int i); - - DEB(if (target 1) { - cmd-result = DID_TIME_OUT 16; - done(cmd); return 0; - } - ); - + if (target 1) { + cmd-result = DID_TIME_OUT 16; + done(cmd); + return 0; + } +#endif if (*cmd-cmnd == REQUEST_SENSE) { /* Don't do the command - we have the sense data already */ cmd-result = 0; @@ -564,7 +550,9 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct #endif if (done) { - DEB(printk(aha1542_queuecommand: now waiting for interrupt )); +#ifdef DEBUG + printk(aha1542_queuecommand: now waiting for interrupt ); +#endif cmd-scsi_done = done; mb[mbo].status = 1; aha1542_outb(cmd-device-host-io_port, CMD_START_SCSI); -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 17/36] aha1542: split out code from aha1542_hw_init
Split out bus times related block of aha1542_hw_init into separate function aha1542_set_bus_times. Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 65 ++-- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 4bfba45..b8e4952 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -867,6 +867,40 @@ static int __init do_setup(char *str) __setup(aha1542=,do_setup); #endif +/* Set the Bus on/off-times as not to ruin floppy performance */ +static void aha1542_set_bus_times(int indx) +{ + unsigned int base_io = bases[indx]; + u8 oncmd[] = {CMD_BUSON_TIME, 7}; + u8 offcmd[] = {CMD_BUSOFF_TIME, 5}; + + if (setup_called[indx]) { + oncmd[1] = setup_buson[indx]; + offcmd[1] = setup_busoff[indx]; + } + aha1542_intr_reset(base_io); + aha1542_out(base_io, oncmd, 2); + if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) + goto fail; + aha1542_intr_reset(base_io); + aha1542_out(base_io, offcmd, 2); + if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) + goto fail; + if (setup_dmaspeed[indx] = 0) { + u8 dmacmd[] = {CMD_DMASPEED, 0}; + dmacmd[1] = setup_dmaspeed[indx]; + aha1542_intr_reset(base_io); + aha1542_out(base_io, dmacmd, 2); + if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) + goto fail; + } + aha1542_intr_reset(base_io); + return; +fail: + printk(KERN_ERR setting bus on/off-time failed\n); + aha1542_intr_reset(base_io); +} + /* return non-zero on detection */ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct device *pdev, int indx) { @@ -897,37 +931,8 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct base_io = bases[indx]; - /* Set the Bus on/off-times as not to ruin floppy performance */ - { - u8 oncmd[] = {CMD_BUSON_TIME, 7}; - u8 offcmd[] = {CMD_BUSOFF_TIME, 5}; + aha1542_set_bus_times(indx); - if (setup_called[indx]) { - oncmd[1] = setup_buson[indx]; - offcmd[1] = setup_busoff[indx]; - } - aha1542_intr_reset(base_io); - aha1542_out(base_io, oncmd, 2); - if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) - goto fail; - aha1542_intr_reset(base_io); - aha1542_out(base_io, offcmd, 2); - if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) - goto fail; - if (setup_dmaspeed[indx] = 0) { - u8 dmacmd[] = {CMD_DMASPEED, 0}; - dmacmd[1] = setup_dmaspeed[indx]; - aha1542_intr_reset(base_io); - aha1542_out(base_io, dmacmd, 2); - if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) - goto fail; - } - while (0) { -fail: - printk(KERN_ERR aha1542_detect: setting bus on/off-time failed\n); - } - aha1542_intr_reset(base_io); - } if (aha1542_query(base_io, trans)) goto unregister; -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 22/36] aha1542: clean up cmd variables
Make sure that there's no variable named cmd Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 53 ++-- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 1615865..dbe4659 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -124,7 +124,7 @@ static inline bool wait_mask(u16 port, u8 mask, u8 allof, u8 noneof, int timeout routine does not send something out while we are in the middle of this. Fortunately, it is only at boot time that multi-byte messages are ever sent. */ -static int aha1542_outb(unsigned int base, u8 cmd) +static int aha1542_outb(unsigned int base, u8 val) { unsigned long flags; @@ -138,13 +138,13 @@ static int aha1542_outb(unsigned int base, u8 cmd) spin_unlock_irqrestore(aha1542_lock, flags); continue; } - outb(cmd, DATA(base)); + outb(val, DATA(base)); spin_unlock_irqrestore(aha1542_lock, flags); return 0; } } -static int aha1542_out(unsigned int base, u8 *cmdp, int len) +static int aha1542_out(unsigned int base, u8 *buf, int len) { unsigned long flags; @@ -155,7 +155,7 @@ static int aha1542_out(unsigned int base, u8 *cmdp, int len) printk(KERN_ERR aha1542_out failed(%d): , len + 1); return 1; } - outb(*cmdp++, DATA(base)); + outb(*buf++, DATA(base)); } spin_unlock_irqrestore(aha1542_lock, flags); if (!wait_mask(INTRFLAGS(base), INTRMASK, HACC, 0, 0)) @@ -167,7 +167,7 @@ static int aha1542_out(unsigned int base, u8 *cmdp, int len) /* Only used at boot time, so we do not need to worry about latency as much here */ -static int aha1542_in(unsigned int base, u8 *cmdp, int len, int timeout) +static int aha1542_in(unsigned int base, u8 *buf, int len, int timeout) { unsigned long flags; @@ -179,7 +179,7 @@ static int aha1542_in(unsigned int base, u8 *cmdp, int len, int timeout) printk(KERN_ERR aha1542_in failed(%d): , len + 1); return 1; } - *cmdp++ = inb(DATA(base)); + *buf++ = inb(DATA(base)); } spin_unlock_irqrestore(aha1542_lock, flags); return 0; @@ -244,8 +244,7 @@ static int makecode(unsigned hosterr, unsigned scsierr) static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) { u8 inquiry_result[4]; - u8 *cmdp; - int len; + int i; /* Quick and dirty test for presence of the card. */ if (inb(STATUS(bse)) == 0xff) @@ -273,13 +272,10 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) aha1542_outb(bse, CMD_INQUIRY); - len = 4; - cmdp = inquiry_result[0]; - - while (len--) { + for (i = 0; i 4; i++) { if (!wait_mask(STATUS(bse), DF, DF, 0, 0)) return 0; - *cmdp++ = inb(DATA(bse)); + inquiry_result[i] = inb(DATA(bse)); } /* Reading port should reset DF */ @@ -463,7 +459,6 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd * { struct aha1542_hostdata *aha1542 = shost_priv(SCpnt-device-host); u8 direction; - u8 *cmd = (u8 *) SCpnt-cmnd; u8 target = SCpnt-device-id; u8 lun = SCpnt-device-lun; unsigned long flags; @@ -480,28 +475,28 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd * } ); - if (*cmd == REQUEST_SENSE) { + if (*SCpnt-cmnd == REQUEST_SENSE) { /* Don't do the command - we have the sense data already */ SCpnt-result = 0; done(SCpnt); return 0; } #ifdef DEBUG - if (*cmd == READ_10 || *cmd == WRITE_10) - i = xscsi2int(cmd + 2); - else if (*cmd == READ_6 || *cmd == WRITE_6) - i = scsi2int(cmd + 2); + if (*SCpnt-cmnd == READ_10 || *SCpnt-cmnd == WRITE_10) + i = xscsi2int(SCpnt-cmnd + 2); + else if (*SCpnt-cmnd == READ_6 || *SCpnt-cmnd == WRITE_6) + i = scsi2int(SCpnt-cmnd + 2); else i = -1; if (done) - printk(KERN_DEBUG aha1542_queuecommand: dev %d cmd %02x pos %d len %d , target, *cmd, i, bufflen); + printk(KERN_DEBUG aha1542_queuecommand: dev %d cmd %02x pos %d len %d , target, *SCpnt-cmnd, i, bufflen); else - printk(KERN_DEBUG aha1542_command: dev %d cmd %02x pos %d len %d , target, *cmd, i, bufflen); + printk(KERN_DEBUG aha1542_command: dev %d cmd %02x pos %d len %d , target, *SCpnt-cmnd, i, bufflen); printk(KERN_DEBUG
[PATCH 11/36] aha1542: Unify aha1542_in and aha1542_in1
Unify aha1542_in and aha1542_in1 functions, they differ only in timeout and printk. Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 33 +++-- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 0e58cef..b4ada24 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -191,34 +191,13 @@ fail: /* Only used at boot time, so we do not need to worry about latency as much here */ -static int aha1542_in(unsigned int base, u8 *cmdp, int len) +static int aha1542_in(unsigned int base, u8 *cmdp, int len, int timeout) { unsigned long flags; spin_lock_irqsave(aha1542_lock, flags); while (len--) { - if (!wait_mask(STATUS(base), DF, DF, 0, 0)) - goto fail; - *cmdp++ = inb(DATA(base)); - } - spin_unlock_irqrestore(aha1542_lock, flags); - return 0; -fail: - spin_unlock_irqrestore(aha1542_lock, flags); - printk(KERN_ERR aha1542_in failed(%d): , len + 1); - return 1; -} - -/* Similar to aha1542_in, except that we wait a very short period of time. - We use this if we know the board is alive and awake, but we are not sure - if the board will respond to the command we are about to send or not */ -static int aha1542_in1(unsigned int base, u8 *cmdp, int len) -{ - unsigned long flags; - - spin_lock_irqsave(aha1542_lock, flags); - while (len--) { - if (!wait_mask(STATUS(base), DF, DF, 0, 100)) + if (!wait_mask(STATUS(base), DF, DF, 0, timeout)) goto fail; *cmdp++ = inb(DATA(base)); } @@ -226,6 +205,8 @@ static int aha1542_in1(unsigned int base, u8 *cmdp, int len) return 0; fail: spin_unlock_irqrestore(aha1542_lock, flags); + if (timeout == 0) + printk(KERN_ERR aha1542_in failed(%d): , len + 1); return 1; } @@ -730,7 +711,7 @@ static int aha1542_getconfig(int base_io, unsigned char *irq_level, unsigned cha i = inb(DATA(base_io)); }; aha1542_out(base_io, inquiry_cmd, 1); - aha1542_in(base_io, inquiry_result, 3); + aha1542_in(base_io, inquiry_result, 3, 0); if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) goto fail; while (0) { @@ -800,7 +781,7 @@ static int aha1542_mbenable(int base) mbenable_cmd[0] = CMD_EXTBIOS; aha1542_out(base, mbenable_cmd, 1); - if (aha1542_in1(base, mbenable_result, 2)) + if (aha1542_in(base, mbenable_result, 2, 100)) return retval; if (!wait_mask(INTRFLAGS(base), INTRMASK, HACC, 0, 100)) goto fail; @@ -837,7 +818,7 @@ static int aha1542_query(int base_io, int *transl) i = inb(DATA(base_io)); }; aha1542_out(base_io, inquiry_cmd, 1); - aha1542_in(base_io, inquiry_result, 4); + aha1542_in(base_io, inquiry_result, 4, 0); if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) goto fail; while (0) { -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 10/36] aha1542: Remove WAIT and WAITd macros
Convert the ugly WAIT and WAITd macros into wait_mask function. Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 104 ++-- 1 file changed, 57 insertions(+), 47 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index ebc5476..0e58cef 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -120,39 +120,32 @@ struct aha1542_hostdata { static DEFINE_SPINLOCK(aha1542_lock); - - -#define WAITnexttimeout 300 - static inline void aha1542_intr_reset(u16 base) { outb(IRST, CONTROL(base)); } -#define WAIT(port, mask, allof, noneof) \ - { register int WAITbits; \ - register int WAITtimeout = WAITnexttimeout; \ - while (1) { \ - WAITbits = inb(port) (mask);\ - if ((WAITbits (allof)) == (allof) ((WAITbits (noneof)) == 0)) \ - break; \ - if (--WAITtimeout == 0) goto fail; \ - } \ - } - -/* Similar to WAIT, except we use the udelay call to regulate the - amount of time we wait. */ -#define WAITd(port, mask, allof, noneof, timeout) \ - { register int WAITbits; \ - register int WAITtimeout = timeout; \ - while (1) { \ - WAITbits = inb(port) (mask);\ - if ((WAITbits (allof)) == (allof) ((WAITbits (noneof)) == 0)) \ - break; \ - mdelay(1);\ - if (--WAITtimeout == 0) goto fail; \ - } \ - } +static inline bool wait_mask(u16 port, u8 mask, u8 allof, u8 noneof, int timeout) +{ + bool delayed = true; + + if (timeout == 0) { + timeout = 300; + delayed = false; + } + + while (1) { + u8 bits = inb(port) mask; + if ((bits allof) == allof ((bits noneof) == 0)) + break; + if (delayed) + mdelay(1); + if (--timeout == 0) + return false; + } + + return true; +} /* This is a bit complicated, but we need to make sure that an interrupt routine does not send something out while we are in the middle of this. @@ -166,7 +159,8 @@ static int aha1542_out(unsigned int base, u8 *cmdp, int len) if (len == 1) { got_lock = 0; while (1 == 1) { - WAIT(STATUS(base), CDF, 0, CDF); + if (!wait_mask(STATUS(base), CDF, 0, CDF, 0)) + goto fail; spin_lock_irqsave(aha1542_lock, flags); if (inb(STATUS(base)) CDF) { spin_unlock_irqrestore(aha1542_lock, flags); @@ -180,7 +174,8 @@ static int aha1542_out(unsigned int base, u8 *cmdp, int len) spin_lock_irqsave(aha1542_lock, flags); got_lock = 1; while (len--) { - WAIT(STATUS(base), CDF, 0, CDF); + if (!wait_mask(STATUS(base), CDF, 0, CDF, 0)) + goto fail; outb(*cmdp++, DATA(base)); } spin_unlock_irqrestore(aha1542_lock, flags); @@ -202,7 +197,8 @@ static int aha1542_in(unsigned int base, u8 *cmdp, int len) spin_lock_irqsave(aha1542_lock, flags); while (len--) { - WAIT(STATUS(base), DF, DF, 0); + if (!wait_mask(STATUS(base), DF, DF, 0, 0)) + goto fail; *cmdp++ = inb(DATA(base)); } spin_unlock_irqrestore(aha1542_lock, flags); @@ -222,7 +218,8 @@ static int aha1542_in1(unsigned int base, u8 *cmdp, int len) spin_lock_irqsave(aha1542_lock, flags); while (len--) { - WAITd(STATUS(base), DF, DF, 0, 100); + if (!wait_mask(STATUS(base), DF, DF, 0, 100)) + goto fail; *cmdp++ = inb(DATA(base)); } spin_unlock_irqrestore(aha1542_lock, flags); @@ -313,7 +310,8 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) debug = 1; /* Expect INIT and IDLE, any of the others are bad */ - WAIT(STATUS(bse), STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF); + if
[PATCH 23/36] aha1524: Use struct scsi_cmnd
Use struct scsi_cmnd instead of Scsi_Cmnd and also rename the variables to get rid of SC prefix Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 150 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index dbe4659..dcc493d 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -86,7 +86,7 @@ struct aha1542_hostdata { int bios_translation; /* Mapping bios uses - for compatibility */ int aha1542_last_mbi_used; int aha1542_last_mbo_used; - Scsi_Cmnd *SCint[AHA1542_MAILBOXES]; + struct scsi_cmnd *int_cmds[AHA1542_MAILBOXES]; struct mailbox mb[2 * AHA1542_MAILBOXES]; struct ccb ccb[AHA1542_MAILBOXES]; }; @@ -296,11 +296,11 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) static void aha1542_intr_handle(struct Scsi_Host *shost) { struct aha1542_hostdata *aha1542 = shost_priv(shost); - void (*my_done) (Scsi_Cmnd *) = NULL; + void (*my_done)(struct scsi_cmnd *) = NULL; int errstatus, mbi, mbo, mbistatus; int number_serviced; unsigned long flags; - Scsi_Cmnd *SCtmp; + struct scsi_cmnd *tmp_cmd; int flag; struct mailbox *mb = aha1542-mb; struct ccb *ccb = aha1542-ccb; @@ -383,22 +383,22 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) printk(KERN_DEBUG ...done %d %d\n, mbo, mbi); #endif - SCtmp = aha1542-SCint[mbo]; + tmp_cmd = aha1542-int_cmds[mbo]; - if (!SCtmp || !SCtmp-scsi_done) { + if (!tmp_cmd || !tmp_cmd-scsi_done) { printk(KERN_WARNING aha1542_intr_handle: Unexpected interrupt\n); printk(KERN_WARNING tarstat=%x, hastat=%x idlun=%x ccb#=%d \n, ccb[mbo].tarstat, ccb[mbo].hastat, ccb[mbo].idlun, mbo); return; } - my_done = SCtmp-scsi_done; - kfree(SCtmp-host_scribble); - SCtmp-host_scribble = NULL; + my_done = tmp_cmd-scsi_done; + kfree(tmp_cmd-host_scribble); + tmp_cmd-host_scribble = NULL; /* Fetch the sense data, and tuck it away, in the required slot. The Adaptec automatically fetches it, and there is no guarantee that we will still have it in the cdb when we come back */ if (ccb[mbo].tarstat == 2) - memcpy(SCtmp-sense_buffer, ccb[mbo].cdb[ccb[mbo].cdblen], + memcpy(tmp_cmd-sense_buffer, ccb[mbo].cdb[ccb[mbo].cdblen], SCSI_SENSE_BUFFERSIZE); @@ -435,10 +435,10 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) */ } DEB(if (errstatus) printk(aha1542_intr_handle: returning %6x\n, errstatus)); - SCtmp-result = errstatus; - aha1542-SCint[mbo] = NULL; /* This effectively frees up the mailbox slot, as + tmp_cmd-result = errstatus; + aha1542-int_cmds[mbo] = NULL; /* This effectively frees up the mailbox slot, as far as queuecommand is concerned */ - my_done(SCtmp); + my_done(tmp_cmd); number_serviced++; }; } @@ -455,14 +455,14 @@ static irqreturn_t do_aha1542_intr_handle(int dummy, void *dev_id) return IRQ_HANDLED; } -static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) +static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct scsi_cmnd *)) { - struct aha1542_hostdata *aha1542 = shost_priv(SCpnt-device-host); + struct aha1542_hostdata *aha1542 = shost_priv(cmd-device-host); u8 direction; - u8 target = SCpnt-device-id; - u8 lun = SCpnt-device-lun; + u8 target = cmd-device-id; + u8 lun = cmd-device-lun; unsigned long flags; - int bufflen = scsi_bufflen(SCpnt); + int bufflen = scsi_bufflen(cmd); int mbo; struct mailbox *mb = aha1542-mb; struct ccb *ccb = aha1542-ccb; @@ -470,33 +470,33 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd * DEB(int i); DEB(if (target 1) { - SCpnt-result = DID_TIME_OUT 16; - done(SCpnt); return 0; + cmd-result = DID_TIME_OUT 16; + done(cmd); return 0; } ); - if (*SCpnt-cmnd == REQUEST_SENSE) { + if (*cmd-cmnd == REQUEST_SENSE) { /* Don't do the command - we have the sense data already */ - SCpnt-result = 0; - done(SCpnt); + cmd-result = 0; + done(cmd);
[PATCH 15/36] aha1542: Remove aha1542_restart
aha1542_restart does nothing (except useless printk), remove it Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 28 ++-- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 29ddcc9..67fdd2f 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -321,22 +321,6 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) return 1; } -static int aha1542_restart(struct Scsi_Host *shost) -{ - struct aha1542_hostdata *aha1542 = shost_priv(shost); - int i; - int count = 0; - - for (i = 0; i AHA1542_MAILBOXES; i++) - if (aha1542-SCint[i] - !(aha1542-SCint[i]-device-soft_reset)) { - count++; - } - printk(KERN_DEBUG Potential to restart %d stalled commands...\n, count); - - return 0; -} - /* A high level interrupt handler */ static void aha1542_intr_handle(struct Scsi_Host *shost) { @@ -347,7 +331,6 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) unsigned long flags; Scsi_Cmnd *SCtmp; int flag; - int needs_restart; struct mailbox *mb = aha1542-mb; struct ccb *ccb = aha1542-ccb; @@ -369,7 +352,6 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) }; #endif number_serviced = 0; - needs_restart = 0; while (1 == 1) { flag = inb(INTRFLAGS(shost-io_port)); @@ -383,10 +365,8 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) printk(MBOF ); if (flag HACC) printk(HACC ); - if (flag SCRD) { - needs_restart = 1; + if (flag SCRD) printk(SCRD ); - } } aha1542_intr_reset(shost-io_port); @@ -406,12 +386,8 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) if (mb[mbi].status == 0) { spin_unlock_irqrestore(aha1542_lock, flags); /* Hmm, no mail. Must have read it the last time around */ - if (!number_serviced !needs_restart) + if (!number_serviced) printk(KERN_WARNING aha1542.c: interrupt received, but no mail.\n); - /* We detected a reset. Restart all pending commands for - devices that use the hard reset option */ - if (needs_restart) - aha1542_restart(shost); return; }; -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 30/36] aha1542: Use shost_printk instead of printk
Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 67 +++- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 6e44a7f..d607f59 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -105,10 +105,8 @@ static int aha1542_outb(unsigned int base, u8 val) unsigned long flags; while (1) { - if (!wait_mask(STATUS(base), CDF, 0, CDF, 0)) { - printk(KERN_ERR aha1542_outb failed); + if (!wait_mask(STATUS(base), CDF, 0, CDF, 0)) return 1; - } spin_lock_irqsave(aha1542_lock, flags); if (inb(STATUS(base)) CDF) { spin_unlock_irqrestore(aha1542_lock, flags); @@ -128,7 +126,6 @@ static int aha1542_out(unsigned int base, u8 *buf, int len) while (len--) { if (!wait_mask(STATUS(base), CDF, 0, CDF, 0)) { spin_unlock_irqrestore(aha1542_lock, flags); - printk(KERN_ERR aha1542_out failed(%d): , len + 1); return 1; } outb(*buf++, DATA(base)); @@ -151,8 +148,6 @@ static int aha1542_in(unsigned int base, u8 *buf, int len, int timeout) while (len--) { if (!wait_mask(STATUS(base), DF, DF, 0, timeout)) { spin_unlock_irqrestore(aha1542_lock, flags); - if (timeout == 0) - printk(KERN_ERR aha1542_in failed(%d): , len + 1); return 1; } *buf++ = inb(DATA(base)); @@ -284,7 +279,7 @@ static void aha1542_intr_handle(struct Scsi_Host *sh) #ifdef DEBUG { flag = inb(INTRFLAGS(sh-io_port)); - printk(KERN_DEBUG aha1542_intr_handle: ); + shost_printk(KERN_DEBUG, sh, aha1542_intr_handle: ); if (!(flag ANYINTR)) printk(no interrupt?); if (flag MBIF) @@ -334,7 +329,7 @@ static void aha1542_intr_handle(struct Scsi_Host *sh) spin_unlock_irqrestore(aha1542_lock, flags); /* Hmm, no mail. Must have read it the last time around */ if (!number_serviced) - printk(KERN_WARNING aha1542.c: interrupt received, but no mail.\n); + shost_printk(KERN_WARNING, sh, interrupt received, but no mail.\n); return; }; @@ -347,7 +342,7 @@ static void aha1542_intr_handle(struct Scsi_Host *sh) #ifdef DEBUG { if (ccb[mbo].tarstat | ccb[mbo].hastat) - printk(KERN_DEBUG aha1542_command: returning %x (status %d)\n, + shost_printk(KERN_DEBUG, sh, aha1542_command: returning %x (status %d)\n, ccb[mbo].tarstat + ((int) ccb[mbo].hastat 16), mb[mbi].status); }; #endif @@ -356,14 +351,14 @@ static void aha1542_intr_handle(struct Scsi_Host *sh) continue; /* Aborted command not found */ #ifdef DEBUG - printk(KERN_DEBUG ...done %d %d\n, mbo, mbi); + shost_printk(KERN_DEBUG, sh, ...done %d %d\n, mbo, mbi); #endif tmp_cmd = aha1542-int_cmds[mbo]; if (!tmp_cmd || !tmp_cmd-scsi_done) { - printk(KERN_WARNING aha1542_intr_handle: Unexpected interrupt\n); - printk(KERN_WARNING tarstat=%x, hastat=%x idlun=%x ccb#=%d \n, ccb[mbo].tarstat, + shost_printk(KERN_WARNING, sh, Unexpected interrupt\n); + shost_printk(KERN_WARNING, sh, tarstat=%x, hastat=%x idlun=%x ccb#=%d\n, ccb[mbo].tarstat, ccb[mbo].hastat, ccb[mbo].idlun, mbo); return; } @@ -389,7 +384,7 @@ static void aha1542_intr_handle(struct Scsi_Host *sh) #ifdef DEBUG if (errstatus) - printk(KERN_DEBUG (aha1542 error:%x %x %x) , errstatus, + shost_printk(KERN_DEBUG, sh, (aha1542 error:%x %x %x) , errstatus, ccb[mbo].hastat, ccb[mbo].tarstat); #endif @@ -433,7 +428,8 @@ static irqreturn_t do_aha1542_intr_handle(int dummy, void *dev_id) static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct scsi_cmnd *)) { - struct aha1542_hostdata *aha1542 = shost_priv(cmd-device-host); + struct Scsi_Host *sh = cmd-device-host; + struct aha1542_hostdata *aha1542 = shost_priv(sh); u8 direction; u8 target = cmd-device-id; u8 lun = cmd-device-lun; @@ -465,10 +461,10 @@ static int
[PATCH 16/36] aha1542: Merge aha1542_host_reset and aha1542_bus_reset
aha1542_host_reset and aha1542_bus_reset are almost same, merge them into aha1542_reset Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 82 +--- 1 file changed, 14 insertions(+), 68 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 67fdd2f..4bfba45 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -1070,7 +1070,7 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt) return SUCCESS; } -static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) +static int aha1542_reset(Scsi_Cmnd *SCpnt, u8 reset_cmd) { struct aha1542_hostdata *aha1542 = shost_priv(SCpnt-device-host); int i; @@ -1081,7 +1081,7 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) * we do this? Try this first, and we can add that later * if it turns out to be useful. */ - outb(SCRST, CONTROL(SCpnt-device-host-io_port)); + outb(reset_cmd, CONTROL(SCpnt-device-host-io_port)); /* * Wait for the thing to settle down a bit. Unfortunately @@ -1091,7 +1091,6 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) * we are pretty desperate anyways. */ ssleep(4); - spin_lock_irq(SCpnt-device-host-host_lock); if (!wait_mask(STATUS(SCpnt-device-host-io_port), @@ -1099,7 +1098,12 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) spin_unlock_irq(SCpnt-device-host-host_lock); return FAILED; } - + /* +* We need to do this too before the 1542 can interact with +* us again after host reset. +*/ + if (reset_cmd HRST) + setup_mailboxes(SCpnt-device-host-io_port, SCpnt-device-host); /* * Now try to pick up the pieces. For all pending commands, * free any internal data structures, and basically clear things @@ -1113,7 +1117,6 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) Scsi_Cmnd *SCtmp; SCtmp = aha1542-SCint[i]; - if (SCtmp-device-soft_reset) { /* * If this device implements the soft reset option, @@ -1134,71 +1137,14 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) return SUCCESS; } -static int aha1542_host_reset(Scsi_Cmnd * SCpnt) +static int aha1542_bus_reset(Scsi_Cmnd *SCpnt) { - struct aha1542_hostdata *aha1542 = shost_priv(SCpnt-device-host); - int i; - - /* -* This does a scsi reset for all devices on the bus. -* In principle, we could also reset the 1542 - should -* we do this? Try this first, and we can add that later -* if it turns out to be useful. -*/ - outb(HRST | SCRST, CONTROL(SCpnt-device-host-io_port)); - - /* -* Wait for the thing to settle down a bit. Unfortunately -* this is going to basically lock up the machine while we -* wait for this to complete. To be 100% correct, we need to -* check for timeout, and if we are doing something like this -* we are pretty desperate anyways. -*/ - ssleep(4); - spin_lock_irq(SCpnt-device-host-host_lock); - - if (!wait_mask(STATUS(SCpnt-device-host-io_port), -STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) { - spin_unlock_irq(SCpnt-device-host-host_lock); - return FAILED; - } - /* -* We need to do this too before the 1542 can interact with -* us again. -*/ - setup_mailboxes(SCpnt-device-host-io_port, SCpnt-device-host); - - /* -* Now try to pick up the pieces. For all pending commands, -* free any internal data structures, and basically clear things -* out. We do not try and restart any commands or anything - -* the strategy handler takes care of that crap. -*/ - printk(KERN_WARNING Sent BUS RESET to scsi host %d\n, SCpnt-device-host-host_no); - - for (i = 0; i AHA1542_MAILBOXES; i++) { - if (aha1542-SCint[i] != NULL) { - Scsi_Cmnd *SCtmp; - SCtmp = aha1542-SCint[i]; - - if (SCtmp-device-soft_reset) { - /* -* If this device implements the soft reset option, -* then it is still holding onto the command, and -* may yet complete it. In this case, we don't -* flush the data. -*/ - continue; - } - kfree(SCtmp-host_scribble); - SCtmp-host_scribble = NULL; - aha1542-SCint[i] = NULL; -
[PATCH 18/36] aha1542: Call wait_mask from aha1542_out
aha1542_out call is always followed by wait_mask. Move the call into aha1542_out to simplify code. Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 17 +++-- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index b8e4952..4849d02 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -185,6 +185,8 @@ static int aha1542_out(unsigned int base, u8 *cmdp, int len) outb(*cmdp++, DATA(base)); } spin_unlock_irqrestore(aha1542_lock, flags); + if (!wait_mask(INTRFLAGS(base), INTRMASK, HACC, 0, 0)) + return 1; return 0; } @@ -650,8 +652,7 @@ static void setup_mailboxes(int bse, struct Scsi_Host *shpnt) }; aha1542_intr_reset(bse);/* reset interrupts, so they don't block */ any2scsi((cmd + 2), isa_virt_to_bus(mb)); - aha1542_out(bse, cmd, 5); - if (!wait_mask(INTRFLAGS(bse), INTRMASK, HACC, 0, 0)) + if (aha1542_out(bse, cmd, 5)) printk(KERN_ERR aha1542_detect: failed setting up mailboxes\n); aha1542_intr_reset(bse); } @@ -744,8 +745,7 @@ static int aha1542_mbenable(int base) if ((mbenable_result[0] 0x08) (mbenable_result[1] 0x03)) retval = BIOS_TRANSLATION_25563; - aha1542_out(base, mbenable_cmd, 3); - if (!wait_mask(INTRFLAGS(base), INTRMASK, HACC, 0, 0)) + if (aha1542_out(base, mbenable_cmd, 3)) goto fail; }; while (0) { @@ -879,19 +879,16 @@ static void aha1542_set_bus_times(int indx) offcmd[1] = setup_busoff[indx]; } aha1542_intr_reset(base_io); - aha1542_out(base_io, oncmd, 2); - if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) + if (aha1542_out(base_io, oncmd, 2)) goto fail; aha1542_intr_reset(base_io); - aha1542_out(base_io, offcmd, 2); - if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) + if (aha1542_out(base_io, offcmd, 2)) goto fail; if (setup_dmaspeed[indx] = 0) { u8 dmacmd[] = {CMD_DMASPEED, 0}; dmacmd[1] = setup_dmaspeed[indx]; aha1542_intr_reset(base_io); - aha1542_out(base_io, dmacmd, 2); - if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) + if (aha1542_out(base_io, dmacmd, 2)) goto fail; } aha1542_intr_reset(base_io); -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 34/36] aha1542: rework locking
Remove aha1542_lock and use host_lock instead. Remove interrupt and queuecommand function wrappers. Remove locking from lowlevel _out and _in functions, they now can onle be called (at runtime) with host_lock being held. Remove ssleep(4) in aha1542_reset as we can't sleep while holding a spinlock. It's useless anyway as wait_mask will wait until the controller is idle and kernel waits for 10 seconds (HOST_RESET_SETTLE_TIME) after that. Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 118 ++-- 1 file changed, 34 insertions(+), 84 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index a19fcb0..7b5d396 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -62,8 +62,6 @@ struct aha1542_hostdata { struct ccb ccb[AHA1542_MAILBOXES]; }; -static DEFINE_SPINLOCK(aha1542_lock); - static inline void aha1542_intr_reset(u16 base) { outb(IRST, CONTROL(base)); @@ -91,41 +89,25 @@ static inline bool wait_mask(u16 port, u8 mask, u8 allof, u8 noneof, int timeout return true; } -/* This is a bit complicated, but we need to make sure that an interrupt - routine does not send something out while we are in the middle of this. - Fortunately, it is only at boot time that multi-byte messages - are ever sent. */ static int aha1542_outb(unsigned int base, u8 val) { - unsigned long flags; - while (1) { if (!wait_mask(STATUS(base), CDF, 0, CDF, 0)) return 1; - spin_lock_irqsave(aha1542_lock, flags); - if (inb(STATUS(base)) CDF) { - spin_unlock_irqrestore(aha1542_lock, flags); + if (inb(STATUS(base)) CDF) continue; - } outb(val, DATA(base)); - spin_unlock_irqrestore(aha1542_lock, flags); return 0; } } static int aha1542_out(unsigned int base, u8 *buf, int len) { - unsigned long flags; - - spin_lock_irqsave(aha1542_lock, flags); while (len--) { - if (!wait_mask(STATUS(base), CDF, 0, CDF, 0)) { - spin_unlock_irqrestore(aha1542_lock, flags); + if (!wait_mask(STATUS(base), CDF, 0, CDF, 0)) return 1; - } outb(*buf++, DATA(base)); } - spin_unlock_irqrestore(aha1542_lock, flags); if (!wait_mask(INTRFLAGS(base), INTRMASK, HACC, 0, 0)) return 1; @@ -137,17 +119,11 @@ static int aha1542_out(unsigned int base, u8 *buf, int len) static int aha1542_in(unsigned int base, u8 *buf, int len, int timeout) { - unsigned long flags; - - spin_lock_irqsave(aha1542_lock, flags); while (len--) { - if (!wait_mask(STATUS(base), DF, DF, 0, timeout)) { - spin_unlock_irqrestore(aha1542_lock, flags); + if (!wait_mask(STATUS(base), DF, DF, 0, timeout)) return 1; - } *buf++ = inb(DATA(base)); } - spin_unlock_irqrestore(aha1542_lock, flags); return 0; } @@ -260,9 +236,9 @@ static int aha1542_test_port(struct Scsi_Host *sh) return 1; } -/* A high level interrupt handler */ -static void aha1542_intr_handle(struct Scsi_Host *sh) +static irqreturn_t aha1542_interrupt(int irq, void *dev_id) { + struct Scsi_Host *sh = dev_id; struct aha1542_hostdata *aha1542 = shost_priv(sh); void (*my_done)(struct scsi_cmnd *) = NULL; int errstatus, mbi, mbo, mbistatus; @@ -292,7 +268,8 @@ static void aha1542_intr_handle(struct Scsi_Host *sh) #endif number_serviced = 0; - while (1 == 1) { + spin_lock_irqsave(sh-host_lock, flags); + while (1) { flag = inb(INTRFLAGS(sh-io_port)); /* Check for unusual interrupts. If any of these happen, we should @@ -309,7 +286,6 @@ static void aha1542_intr_handle(struct Scsi_Host *sh) } aha1542_intr_reset(sh-io_port); - spin_lock_irqsave(aha1542_lock, flags); mbi = aha1542-aha1542_last_mbi_used + 1; if (mbi = 2 * AHA1542_MAILBOXES) mbi = AHA1542_MAILBOXES; @@ -323,18 +299,17 @@ static void aha1542_intr_handle(struct Scsi_Host *sh) } while (mbi != aha1542-aha1542_last_mbi_used); if (mb[mbi].status == 0) { - spin_unlock_irqrestore(aha1542_lock, flags); + spin_unlock_irqrestore(sh-host_lock, flags); /* Hmm, no mail. Must have read it the last time around */ if (!number_serviced) shost_printk(KERN_WARNING, sh, interrupt received, but no mail.\n); - return; + return
[PATCH 36/36] aha1542: remove loop from aha1542_outb
The loop in aha1542_outb with double-check is no longer needed, remove it. Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index af821f3..ec43276 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -91,14 +91,11 @@ static inline bool wait_mask(u16 port, u8 mask, u8 allof, u8 noneof, int timeout static int aha1542_outb(unsigned int base, u8 val) { - while (1) { - if (!wait_mask(STATUS(base), CDF, 0, CDF, 0)) - return 1; - if (inb(STATUS(base)) CDF) - continue; - outb(val, DATA(base)); - return 0; - } + if (!wait_mask(STATUS(base), CDF, 0, CDF, 0)) + return 1; + outb(val, DATA(base)); + + return 0; } static int aha1542_out(unsigned int base, u8 *buf, int len) -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 13/36] aha1542: Remove unneeded gotos
Remove gotos that are no longer needed. Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 58 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 7bf4604..af2c69e 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -198,17 +198,16 @@ static int aha1542_in(unsigned int base, u8 *cmdp, int len, int timeout) spin_lock_irqsave(aha1542_lock, flags); while (len--) { - if (!wait_mask(STATUS(base), DF, DF, 0, timeout)) - goto fail; + if (!wait_mask(STATUS(base), DF, DF, 0, timeout)) { + spin_unlock_irqrestore(aha1542_lock, flags); + if (timeout == 0) + printk(KERN_ERR aha1542_in failed(%d): , len + 1); + return 1; + } *cmdp++ = inb(DATA(base)); } spin_unlock_irqrestore(aha1542_lock, flags); return 0; -fail: - spin_unlock_irqrestore(aha1542_lock, flags); - if (timeout == 0) - printk(KERN_ERR aha1542_in failed(%d): , len + 1); - return 1; } static int makecode(unsigned hosterr, unsigned scsierr) @@ -292,12 +291,12 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) debug = 1; /* Expect INIT and IDLE, any of the others are bad */ if (!wait_mask(STATUS(bse), STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) - goto fail; + return 0; debug = 2; /* Shouldn't have generated any interrupts during reset */ if (inb(INTRFLAGS(bse)) INTRMASK) - goto fail; + return 0; /* Perform a host adapter inquiry instead so we do not need to set @@ -311,19 +310,19 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) while (len--) { if (!wait_mask(STATUS(bse), DF, DF, 0, 0)) - goto fail; + return 0; *cmdp++ = inb(DATA(bse)); } debug = 8; /* Reading port should reset DF */ if (inb(STATUS(bse)) DF) - goto fail; + return 0; debug = 9; /* When HACC, command is completed, and we're though testing */ if (!wait_mask(INTRFLAGS(bse), HACC, HACC, 0, 0)) - goto fail; + return 0; /* now initialize adapter */ debug = 10; @@ -333,8 +332,6 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) debug = 11; return debug; /* 1 = ok */ -fail: - return 0; /* 0 = not ok */ } static int aha1542_restart(struct Scsi_Host *shost) @@ -692,11 +689,7 @@ static void setup_mailboxes(int bse, struct Scsi_Host *shpnt) any2scsi((cmd + 2), isa_virt_to_bus(mb)); aha1542_out(bse, cmd, 5); if (!wait_mask(INTRFLAGS(bse), INTRMASK, HACC, 0, 0)) - goto fail; - while (0) { -fail: printk(KERN_ERR aha1542_detect: failed setting up mailboxes\n); - } aha1542_intr_reset(bse); } @@ -711,11 +704,7 @@ static int aha1542_getconfig(int base_io, unsigned char *irq_level, unsigned cha aha1542_outb(base_io, CMD_RETCONF); aha1542_in(base_io, inquiry_result, 3, 0); if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) - goto fail; - while (0) { -fail: printk(KERN_ERR aha1542_detect: query board settings\n); - } aha1542_intr_reset(base_io); switch (inquiry_result[0]) { case 0x80: @@ -816,11 +805,7 @@ static int aha1542_query(int base_io, int *transl) aha1542_outb(base_io, CMD_INQUIRY); aha1542_in(base_io, inquiry_result, 4, 0); if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) - goto fail; - while (0) { -fail: printk(KERN_ERR aha1542_detect: query card type\n); - } aha1542_intr_reset(base_io); *transl = BIOS_TRANSLATION_6432;/* Default case */ @@ -1147,8 +1132,10 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) spin_lock_irq(SCpnt-device-host-host_lock); if (!wait_mask(STATUS(SCpnt-device-host-io_port), -STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) - goto fail; +STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) { + spin_unlock_irq(SCpnt-device-host-host_lock); + return FAILED; + } /* * Now try to pick up the pieces. For all pending commands, @@ -1182,10 +1169,6 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) spin_unlock_irq(SCpnt-device-host-host_lock); return SUCCESS; - -fail: -
[PATCH 32/36] aha1542: Use print_hex_dump_bytes in debug code
Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 34 -- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 6d4532c..87017fb 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -381,14 +381,8 @@ static void aha1542_intr_handle(struct Scsi_Host *sh) if (errstatus) shost_printk(KERN_DEBUG, sh, (aha1542 error:%x %x %x) , errstatus, ccb[mbo].hastat, ccb[mbo].tarstat); - if (ccb[mbo].tarstat == 2) { - int i; - - printk(aha1542_intr_handle: sense:); - for (i = 0; i 12; i++) - printk(%02x , ccb[mbo].cdb[ccb[mbo].cdblen + i]); - printk(\n); - } + if (ccb[mbo].tarstat == 2) + print_hex_dump_bytes(sense: , DUMP_PREFIX_NONE, ccb[mbo].cdb[ccb[mbo].cdblen], 12); if (errstatus) printk(aha1542_intr_handle: returning %6x\n, errstatus); #endif @@ -450,10 +444,7 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct shost_printk(KERN_DEBUG, sh, aha1542_queuecommand: dev %d cmd %02x pos %d len %d , target, *cmd-cmnd, i, bufflen); else shost_printk(KERN_DEBUG, sh, aha1542_command: dev %d cmd %02x pos %d len %d , target, *cmd-cmnd, i, bufflen); - shost_printk(KERN_DEBUG, sh, aha1542_queuecommand: dumping scsi cmd:); - for (i = 0; i cmd-cmd_len; i++) - printk(%02x , cmd-cmnd[i]); - printk(\n); + print_hex_dump_bytes(command: , DUMP_PREFIX_NONE, cmd-cmnd, cmd-cmd_len); if (*cmd-cmnd == WRITE_10 || *cmd-cmnd == WRITE_6) return 0; /* we are still testing, so *don't* write */ #endif @@ -483,7 +474,7 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct spin_unlock_irqrestore(aha1542_lock, flags); #ifdef DEBUG - shost_printk(KERN_DEBUG, sh, Sending command (%d %x)..., mbo, done); + shost_printk(KERN_DEBUG, sh, Sending command (%d %p)..., mbo, done); #endif any2scsi(mb[mbo].ccbptr, isa_virt_to_bus(ccb[mbo])); /* This gets trashed for some reason */ @@ -503,10 +494,8 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct if (bufflen) { struct scatterlist *sg; struct chain *cptr; -#ifdef DEBUG - unsigned char *ptr; -#endif int i, sg_count = scsi_sg_count(cmd); + ccb[mbo].op = 2;/* SCSI Initiator Command w/scatter-gather */ cmd-host_scribble = kmalloc(sizeof(*cptr)*sg_count, GFP_KERNEL | GFP_DMA); @@ -524,10 +513,8 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct any2scsi(ccb[mbo].datalen, sg_count * sizeof(struct chain)); any2scsi(ccb[mbo].dataptr, isa_virt_to_bus(cptr)); #ifdef DEBUG - printk(cptr %x: , cptr); - ptr = (unsigned char *) cptr; - for (i = 0; i 18; i++) - printk(%02x , ptr[i]); + shost_printk(KERN_DEBUG, sh, cptr %p: , cptr); + print_hex_dump_bytes(cptr: , DUMP_PREFIX_NONE, cptr, 18); #endif } else { ccb[mbo].op = 0;/* SCSI Initiator Command */ @@ -541,12 +528,7 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct ccb[mbo].commlinkid = 0; #ifdef DEBUG - { - int i; - shost_printk(KERN_DEBUG, sh, aha1542_command: sending.. ); - for (i = 0; i sizeof(ccb[mbo]) - 10; i++) - printk(%02x , ((u8 *) ccb[mbo])[i]); - }; + print_hex_dump_bytes(sending: , DUMP_PREFIX_NONE, ccb[mbo], sizeof(ccb[mbo]) - 10); #endif if (done) { -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 20/36] aha1542: rework configuration parameters
Remove __setup and introduce separate io, bus_on, bus_off and dma_speed module parameters. Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 213 1 file changed, 54 insertions(+), 159 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 8c915d7..d151913 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -53,56 +53,30 @@ #else #define DEB(x) #endif +#define MAXBOARDS 4 -/* - static const char RCSid[] = $Header: /usr/src/linux/kernel/blk_drv/scsi/RCS/aha1542.c,v 1.1 1992/07/24 06:27:38 root Exp root $; - */ - -/* The adaptec can be configured for quite a number of addresses, but - I generally do not want the card poking around at random. We allow - two addresses - this allows people to use the Adaptec with a Midi - card, which also used 0x330 -- can be overridden with LILO! */ - -#define MAXBOARDS 4/* Increase this and the sizes of the - arrays below, if you need more.. */ - -/* Boards 3,4 slots are reserved for ISAPnP scans */ - -static unsigned int bases[MAXBOARDS] = {0x330, 0x334, 0, 0}; +static bool isapnp = 1; +module_param(isapnp, bool, 0); +MODULE_PARM_DESC(isapnp, enable PnP support (default=1)); -/* set by aha1542_setup according to the command line; they also may - be marked __initdata, but require zero initializers then */ +static int io[MAXBOARDS] = { 0x330, 0x334, 0, 0 }; +module_param_array(io, int, NULL, 0); +MODULE_PARM_DESC(io, base IO address of controller (0x130,0x134,0x230,0x234,0x330,0x334, default=0x330,0x334)); -static int setup_called[MAXBOARDS]; -static int setup_buson[MAXBOARDS]; -static int setup_busoff[MAXBOARDS]; -static int setup_dmaspeed[MAXBOARDS] = { -1, -1, -1, -1 }; +/* time AHA spends on the AT-bus during data transfer */ +static int bus_on[MAXBOARDS] = { -1, -1, -1, -1 }; /* power-on default: 11us */ +module_param_array(bus_on, int, NULL, 0); +MODULE_PARM_DESC(bus_on, bus on time [us] (2-15, default=-1 [HW default: 11])); -/* - * LILO/Module params: aha1542=PORTBASE[,BUSON,BUSOFF[,DMASPEED]] - * - * Where: PORTBASE is any of the valid AHA addresses: - * 0x130, 0x134, 0x230, 0x234, 0x330, 0x334 - * BUSON is the time (in microsecs) that AHA spends on the AT-bus - * when transferring data. 1542A power-on default is 11us, - * valid values are in range: 2..15 (decimal) - * BUSOFF is the time that AHA spends OFF THE BUS after while - * it is transferring data (not to monopolize the bus). - * Power-on default is 4us, valid range: 1..64 microseconds. - * DMASPEED Default is jumper selected (1542A: on the J1), - * but experimenter can alter it with this. - * Valid values: 5, 6, 7, 8, 10 (MB/s) - * Factory default is 5 MB/s. - */ +/* time AHA spends off the bus (not to monopolize it) during data transfer */ +static int bus_off[MAXBOARDS] = { -1, -1, -1, -1 }; /* power-on default: 4us */ +module_param_array(bus_off, int, NULL, 0); +MODULE_PARM_DESC(bus_off, bus off time [us] (1-64, default=-1 [HW default: 4])); -#if defined(MODULE) -static bool isapnp = 0; -static int aha1542[] = {0x330, 11, 4, -1}; -module_param_array(aha1542, int, NULL, 0); -module_param(isapnp, bool, 0); -#else -static int isapnp = 1; -#endif +/* default is jumper selected (J1 on 1542A), factory default = 5 MB/s */ +static int dma_speed[MAXBOARDS] = { -1, -1, -1, -1 }; +module_param_array(dma_speed, int, NULL, 0); +MODULE_PARM_DESC(dma_speed, DMA speed [MB/s] (5,6,7,8,10, default=-1 [by jumper])); #define BIOS_TRANSLATION_1632 0/* Used by some old 1542A boards */ #define BIOS_TRANSLATION_6432 1/* Default case these days */ @@ -792,101 +766,48 @@ static int aha1542_query(int base_io, int *transl) return 0; } -#ifndef MODULE -static char *setup_str[MAXBOARDS] __initdata; -static int setup_idx = 0; - -static void __init aha1542_setup(char *str, int *ints) +static u8 dma_speed_hw(int dma_speed) { - const char *ahausage = aha1542: usage: aha1542=PORTBASE[,BUSON,BUSOFF[,DMASPEED]]\n; - int setup_portbase; - - if (setup_idx = MAXBOARDS) { - printk(KERN_ERR aha1542: aha1542_setup called too many times! Bad LILO params ?\n); - printk(KERN_ERREntryline 1: %s\n, setup_str[0]); - printk(KERN_ERREntryline 2: %s\n, setup_str[1]); - printk(KERN_ERRThis line: %s\n, str); - return; - } - if (ints[0] 1 || ints[0] 4) { - printk(KERN_ERR aha1542: %s\n, str); - printk(ahausage); - printk(KERN_ERR aha1542: Wrong parameters may cause system malfunction.. We try anyway..\n); - } - setup_called[setup_idx] = ints[0]; - setup_str[setup_idx] = str; - -
[PATCH 25/36] aha1542: fix include guard and remove useless changelog
Fix include guard in header file and remove useless changelog Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.h | 36 +++- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/drivers/scsi/aha1542.h b/drivers/scsi/aha1542.h index f58792b..0fe9bae 100644 --- a/drivers/scsi/aha1542.h +++ b/drivers/scsi/aha1542.h @@ -1,35 +1,5 @@ -#ifndef _AHA1542_H - -/* $Id: aha1542.h,v 1.1 1992/07/24 06:27:38 root Exp root $ - * - * Header file for the adaptec 1542 driver for Linux - * - * $Log: aha1542.h,v $ - * Revision 1.1 1992/07/24 06:27:38 root - * Initial revision - * - * Revision 1.2 1992/07/04 18:41:49 root - * Replaced distribution with current drivers - * - * Revision 1.3 1992/06/23 23:58:20 root - * Fixes. - * - * Revision 1.2 1992/05/26 22:13:23 root - * Changed bug that prevented DMA above first 2 mbytes. - * - * Revision 1.1 1992/05/22 21:00:29 root - * Initial revision - * - * Revision 1.1 1992/04/24 18:01:50 root - * Initial revision - * - * Revision 1.1 1992/04/02 03:23:13 drew - * Initial revision - * - * Revision 1.3 1992/01/27 14:46:29 tthorn - * *** empty log message *** - * - */ +#ifndef _AHA1542_H_ +#define _AHA1542_H_ #include linux/types.h @@ -129,4 +99,4 @@ struct ccb { /* Command Control Block 5.3 */ #define AHA1542_REGION_SIZE 4 #define AHA1542_MAILBOXES 8 -#endif +#endif /* _AHA1542_H_ */ -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 27/36] aha1542: cleanup includes
Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 11 +++ 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 214b9f4..16cb6f9 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -11,23 +11,18 @@ #include linux/kernel.h #include linux/types.h #include linux/string.h -#include linux/ioport.h #include linux/delay.h -#include linux/proc_fs.h #include linux/init.h #include linux/spinlock.h #include linux/isa.h #include linux/pnp.h -#include linux/blkdev.h #include linux/slab.h - +#include linux/io.h #include asm/dma.h -#include asm/io.h - -#include scsi.h +#include scsi/scsi_cmnd.h +#include scsi/scsi_device.h #include scsi/scsi_host.h #include aha1542.h -#include linux/stat.h #ifdef DEBUG #define DEB(x) x -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 35/36] aha1542: Fix bus reset
Bus reset always fails because aha1542_reset waits for the controller to assert the INIT bit (Mailbox Initialization Required) which it never does. This bit is asserted only after host reset. Remove the requirement for INIT bit (we really need only the IDLE bit). Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 7b5d396..af821f3 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -867,7 +867,7 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd) outb(reset_cmd, CONTROL(cmd-device-host-io_port)); if (!wait_mask(STATUS(cmd-device-host-io_port), -STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) { +STATMASK, IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) { spin_unlock_irqrestore(sh-host_lock, flags); return FAILED; } -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 28/36] aha1542: Pass struct Scsi_Host * to functions
Pass struct Scsi_Host * to functions instead of base address. This reduces the number of parameters and is also required for printk conversion. Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 125 1 file changed, 63 insertions(+), 62 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 16cb6f9..12b90a2 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -217,53 +217,53 @@ static int makecode(unsigned hosterr, unsigned scsierr) return scsierr | (hosterr 16); } -static int aha1542_test_port(int bse, struct Scsi_Host *sh) +static int aha1542_test_port(struct Scsi_Host *sh) { u8 inquiry_result[4]; int i; /* Quick and dirty test for presence of the card. */ - if (inb(STATUS(bse)) == 0xff) + if (inb(STATUS(sh-io_port)) == 0xff) return 0; /* Reset the adapter. I ought to make a hard reset, but it's not really necessary */ /* In case some other card was probing here, reset interrupts */ - aha1542_intr_reset(bse);/* reset interrupts, so they don't block */ + aha1542_intr_reset(sh-io_port);/* reset interrupts, so they don't block */ - outb(SRST | IRST /*|SCRST */ , CONTROL(bse)); + outb(SRST | IRST /*|SCRST */ , CONTROL(sh-io_port)); mdelay(20); /* Wait a little bit for things to settle down. */ /* Expect INIT and IDLE, any of the others are bad */ - if (!wait_mask(STATUS(bse), STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) + if (!wait_mask(STATUS(sh-io_port), STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) return 0; /* Shouldn't have generated any interrupts during reset */ - if (inb(INTRFLAGS(bse)) INTRMASK) + if (inb(INTRFLAGS(sh-io_port)) INTRMASK) return 0; /* Perform a host adapter inquiry instead so we do not need to set up the mailboxes ahead of time */ - aha1542_outb(bse, CMD_INQUIRY); + aha1542_outb(sh-io_port, CMD_INQUIRY); for (i = 0; i 4; i++) { - if (!wait_mask(STATUS(bse), DF, DF, 0, 0)) + if (!wait_mask(STATUS(sh-io_port), DF, DF, 0, 0)) return 0; - inquiry_result[i] = inb(DATA(bse)); + inquiry_result[i] = inb(DATA(sh-io_port)); } /* Reading port should reset DF */ - if (inb(STATUS(bse)) DF) + if (inb(STATUS(sh-io_port)) DF) return 0; /* When HACC, command is completed, and we're though testing */ - if (!wait_mask(INTRFLAGS(bse), HACC, HACC, 0, 0)) + if (!wait_mask(INTRFLAGS(sh-io_port), HACC, HACC, 0, 0)) return 0; /* Clear interrupts */ - outb(IRST, CONTROL(bse)); + outb(IRST, CONTROL(sh-io_port)); return 1; } @@ -581,7 +581,7 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct static DEF_SCSI_QCMD(aha1542_queuecommand) /* Initialize mailboxes */ -static void setup_mailboxes(int bse, struct Scsi_Host *sh) +static void setup_mailboxes(struct Scsi_Host *sh) { struct aha1542_hostdata *aha1542 = shost_priv(sh); int i; @@ -594,43 +594,43 @@ static void setup_mailboxes(int bse, struct Scsi_Host *sh) mb[i].status = mb[AHA1542_MAILBOXES + i].status = 0; any2scsi(mb[i].ccbptr, isa_virt_to_bus(ccb[i])); }; - aha1542_intr_reset(bse);/* reset interrupts, so they don't block */ + aha1542_intr_reset(sh-io_port);/* reset interrupts, so they don't block */ any2scsi((mb_cmd + 2), isa_virt_to_bus(mb)); - if (aha1542_out(bse, mb_cmd, 5)) + if (aha1542_out(sh-io_port, mb_cmd, 5)) printk(KERN_ERR aha1542_detect: failed setting up mailboxes\n); - aha1542_intr_reset(bse); + aha1542_intr_reset(sh-io_port); } -static int aha1542_getconfig(int base_io, unsigned int *irq_level, unsigned char *dma_chan, unsigned int *scsi_id) +static int aha1542_getconfig(struct Scsi_Host *sh) { u8 inquiry_result[3]; int i; - i = inb(STATUS(base_io)); + i = inb(STATUS(sh-io_port)); if (i DF) { - i = inb(DATA(base_io)); + i = inb(DATA(sh-io_port)); }; - aha1542_outb(base_io, CMD_RETCONF); - aha1542_in(base_io, inquiry_result, 3, 0); - if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) + aha1542_outb(sh-io_port, CMD_RETCONF); + aha1542_in(sh-io_port, inquiry_result, 3, 0); + if (!wait_mask(INTRFLAGS(sh-io_port), INTRMASK, HACC, 0, 0)) printk(KERN_ERR aha1542_detect: query board settings\n); - aha1542_intr_reset(base_io); + aha1542_intr_reset(sh-io_port); switch (inquiry_result[0]) {
[PATCH 26/36] aha1542: remove useless changelog
Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 25 +++-- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 7b06698..214b9f4 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -1,28 +1,9 @@ -/* $Id: aha1542.c,v 1.1 1992/07/24 06:27:38 root Exp root $ - * linux/kernel/aha1542.c +/* + * Driver for Adaptec AHA-1542 SCSI host adapters * * Copyright (C) 1992 Tommy Thorn * Copyright (C) 1993, 1994, 1995 Eric Youngdale - * - * Modified by Eric Youngdale - *Use request_irq and request_dma to help prevent unexpected conflicts - *Set up on-board DMA controller, such that we do not have to - *have the bios enabled to use the aha1542. - * Modified by David Gentzel - *Don't call request_dma if dma mask is 0 (for BusLogic BT-445S VL-Bus - *controller). - * Modified by Matti Aarnio - *Accept parameters from LILO cmd-line. -- 1-Oct-94 - * Modified by Mike McLagan mike.mcla...@linux.org - *Recognise extended mode on AHA1542CP, different bit than 1542CF - *1-Jan-97 - * Modified by Bjorn L. Thordarson and Einar Thor Einarsson - *Recognize that DMA0 is valid DMA channel -- 13-Jul-98 - * Modified by Chris Faulhaber jed...@fxp.org - *Added module command-line options - *19-Jul-99 - * Modified by Adam Fritzler - *Added proper detection of the AHA-1640 (MCA, now deleted) + * Copyright (C) 2015 Ondrej Zary */ #include linux/module.h -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 19/36] aha1542: rework hw_init
Cleanup hw_init, use goto for error handling. Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 139 drivers/scsi/aha1542.h |1 + 2 files changed, 59 insertions(+), 81 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 4849d02..8c915d7 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -657,7 +657,7 @@ static void setup_mailboxes(int bse, struct Scsi_Host *shpnt) aha1542_intr_reset(bse); } -static int aha1542_getconfig(int base_io, unsigned char *irq_level, unsigned char *dma_chan, unsigned char *scsi_id) +static int aha1542_getconfig(int base_io, unsigned int *irq_level, unsigned char *dma_chan, unsigned int *scsi_id) { u8 inquiry_result[3]; int i; @@ -901,99 +901,76 @@ fail: /* return non-zero on detection */ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct device *pdev, int indx) { - unsigned char dma_chan; - unsigned char irq_level; - unsigned char scsi_id; - unsigned long flags; - unsigned int base_io; - int trans; - struct Scsi_Host *shpnt = NULL; + unsigned int base_io = bases[indx]; + struct Scsi_Host *shpnt; struct aha1542_hostdata *aha1542; - DEB(printk(aha1542_detect: \n)); - - tpnt-proc_name = aha1542; - - if (bases[indx] != 0 request_region(bases[indx], 4, aha1542)) { - shpnt = scsi_host_alloc(tpnt, - sizeof(struct aha1542_hostdata)); - - if(shpnt==NULL) { - release_region(bases[indx], 4); - return NULL; - } - aha1542 = shost_priv(shpnt); - if (!aha1542_test_port(bases[indx], shpnt)) - goto unregister; + if (base_io == 0) + return NULL; - base_io = bases[indx]; + if (!request_region(base_io, AHA1542_REGION_SIZE, aha1542)) + return NULL; - aha1542_set_bus_times(indx); + shpnt = scsi_host_alloc(tpnt, sizeof(struct aha1542_hostdata)); + if (!shpnt) + goto release; + aha1542 = shost_priv(shpnt); - if (aha1542_query(base_io, trans)) - goto unregister; + if (!aha1542_test_port(base_io, shpnt)) + goto unregister; - if (aha1542_getconfig(base_io, irq_level, dma_chan, scsi_id) == -1) - goto unregister; + aha1542_set_bus_times(indx); + if (aha1542_query(base_io, aha1542-bios_translation)) + goto unregister; + if (aha1542_getconfig(base_io, shpnt-irq, shpnt-dma_channel, shpnt-this_id) == -1) + goto unregister; - printk(KERN_INFO Configuring Adaptec (SCSI-ID %d) at IO:%x, IRQ %d, scsi_id, base_io, irq_level); - if (dma_chan != 0xFF) - printk(, DMA priority %d, dma_chan); - printk(\n); + printk(KERN_INFO Adaptec AHA-1542 (SCSI-ID %d) at IO 0x%x, IRQ %d, shpnt-this_id, base_io, shpnt-irq); + if (shpnt-dma_channel != 0xFF) + printk(, DMA %d, shpnt-dma_channel); + printk(\n); + if (aha1542-bios_translation == BIOS_TRANSLATION_25563) + printk(KERN_INFO aha1542.c: Using extended bios translation\n); - setup_mailboxes(base_io, shpnt); + setup_mailboxes(base_io, shpnt); - DEB(printk(aha1542_detect: enable interrupt channel %d\n, irq_level)); - spin_lock_irqsave(aha1542_lock, flags); - if (request_irq(irq_level, do_aha1542_intr_handle, 0, + if (request_irq(shpnt-irq, do_aha1542_intr_handle, 0, aha1542, shpnt)) { - printk(KERN_ERR Unable to allocate IRQ for adaptec controller.\n); - spin_unlock_irqrestore(aha1542_lock, flags); - goto unregister; - } - if (dma_chan != 0xFF) { - if (request_dma(dma_chan, aha1542)) { - printk(KERN_ERR Unable to allocate DMA channel for Adaptec.\n); - free_irq(irq_level, shpnt); - spin_unlock_irqrestore(aha1542_lock, flags); - goto unregister; - } - if (dma_chan == 0 || dma_chan = 5) { - set_dma_mode(dma_chan, DMA_MODE_CASCADE); -
[PATCH 33/36] aha1542: Don't reduce functionality with DEBUG enabled
Enabling DEBUG disables write commands and devices with ID 1. Remove this feature to allow real debugging. Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 31 ++- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 87017fb..a19fcb0 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -418,15 +418,7 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct int mbo; struct mailbox *mb = aha1542-mb; struct ccb *ccb = aha1542-ccb; -#ifdef DEBUG - int i; - if (target 1) { - cmd-result = DID_TIME_OUT 16; - done(cmd); - return 0; - } -#endif if (*cmd-cmnd == REQUEST_SENSE) { /* Don't do the command - we have the sense data already */ cmd-result = 0; @@ -434,19 +426,16 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct return 0; } #ifdef DEBUG - if (*cmd-cmnd == READ_10 || *cmd-cmnd == WRITE_10) - i = xscsi2int(cmd-cmnd + 2); - else if (*cmd-cmnd == READ_6 || *cmd-cmnd == WRITE_6) - i = scsi2int(cmd-cmnd + 2); - else - i = -1; - if (done) - shost_printk(KERN_DEBUG, sh, aha1542_queuecommand: dev %d cmd %02x pos %d len %d , target, *cmd-cmnd, i, bufflen); - else - shost_printk(KERN_DEBUG, sh, aha1542_command: dev %d cmd %02x pos %d len %d , target, *cmd-cmnd, i, bufflen); - print_hex_dump_bytes(command: , DUMP_PREFIX_NONE, cmd-cmnd, cmd-cmd_len); - if (*cmd-cmnd == WRITE_10 || *cmd-cmnd == WRITE_6) - return 0; /* we are still testing, so *don't* write */ + { + int i = -1; + if (*cmd-cmnd == READ_10 || *cmd-cmnd == WRITE_10) + i = xscsi2int(cmd-cmnd + 2); + else if (*cmd-cmnd == READ_6 || *cmd-cmnd == WRITE_6) + i = scsi2int(cmd-cmnd + 2); + shost_printk(KERN_DEBUG, sh, aha1542_queuecommand: dev %d cmd %02x pos %d len %d, + target, *cmd-cmnd, i, bufflen); + print_hex_dump_bytes(command: , DUMP_PREFIX_NONE, cmd-cmnd, cmd-cmd_len); + } #endif /* Use the outgoing mailboxes in a round-robin fashion, because this is how the host adapter will scan for them */ -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 29/36] aha1542: Change aha1542_set_bus_times parameters
Pass struct Scsi_Host *sh and dma parameters instead of index to aha1542_set_bus_times. This is required for printk conversion. Signed-off-by: Ondrej Zary li...@rainbow-software.org --- drivers/scsi/aha1542.c | 34 -- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 12b90a2..6e44a7f 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -756,38 +756,36 @@ static u8 dma_speed_hw(int dma_speed) } /* Set the Bus on/off-times as not to ruin floppy performance */ -static void aha1542_set_bus_times(int indx) +static void aha1542_set_bus_times(struct Scsi_Host *sh, int bus_on, int bus_off, int dma_speed) { - unsigned int base_io = io[indx]; - - if (bus_on[indx] 0) { - u8 oncmd[] = { CMD_BUSON_TIME, clamp(bus_on[indx], 2, 15) }; + if (bus_on 0) { + u8 oncmd[] = { CMD_BUSON_TIME, clamp(bus_on, 2, 15) }; - aha1542_intr_reset(base_io); - if (aha1542_out(base_io, oncmd, 2)) + aha1542_intr_reset(sh-io_port); + if (aha1542_out(sh-io_port, oncmd, 2)) goto fail; } - if (bus_off[indx] 0) { - u8 offcmd[] = { CMD_BUSOFF_TIME, clamp(bus_off[indx], 1, 64) }; + if (bus_off 0) { + u8 offcmd[] = { CMD_BUSOFF_TIME, clamp(bus_off, 1, 64) }; - aha1542_intr_reset(base_io); - if (aha1542_out(base_io, offcmd, 2)) + aha1542_intr_reset(sh-io_port); + if (aha1542_out(sh-io_port, offcmd, 2)) goto fail; } - if (dma_speed_hw(dma_speed[indx]) != 0xff) { - u8 dmacmd[] = { CMD_DMASPEED, dma_speed_hw(dma_speed[indx]) }; + if (dma_speed_hw(dma_speed) != 0xff) { + u8 dmacmd[] = { CMD_DMASPEED, dma_speed_hw(dma_speed) }; - aha1542_intr_reset(base_io); - if (aha1542_out(base_io, dmacmd, 2)) + aha1542_intr_reset(sh-io_port); + if (aha1542_out(sh-io_port, dmacmd, 2)) goto fail; } - aha1542_intr_reset(base_io); + aha1542_intr_reset(sh-io_port); return; fail: printk(KERN_ERR setting bus on/off-time failed\n); - aha1542_intr_reset(base_io); + aha1542_intr_reset(sh-io_port); } /* return non-zero on detection */ @@ -817,7 +815,7 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct if (!aha1542_test_port(sh)) goto unregister; - aha1542_set_bus_times(indx); + aha1542_set_bus_times(sh, bus_on[indx], bus_off[indx], dma_speed[indx]); if (aha1542_query(sh)) goto unregister; if (aha1542_getconfig(sh) == -1) -- Ondrej Zary -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC] implementing tape statistics single file vs multi-file in sysfs
On Fri, Feb 06, 2015 at 12:20:53AM +, Seymour, Shane M wrote: There has been some ongoing discussion about the best way to implement tape statistics. The original method suggested a long time ago used a single file in sysfs similar to block statistics in sysfs. That lead to an impass about the code on the linux-scsi mailing list. I would have a strong preference for a single file containing an array of integer counters. This is in keeping with other statistics attributes in sysfs and follows the principle of least surprise: it's essentially the same general format as /proc/diskstats and sysfs disk and partition stats (dm statistics also follow this convention via the @print_stats message). This simplifies userspace code to read and parse the counters and avoids additional sample jitter when reading stats for very large numbers of devices; each device would require at least eleven open()/read()/close() cycles. For a small number of devices this shouldn't matter too much but eventually the additional syscall overhead could become significant (I think you mentioned users with ~20k devices?). The sync file mechanism in the v2 patch that addresses this problem is kinda cute but also significantly more complex than a plain old array and as you pointed out adds hundreds of lines to the patch.. Sticking to arrays also allows existing tools like sysstat to be easily adapted to the new data source. The sysfs documentation says that files should contain one item per file (with some small exceptions): Attributes should be ASCII text files, preferably with only one value per file. It is noted that it may not be efficient to contain only one value per file, so it is socially acceptable to express an array of values of the same type. Right: I think there's good precedent for the array file style when dealing with counter sets. Regards, Bryn. -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] scsi: megaraid_sas: Prevent future %p disaster
There is currently no %po format extension, so currently the letters on are simply skipped and the pointer is printed as expected (while missing the word on). However, it is probably only a matter of time before someone comes up with a %po extension, at which point this is likely to fail spectacularly. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/scsi/megaraid/megaraid_sas_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index ff283d23788a..e7c6b9c946d6 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -3105,7 +3105,7 @@ megasas_internal_reset_defer_cmds(struct megasas_instance *instance) for (i = 0; i max_cmd; i++) { cmd = instance-cmd_list[i]; if (cmd-sync_cmd == 1 || cmd-scmd) { - printk(KERN_NOTICE megasas: moving cmd[%d]:%p:%d:%p + printk(KERN_NOTICE megasas: moving cmd[%d]:%p:%d:%p on the defer queue as internal\n, defer_index, cmd, cmd-sync_cmd, cmd-scmd); -- 2.1.3 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] scsi: 3w-xxxx: Drop duplicated function name
Mentioning the enclosing function twice doesn't add value. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/scsi/3w-.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/3w-.c b/drivers/scsi/3w-.c index c75f2048319f..67539e73fdad 100644 --- a/drivers/scsi/3w-.c +++ b/drivers/scsi/3w-.c @@ -860,7 +860,7 @@ static int tw_allocate_memory(TW_Device_Extension *tw_dev, int size, int which) tw_dev-alignment_virtual_address[i] = (unsigned long *)((unsigned char *)cpu_addr + (i*size)); break; default: - printk(KERN_WARNING 3w-: tw_allocate_memory(): case slip in tw_allocate_memory()\n); + printk(KERN_WARNING 3w-: tw_allocate_memory(): case slip\n); return 1; } } -- 2.1.3 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC] implementing tape statistics single file vs multi-file in sysfs
On Fri, Feb 06, 2015 at 09:13:55AM +, Bryn M. Reeves wrote: The sysfs documentation says that files should contain one item per file (with some small exceptions): Attributes should be ASCII text files, preferably with only one value per file. It is noted that it may not be efficient to contain only one value per file, so it is socially acceptable to express an array of values of the same type. Right: I think there's good precedent for the array file style when dealing with counter sets. See my previous reply for why I strongly feel this is incorrect, sorry. greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/3] SCSI-debug: Deletion of a few unnecessary checks
From: Markus Elfring elfr...@users.sourceforge.net Date: Fri, 6 Feb 2015 18:08:53 +0100 Further update suggestions were taken into account after a patch was applied from static source code analysis. Markus Elfring (3): Deletion of unnecessary checks before the function call vfree Less function calls in scsi_debug_init() after error detection Fix exception handling for an alignment/granularity mismatch in scsi_debug_init() drivers/scsi/scsi_debug.c | 25 +++-- 1 file changed, 11 insertions(+), 14 deletions(-) -- 2.2.2 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/3] SCSI-debug: Deletion of unnecessary checks before the function call vfree
From: Markus Elfring elfr...@users.sourceforge.net Date: Fri, 6 Feb 2015 16:56:57 +0100 The vfree() function performs also input parameter validation. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring elfr...@users.sourceforge.net --- drivers/scsi/scsi_debug.c | 12 +++- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 1132321..9e4add7 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -4969,12 +4969,9 @@ bus_unreg: dev_unreg: root_device_unregister(pseudo_primary); free_vm: - if (map_storep) - vfree(map_storep); - if (dif_storep) - vfree(dif_storep); + vfree(map_storep); + vfree(dif_storep); vfree(fake_storep); - return ret; } @@ -4989,10 +4986,7 @@ static void __exit scsi_debug_exit(void) driver_unregister(sdebug_driverfs_driver); bus_unregister(pseudo_lld_bus); root_device_unregister(pseudo_primary); - - if (dif_storep) - vfree(dif_storep); - + vfree(dif_storep); vfree(fake_storep); } -- 2.2.2 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/3] SCSI-debug: Less function calls in scsi_debug_init() after error detection
From: Markus Elfring elfr...@users.sourceforge.net Date: Fri, 6 Feb 2015 17:48:34 +0100 The vfree() function was called in two cases by the scsi_debug_init() function during error handling even if the passed variables dif_storep and map_storep contained null pointers eventually. This implementation detail could be improved by the introduction of two jump labels. Signed-off-by: Markus Elfring elfr...@users.sourceforge.net --- drivers/scsi/scsi_debug.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 9e4add7..756b7be 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -4887,7 +4887,7 @@ static int __init scsi_debug_init(void) if (dif_storep == NULL) { pr_err(%s: out of mem. (DIX)\n, __func__); ret = -ENOMEM; - goto free_vm; + goto free_fake; } memset(dif_storep, 0xff, dif_size); @@ -4920,7 +4920,7 @@ static int __init scsi_debug_init(void) if (map_storep == NULL) { pr_err(%s: out of mem. (MAP)\n, __func__); ret = -ENOMEM; - goto free_vm; + goto free_dif; } bitmap_zero(map_storep, map_size); @@ -4934,7 +4934,7 @@ static int __init scsi_debug_init(void) if (IS_ERR(pseudo_primary)) { pr_warn(%s: root_device_register() error\n, __func__); ret = PTR_ERR(pseudo_primary); - goto free_vm; + goto free_map; } ret = bus_register(pseudo_lld_bus); if (ret 0) { @@ -4968,9 +4968,11 @@ bus_unreg: bus_unregister(pseudo_lld_bus); dev_unreg: root_device_unregister(pseudo_primary); -free_vm: +free_map: vfree(map_storep); +free_dif: vfree(dif_storep); +free_fake: vfree(fake_storep); return ret; } -- 2.2.2 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] SCSI-debug: Fix exception handling for an alignment/granularity mismatch in scsi_debug_init()
From: Markus Elfring elfr...@users.sourceforge.net Date: Fri, 6 Feb 2015 17:57:32 +0100 The scsi_debug_init() function returned directly if the data items alignment and granularity did not fit together. Let us improve the affected exception handling by replacing the return statement by a goto statement so that previously allocated resources will also be appropriately released. Signed-off-by: Markus Elfring elfr...@users.sourceforge.net --- drivers/scsi/scsi_debug.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 756b7be..2c78663 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -4909,7 +4909,8 @@ static int __init scsi_debug_init(void) scsi_debug_unmap_alignment) { pr_err(%s: ERR: unmap_granularity = unmap_alignment\n, __func__); - return -EINVAL; + ret = -EINVAL; + goto free_dif; } map_size = lba_to_map_index(sdebug_store_sectors - 1) + 1; -- 2.2.2 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 07/21] lpfc: Fix setting of EQ delay Multiplier
On 02/05/2015 08:24 PM, James Smart wrote: --- drivers/scsi/lpfc/lpfc_init.c | 8 drivers/scsi/lpfc/lpfc_sli.c | 9 +++-- drivers/scsi/lpfc/lpfc_sli4.h | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 74672e0..e01619c 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -7721,6 +7721,14 @@ lpfc_sli4_queue_setup(struct lpfc_hba *phba) goto out_destroy_els_rq; } } + + /* + * Configure EQ delay multipier for interrupt coalescing using + * MODIFY_EQ_DELAY for all EQs created, LPFC_MAX_EQ_DELAY at a time. + */ + for (fcp_eqidx = 0; fcp_eqidx phba-cfg_fcp_io_channel; + fcp_eqidx += LPFC_MAX_EQ_DELAY) + lpfc_modify_fcp_eq_delay(phba, fcp_eqidx); return 0; out_destroy_els_rq: diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 207a43d..303b231 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -12842,7 +12842,7 @@ lpfc_dual_chute_pci_bar_map(struct lpfc_hba *phba, uint16_t pci_barset) * fails this function will return -ENXIO. **/ int -lpfc_modify_fcp_eq_delay(struct lpfc_hba *phba, uint16_t startq) +lpfc_modify_fcp_eq_delay(struct lpfc_hba *phba, uint32_t startq) { struct lpfc_mbx_modify_eq_delay *eq_delay; LPFC_MBOXQ_t *mbox; @@ -12959,11 +12959,8 @@ lpfc_eq_create(struct lpfc_hba *phba, struct lpfc_queue *eq, uint32_t imax) bf_set(lpfc_eq_context_size, eq_create-u.request.context, LPFC_EQE_SIZE); bf_set(lpfc_eq_context_valid, eq_create-u.request.context, 1); - /* Calculate delay multiper from maximum interrupt per second */ - if (imax LPFC_DMULT_CONST) - dmult = 0; - else - dmult = LPFC_DMULT_CONST/imax - 1; + /* don't setup delay multiplier using EQ_CREATE */ + dmult = 0; bf_set(lpfc_eq_context_delay_multi, eq_create-u.request.context, dmult); This is the only use of 'dmult' in this function, please remove the variable completely and use this instead - bf_set(lpfc_eq_context_delay_multi, eq_create-u.request.context, 0); Thanks, Tomas switch (eq-entry_count) { diff --git a/drivers/scsi/lpfc/lpfc_sli4.h b/drivers/scsi/lpfc/lpfc_sli4.h index 22ceb2b..935b8eb 100644 --- a/drivers/scsi/lpfc/lpfc_sli4.h +++ b/drivers/scsi/lpfc/lpfc_sli4.h @@ -671,7 +671,7 @@ struct lpfc_queue *lpfc_sli4_queue_alloc(struct lpfc_hba *, uint32_t, uint32_t); void lpfc_sli4_queue_free(struct lpfc_queue *); int lpfc_eq_create(struct lpfc_hba *, struct lpfc_queue *, uint32_t); -int lpfc_modify_fcp_eq_delay(struct lpfc_hba *, uint16_t); +int lpfc_modify_fcp_eq_delay(struct lpfc_hba *, uint32_t); int lpfc_cq_create(struct lpfc_hba *, struct lpfc_queue *, struct lpfc_queue *, uint32_t, uint32_t); int32_t lpfc_mq_create(struct lpfc_hba *, struct lpfc_queue *, -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 02/21] lpfc: Add Lancer Temperature Event support to the lpfc driver
On 02/05/2015 08:23 PM, James Smart wrote: --- drivers/scsi/lpfc/lpfc_hw4.h | 1 + drivers/scsi/lpfc/lpfc_init.c | 179 +- 2 files changed, 125 insertions(+), 55 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h index f432ec1..3121ec4 100644 --- a/drivers/scsi/lpfc/lpfc_hw4.h +++ b/drivers/scsi/lpfc/lpfc_hw4.h @@ -3244,6 +3244,7 @@ struct lpfc_acqe_sli { #define LPFC_SLI_EVENT_TYPE_NVLOG_POST 0x4 #define LPFC_SLI_EVENT_TYPE_DIAG_DUMP0x5 #define LPFC_SLI_EVENT_TYPE_MISCONFIGURED0x9 +#define LPFC_SLI_EVENT_TYPE_REMOTE_DPORT 0xA }; /* diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 2b5b910..4ba91af 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -1330,13 +1330,14 @@ lpfc_offline_eratt(struct lpfc_hba *phba) void lpfc_sli4_offline_eratt(struct lpfc_hba *phba) { + spin_lock_irq(phba-hbalock); + phba-link_state = LPFC_HBA_ERROR; + spin_unlock_irq(phba-hbalock); Hi James, please explain why is the spinlock^ needed? There seems to be lot of other places where link_state is not protected, for example it is evaluated in lpfc_sli4_handle_received_buffer with no lock. Could you please also add some more description to the of the body your mails, sometimes a subject only is not enough. Thanks, Tomas + lpfc_offline_prep(phba, LPFC_MBX_NO_WAIT); lpfc_offline(phba); - lpfc_sli4_brdreset(phba); lpfc_hba_down_post(phba); - lpfc_sli4_post_status_check(phba); lpfc_unblock_mgmt_io(phba); - phba-link_state = LPFC_HBA_ERROR; } /** @@ -1629,6 +1630,7 @@ lpfc_handle_eratt_s4(struct lpfc_hba *phba) uint32_t uerrlo_reg, uemasklo_reg; uint32_t pci_rd_rc1, pci_rd_rc2; bool en_rn_msg = true; + struct temp_event temp_event_data; int rc; /* If the pci channel is offline, ignore possible errors, since @@ -1636,9 +1638,6 @@ lpfc_handle_eratt_s4(struct lpfc_hba *phba) */ if (pci_channel_offline(phba-pcidev)) return; - /* If resets are disabled then leave the HBA alone and return */ - if (!phba-cfg_enable_hba_reset) - return; if_type = bf_get(lpfc_sli_intf_if_type, phba-sli4_hba.sli_intf); switch (if_type) { @@ -1654,6 +1653,7 @@ lpfc_handle_eratt_s4(struct lpfc_hba *phba) return; lpfc_sli4_offline_eratt(phba); break; + case LPFC_SLI_INTF_IF_TYPE_2: pci_rd_rc1 = lpfc_readl( phba-sli4_hba.u.if_type2.STATUSregaddr, @@ -1668,15 +1668,27 @@ lpfc_handle_eratt_s4(struct lpfc_hba *phba) reg_err1 = readl(phba-sli4_hba.u.if_type2.ERR1regaddr); reg_err2 = readl(phba-sli4_hba.u.if_type2.ERR2regaddr); if (bf_get(lpfc_sliport_status_oti, portstat_reg)) { - /* TODO: Register for Overtemp async events. */ lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 2889 Port Overtemperature event, - taking port offline\n); + taking port offline Data: x%x x%x\n, + reg_err1, reg_err2); + + temp_event_data.event_type = FC_REG_TEMPERATURE_EVENT; + temp_event_data.event_code = LPFC_CRIT_TEMP; + temp_event_data.data = 0x; + + shost = lpfc_shost_from_vport(phba-pport); + fc_host_post_vendor_event(shost, fc_get_event_number(), + sizeof(temp_event_data), + (char *)temp_event_data, + SCSI_NL_VID_TYPE_PCI + | PCI_VENDOR_ID_EMULEX); + spin_lock_irq(phba-hbalock); phba-over_temp_state = HBA_OVER_TEMP; spin_unlock_irq(phba-hbalock); lpfc_sli4_offline_eratt(phba); - break; + return; } if (reg_err1 == SLIPORT_ERR1_REG_ERR_CODE_2 reg_err2 == SLIPORT_ERR2_REG_FW_RESTART) { @@ -1693,6 +1705,10 @@ lpfc_handle_eratt_s4(struct lpfc_hba *phba) lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 3145 Port Down: Provisioning\n); + /* If resets are disabled then leave the HBA alone and return */ + if (!phba-cfg_enable_hba_reset) + return; + /* Check port status register for function reset */ rc = lpfc_sli4_port_sta_fn_reset(phba, LPFC_MBX_NO_WAIT,
Re: [RFC] implementing tape statistics single file vs multi-file in sysfs
On Fri, Feb 06, 2015 at 12:20:53AM +, Seymour, Shane M wrote: Hello linux-api'ers There has been some ongoing discussion about the best way to implement tape statistics. The original method suggested a long time ago used a single file in sysfs similar to block statistics in sysfs. That lead to an impass about the code on the linux-scsi mailing list. The sysfs documentation says that files should contain one item per file (with some small exceptions): Attributes should be ASCII text files, preferably with only one value per file. It is noted that it may not be efficient to contain only one value per file, so it is socially acceptable to express an array of values of the same type. The current patch that implements tape statistics is here: http://marc.info/?l=linux-scsim=142112067313723w=2 Aside from the do we want to do this all in a single file issue that I will say more on below, this patch has issues. Please don't use a kobject for _ANYTHING_ in sysfs that has a struct device as a parent. If you do that, it can't be seen by userspace tools very well, if at all. Instead, if you want to create a directory, just use an attribute group, which will be created at the proper time (before the device is announced to userspace), and then userspace can see it with the tools it is used to using (i.e. libudev and friends.) That should simplify your code a lot, please make that change no matter what happens here with the content of the files. Recently there was was another discussion here about one file vs a collection of files for tape statistics: http://marc.info/?l=linux-scsim=142316255501550w=2 The result was that I should ask here what method I should use. I would like to get feedback in relation to tape statistics and one file vs multi-file in sysfs. I'm happy to keep the existing code or change to a single file approach. One of the primary reasons we created sysfs and the one value per file rule is that multi-value files just do not work well. Yes, you get an atomic snapshot, and you save some open/read/close syscall roundtrips, but you do so at the expense of forcing userspace to know what the format of the file is. And once you create it, you can NEVER CHANGE IT AGAIN. Yes, that's right, if you come up with some new statistic in the future, or realize that one of the ones you have now is wrong, you can't change it, you have to make a whole new file, otherwise you could break userspace tools. Instead, a one-value-per-file rule forces userspace to know that if the file is present, it can be opened and read from for a single value. If it isn't there, it should fail properly and move on to the next statistic. If you want to add a new statistic, great, just add a new file and you are set. You aren't dealing with performance-sensitive numbers here that have to have an atomic snapshot of the state at a specific point in time in order to work properly, so just have a bunch of files, all one value per file, then all userspace tools will just work (i.e. libudev), and everyone is happy. And yes, open/read/close does take take a few extra cycles, but you can't really measure it for a virtual filesystem like this on any modern system. Hope this helps explain why we have the sysfs rule, and why you should continue to follow it as well. Yes, it's not always followed, but that's usually because people forgot why we had this rule, and no one noticed or pointed it out to me that it was wrong. thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 10/21] lpfc: Fix provide host name and OS name in RSNN-NN FC-GS command
On 02/05/2015 08:24 PM, James Smart wrote: --- drivers/scsi/lpfc/lpfc_ct.c | 23 --- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index 61a32cd..5091184 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c @@ -1070,12 +1070,29 @@ lpfc_vport_symbolic_node_name(struct lpfc_vport *vport, char *symbol, size_t size) { char fwrev[FW_REV_STR_SIZE]; - int n; + int n = 0; No need for this^ initialisation , as 'n' is directly set two lines later lpfc_decode_firmware_rev(vport-phba, fwrev, 0); - n = snprintf(symbol, size, Emulex %s FV%s DV%s, - vport-phba-ModelName, fwrev, lpfc_release_version); + n = snprintf(symbol, size, Emulex %s, vport-phba-ModelName); + + if (size n) + return n; + n += snprintf(symbol + n, size - n, FV%s, fwrev); + + if (size n) + return n; + n += snprintf(symbol + n, size - n, DV%s, lpfc_release_version); + + if (size n) + return n; + n += snprintf(symbol + n, size - n, HN:%s, init_utsname()-nodename); + + /* Note :- OS name is Linux as per requirement BZ168199. */ + if (size n) + return n; + n += snprintf(symbol + n, size - n, OS:%s, init_utsname()-sysname); + return n; } -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC] implementing tape statistics single file vs multi-file in sysfs
On Fri, Feb 06, 2015 at 04:59:16AM -0800, Greg KH wrote: On Fri, Feb 06, 2015 at 12:20:53AM +, Seymour, Shane M wrote: The current patch that implements tape statistics is here: http://marc.info/?l=linux-scsim=142112067313723w=2 Aside from the do we want to do this all in a single file issue that I will say more on below, this patch has issues. Please don't use a kobject for _ANYTHING_ in sysfs that has a struct device as a parent. If you do that, it can't be seen by userspace tools very well, if at all. I can't speak for Shane but wouldn't spend too much time looking at the current v2 patch: it's the result of a pretty ugly compromise suggested on linux-scsi. This thread was really to try to settle the discussion on the structure of the stats files. Recently there was was another discussion here about one file vs a collection of files for tape statistics: http://marc.info/?l=linux-scsim=142316255501550w=2 The result was that I should ask here what method I should use. I would like to get feedback in relation to tape statistics and one file vs multi-file in sysfs. I'm happy to keep the existing code or change to a single file approach. One of the primary reasons we created sysfs and the one value per file rule is that multi-value files just do not work well. Yes, you get an atomic snapshot, and you save some open/read/close syscall roundtrips, but you do so at the expense of forcing userspace to know what the format of the file is. And once you create it, you can NEVER CHANGE IT AGAIN. I am not convinced this is a concern for tape statistics: they are pretty much a solved problem. The commercial *nixes have had this for decades. Likewise for disk stats: although fluff like maj:min/name etc. has been shuffled a few times the basic fields have remained unchanged for a very long time and sysfs already removes the need to include an identity field. Yes, that's right, if you come up with some new statistic in the future, or realize that one of the ones you have now is wrong, you can't change it, you have to make a whole new file, otherwise you could break userspace tools. I understand the fact that you can't change them; I just don't think it's a big problem in this specific case (and much less than some of the more imaginative sysfs content - 2d int arrays with column headers anyone?). And yes, open/read/close does take take a few extra cycles, but you can't really measure it for a virtual filesystem like this on any modern system. I'll try to get some numbers when I get back home next week - Shane is talking about use cases involving tens of thousands of tape devices. I am not certain that the overhead would be unmeasurable in that case: the additional context switching TLB flushes alone seem like they would add up. Hope this helps explain why we have the sysfs rule, and why you should continue to follow it as well. Yes, it's not always followed, but that's usually because people forgot why we had this rule, and no one noticed or pointed it out to me that it was wrong. Perhaps sysfs.txt should be updated to make the position more clear? The current wording seems rather more liberal than this thread would suggest. Maybe something like the patch below? This would help people who are trying to dtrt by reading the documentation. Regards, Bryn. From 3081aad4cc4d19b68f39499dbeb3837f0642f70e Mon Sep 17 00:00:00 2001 From: Bryn M. Reeves b...@redhat.com Date: Fri, 6 Feb 2015 15:19:39 + Subject: [PATCH] docs/sysfs: Specify array valued attribute review requirements Although the linux-api position that one-value-per-file is a strong rule is very clear in mailing list discussions the sysfs.txt documentation suggests a rather more liberal stance: ... it is socially acceptable to express an array of values of the same type. Fix the documentation to make it clear that such uses should be discussed on linux-api first. Signed-off-by: Bryn M. Reeves b...@redhat.com --- Documentation/filesystems/sysfs.txt | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Documentation/filesystems/sysfs.txt b/Documentation/filesystems/sysfs.txt index b35a64b..494fa78 100644 --- a/Documentation/filesystems/sysfs.txt +++ b/Documentation/filesystems/sysfs.txt @@ -57,8 +57,15 @@ attributes. Attributes should be ASCII text files, preferably with only one value per file. It is noted that it may not be efficient to contain only one -value per file, so it is socially acceptable to express an array of -values of the same type. +value per file, so it may be socially acceptable to express an array of +values of the same type. + +If you are considering adding such an array attribute to sysfs please +discuss it via the linux-api mailing list first to ensure that your +proposed use is acceptable: + + https://www.kernel.org/doc/man-pages/linux-api-ml.html + linux-...@vger.kernel.org Mixing types,
Re: [PATCH] st: implement sysfs based tape statistics v2
On 1/26/2015 6:11 PM, Seymour, Shane M wrote: I was wondering if anyone had any feedback or had any chance to review the changes? Per the other discussion about having the same stat format forever. It seems to me that you might want to preemptively add a few additional counters. A counter for WRITE_FILEMARKS, particularly non immediate count=0 ones, which are often used to flush the drive write buffer. A counter for movement related commands like SPACE/LOCATE/REWIND would also be helpful. Finally, abnormal read conditions like, ILI's, and hit FMs should have their own stat. Those three should provide a better view into how the drive is being used and why performance may not be what is expected. There may be others, but those three are high on my list of things I want to know about a tape stream that is not performing up to expectations. -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] SCSI-csiostor: Delete an unnecessary check before the function call release_firmware
From: Markus Elfring elfr...@users.sourceforge.net Date: Fri, 6 Feb 2015 19:10:25 +0100 The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring elfr...@users.sourceforge.net --- drivers/scsi/csiostor/csio_hw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/csiostor/csio_hw.c b/drivers/scsi/csiostor/csio_hw.c index 35c5f83..37fa8bf 100644 --- a/drivers/scsi/csiostor/csio_hw.c +++ b/drivers/scsi/csiostor/csio_hw.c @@ -2117,8 +2117,7 @@ csio_hw_flash_fw(struct csio_hw *hw, int *reset) hw-fw_state, reset); /* Cleaning up */ - if (fw != NULL) - release_firmware(fw); + release_firmware(fw); kfree(card_fw); return ret; } -- 2.2.2 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html