[PATCH] vmw_pvscsi: fixup tagging

2014-10-02 Thread Hannes Reinecke
The request (and SCSI command) tag is the tag number assigned
by the generic block-tagging code, not the SCSI-II tag messages.
Those are represented by the device flags 'tagged_supported',
'simple_tags', and 'ordered_tags'.
(The SCSI midlayer doesn't use HEAD_OF_QUEUE tags).
So fixup vmw_pvscsi to assign the correct tag type.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/vmw_pvscsi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
index 598f65e..d18df8c 100644
--- a/drivers/scsi/vmw_pvscsi.c
+++ b/drivers/scsi/vmw_pvscsi.c
@@ -724,9 +724,8 @@ static int pvscsi_queue_ring(struct pvscsi_adapter *adapter,
 
e->tag = SIMPLE_QUEUE_TAG;
if (sdev->tagged_supported &&
-   (cmd->tag == HEAD_OF_QUEUE_TAG ||
-cmd->tag == ORDERED_QUEUE_TAG))
-   e->tag = cmd->tag;
+   sdev->ordered_tags)
+   e->tag = ORDERED_QUEUE_TAG;
 
if (cmd->sc_data_direction == DMA_FROM_DEVICE)
e->flags = PVSCSI_FLAG_CMD_DIR_TOHOST;
-- 
1.8.5.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] tcm_loop: Fixup tag handling

2014-10-02 Thread Hannes Reinecke
The SCSI command tag is set to the tag assigned from the block
layer, not the SCSI-II tag message. So we need to convert
it into the correct SCSI-II tag message based on the
device flags, not the tag value itself.

Signed-off-by: Hannes Reinecke 
---
 drivers/target/loopback/tcm_loop.c | 23 ---
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/target/loopback/tcm_loop.c 
b/drivers/target/loopback/tcm_loop.c
index 340de9d..c2a9370 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -153,18 +153,11 @@ static int tcm_loop_change_queue_type(struct scsi_device 
*sdev, int tag)
 /*
  * Locate the SAM Task Attr from struct scsi_cmnd *
  */
-static int tcm_loop_sam_attr(struct scsi_cmnd *sc)
-{
-   if (sc->device->tagged_supported) {
-   switch (sc->tag) {
-   case HEAD_OF_QUEUE_TAG:
-   return MSG_HEAD_TAG;
-   case ORDERED_QUEUE_TAG:
-   return MSG_ORDERED_TAG;
-   default:
-   break;
-   }
-   }
+static int tcm_loop_sam_attr(struct scsi_cmnd *sc, int tag)
+{
+   if (sc->device->tagged_supported &&
+   sc->device->ordered_tags && tag >= 0)
+   return MSG_ORDERED_TAG;
 
return MSG_SIMPLE_TAG;
 }
@@ -227,7 +220,7 @@ static void tcm_loop_submission_work(struct work_struct 
*work)
 
rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd,
&tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun,
-   transfer_length, tcm_loop_sam_attr(sc),
+   transfer_length, tcm_loop_sam_attr(sc, 
tl_cmd->sc_cmd_tag),
sc->sc_data_direction, 0,
scsi_sglist(sc), scsi_sg_count(sc),
sgl_bidi, sgl_bidi_count,
@@ -266,7 +259,7 @@ static int tcm_loop_queuecommand(struct Scsi_Host *sh, 
struct scsi_cmnd *sc)
}
 
tl_cmd->sc = sc;
-   tl_cmd->sc_cmd_tag = sc->tag;
+   tl_cmd->sc_cmd_tag = sc->request->tag;
INIT_WORK(&tl_cmd->work, tcm_loop_submission_work);
queue_work(tcm_loop_workqueue, &tl_cmd->work);
return 0;
@@ -370,7 +363,7 @@ static int tcm_loop_abort_task(struct scsi_cmnd *sc)
 */
tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id];
ret = tcm_loop_issue_tmr(tl_tpg, tl_nexus, sc->device->lun,
-sc->tag, TMR_ABORT_TASK);
+sc->request->tag, TMR_ABORT_TASK);
return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED;
 }
 
-- 
1.8.5.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] tcm_loop: Fixup tag handling

2014-10-02 Thread Sagi Grimberg

On 10/2/2014 10:30 AM, Hannes Reinecke wrote:

The SCSI command tag is set to the tag assigned from the block
layer, not the SCSI-II tag message. So we need to convert
it into the correct SCSI-II tag message based on the
device flags, not the tag value itself.



Looks Good

Reviewed-by: Sagi Grimberg 


Signed-off-by: Hannes Reinecke 
---
  drivers/target/loopback/tcm_loop.c | 23 ---
  1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/target/loopback/tcm_loop.c 
b/drivers/target/loopback/tcm_loop.c
index 340de9d..c2a9370 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -153,18 +153,11 @@ static int tcm_loop_change_queue_type(struct scsi_device 
*sdev, int tag)
  /*
   * Locate the SAM Task Attr from struct scsi_cmnd *
   */
-static int tcm_loop_sam_attr(struct scsi_cmnd *sc)
-{
-   if (sc->device->tagged_supported) {
-   switch (sc->tag) {
-   case HEAD_OF_QUEUE_TAG:
-   return MSG_HEAD_TAG;
-   case ORDERED_QUEUE_TAG:
-   return MSG_ORDERED_TAG;
-   default:
-   break;
-   }
-   }
+static int tcm_loop_sam_attr(struct scsi_cmnd *sc, int tag)
+{
+   if (sc->device->tagged_supported &&
+   sc->device->ordered_tags && tag >= 0)
+   return MSG_ORDERED_TAG;

return MSG_SIMPLE_TAG;
  }
@@ -227,7 +220,7 @@ static void tcm_loop_submission_work(struct work_struct 
*work)

rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd,
&tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun,
-   transfer_length, tcm_loop_sam_attr(sc),
+   transfer_length, tcm_loop_sam_attr(sc, 
tl_cmd->sc_cmd_tag),
sc->sc_data_direction, 0,
scsi_sglist(sc), scsi_sg_count(sc),
sgl_bidi, sgl_bidi_count,
@@ -266,7 +259,7 @@ static int tcm_loop_queuecommand(struct Scsi_Host *sh, 
struct scsi_cmnd *sc)
}

tl_cmd->sc = sc;
-   tl_cmd->sc_cmd_tag = sc->tag;
+   tl_cmd->sc_cmd_tag = sc->request->tag;
INIT_WORK(&tl_cmd->work, tcm_loop_submission_work);
queue_work(tcm_loop_workqueue, &tl_cmd->work);
return 0;
@@ -370,7 +363,7 @@ static int tcm_loop_abort_task(struct scsi_cmnd *sc)
 */
tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id];
ret = tcm_loop_issue_tmr(tl_tpg, tl_nexus, sc->device->lun,
-sc->tag, TMR_ABORT_TASK);
+sc->request->tag, TMR_ABORT_TASK);
return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED;
  }




--
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 v2 10/24] uas: zap_pending: data urbs should have completed at this time

2014-10-02 Thread Oliver Neukum
On Sun, 2014-09-14 at 11:34 +0100, James Bottomley wrote:

> I'm agnostic on that.  I was just combatting the impression that you had
> to be careful about side effects in known macro statements.

No you haven't. But it is very good practice to not have side effects
in warnings, as people, not compilers, like to remove them.

Regards
Oliver


--
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] megaraid_sas: Enable shared tag map

2014-10-02 Thread Christoph Hellwig
On Thu, Oct 02, 2014 at 08:51:20AM +0200, Hannes Reinecke wrote:
> 
> I'm afraid it's not _that_ easy.
> SCSI-II tagged queueing has some specific tag values:
> 
> #define SIMPLE_QUEUE_TAG0x20
> #define HEAD_OF_QUEUE_TAG   0x21
> #define ORDERED_QUEUE_TAG   0x22

These are not tag values.  These are message codes set in the first byte
of the Queue tag message, the second byte is the actual tag.

> The recommendation here is to use 'scmd->request->tag' whenever
> you want to get to the tag number, and 'scmd->tag' if you have to
> play around with SCSI-II TCQ.
> But if not I would strongly advise to leave 'scmd->tag' alone.

Or kill off scmd->tag..  Let's see how feasible that is.

--
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] megaraid_sas: Enable shared tag map

2014-10-02 Thread Hannes Reinecke
On 10/02/2014 11:19 AM, Christoph Hellwig wrote:
> On Thu, Oct 02, 2014 at 08:51:20AM +0200, Hannes Reinecke wrote:
>>
>> I'm afraid it's not _that_ easy.
>> SCSI-II tagged queueing has some specific tag values:
>>
>> #define SIMPLE_QUEUE_TAG0x20
>> #define HEAD_OF_QUEUE_TAG   0x21
>> #define ORDERED_QUEUE_TAG   0x22
> 
> These are not tag values.  These are message codes set in the first byte
> of the Queue tag message, the second byte is the actual tag.
> 
>> The recommendation here is to use 'scmd->request->tag' whenever
>> you want to get to the tag number, and 'scmd->tag' if you have to
>> play around with SCSI-II TCQ.
>> But if not I would strongly advise to leave 'scmd->tag' alone.
> 
> Or kill off scmd->tag..  Let's see how feasible that is.
> 
I'm about to.
(See my last two patches).
There are now two instances left:
NCR5380 (and derived LLDDs) and fnic.
For some weird reasons fnic decided to duplicate blk-tag
functionality. Looking into it.

And NCR5380 tag support can be safely ignored, it never worked anyway.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries & Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
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/2] uas: Reduce number of function arguments for uas_alloc_foo functions

2014-10-02 Thread Hans de Goede
The stream_id and pipe are already present in uas_cmd_info resp uas_dev_info,
so there is no need to pass a copy along.

Signed-off-by: Hans de Goede 
---
 drivers/usb/storage/uas.c | 29 ++---
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index b27fe21..d1dbe88 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -412,20 +412,22 @@ static void uas_cmd_cmplt(struct urb *urb)
 }
 
 static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp,
- unsigned int pipe, u16 stream_id,
  struct scsi_cmnd *cmnd,
  enum dma_data_direction dir)
 {
struct usb_device *udev = devinfo->udev;
+   struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
struct urb *urb = usb_alloc_urb(0, gfp);
struct scsi_data_buffer *sdb = (dir == DMA_FROM_DEVICE)
? scsi_in(cmnd) : scsi_out(cmnd);
+   unsigned int pipe = (dir == DMA_FROM_DEVICE)
+   ? devinfo->data_in_pipe : devinfo->data_out_pipe;
 
if (!urb)
goto out;
usb_fill_bulk_urb(urb, udev, pipe, NULL, sdb->length,
  uas_data_cmplt, cmnd);
-   urb->stream_id = stream_id;
+   urb->stream_id = cmdinfo->stream;
urb->num_sgs = udev->bus->sg_tablesize ? sdb->table.nents : 0;
urb->sg = sdb->table.sgl;
  out:
@@ -433,9 +435,10 @@ static struct urb *uas_alloc_data_urb(struct uas_dev_info 
*devinfo, gfp_t gfp,
 }
 
 static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp,
-  struct Scsi_Host *shost, u16 stream_id)
+  struct scsi_cmnd *cmnd)
 {
struct usb_device *udev = devinfo->udev;
+   struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
struct urb *urb = usb_alloc_urb(0, gfp);
struct sense_iu *iu;
 
@@ -447,8 +450,8 @@ static struct urb *uas_alloc_sense_urb(struct uas_dev_info 
*devinfo, gfp_t gfp,
goto free;
 
usb_fill_bulk_urb(urb, udev, devinfo->status_pipe, iu, sizeof(*iu),
-   uas_stat_cmplt, shost);
-   urb->stream_id = stream_id;
+ uas_stat_cmplt, cmnd->device->host);
+   urb->stream_id = cmdinfo->stream;
urb->transfer_flags |= URB_FREE_BUFFER;
  out:
return urb;
@@ -500,15 +503,13 @@ static struct urb *uas_alloc_cmd_urb(struct uas_dev_info 
*devinfo, gfp_t gfp,
  * daft to me.
  */
 
-static struct urb *uas_submit_sense_urb(struct scsi_cmnd *cmnd,
-   gfp_t gfp, unsigned int stream)
+static struct urb *uas_submit_sense_urb(struct scsi_cmnd *cmnd, gfp_t gfp)
 {
-   struct Scsi_Host *shost = cmnd->device->host;
-   struct uas_dev_info *devinfo = (struct uas_dev_info *)shost->hostdata;
+   struct uas_dev_info *devinfo = cmnd->device->hostdata;
struct urb *urb;
int err;
 
-   urb = uas_alloc_sense_urb(devinfo, gfp, shost, stream);
+   urb = uas_alloc_sense_urb(devinfo, gfp, cmnd);
if (!urb)
return NULL;
usb_anchor_urb(urb, &devinfo->sense_urbs);
@@ -531,7 +532,7 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
 
lockdep_assert_held(&devinfo->lock);
if (cmdinfo->state & SUBMIT_STATUS_URB) {
-   urb = uas_submit_sense_urb(cmnd, gfp, cmdinfo->stream);
+   urb = uas_submit_sense_urb(cmnd, gfp);
if (!urb)
return SCSI_MLQUEUE_DEVICE_BUSY;
cmdinfo->state &= ~SUBMIT_STATUS_URB;
@@ -539,8 +540,7 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
 
if (cmdinfo->state & ALLOC_DATA_IN_URB) {
cmdinfo->data_in_urb = uas_alloc_data_urb(devinfo, gfp,
-   devinfo->data_in_pipe, cmdinfo->stream,
-   cmnd, DMA_FROM_DEVICE);
+   cmnd, DMA_FROM_DEVICE);
if (!cmdinfo->data_in_urb)
return SCSI_MLQUEUE_DEVICE_BUSY;
cmdinfo->state &= ~ALLOC_DATA_IN_URB;
@@ -560,8 +560,7 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
 
if (cmdinfo->state & ALLOC_DATA_OUT_URB) {
cmdinfo->data_out_urb = uas_alloc_data_urb(devinfo, gfp,
-   devinfo->data_out_pipe, cmdinfo->stream,
-   cmnd, DMA_TO_DEVICE);
+   cmnd, DMA_TO_DEVICE);
if (!cmdinfo->data_out_urb)
return SCSI_MLQUEUE_DEVICE_BUSY;
cmdinfo->state &= ~ALLOC_DATA_OUT_URB;
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
t

[PATCH 2/2] uas: Make uas work with blk-mq

2014-10-02 Thread Hans de Goede
With uas over usb-3 the tags inside the uas iu-s must match the usb-3 stream
ids, and those go from 1 - qdepth.

Before blk-mq calling scsi_activate_tcq(sdev, qdepth) guaranteed that we would
only get cmnd->request->tag from 0 - (qdepth - 1), and we used those as
uas-tags / stream-ids.

With blk-mq however we are guaranteed to never get more then qdepth commands
queued at the same time, but the cmnd->request->tag values may be much larger,
which breaks uas.

This commit fixes this by generating uas tags in the 1 - qdepth range ourselves
instead of using cmnd->request->tag.

While touching all involved code anyways also rename the uas_cmd_info stream
field to uas_tag, because when using uas over usb-2 streams are not used.

Cc: Christoph Hellwig 
Reported-by: Douglas Gilbert 
Signed-off-by: Hans de Goede 
---
 drivers/usb/storage/uas.c | 57 +++
 1 file changed, 23 insertions(+), 34 deletions(-)

diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index d1dbe88..004ebc1 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -66,7 +66,7 @@ enum {
 /* Overrides scsi_pointer */
 struct uas_cmd_info {
unsigned int state;
-   unsigned int stream;
+   unsigned int uas_tag;
struct urb *cmd_urb;
struct urb *data_in_urb;
struct urb *data_out_urb;
@@ -173,30 +173,15 @@ static void uas_sense(struct urb *urb, struct scsi_cmnd 
*cmnd)
cmnd->result = sense_iu->status;
 }
 
-/*
- * scsi-tags go from 0 - (nr_tags - 1), uas tags need to match stream-ids,
- * which go from 1 - nr_streams. And we use 1 for untagged commands.
- */
-static int uas_get_tag(struct scsi_cmnd *cmnd)
-{
-   int tag;
-
-   if (blk_rq_tagged(cmnd->request))
-   tag = cmnd->request->tag + 2;
-   else
-   tag = 1;
-
-   return tag;
-}
-
 static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *prefix,
  int status)
 {
struct uas_cmd_info *ci = (void *)&cmnd->SCp;
+   struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
 
scmd_printk(KERN_INFO, cmnd,
-   "%s %d tag %d inflight:%s%s%s%s%s%s%s%s%s%s%s%s ",
-   prefix, status, uas_get_tag(cmnd),
+   "%s %d uas-tag %d inflight:%s%s%s%s%s%s%s%s%s%s%s%s ",
+   prefix, status, cmdinfo->uas_tag,
(ci->state & SUBMIT_STATUS_URB) ? " s-st"  : "",
(ci->state & ALLOC_DATA_IN_URB) ? " a-in"  : "",
(ci->state & SUBMIT_DATA_IN_URB)? " s-in"  : "",
@@ -242,7 +227,7 @@ static int uas_try_complete(struct scsi_cmnd *cmnd, const 
char *caller)
  DATA_OUT_URB_INFLIGHT |
  COMMAND_ABORTED))
return -EBUSY;
-   devinfo->cmnd[uas_get_tag(cmnd) - 1] = NULL;
+   devinfo->cmnd[cmdinfo->uas_tag - 1] = NULL;
uas_free_unsubmitted_urbs(cmnd);
cmnd->scsi_done(cmnd);
return 0;
@@ -289,7 +274,7 @@ static void uas_stat_cmplt(struct urb *urb)
idx = be16_to_cpup(&iu->tag) - 1;
if (idx >= MAX_CMNDS || !devinfo->cmnd[idx]) {
dev_err(&urb->dev->dev,
-   "stat urb: no pending cmd for tag %d\n", idx + 1);
+   "stat urb: no pending cmd for uas-tag %d\n", idx + 1);
goto out;
}
 
@@ -427,7 +412,8 @@ static struct urb *uas_alloc_data_urb(struct uas_dev_info 
*devinfo, gfp_t gfp,
goto out;
usb_fill_bulk_urb(urb, udev, pipe, NULL, sdb->length,
  uas_data_cmplt, cmnd);
-   urb->stream_id = cmdinfo->stream;
+   if (devinfo->use_streams)
+   urb->stream_id = cmdinfo->uas_tag;
urb->num_sgs = udev->bus->sg_tablesize ? sdb->table.nents : 0;
urb->sg = sdb->table.sgl;
  out:
@@ -451,7 +437,8 @@ static struct urb *uas_alloc_sense_urb(struct uas_dev_info 
*devinfo, gfp_t gfp,
 
usb_fill_bulk_urb(urb, udev, devinfo->status_pipe, iu, sizeof(*iu),
  uas_stat_cmplt, cmnd->device->host);
-   urb->stream_id = cmdinfo->stream;
+   if (devinfo->use_streams)
+   urb->stream_id = cmdinfo->uas_tag;
urb->transfer_flags |= URB_FREE_BUFFER;
  out:
return urb;
@@ -465,6 +452,7 @@ static struct urb *uas_alloc_cmd_urb(struct uas_dev_info 
*devinfo, gfp_t gfp,
 {
struct usb_device *udev = devinfo->udev;
struct scsi_device *sdev = cmnd->device;
+   struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
struct urb *urb = usb_alloc_urb(0, gfp);
struct command_iu *iu;
int len;
@@ -481,7 +469,7 @@ static struct urb *uas_alloc_cmd_urb(struct uas_dev_info 
*devinfo, gfp_t gfp,
goto free;
 
iu->iu_id = IU_ID_COMMAND;
-   iu->tag = cpu_to_be16(uas_get_tag(cmnd));
+   iu->tag = cpu_to_be16(cmdinfo->uas_tag);
iu->prio_

Re: [PATCH 5/8] IB/srp: Remove stale connection retry mechanism

2014-10-02 Thread Bart Van Assche

On 09/20/14 19:45, Or Gerlitz wrote:

On Fri, Sep 19, 2014 at 3:58 PM, Bart Van Assche  wrote:

Attempting to connect three times may be insufficient after an
initiator system that was using multiple RDMA channels tries to
relogin. Additionally, this login retry mechanism is a workaround
for particular behavior of the IB/CM.


Can you be more specific re the particular behavior of the IB CM?
added Sean, the CM maintainer.


Let's focus on the software behavior instead of the people who are 
involved. What I have observed several times is that after a power cycle 
of the initiator system the first few login attempts are rejected. I was 
assuming that this was due to the IB/CM implementation but now that I 
have had another look at the logs I see that there is not enough 
information in the system logs to draw this conclusion. I will add 
additional logging statements in the initiator and target kernel code 
such that I can determine the root cause of this behavior.


Bart.
--
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/5] tcm_loop: Fixup tag handling

2014-10-02 Thread Hannes Reinecke
The SCSI command tag is set to the tag assigned from the block
layer, not the SCSI-II tag message. So we need to convert
it into the correct SCSI-II tag message based on the
device flags, not the tag value itself.

Reviewed-by: Sagi Grimberg 
Signed-off-by: Hannes Reinecke 
---
 drivers/target/loopback/tcm_loop.c | 23 ---
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/target/loopback/tcm_loop.c 
b/drivers/target/loopback/tcm_loop.c
index 340de9d..c2a9370 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -153,18 +153,11 @@ static int tcm_loop_change_queue_type(struct scsi_device 
*sdev, int tag)
 /*
  * Locate the SAM Task Attr from struct scsi_cmnd *
  */
-static int tcm_loop_sam_attr(struct scsi_cmnd *sc)
-{
-   if (sc->device->tagged_supported) {
-   switch (sc->tag) {
-   case HEAD_OF_QUEUE_TAG:
-   return MSG_HEAD_TAG;
-   case ORDERED_QUEUE_TAG:
-   return MSG_ORDERED_TAG;
-   default:
-   break;
-   }
-   }
+static int tcm_loop_sam_attr(struct scsi_cmnd *sc, int tag)
+{
+   if (sc->device->tagged_supported &&
+   sc->device->ordered_tags && tag >= 0)
+   return MSG_ORDERED_TAG;
 
return MSG_SIMPLE_TAG;
 }
@@ -227,7 +220,7 @@ static void tcm_loop_submission_work(struct work_struct 
*work)
 
rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd,
&tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun,
-   transfer_length, tcm_loop_sam_attr(sc),
+   transfer_length, tcm_loop_sam_attr(sc, 
tl_cmd->sc_cmd_tag),
sc->sc_data_direction, 0,
scsi_sglist(sc), scsi_sg_count(sc),
sgl_bidi, sgl_bidi_count,
@@ -266,7 +259,7 @@ static int tcm_loop_queuecommand(struct Scsi_Host *sh, 
struct scsi_cmnd *sc)
}
 
tl_cmd->sc = sc;
-   tl_cmd->sc_cmd_tag = sc->tag;
+   tl_cmd->sc_cmd_tag = sc->request->tag;
INIT_WORK(&tl_cmd->work, tcm_loop_submission_work);
queue_work(tcm_loop_workqueue, &tl_cmd->work);
return 0;
@@ -370,7 +363,7 @@ static int tcm_loop_abort_task(struct scsi_cmnd *sc)
 */
tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id];
ret = tcm_loop_issue_tmr(tl_tpg, tl_nexus, sc->device->lun,
-sc->tag, TMR_ABORT_TASK);
+sc->request->tag, TMR_ABORT_TASK);
return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED;
 }
 
-- 
1.8.5.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/5] NCR5380: Whitespace cleanup

2014-10-02 Thread Hannes Reinecke
Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/NCR5380.c | 652 +
 1 file changed, 333 insertions(+), 319 deletions(-)

diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index 45da3c8..c8aa935 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -1,4 +1,4 @@
-/* 
+/*
  * NCR 5380 generic driver routines.  These should make it *trivial*
  *  to implement 5380 SCSI drivers under Linux with a non-trantor
  *  architecture.
@@ -6,14 +6,14 @@
  *  Note that these routines also work with NR53c400 family chips.
  *
  * Copyright 1993, Drew Eckhardt
- *  Visionary Computing 
+ *  Visionary Computing
  *  (Unix and Linux consulting and custom programming)
  *  d...@colorado.edu
  *  +1 (303) 666-5836
  *
- * DISTRIBUTION RELEASE 6. 
+ * DISTRIBUTION RELEASE 6.
  *
- * For more information, please consult 
+ * For more information, please consult
  *
  * NCR 5380 Family
  * SCSI Protocol Controller
@@ -29,10 +29,10 @@
 /*
  * Revision 1.10 1998/9/2  Alan Cox
  * (a...@lxorguk.ukuu.org.uk)
- * Fixed up the timer lockups reported so far. Things still suck. Looking 
+ * Fixed up the timer lockups reported so far. Things still suck. Looking
  * forward to 2.3 and per device request queues. Then it'll be possible to
  * SMP thread this beast and improve life no end.
- 
+
  * Revision 1.9  1997/7/27 Ronald van Cuijlenborg
  * (ronald.van.cuijlenb...@tip.nl or nu...@dds.nl)
  * (hopefully) fixed and enhanced USLEEP
@@ -69,27 +69,35 @@
  */
 
 /*
- * Further development / testing that should be done : 
+ * Further development / testing that should be done :
  * 1.  Cleanup the NCR5380_transfer_dma function and DMA operation complete
- * code so that everything does the same thing that's done at the 
+ * code so that everything does the same thing that's done at the
  * end of a pseudo-DMA read operation.
  *
  * 2.  Fix REAL_DMA (interrupt driven, polled works fine) -
- * basically, transfer size needs to be reduced by one 
+ * basically, transfer size needs to be reduced by one
  * and the last byte read as is done with PSEUDO_DMA.
- * 
- * 4.  Test SCSI-II tagged queueing (I have no devices which support 
+ *
+ * 4.  Test SCSI-II tagged queueing (I have no devices which support
  *  tagged queueing)
  *
- * 5.  Test linked command handling code after Eric is ready with 
+ * 5.  Test linked command handling code after Eric is ready with
  *  the high level code.
  */
 #include 
 #include 
 
 #if (NDEBUG & NDEBUG_LISTS)
-#define LIST(x,y) {printk("LINE:%d   Adding %p to %p\n", __LINE__, (void*)(x), 
(void*)(y)); if ((x)==(y)) udelay(5); }
-#define REMOVE(w,x,y,z) {printk("LINE:%d   Removing: %p->%p  %p->%p \n", 
__LINE__, (void*)(w), (void*)(x), (void*)(y), (void*)(z)); if ((x)==(y)) 
udelay(5); }
+#define LIST(x,y) {\
+   printk("LINE:%d   Adding %p to %p\n", __LINE__, \
+  (void*)(x), (void*)(y)); \
+   if ((x)==(y)) udelay(5);\
+   }
+#define REMOVE(w,x,y,z) {  \
+   printk("LINE:%d   Removing: %p->%p  %p->%p \n", __LINE__, \
+  (void*)(w), (void*)(x), (void*)(y), (void*)(z)); \
+   if ((x)==(y)) udelay(5);\
+}
 #else
 #define LIST(x,y)
 #define REMOVE(w,x,y,z)
@@ -114,9 +122,9 @@
 /*
  * Design
  *
- * This is a generic 5380 driver.  To use it on a different platform, 
+ * This is a generic 5380 driver.  To use it on a different platform,
  * one simply writes appropriate system specific macros (ie, data
- * transfer - some PC's will use the I/O bus, 68K's must use 
+ * transfer - some PC's will use the I/O bus, 68K's must use
  * memory mapped) and drops this file in their 'C' wrapper.
  *
  * (Note from hch:  unfortunately it was not enough for the different
@@ -125,33 +133,33 @@
  * most updates to this driver.  Maybe someone will fix all these
  * drivers to use a common core one day..)
  *
- * As far as command queueing, two queues are maintained for 
+ * As far as command queueing, two queues are maintained for
  * each 5380 in the system - commands that haven't been issued yet,
- * and commands that are currently executing.  This means that an 
- * unlimited number of commands may be queued, letting 
- * more commands propagate from the higher driver levels giving higher 
- * throughput.  Note that both I_T_L and I_T_L_Q nexuses are supported, 
- * allowing multiple commands to propagate all the way to a SCSI-II device 
+ * and commands that are currently executing.  This means that an
+ * unlimited number of commands may be queued, letting
+ * more commands propagate from the higher driver levels giving higher
+ * throughput.  Note t

[PATCH 2/5] scsi: Remove references to linked commands

2014-10-02 Thread Hannes Reinecke
Some NCR5380-based drivers implement support for linked commands
via a 'next_link' pointer in struct scsi_cmnd. This pointer has
long since removed, rendering the code pointless.
So remove it.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/NCR5380.c   | 40 ---
 drivers/scsi/atari_NCR5380.c | 57 
 drivers/scsi/sun3_NCR5380.c  | 57 
 3 files changed, 154 deletions(-)

diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index c8aa935..a0c8c5d 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -104,7 +104,6 @@
 #endif
 
 #ifndef notyet
-#undef LINKED
 #undef REAL_DMA
 #endif
 
@@ -216,8 +215,6 @@
  *  these transfers, we might need this to give reasonable interrupt
  *  service time if the transfer size gets too large.
  *
- * LINKED - if defined, linked commands are supported.
- *
  * PSEUDO_DMA - if defined, PSEUDO DMA is used during the data transfer phases.
  *
  * REAL_DMA - if defined, REAL DMA is used during the data transfer phases.
@@ -2210,43 +2207,6 @@ static void NCR5380_information_transfer(struct 
Scsi_Host *instance) {
cmd->SCp.Message = tmp;
 
switch (tmp) {
-   /*
-* Linking lets us reduce the time 
required to get the
-* next command out to the device, 
hopefully this will
-* mean we don't waste another 
revolution due to the delays
-* required by ARBITRATION and another 
SELECTION.
-*
-* In the current implementation 
proposal, low level drivers
-* merely have to start the next 
command, pointed to by
-* next_link, done() is called as with 
unlinked commands.
-*/
-#ifdef LINKED
-   case LINKED_CMD_COMPLETE:
-   case LINKED_FLG_CMD_COMPLETE:
-   /* Accept message by clearing ACK */
-   NCR5380_write(INITIATOR_COMMAND_REG, 
ICR_BASE);
-   dprintk(NDEBUG_LINKED, "scsi%d : target 
%d lun %llu linked command complete.\n", instance->host_no, cmd->device->id, 
cmd->device->lun);
-   /*
-* Sanity check : A linked command 
should only terminate with
-* one of these messages if there are 
more linked commands
-* available.
-*/
-   if (!cmd->next_link) {
-   printk("scsi%d : target %d lun %llu 
linked command complete, no next_link\n" instance->host_no, cmd->device->id, 
cmd->device->lun);
-   sink = 1;
-   do_abort(instance);
-   return;
-   }
-   initialize_SCp(cmd->next_link);
-   /* The next command is still part of 
this process */
-   cmd->next_link->tag = cmd->tag;
-   cmd->result = cmd->SCp.Status | 
(cmd->SCp.Message << 8);
-   dprintk(NDEBUG_LINKED, "scsi%d : target 
%d lun %llu linked request done, calling scsi_done().\n", instance->host_no, 
cmd->device->id, cmd->device->lun);
-   collect_stats(hostdata, cmd);
-   cmd->scsi_done(cmd);
-   cmd = hostdata->connected;
-   break;
-#endif /* def LINKED */
case ABORT:
case COMMAND_COMPLETE:
/* Accept message by clearing ACK */
diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c
index 79e6f04..d11c271 100644
--- a/drivers/scsi/atari_NCR5380.c
+++ b/drivers/scsi/atari_NCR5380.c
@@ -97,10 +97,6 @@
 #define REMOVE(w,x,y,z)
 #endif
 
-#ifndef notyet
-#undef LINKED
-#endif
-
 /*
  * Design
  * Issues :
@@ -211,8 +207,6 @@
  * AUTOSENSE - if defined, REQUEST SENSE will be performed automatically
  * for commands that return with a CHECK CONDITION status.
  *
- * LINKED - if defined, linked commands are supported.
- *
  * REAL_DMA - if defined, REAL DMA is used during the data transfer ph

[RFC PATCH 0/5] Remove scmd->tag

2014-10-02 Thread Hannes Reinecke
The 'tag' field of struct scsi_cmnd has not separate meaning anymore,
and the same information is present in the associated request.
So remove it.

Hannes Reinecke (5):
  NCR5380: Whitespace cleanup
  scsi: Remove references to linked commands
  vmw_pvscsi: fixup tagging
  tcm_loop: Fixup tag handling
  scsi: Remove scmd->tag

 drivers/scsi/NCR5380.c | 691 ++---
 drivers/scsi/atari_NCR5380.c   |  57 ---
 drivers/scsi/fnic/fnic_scsi.c  |   1 -
 drivers/scsi/scsi_lib.c|   4 -
 drivers/scsi/sun3_NCR5380.c|  57 ---
 drivers/scsi/vmw_pvscsi.c  |   5 +-
 drivers/target/loopback/tcm_loop.c |  23 +-
 include/scsi/scsi_cmnd.h   |   2 -
 8 files changed, 342 insertions(+), 498 deletions(-)

-- 
1.8.5.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 5/5] scsi: Remove scmd->tag

2014-10-02 Thread Hannes Reinecke
struct scsi_cmnd has a 'tag' field, which was supposed to be
used to support SCSI-II tagged command queueing.
In the end tagged command queueing support moved into the
block layer, with the tag number available in the request.
So the 'tag' field lost its original meaning and can be
removed.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/NCR5380.c| 5 ++---
 drivers/scsi/fnic/fnic_scsi.c | 1 -
 drivers/scsi/scsi_lib.c   | 4 
 include/scsi/scsi_cmnd.h  | 2 --
 4 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index a0c8c5d..cb68089 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -1527,7 +1527,6 @@ part2:
tmp[0] = IDENTIFY(((instance->irq == SCSI_IRQ_NONE) ? 0 : 1), 
cmd->device->lun);
 
len = 1;
-   cmd->tag = 0;
 
/* Send message(s) */
data = tmp;
@@ -2563,7 +2562,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) {
do_abort(instance);
} else {
hostdata->connected = tmp;
-   dprintk(NDEBUG_RESELECTION, "scsi%d : nexus established, target 
= %d, lun = %llu, tag = %d\n", instance->host_no, tmp->device->id, 
tmp->device->lun, tmp->tag);
+   dprintk(NDEBUG_RESELECTION, "scsi%d : nexus established, target 
= %d, lun = %llu, tag = %d\n", instance->host_no, tmp->device->id, 
tmp->device->lun, tmp->request->tag);
}
 }
 
@@ -2748,7 +2747,7 @@ static int NCR5380_abort(Scsi_Cmnd * cmd) {
if (cmd == tmp) {
dprintk(NDEBUG_ABORT, "scsi%d : aborting disconnected 
command.\n", instance->host_no);
 
-   if (NCR5380_select(instance, cmd, (int) cmd->tag))
+   if (NCR5380_select(instance, cmd, cmd->request->tag))
return FAILED;
dprintk(NDEBUG_ABORT, "scsi%d : nexus 
reestablished.\n", instance->host_no);
 
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 961bdf5..e54ace9 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -2137,7 +2137,6 @@ fnic_scsi_host_start_tag(struct fnic *fnic, struct 
scsi_cmnd *sc)
 
bqt->tag_index[tag] = sc->request;
sc->request->tag = tag;
-   sc->tag = tag;
if (!sc->request->special)
sc->request->special = sc;
 
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index b9a8ddd..a7d4d93 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1191,8 +1191,6 @@ static struct scsi_cmnd *scsi_get_cmd_from_req(struct 
scsi_device *sdev,
cmd = req->special;
}
 
-   /* pull a tag out of the request if we have one */
-   cmd->tag = req->tag;
cmd->request = req;
 
cmd->cmnd = req->cmd;
@@ -1808,8 +1806,6 @@ static int scsi_mq_prep_fn(struct request *req)
cmd->device = sdev;
cmd->sense_buffer = sense_buf;
 
-   cmd->tag = req->tag;
-
cmd->cmnd = req->cmd;
cmd->prot_op = SCSI_PROT_NORMAL;
 
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 73f3490..45c9eb0 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -130,8 +130,6 @@ struct scsi_cmnd {
 * to be at an address < 16Mb). */
 
int result; /* Status code from lower level driver */
-
-   unsigned char tag;  /* SCSI-II queued command tag */
 };
 
 /*
-- 
1.8.5.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/5] vmw_pvscsi: fixup tagging

2014-10-02 Thread Hannes Reinecke
The request (and SCSI command) tag is the tag number assigned
by the generic block-tagging code, not the SCSI-II tag messages.
Those are represented by the device flags 'tagged_supported',
'simple_tags', and 'ordered_tags'.
(The SCSI midlayer doesn't use HEAD_OF_QUEUE tags).
So fixup vmw_pvscsi to assign the correct tag type.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/vmw_pvscsi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
index 598f65e..d18df8c 100644
--- a/drivers/scsi/vmw_pvscsi.c
+++ b/drivers/scsi/vmw_pvscsi.c
@@ -724,9 +724,8 @@ static int pvscsi_queue_ring(struct pvscsi_adapter *adapter,
 
e->tag = SIMPLE_QUEUE_TAG;
if (sdev->tagged_supported &&
-   (cmd->tag == HEAD_OF_QUEUE_TAG ||
-cmd->tag == ORDERED_QUEUE_TAG))
-   e->tag = cmd->tag;
+   sdev->ordered_tags)
+   e->tag = ORDERED_QUEUE_TAG;
 
if (cmd->sc_data_direction == DMA_FROM_DEVICE)
e->flags = PVSCSI_FLAG_CMD_DIR_TOHOST;
-- 
1.8.5.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


PR registration on LIO iscsi returns sense key not ready

2014-10-02 Thread Luigi Tarenga

hello everybody,
I have a little problem with LIO iscsi target and SPC-3 persistent 
reservation.

The summary of my setup is:
host:
  centos 6.5 x86_64 with custom kernel 3.16.3 + scst patches
  targetcli (-fb) 2.1.fb37
  this host is configured to export a lun0 to the guest via iscsi

guest:
  centos 7 x64_64 with stock kernel 3.10.0-123.6.3.el7.x86_64
  iscsi-initiator-utils-6.2.0.873-21.el7.x86_64
  sg3_utils-1.37-5.el7.x86_64

on the host LIO is configured as:
[root@lizard ~]# targetcli ls
o- / 
... 
[...]
  o- backstores 
 
[...]
  | o- block 
 
[Storage Objects: 0]
  | o- fileio 
... 
[Storage Objects: 1]
  | | o- disk0 
.. 
[/root/lun-test1 (10.0MiB) write-back activated]
  | o- pscsi 
 
[Storage Objects: 0]
  | o- ramdisk 
.. 
[Storage Objects: 0]
  o- iscsi 
.. 
[Targets: 1]
  | o- iqn.2003-01.org.linux-iscsi.lizard.x8664:sn.15df8aa9db1d 
 [TPGs: 1]
  |   o- tpg1 
. 
[no-gen-acls, no-auth]
  | o- acls 
 
[ACLs: 2]
  | | o- iqn.1994-05.com.redhat:1fc561f74faa 
 [Mapped 
LUNs: 1]
  | | | o- mapped_lun0 
.. 
[lun0 fileio/disk0 (rw)]
  | | o- iqn.1994-05.com.redhat:b45af55c1b7e 
 [Mapped 
LUNs: 1]
  | |   o- mapped_lun0 
.. 
[lun0 fileio/disk0 (rw)]
  | o- luns 
 
[LUNs: 1]
  | | o- lun0 
... 
[fileio/disk0 (/root/lun-test1)]
  | o- portals 
.. 
[Portals: 1]
  |   o- 0.0.0.0:3260 
... 
[OK]
  o- loopback 
... 
[Targets: 0]
  o- sbp 
 
[Targets: 0]
  o- vhost 
.. 
[Targets: 0]



the guest virtualization is done with qemu-2.0.0+kvm, NIC is virt-io and 
the guest

connect to the host via a tap device.

The guest can connect to the iSCSI target and i see the device as /dev/sda.
I partitioned, formatted and mounted it successfully.

My problem that every PR Out command return a sense key not ready
even if the command run successfully, see this sequence:

[root@centos7 ~]# ll 
/dev/disk/by-path/ip-172.24.49.193\:3260-iscsi-iqn.2003-01.org.linux-iscsi.lizard.x8664\:sn.15df8aa9db1d-lun-0
lrwxrwxrwx. 1 root root 9 Oct  2 12:29 
/dev/disk/by-path/ip-172.24.49.193:3260-iscsi-iqn.2003-01.org.linux-iscsi.lizard.x8664:sn.15df8aa9db1d-lun-0 
-> ../../sda


[root@centos7 ~]# sg_persist -n --read-keys --device=/dev/sda
  PR generation=0x0, there are NO registered reservation keys

[root@centos7 ~]# sg_persist -n -v --out --register 
--param-sark=ac1831c2 --device=/dev/sda

Persistent Reservation Out cmd: 5f 00 00 00 00 00 00 00 18 00
persistent reserve out:  Fixed format, current;  Sense key: Not Ready
 Additional sense: Logical unit communication failure
PR out: command failed

[root@centos7 ~]# sg_persist -n --read-keys --device=/dev/sda
  PR generation=0x1, 1 registered reservation key follows:
0xac1831c2

[root@centos7 ~]# sg_persist -n -v --out --register --param-rk=ac1831c2 
--device=/dev/sda

Persistent Reservation Out cmd: 5f 00 00 00 00 00 00 00 18 00
persistent reserve out:  Fixed format, current;  Sense key: Not Ready
 Additional sense: Logical unit communication failure
PR out: command failed

[root@centos7 ~]#

Re: [PATCH 1/5] NCR5380: Whitespace cleanup

2014-10-02 Thread Finn Thain

On Thu, 2 Oct 2014, Hannes Reinecke wrote:

> Signed-off-by: Hannes Reinecke 
> ---
>  drivers/scsi/NCR5380.c | 652 
> +
>  1 file changed, 333 insertions(+), 319 deletions(-)
> 

This is going to break about 30 or 40 patches that I'm working on. Can we 
not do this yet? The white space clean up is a smaller patch if it happens 
after all the other bug fixing and modernization work.

-- 
--
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 1/5] NCR5380: Whitespace cleanup

2014-10-02 Thread Hannes Reinecke
On 10/02/2014 01:07 PM, Finn Thain wrote:
> 
> On Thu, 2 Oct 2014, Hannes Reinecke wrote:
> 
>> Signed-off-by: Hannes Reinecke 
>> ---
>>  drivers/scsi/NCR5380.c | 652 
>> +
>>  1 file changed, 333 insertions(+), 319 deletions(-)
>>
> 
> This is going to break about 30 or 40 patches that I'm working on. Can we 
> not do this yet? The white space clean up is a smaller patch if it happens 
> after all the other bug fixing and modernization work.
> 
Oh, you're most welcome.
I've just included it as my eyes nearly fell out when turning on
syntax highlighting.
The patch is an RFC anyway, so I doubt it'll be included in 3.18.

And indeed the NCR5380 is in dire need of modernization; having
three to four identical copies with just minor modifications
between each simply cries out for consolidation.

Thanks for doing that.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries & Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
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 PATCH 0/5] Remove scmd->tag

2014-10-02 Thread Christoph Hellwig
This seems to miss a places, that mostly just seem to use scmd->tag
where they should be using scmd->request->tag:

 - acornscsi.c (and arm/queue.c)
 - fas216
 - qla1280

As well as virtio_scsi, which does a pointless assignment to scmd->tag.

It might be worth to push this out to somewhere where the buildbot
can find it while waiting for the NCR5380 overhaul.
--
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 5/5] scsi: Remove scmd->tag

2014-10-02 Thread Christoph Hellwig
> diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
> index a0c8c5d..cb68089 100644
> --- a/drivers/scsi/NCR5380.c
> +++ b/drivers/scsi/NCR5380.c
> @@ -1527,7 +1527,6 @@ part2:
>   tmp[0] = IDENTIFY(((instance->irq == SCSI_IRQ_NONE) ? 0 : 1), 
> cmd->device->lun);
>  
>   len = 1;
> - cmd->tag = 0;

The driver was explicitly setting the tag to zero here, so this needs
a good explanation instead of a blind removal.

But given how nice the code that Finn delivered in the past is I have high
hopes that his NCR5380 overhaul will get rid of a lot of this cruft :)

--
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 1/2] uas: Reduce number of function arguments for uas_alloc_foo functions

2014-10-02 Thread Christoph Hellwig
On Thu, Oct 02, 2014 at 12:04:39PM +0200, Hans de Goede wrote:
> The stream_id and pipe are already present in uas_cmd_info resp uas_dev_info,
> so there is no need to pass a copy along.
> 
> Signed-off-by: Hans de Goede 

Looks good,

Reviewed-by: Christoph Hellwig 
--
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 2/2] uas: Make uas work with blk-mq

2014-10-02 Thread Christoph Hellwig
Looks fine to me (and actually removes code..)

Reviewed-by: Christoph Hellwig 

It's fairly late in 3.17 to get something like this in, but would you
consider Ccing it to stable so we can get it into the first 3.17 stable
release?
--
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] megaraid_sas: Enable shared tag map

2014-10-02 Thread Christoph Hellwig
On Thu, Oct 02, 2014 at 11:50:42AM +0200, Hannes Reinecke wrote:
> NCR5380 (and derived LLDDs) and fnic.

fnic needs a tag for a device reset, which we don't provide if it
is issue by ioctl.  This is also showed up during the blk-mq work.
--
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 5/5] scsi: Remove scmd->tag

2014-10-02 Thread Hannes Reinecke
On 10/02/2014 01:22 PM, Christoph Hellwig wrote:
>> diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
>> index a0c8c5d..cb68089 100644
>> --- a/drivers/scsi/NCR5380.c
>> +++ b/drivers/scsi/NCR5380.c
>> @@ -1527,7 +1527,6 @@ part2:
>>  tmp[0] = IDENTIFY(((instance->irq == SCSI_IRQ_NONE) ? 0 : 1), 
>> cmd->device->lun);
>>  
>>  len = 1;
>> -cmd->tag = 0;
> 
> The driver was explicitly setting the tag to zero here, so this needs
> a good explanation instead of a blind removal.
> 
> But given how nice the code that Finn delivered in the past is I have high
> hopes that his NCR5380 overhaul will get rid of a lot of this cruft :)
> 
Yep. (Removing the above line shouldn't actually doing any harm, as
the tagged queueing support in NCR5380 is currently disabled anyway).
(Famous last words).

But this was just a test for the feasibility of scmd->tag removal.
Once Finn's patchset is posted we definitely should be revisiting
it.

And arguably the tcm_loop and vmw_pvscsi patches are real bugfixes,
so maybe they should be applied anyway.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries & Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
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 5/5] scsi: Remove scmd->tag

2014-10-02 Thread Finn Thain

On Thu, 2 Oct 2014, Hannes Reinecke wrote:

> struct scsi_cmnd has a 'tag' field, which was supposed to be
> used to support SCSI-II tagged command queueing.
> In the end tagged command queueing support moved into the
> block layer, with the tag number available in the request.
> So the 'tag' field lost its original meaning and can be
> removed.

I'm pretty sure this patch will break atari_scsi. sun3_scsi does not 
define SUPPORT_TAGS, so it should be mostly unaffected.

We may need to comment out the #define SUPPORT_TAGS in atari_scsi until 
Michael and I figure out how to make the driver work with block layer 
tags.

> diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
> index a0c8c5d..cb68089 100644
> --- a/drivers/scsi/NCR5380.c
> +++ b/drivers/scsi/NCR5380.c

...

> @@ -2748,7 +2747,7 @@ static int NCR5380_abort(Scsi_Cmnd * cmd) {
>   if (cmd == tmp) {
>   dprintk(NDEBUG_ABORT, "scsi%d : aborting disconnected 
> command.\n", instance->host_no);
>  
> - if (NCR5380_select(instance, cmd, (int) cmd->tag))
> + if (NCR5380_select(instance, cmd, cmd->request->tag))

NCR5380_select() does not use its tag parameter. I have a patch that 
removes it. I'll send the first set of patches I've been working on.

-- 
--
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] megaraid_sas: Enable shared tag map

2014-10-02 Thread Hannes Reinecke
On 10/02/2014 01:36 PM, Christoph Hellwig wrote:
> On Thu, Oct 02, 2014 at 11:50:42AM +0200, Hannes Reinecke wrote:
>> NCR5380 (and derived LLDDs) and fnic.
> 
> fnic needs a tag for a device reset, which we don't provide if it
> is issue by ioctl.  This is also showed up during the blk-mq work.
> 
Actually, I've hit a similar issue for megaraid_sas (and I guess
others which implement a host-wide tag map might suffer here, too):
tags need to be used even for internal commands.
But tag allocation is done exclusively in the block layer, so one
cannot readily influence this.
(Or, if you do, you'll end up with code duplication like the fnic
driver).
Thing is, for internal commands we typically do not _need_ a fully
formed request, we just need to tag number.

So we could try to implement a function like 'blk_tag_reserve'
to return the next free tag.

But even with that we'd be hitting a tag starvation issue; when
all command tags are in use we cannot send internal commands.
And if the command abort happens to be modelled with an internal
command, we cannot even abort commands anymore.
Which is probably _not_ what we want.
(And I think fnic will suffer from this, too ...)

So I guess we need to set aside a reserved tag pool from which
the internal commands will be allocated.
(Bit like the emergency network skb pool).
With that the tag starvation issue will be resolved, and
we should be able to remove the custom code in fnic.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries & Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
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] megaraid_sas: Enable shared tag map

2014-10-02 Thread James Bottomley
On Thu, 2014-10-02 at 08:51 +0200, Hannes Reinecke wrote:
> On 10/01/2014 11:10 PM, Christoph Hellwig wrote:
> > On Wed, Oct 01, 2014 at 02:51:31PM -0400, Webb Scales wrote:
> >> Hannes,
> >>
> >> In megasas_change_queue_type(), is it possible for sdev->queue_depth to be
> >> greater than 256?
> >>
> >> Unless I'm misunderstanding the SCSI code, we can request a
> >> queue-depth/tag-map-size which is greater than 256, but, since the
> >> scsi_cmnd::tag field is an unsigned char, depths greater than 256 may
> >> overflow the field when high-numbered tags are used...do I have that right?
> > 
> > Yes, we really need to increase the size of the tag field.  SAM allows
> > a transport specific limit of up to 64 _bytes_ for it, although I don't
> > know implementation that large.  Given that the block layer can generate
> > up to 32-bit tags both for the old blk-tag.c code and the new
> > blk-mq-tag.c version it would be good to use a u32 there.  Can you send
> > me a patch?
> > 
> Weeelll ...
> 
> I'm afraid it's not _that_ easy.
> SCSI-II tagged queueing has some specific tag values:
> 
> #define SIMPLE_QUEUE_TAG0x20
> #define HEAD_OF_QUEUE_TAG   0x21
> #define ORDERED_QUEUE_TAG   0x22
> 
> drivers/scsi/vmw_pvscsi.c:
>   e->tag = SIMPLE_QUEUE_TAG;
>   if (sdev->tagged_supported &&
>   (cmd->tag == HEAD_OF_QUEUE_TAG ||
>cmd->tag == ORDERED_QUEUE_TAG))
>   e->tag = cmd->tag;

A SCSI-2 tag is a SPI two byte message.  The first byte is the message
type.  The values you have above identify the message type for simple,
ordered and head of queue tags.  The *second* byte is the tag value.

See page 55 and 56 of the SCSI-2 standard.  There's no connection (or
shouldn't be) between the message type and the tag value, so it looks
like a bug in the pvscsi driver.

James



Re: [PATCH] megaraid_sas: Enable shared tag map

2014-10-02 Thread Hannes Reinecke
On 10/02/2014 02:05 PM, James Bottomley wrote:
> On Thu, 2014-10-02 at 08:51 +0200, Hannes Reinecke wrote:
>> On 10/01/2014 11:10 PM, Christoph Hellwig wrote:
>>> On Wed, Oct 01, 2014 at 02:51:31PM -0400, Webb Scales wrote:
 Hannes,

 In megasas_change_queue_type(), is it possible for sdev->queue_depth to be
 greater than 256?

 Unless I'm misunderstanding the SCSI code, we can request a
 queue-depth/tag-map-size which is greater than 256, but, since the
 scsi_cmnd::tag field is an unsigned char, depths greater than 256 may
 overflow the field when high-numbered tags are used...do I have that right?
>>>
>>> Yes, we really need to increase the size of the tag field.  SAM allows
>>> a transport specific limit of up to 64 _bytes_ for it, although I don't
>>> know implementation that large.  Given that the block layer can generate
>>> up to 32-bit tags both for the old blk-tag.c code and the new
>>> blk-mq-tag.c version it would be good to use a u32 there.  Can you send
>>> me a patch?
>>>
>> Weeelll ...
>>
>> I'm afraid it's not _that_ easy.
>> SCSI-II tagged queueing has some specific tag values:
>>
>> #define SIMPLE_QUEUE_TAG0x20
>> #define HEAD_OF_QUEUE_TAG   0x21
>> #define ORDERED_QUEUE_TAG   0x22
>>
>> drivers/scsi/vmw_pvscsi.c:
>>  e->tag = SIMPLE_QUEUE_TAG;
>>  if (sdev->tagged_supported &&
>>  (cmd->tag == HEAD_OF_QUEUE_TAG ||
>>   cmd->tag == ORDERED_QUEUE_TAG))
>>  e->tag = cmd->tag;
> 
> A SCSI-2 tag is a SPI two byte message.  The first byte is the message
> type.  The values you have above identify the message type for simple,
> ordered and head of queue tags.  The *second* byte is the tag value.
> 
> See page 55 and 56 of the SCSI-2 standard.  There's no connection (or
> shouldn't be) between the message type and the tag value, so it looks
> like a bug in the pvscsi driver.
> 
It is. I've already sent a patch.

But that just proves the scmd->tag is essentially a duplicate
and we should be removing it.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries & Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
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 2/2] uas: Make uas work with blk-mq

2014-10-02 Thread Hans de Goede
Hi,

On 10/02/2014 01:26 PM, Christoph Hellwig wrote:
> Looks fine to me (and actually removes code..)
> 
> Reviewed-by: Christoph Hellwig 
> 
> It's fairly late in 3.17 to get something like this in, but would you
> consider Ccing it to stable so we can get it into the first 3.17 stable
> release?

This patch sits on top of a whole bunch of uas cleanups / fixes which
are going into 3.18, and which are to big of a change to backport.

Regards,

Hans
--
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/29] ncr5380: Use printk() not pr_debug()

2014-10-02 Thread Finn Thain
Having defined NDEBUG, and having set the console log level, I'd like to see
some output. Don't use pr_debug(), it's annoying to have to define DEBUG as
well.

Signed-off-by: Finn Thain 

---

Use of pr_debug() here was a bad idea of mine. Joe was right when
he questioned it.

---
 drivers/scsi/NCR5380.h |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux/drivers/scsi/NCR5380.h
===
--- linux.orig/drivers/scsi/NCR5380.h   2014-10-02 16:55:29.0 +1000
+++ linux/drivers/scsi/NCR5380.h2014-10-02 16:55:49.0 +1000
@@ -296,7 +296,8 @@ struct NCR5380_hostdata {
 #endif
 
 #define dprintk(flg, fmt, ...) \
-   do { if ((NDEBUG) & (flg)) pr_debug(fmt, ## __VA_ARGS__); } while (0)
+   do { if ((NDEBUG) & (flg)) \
+   printk(KERN_DEBUG fmt, ## __VA_ARGS__); } while (0)
 
 #if NDEBUG
 #define NCR5380_dprint(flg, arg) \


--
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 00/29] Fixes, cleanups and modernization for NCR5380 drivers

2014-10-02 Thread Finn Thain

This patch series has fixes for bugs and compiler warnings as well as code
cleanup and modernization. It covers all ten NCR5380 drivers and the three
core NCR5380 drivers so it's fairly large.

At the end of this series about a thousand lines (net) have been removed
including two header files. A lot of C pre-processor abuse is eliminated.
There are patches for scsi_add_host() conversion for atari_scsi, mac_scsi
and sun3_scsi.

Some steps are taken toward re-unification of the NCR5380 core driver forks
by reducing divergence between them. Also, the atari_NCR5380.c core driver
is generalized such that it can be used by sun3_scsi.c. The next step is
to remove sun_NCR5380.c by adopting atari_NCR5380.c.

I have compile-tested all of the NCR5380 drivers (x86, ARM and m68k) and
executed mac_scsi and dmx3191d on suitable hardware. I found no regressions
but the core NCR5380 drivers have bugs unrelated to these patches.

Testing mac_scsi and dmx3191d provides only limited code coverage for these
patches. Some testing on Sun 3, Atari ST and/or Atari TT would be nice
(I don't have the hardware).

There are old bugs relating to exception handling and autosense in the
core NCR5380 drivers that can make testing difficult. I'm working on a series
of patches to address these bugs. Those patches are not yet ready for
submission but they were helpful in testing this patch series and may be
helpful to other testers. Let me know if so.

---
 arch/m68k/atari/config.c|5 
 arch/m68k/atari/stdma.c |   62 ++-
 arch/m68k/include/asm/atari_stdma.h |4 
 arch/m68k/include/asm/macintosh.h   |3 
 arch/m68k/mac/config.c  |  101 -
 arch/m68k/sun3/config.c |   11 
 drivers/scsi/Kconfig|2 
 drivers/scsi/NCR5380.c  |  296 +--
 drivers/scsi/NCR5380.h  |   59 +--
 drivers/scsi/arm/cumana_1.c |   18 
 drivers/scsi/arm/oak.c  |   21 -
 drivers/scsi/atari_NCR5380.c|  383 
 drivers/scsi/atari_scsi.c   |  677 +++-
 drivers/scsi/atari_scsi.h   |   60 ---
 drivers/scsi/dmx3191d.c |   31 -
 drivers/scsi/dtc.c  |   85 +---
 drivers/scsi/dtc.h  |   26 -
 drivers/scsi/g_NCR5380.c|  224 ---
 drivers/scsi/g_NCR5380.h|   26 -
 drivers/scsi/mac_scsi.c |  545 
 drivers/scsi/mac_scsi.h |   74 ---
 drivers/scsi/pas16.c|  106 +
 drivers/scsi/pas16.h|   21 -
 drivers/scsi/sun3_NCR5380.c |  187 ++---
 drivers/scsi/sun3_scsi.c|  518 ---
 drivers/scsi/sun3_scsi.h|   75 ---
 drivers/scsi/t128.c |   83 +---
 drivers/scsi/t128.h |   23 -
 28 files changed, 1366 insertions(+), 2360 deletions(-)




--
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/29] ncr5380: Remove unused macros

2014-10-02 Thread Finn Thain
Some macros are never evaluated (i.e. FOO, USLEEP, SCSI2 and USE_WRAPPER; and 
in some drivers, NCR5380_intr and NCR5380_proc_info). DRIVER_SETUP serves no
purpose anymore. Remove these macro definitions.

Signed-off-by: Finn Thain 

---
 drivers/scsi/NCR5380.c|2 +-
 drivers/scsi/arm/oak.c|1 -
 drivers/scsi/atari_scsi.h |1 -
 drivers/scsi/g_NCR5380.c  |5 -
 drivers/scsi/g_NCR5380.h  |1 -
 drivers/scsi/mac_scsi.c   |3 ---
 drivers/scsi/pas16.c  |5 -
 drivers/scsi/sun3_scsi.c  |   15 ---
 drivers/scsi/sun3_scsi.h  |1 -
 drivers/scsi/t128.c   |5 -
 10 files changed, 1 insertion(+), 38 deletions(-)

Index: linux/drivers/scsi/mac_scsi.c
===
--- linux.orig/drivers/scsi/mac_scsi.c  2014-10-02 16:55:50.0 +1000
+++ linux/drivers/scsi/mac_scsi.c   2014-10-02 16:55:52.0 +1000
@@ -55,7 +55,6 @@
 #include "NCR5380.h"
 
 #define RESET_BOOT
-#define DRIVER_SETUP
 
 extern void via_scsi_clear(void);
 
@@ -113,7 +112,6 @@ static __inline__ void macscsi_write(str
  */
 
 static int __init mac_scsi_setup(char *str) {
-#ifdef DRIVER_SETUP
int ints[7];

(void)get_options( str, ARRAY_SIZE(ints), ints);
@@ -166,7 +164,6 @@ static int __init mac_scsi_setup(char *s
}
 #endif /* SUPPORT_TAGS */

-#endif /* DRIVER_SETUP */
return 1;
 }
 
Index: linux/drivers/scsi/sun3_scsi.c
===
--- linux.orig/drivers/scsi/sun3_scsi.c 2014-10-02 16:55:50.0 +1000
+++ linux/drivers/scsi/sun3_scsi.c  2014-10-02 16:55:52.0 +1000
@@ -43,10 +43,6 @@
  * Options :
  *
  * PARITY - enable parity checking.  Not supported.
- *
- * SCSI2 - enable support for SCSI-II tagged queueing.  Untested.
- *
- * USLEEP - enable support for devices that don't disconnect.  Untested.
  */
 
 #define AUTOSENSE
@@ -79,18 +75,7 @@
 
 extern int sun3_map_test(unsigned long, char *);
 
-#define USE_WRAPPER
 /*#define RESET_BOOT */
-#define DRIVER_SETUP
-
-/*
- * BUG can be used to trigger a strange code-size related hang on 2.1 kernels
- */
-#ifdef BUG
-#undef RESET_BOOT
-#undef DRIVER_SETUP
-#endif
-
 /* #define SUPPORT_TAGS */
 
 #ifdef SUN3_SCSI_VME
Index: linux/drivers/scsi/NCR5380.c
===
--- linux.orig/drivers/scsi/NCR5380.c   2014-10-02 16:55:28.0 +1000
+++ linux/drivers/scsi/NCR5380.c2014-10-02 16:55:52.0 +1000
@@ -649,7 +649,7 @@ NCR5380_print_options(struct Scsi_Host *
   " UNSAFE "
 #endif
);
-   printk(" USLEEP, USLEEP_POLL=%d USLEEP_SLEEP=%d", USLEEP_POLL, 
USLEEP_SLEEP);
+   printk(" USLEEP_POLL=%d USLEEP_SLEEP=%d", USLEEP_POLL, USLEEP_SLEEP);
printk(" generic release=%d", NCR5380_PUBLIC_RELEASE);
if (((struct NCR5380_hostdata *) instance->hostdata)->flags & 
FLAG_NCR53C400) {
printk(" ncr53c400 release=%d", NCR53C400_PUBLIC_RELEASE);
Index: linux/drivers/scsi/pas16.c
===
--- linux.orig/drivers/scsi/pas16.c 2014-10-02 16:55:51.0 +1000
+++ linux/drivers/scsi/pas16.c  2014-10-02 16:55:52.0 +1000
@@ -1,6 +1,5 @@
 #define AUTOSENSE
 #define PSEUDO_DMA
-#define FOO
 #define UNSAFE  /* Not unsafe for PAS16 -- use it */
 #define PDEBUG 0
 
@@ -52,8 +51,6 @@
  * increase compared to polled I/O.
  *
  * PARITY - enable parity checking.  Not supported.
- * 
- * SCSI2 - enable support for SCSI-II tagged queueing.  Untested.
  *
  * UNSAFE - leave interrupts enabled during pseudo-DMA transfers.  This
  * parameter comes from the NCR5380 code.  It is NOT unsafe with
@@ -63,8 +60,6 @@
  * want to use UNSAFE you can try defining LIMIT_TRANSFERSIZE or
  * twiddle with the transfer size in the high level code.
  *
- * USLEEP - enable support for devices that don't disconnect.  Untested.
- *
  * The card is detected and initialized in one of several ways : 
  * 1.  Autoprobe (default) - There are many different models of
  * the Pro Audio Spectrum/Studio 16, and I only have one of
Index: linux/drivers/scsi/g_NCR5380.c
===
--- linux.orig/drivers/scsi/g_NCR5380.c 2014-10-02 16:55:28.0 +1000
+++ linux/drivers/scsi/g_NCR5380.c  2014-10-02 16:55:52.0 +1000
@@ -44,10 +44,6 @@
  *
  * PARITY - enable parity checking.  Not supported.
  *
- * SCSI2 - enable support for SCSI-II tagged queueing.  Untested.
- *
- * USLEEP - enable support for devices that don't disconnect.  Untested.
- *
  * The card is detected and initialized in one of several ways : 
  * 1.  With command line overrides - NCR5380=port,irq may be 
  * used on the LILO command line to override the defaults.
@@ -79,7 +75,6 @@
  */
 
 /* settings for DTC3181E card with only Mustek scanner attache

[PATCH 03/29] ncr5380: Fix compiler warnings and __setup options

2014-10-02 Thread Finn Thain
Some __setup() options mentioned in Documentation/scsi don't work because
a few lines of code went missing sometime since Linux 2.4. Fix the options
and thus fix some compiler warnings for both the non-modular case,

CC  drivers/scsi/dtc.o
drivers/scsi/dtc.c:176:20: warning: 'dtc_setup' defined but not used 
[-Wunused-function]

and the modular case,

CC [M]  drivers/scsi/pas16.o
drivers/scsi/pas16.c:335:20: warning: 'pas16_setup' defined but not used 
[-Wunused-function]
CC [M]  drivers/scsi/t128.o
drivers/scsi/t128.c:147:20: warning: 't128_setup' defined but not used 
[-Wunused-function]

Signed-off-by: Finn Thain 

---
 drivers/scsi/dtc.c   |8 +++-
 drivers/scsi/pas16.c |   10 +-
 drivers/scsi/t128.c  |   11 ++-
 3 files changed, 26 insertions(+), 3 deletions(-)

Index: linux/drivers/scsi/dtc.c
===
--- linux.orig/drivers/scsi/dtc.c   2014-10-02 16:55:29.0 +1000
+++ linux/drivers/scsi/dtc.c2014-10-02 16:55:51.0 +1000
@@ -173,10 +173,13 @@ static const struct signature {
  *
  */
 
-static void __init dtc_setup(char *str, int *ints)
+static int __init dtc_setup(char *str)
 {
static int commandline_current = 0;
int i;
+   int ints[10];
+
+   get_options(str, ARRAY_SIZE(ints), ints);
if (ints[0] != 2)
printk("dtc_setup: usage dtc=address,irq\n");
else if (commandline_current < NO_OVERRIDES) {
@@ -189,7 +192,10 @@ static void __init dtc_setup(char *str,
}
++commandline_current;
}
+   return 1;
 }
+
+__setup("dtc=", dtc_setup);
 #endif
 
 /* 
Index: linux/drivers/scsi/pas16.c
===
--- linux.orig/drivers/scsi/pas16.c 2014-10-02 16:55:29.0 +1000
+++ linux/drivers/scsi/pas16.c  2014-10-02 16:55:51.0 +1000
@@ -337,6 +337,7 @@ static int __init
 }
 
 
+#ifndef MODULE
 /*
  * Function : pas16_setup(char *str, int *ints)
  *
@@ -347,10 +348,13 @@ static int __init
  *
  */
 
-void __init pas16_setup(char *str, int *ints)
+static int __init pas16_setup(char *str)
 {
 static int commandline_current = 0;
 int i;
+int ints[10];
+
+get_options(str, ARRAY_SIZE(ints), ints);
 if (ints[0] != 2) 
printk("pas16_setup : usage pas16=io_port,irq\n");
 else 
@@ -364,8 +368,12 @@ void __init pas16_setup(char *str, int *
}
++commandline_current;
}
+return 1;
 }
 
+__setup("pas16=", pas16_setup);
+#endif
+
 /* 
  * Function : int pas16_detect(struct scsi_host_template * tpnt)
  *
Index: linux/drivers/scsi/t128.c
===
--- linux.orig/drivers/scsi/t128.c  2014-10-02 16:55:29.0 +1000
+++ linux/drivers/scsi/t128.c   2014-10-02 16:55:51.0 +1000
@@ -148,6 +148,7 @@ static struct signature {
 
 #define NO_SIGNATURES ARRAY_SIZE(signatures)
 
+#ifndef MODULE
 /*
  * Function : t128_setup(char *str, int *ints)
  *
@@ -158,9 +159,13 @@ static struct signature {
  *
  */
 
-void __init t128_setup(char *str, int *ints){
+static int __init t128_setup(char *str)
+{
 static int commandline_current = 0;
 int i;
+int ints[10];
+
+get_options(str, ARRAY_SIZE(ints), ints);
 if (ints[0] != 2) 
printk("t128_setup : usage t128=address,irq\n");
 else 
@@ -174,8 +179,12 @@ void __init t128_setup(char *str, int *i
}
++commandline_current;
}
+return 1;
 }
 
+__setup("t128=", t128_setup);
+#endif
+
 /* 
  * Function : int t128_detect(struct scsi_host_template * tpnt)
  *


--
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/29] ncr5380: Fix SCSI_IRQ_NONE bugs

2014-10-02 Thread Finn Thain
Oak scsi doesn't use any IRQ, but it sets irq = IRQ_NONE rather than
SCSI_IRQ_NONE. Problem is, the core NCR5380 driver expects SCSI_IRQ_NONE
if it is to issue IDENTIFY commands that prevent target disconnection.

Other drivers, when they can't get an IRQ or can't use one, will set
host->irq = SCSI_IRQ_NONE (that is, 255). But when they exit they will
attempt to free IRQ 255 which was never requested.

Fix these bugs by using IRQ_NONE in place of SCSI_IRQ_NONE. This means
IRQ 0 is no longer probed by ISA drivers but I don't think this matters.

Setting IRQ = 255 for these ISA drivers is understood to mean no IRQ.
This remains supported so as to avoid breaking existing ISA setups (which
can be difficult to get working) and because existing documentation
(SANE, TLDP etc) describes this usage for the ISA NCR5380 driver options.

Signed-off-by: Finn Thain 

---

The are whitespace issues with this code; it will be cleaned up in a
later patch.

---
 drivers/scsi/NCR5380.c   |   12 ++--
 drivers/scsi/NCR5380.h   |1 -
 drivers/scsi/dmx3191d.c  |7 ---
 drivers/scsi/dtc.c   |   22 +-
 drivers/scsi/g_NCR5380.c |   18 +++---
 drivers/scsi/mac_scsi.c  |8 
 drivers/scsi/pas16.c |   20 +++-
 drivers/scsi/sun3_scsi.c |6 +++---
 drivers/scsi/t128.c  |   14 +-
 9 files changed, 61 insertions(+), 47 deletions(-)

Index: linux/drivers/scsi/dtc.c
===
--- linux.orig/drivers/scsi/dtc.c   2014-10-02 16:56:00.0 +1000
+++ linux/drivers/scsi/dtc.c2014-10-02 16:56:02.0 +1000
@@ -254,31 +254,35 @@ found:
else
instance->irq = NCR5380_probe_irq(instance, DTC_IRQS);
 
+   /* Compatibility with documented NCR5380 kernel parameters */
+   if (instance->irq == 255)
+   instance->irq = IRQ_NONE;
+
 #ifndef DONT_USE_INTR
/* With interrupts enabled, it will sometimes hang when doing 
heavy
 * reads. So better not enable them until I finger it out. */
-   if (instance->irq != SCSI_IRQ_NONE)
+   if (instance->irq != IRQ_NONE)
if (request_irq(instance->irq, dtc_intr, 0,
"dtc", instance)) {
printk(KERN_ERR "scsi%d : IRQ%d not free, 
interrupts disabled\n", instance->host_no, instance->irq);
-   instance->irq = SCSI_IRQ_NONE;
+   instance->irq = IRQ_NONE;
}
 
-   if (instance->irq == SCSI_IRQ_NONE) {
+   if (instance->irq == IRQ_NONE) {
printk(KERN_WARNING "scsi%d : interrupts not enabled. 
for better interactive performance,\n", instance->host_no);
printk(KERN_WARNING "scsi%d : please jumper the board 
for a free IRQ.\n", instance->host_no);
}
 #else
-   if (instance->irq != SCSI_IRQ_NONE)
+   if (instance->irq != IRQ_NONE)
printk(KERN_WARNING "scsi%d : interrupts not used. 
Might as well not jumper it.\n", instance->host_no);
-   instance->irq = SCSI_IRQ_NONE;
+   instance->irq = IRQ_NONE;
 #endif
 #if defined(DTCDEBUG) && (DTCDEBUG & DTCDEBUG_INIT)
printk("scsi%d : irq = %d\n", instance->host_no, instance->irq);
 #endif
 
printk(KERN_INFO "scsi%d : at 0x%05X", instance->host_no, (int) 
instance->base);
-   if (instance->irq == SCSI_IRQ_NONE)
+   if (instance->irq == IRQ_NONE)
printk(" interrupts disabled");
else
printk(" irq %d", instance->irq);
@@ -350,7 +354,7 @@ static inline int NCR5380_pread(struct S
i = 0;
NCR5380_read(RESET_PARITY_INTERRUPT_REG);
NCR5380_write(MODE_REG, MR_ENABLE_EOP_INTR | MR_DMA_MODE);
-   if (instance->irq == SCSI_IRQ_NONE)
+   if (instance->irq == IRQ_NONE)
NCR5380_write(DTC_CONTROL_REG, CSR_DIR_READ);
else
NCR5380_write(DTC_CONTROL_REG, CSR_DIR_READ | CSR_INT_BASE);
@@ -401,7 +405,7 @@ static inline int NCR5380_pwrite(struct
NCR5380_read(RESET_PARITY_INTERRUPT_REG);
NCR5380_write(MODE_REG, MR_ENABLE_EOP_INTR | MR_DMA_MODE);
/* set direction (write) */
-   if (instance->irq == SCSI_IRQ_NONE)
+   if (instance->irq == IRQ_NONE)
NCR5380_write(DTC_CONTROL_REG, 0);
else
NCR5380_write(DTC_CONTROL_REG, CSR_5380_INTR);
@@ -440,7 +444,7 @@ static int dtc_release(struct Scsi_Host
 {
NCR5380_local_declare();
NCR5380_setup(shost);
-   if (shost->irq)
+   if (shost->irq != IRQ_NONE)
free_irq(shost->irq, shost);
NCR5380_exit(shost);
if (shost->io_port && sho

[PATCH 02/29] ncr5380: Remove unused hostdata fields

2014-10-02 Thread Finn Thain
Remove unused fields from hostdata structs declared with the
NCR5380_implementation_fields macro.

Signed-off-by: Finn Thain 

---
 drivers/scsi/dmx3191d.c  |4 ++--
 drivers/scsi/mac_scsi.c  |   33 -
 drivers/scsi/mac_scsi.h  |3 +--
 drivers/scsi/sun3_scsi.c |2 --
 drivers/scsi/sun3_scsi.h |3 +--
 5 files changed, 4 insertions(+), 41 deletions(-)

Index: linux/drivers/scsi/dmx3191d.c
===
--- linux.orig/drivers/scsi/dmx3191d.c  2014-10-02 16:55:29.0 +1000
+++ linux/drivers/scsi/dmx3191d.c   2014-10-02 16:55:50.0 +1000
@@ -38,8 +38,8 @@
 #define NCR5380_read(reg)  inb(port + reg)
 #define NCR5380_write(reg, value)  outb(value, port + reg)
 
-#define NCR5380_implementation_fields  unsigned int port
-#define NCR5380_local_declare()NCR5380_implementation_fields
+#define NCR5380_implementation_fields  /* none */
+#define NCR5380_local_declare()unsigned int port
 #define NCR5380_setup(instance)port = instance->io_port
 
 /*
Index: linux/drivers/scsi/mac_scsi.c
===
--- linux.orig/drivers/scsi/mac_scsi.c  2014-10-02 16:55:29.0 +1000
+++ linux/drivers/scsi/mac_scsi.c   2014-10-02 16:55:50.0 +1000
@@ -93,35 +93,6 @@ static volatile unsigned char *mac_scsi_
  * NCR 5380 register access functions
  */
 
-#if 0
-/* Debug versions */
-#define CTRL(p,v) (*ctrl = (v))
-
-static char macscsi_read(struct Scsi_Host *instance, int reg)
-{
-  int iobase = instance->io_port;
-  int i;
-  int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
-
-  CTRL(iobase, 0);
-  i = in_8(iobase + (reg<<4));
-  CTRL(iobase, 0x40);
-
-  return i;
-}
-
-static void macscsi_write(struct Scsi_Host *instance, int reg, int value)
-{
-  int iobase = instance->io_port;
-  int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
-
-  CTRL(iobase, 0);
-  out_8(iobase + (reg<<4), value);
-  CTRL(iobase, 0x40);
-}
-#else
-
-/* Fast versions */
 static __inline__ char macscsi_read(struct Scsi_Host *instance, int reg)
 {
   return in_8(instance->io_port + (reg<<4));
@@ -131,8 +102,6 @@ static __inline__ void macscsi_write(str
 {
   out_8(instance->io_port + (reg<<4), value);
 }
-#endif
-
 
 /*
  * Function : mac_scsi_setup(char *str)
@@ -279,8 +248,6 @@ int __init macscsi_detect(struct scsi_ho
 
 instance->n_io_port = 255;
 
-((struct NCR5380_hostdata *)instance->hostdata)->ctrl = 0;
-
 if (instance->irq != SCSI_IRQ_NONE)
if (request_irq(instance->irq, NCR5380_intr, 0, "ncr5380", instance)) {
printk(KERN_WARNING "scsi%d: IRQ%d not free, interrupts disabled\n",
Index: linux/drivers/scsi/mac_scsi.h
===
--- linux.orig/drivers/scsi/mac_scsi.h  2014-10-02 16:55:29.0 +1000
+++ linux/drivers/scsi/mac_scsi.h   2014-10-02 16:55:50.0 +1000
@@ -47,8 +47,7 @@
 
 #include 
 
-#define NCR5380_implementation_fields \
-int port, ctrl
+#define NCR5380_implementation_fields /* none */
 
 #define NCR5380_local_declare() \
 struct Scsi_Host *_instance
Index: linux/drivers/scsi/sun3_scsi.c
===
--- linux.orig/drivers/scsi/sun3_scsi.c 2014-10-02 16:55:29.0 +1000
+++ linux/drivers/scsi/sun3_scsi.c  2014-10-02 16:55:50.0 +1000
@@ -313,8 +313,6 @@ static int __init sun3scsi_detect(struct
 
instance->n_io_port = 32;
 
-((struct NCR5380_hostdata *)instance->hostdata)->ctrl = 0;
-
if (request_irq(instance->irq, scsi_sun3_intr,
 0, "Sun3SCSI-5380", instance)) {
 #ifndef REAL_DMA
Index: linux/drivers/scsi/sun3_scsi.h
===
--- linux.orig/drivers/scsi/sun3_scsi.h 2014-10-02 16:55:29.0 +1000
+++ linux/drivers/scsi/sun3_scsi.h  2014-10-02 16:55:50.0 +1000
@@ -78,8 +78,7 @@ static int sun3scsi_release (struct Scsi
 #define SUN3_SCSI_NAME "Sun3 NCR5380 SCSI"
 #endif
 
-#define NCR5380_implementation_fields \
-int port, ctrl
+#define NCR5380_implementation_fields /* none */
 
 #define NCR5380_local_declare() \
 struct Scsi_Host *_instance


--
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 08/29] ncr5380: Remove redundant AUTOSENSE macro

2014-10-02 Thread Finn Thain
Every NCR5380 driver sets AUTOSENSE so it need not be optional (and the
mid-layer expects it). Remove this redundant macro to improve readability.

Signed-off-by: Finn Thain 

---
 drivers/scsi/NCR5380.c   |   14 +-
 drivers/scsi/NCR5380.h   |5 -
 drivers/scsi/arm/cumana_1.c  |1 -
 drivers/scsi/arm/oak.c   |1 -
 drivers/scsi/atari_NCR5380.c |   15 +--
 drivers/scsi/atari_scsi.c|1 -
 drivers/scsi/dmx3191d.c  |1 -
 drivers/scsi/dtc.c   |4 
 drivers/scsi/g_NCR5380.c |2 --
 drivers/scsi/mac_scsi.c  |2 --
 drivers/scsi/pas16.c |4 
 drivers/scsi/sun3_NCR5380.c  |   16 +---
 drivers/scsi/sun3_scsi.c |2 --
 drivers/scsi/t128.c  |4 
 14 files changed, 3 insertions(+), 69 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===
--- linux.orig/drivers/scsi/NCR5380.c   2014-10-02 16:55:57.0 +1000
+++ linux/drivers/scsi/NCR5380.c2014-10-02 16:55:58.0 +1000
@@ -627,9 +627,6 @@ NCR5380_print_options(struct Scsi_Host *
 #ifdef AUTOPROBE_IRQ
   " AUTOPROBE_IRQ"
 #endif
-#ifdef AUTOSENSE
-  " AUTOSENSE"
-#endif
 #ifdef DIFFERENTIAL
   " DIFFERENTIAL"
 #endif
@@ -857,12 +854,6 @@ static int NCR5380_init(struct Scsi_Host
hostdata->host = instance;
hostdata->time_expires = 0;
 
-#ifndef AUTOSENSE
-   if ((instance->cmd_per_lun > 1) || instance->can_queue > 1)
-   printk(KERN_WARNING "scsi%d : WARNING : support for 
multiple outstanding commands enabled\n" " without AUTOSENSE option, 
contingent allegiance conditions may\n"
-  " be incorrectly cleared.\n", 
instance->host_no);
-#endif /* def AUTOSENSE */
-
NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
NCR5380_write(MODE_REG, MR_BASE);
NCR5380_write(TARGET_COMMAND_REG, 0);
@@ -2259,7 +2250,6 @@ static void NCR5380_information_transfer
else if (status_byte(cmd->SCp.Status) 
!= GOOD)
cmd->result = (cmd->result & 
0x00) | (DID_ERROR << 16);
 
-#ifdef AUTOSENSE
if ((cmd->cmnd[0] == REQUEST_SENSE) &&
hostdata->ses.cmd_len) {
scsi_eh_restore_cmnd(cmd, 
&hostdata->ses);
@@ -2276,9 +2266,7 @@ static void NCR5380_information_transfer
hostdata->issue_queue;
hostdata->issue_queue = 
(Scsi_Cmnd *) cmd;
dprintk(NDEBUG_QUEUES, "scsi%d 
: REQUEST SENSE added to head of issue queue\n", instance->host_no);
-   } else
-#endif /* def AUTOSENSE */
-   {
+   } else {
collect_stats(hostdata, cmd);
cmd->scsi_done(cmd);
}
Index: linux/drivers/scsi/NCR5380.h
===
--- linux.orig/drivers/scsi/NCR5380.h   2014-10-02 16:55:57.0 +1000
+++ linux/drivers/scsi/NCR5380.h2014-10-02 16:55:58.0 +1000
@@ -25,10 +25,7 @@
 #define NCR5380_H
 
 #include 
-
-#ifdef AUTOSENSE
 #include 
-#endif
 
 #define NCR5380_PUBLIC_RELEASE 7
 #define NCR53C400_PUBLIC_RELEASE 2
@@ -281,9 +278,7 @@ struct NCR5380_hostdata {
unsigned pendingr;
unsigned pendingw;
 #endif
-#ifdef AUTOSENSE
struct scsi_eh_save ses;
-#endif
 };
 
 #ifdef __KERNEL__
Index: linux/drivers/scsi/arm/cumana_1.c
===
--- linux.orig/drivers/scsi/arm/cumana_1.c  2014-10-02 16:55:28.0 
+1000
+++ linux/drivers/scsi/arm/cumana_1.c   2014-10-02 16:55:58.0 +1000
@@ -18,7 +18,6 @@
 
 #include 
 
-#define AUTOSENSE
 #define PSEUDO_DMA
 
 #define CUMANASCSI_PUBLIC_RELEASE 1
Index: linux/drivers/scsi/arm/oak.c
===
--- linux.orig/drivers/scsi/arm/oak.c   2014-10-02 16:55:52.0 +1000
+++ linux/drivers/scsi/arm/oak.c2014-10-02 16:55:58.0 +1000
@@ -17,7 +17,6 @@
 #include "../scsi.h"
 #include 
 
-#define AUTOSENSE
 /*#define PSEUDO_DMA*/
 
 #define OAKSCSI_PUBLIC_RELEASE 1
Index: linux/drivers/scsi/atari_NCR5380.c
===
--- linux.orig/drivers/scsi/atari_NCR5380.c 2014-10-02 16:55:57.0 
+1000
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-02 16:55:58.0 +1000
@@ -680,9 +680,6 @@ static inline void N

[PATCH 18/29] mac_scsi: Remove header

2014-10-02 Thread Finn Thain
The #defines in mac_scsi.h are intended to influence subsequent #includes in
mac_scsi.c. IMHO, that's too convoluted.

Remove mac_scsi.h by moving those macro definitions to mac_scsi.c, consistent
with other NCR5380 drivers.

Signed-off-by: Finn Thain 

---
 drivers/scsi/mac_scsi.c |   21 -
 drivers/scsi/mac_scsi.h |   42 --
 2 files changed, 20 insertions(+), 43 deletions(-)

Index: linux/drivers/scsi/mac_scsi.c
===
--- linux.orig/drivers/scsi/mac_scsi.c  2014-10-02 16:56:14.0 +1000
+++ linux/drivers/scsi/mac_scsi.c   2014-10-02 16:56:17.0 +1000
@@ -31,10 +31,29 @@
 #include 
 
 #include 
-#include "mac_scsi.h"
+
+/* Definitions for the core NCR5380 driver. */
 
 #define PSEUDO_DMA
 
+#define NCR5380_implementation_fields   /* none */
+#define NCR5380_local_declare() struct Scsi_Host *_instance
+#define NCR5380_setup(instance) _instance = instance
+
+#define NCR5380_read(reg)   macscsi_read(_instance, reg)
+#define NCR5380_write(reg, value)   macscsi_write(_instance, reg, value)
+
+#define NCR5380_pread   macscsi_pread
+#define NCR5380_pwrite  macscsi_pwrite
+
+#define NCR5380_intrmacscsi_intr
+#define NCR5380_queue_command   macscsi_queue_command
+#define NCR5380_abort   macscsi_abort
+#define NCR5380_bus_reset   macscsi_bus_reset
+#define NCR5380_infomacscsi_info
+#define NCR5380_show_info   macscsi_show_info
+#define NCR5380_write_info  macscsi_write_info
+
 #include "NCR5380.h"
 
 #define RESET_BOOT
Index: linux/drivers/scsi/mac_scsi.h
===
--- linux.orig/drivers/scsi/mac_scsi.h  2014-10-02 16:56:11.0 +1000
+++ /dev/null   1970-01-01 00:00:00.0 +
@@ -1,42 +0,0 @@
-/*
- * Cumana Generic NCR5380 driver defines
- *
- * Copyright 1993, Drew Eckhardt
- * Visionary Computing
- * (Unix and Linux consulting and custom programming)
- * d...@colorado.edu
- *  +1 (303) 440-4894
- */
-
-#ifndef MAC_NCR5380_H
-#define MAC_NCR5380_H
-
-#ifndef ASM
-
-#include 
-
-#define NCR5380_implementation_fields /* none */
-
-#define NCR5380_local_declare() \
-struct Scsi_Host *_instance
-
-#define NCR5380_setup(instance) \
-_instance = instance
-
-#define NCR5380_read(reg) macscsi_read(_instance, reg)
-#define NCR5380_write(reg, value) macscsi_write(_instance, reg, value)
-
-#define NCR5380_pread  macscsi_pread
-#define NCR5380_pwrite macscsi_pwrite
-   
-#define NCR5380_intr macscsi_intr
-#define NCR5380_queue_command macscsi_queue_command
-#define NCR5380_abort macscsi_abort
-#define NCR5380_bus_reset macscsi_bus_reset
-#define NCR5380_info macscsi_info
-#define NCR5380_show_info macscsi_show_info
-#define NCR5380_write_info macscsi_write_info
-
-#endif /* ndef ASM */
-#endif /* MAC_NCR5380_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 15/29] ncr5380: Remove *_RELEASE macros

2014-10-02 Thread Finn Thain
The *_RELEASE macros don't tell me anything. In some cases the version in
the macro contradicts the version in the comments. Anyway, the Linux kernel
version is sufficient information. Remove these macros to improve readability.

Signed-off-by: Finn Thain 

---
 drivers/scsi/NCR5380.c   |   18 --
 drivers/scsi/NCR5380.h   |5 -
 drivers/scsi/arm/cumana_1.c  |2 --
 drivers/scsi/arm/oak.c   |2 --
 drivers/scsi/atari_NCR5380.c |4 
 drivers/scsi/dtc.c   |5 -
 drivers/scsi/dtc.h   |2 --
 drivers/scsi/g_NCR5380.c |2 --
 drivers/scsi/g_NCR5380.h |5 -
 drivers/scsi/mac_scsi.c  |2 --
 drivers/scsi/mac_scsi.h  |4 
 drivers/scsi/pas16.h |2 --
 drivers/scsi/sun3_NCR5380.c  |4 
 drivers/scsi/sun3_scsi.c |2 --
 drivers/scsi/sun3_scsi.h |4 
 drivers/scsi/t128.c  |2 --
 drivers/scsi/t128.h  |4 
 17 files changed, 69 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===
--- linux.orig/drivers/scsi/NCR5380.c   2014-10-02 16:56:09.0 +1000
+++ linux/drivers/scsi/NCR5380.c2014-10-02 16:56:11.0 +1000
@@ -11,8 +11,6 @@
  *  d...@colorado.edu
  *  +1 (303) 666-5836
  *
- * DISTRIBUTION RELEASE 6. 
- *
  * For more information, please consult 
  *
  * NCR 5380 Family
@@ -736,22 +734,6 @@ static int __maybe_unused NCR5380_show_i
 
hostdata = (struct NCR5380_hostdata *) instance->hostdata;
 
-   SPRINTF("NCR5380 core release=%d.   ", NCR5380_PUBLIC_RELEASE);
-   if (((struct NCR5380_hostdata *) instance->hostdata)->flags & 
FLAG_NCR53C400)
-   SPRINTF("ncr53c400 release=%d.  ", NCR53C400_PUBLIC_RELEASE);
-#ifdef DTC_PUBLIC_RELEASE
-   SPRINTF("DTC 3180/3280 release %d", DTC_PUBLIC_RELEASE);
-#endif
-#ifdef T128_PUBLIC_RELEASE
-   SPRINTF("T128 release %d", T128_PUBLIC_RELEASE);
-#endif
-#ifdef GENERIC_NCR5380_PUBLIC_RELEASE
-   SPRINTF("Generic5380 release %d", GENERIC_NCR5380_PUBLIC_RELEASE);
-#endif
-#ifdef PAS16_PUBLIC_RELEASE
-   SPRINTF("PAS16 release=%d", PAS16_PUBLIC_RELEASE);
-#endif
-
 #ifdef PSEUDO_DMA
SPRINTF("Highwater I/O busy spin counts: write %d, read %d\n",
hostdata->spin_max_w, hostdata->spin_max_r);
Index: linux/drivers/scsi/atari_NCR5380.c
===
--- linux.orig/drivers/scsi/atari_NCR5380.c 2014-10-02 16:56:05.0 
+1000
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-02 16:56:11.0 +1000
@@ -11,8 +11,6 @@
  * d...@colorado.edu
  * +1 (303) 666-5836
  *
- * DISTRIBUTION RELEASE 6.
- *
  * For more information, please consult
  *
  * NCR 5380 Family
@@ -739,7 +737,6 @@ static void NCR5380_print_status(struct
 
hostdata = (struct NCR5380_hostdata *)instance->hostdata;
 
-   printk("\nNCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE);
local_irq_save(flags);
printk("NCR5380: coroutine is%s running.\n",
main_running ? "" : "n't");
@@ -783,7 +780,6 @@ static int __maybe_unused NCR5380_show_i
 
hostdata = (struct NCR5380_hostdata *)instance->hostdata;
 
-   seq_printf(m, "NCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE);
local_irq_save(flags);
seq_printf(m, "NCR5380: coroutine is%s running.\n",
main_running ? "" : "n't");
Index: linux/drivers/scsi/sun3_NCR5380.c
===
--- linux.orig/drivers/scsi/sun3_NCR5380.c  2014-10-02 16:56:05.0 
+1000
+++ linux/drivers/scsi/sun3_NCR5380.c   2014-10-02 16:56:11.0 +1000
@@ -13,8 +13,6 @@
  * d...@colorado.edu
  * +1 (303) 666-5836
  *
- * DISTRIBUTION RELEASE 6. 
- *
  * For more information, please consult 
  *
  * NCR 5380 Family
@@ -685,7 +683,6 @@ static void NCR5380_print_status(struct
 
hostdata = (struct NCR5380_hostdata *)instance->hostdata;
 
-   printk("\nNCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE);
local_irq_save(flags);
printk("NCR5380: coroutine is%s running.\n",
main_running ? "" : "n't");
@@ -729,7 +726,6 @@ static int __maybe_unused NCR5380_show_i
 
hostdata = (struct NCR5380_hostdata *)instance->hostdata;
 
-   seq_printf(m, "NCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE);
local_irq_save(flags);
seq_printf(m, "NCR5380: coroutine is%s running.\n",
main_running ? "" : "n't");
Index: linux/drivers/scsi/NCR5380.h
===
--- linux.orig/drivers/scsi/NCR5380.h   2014-10-02 16:56:09.0 +1000
+++ linux/drivers/scsi/NCR5380.h2014-10-02 16:56:11.0 +1000
@@ -7,8 +7,6 @@
  * d...@colorado.edu
  *  +1 (303) 666-5836
  *
- * DISTRIBUTION RELEASE 7
- *
  * For more information, plea

[PATCH 07/29] ncr5380: Cleanup TAG_NEXT and TAG_NONE macros

2014-10-02 Thread Finn Thain
Both atari_NCR5380.c and sun3_NCR5380.c core drivers #undef TAG_NONE and then
redefine it. But the original definition is unused because NCR5380.c lacks
support for tagged queueing. So just define it once.

The TAG_NEXT macro only appears in the arguments to NCR5380_select() calls.
But that routine doesn't use its tag argument as the tag was already assigned
in NCR5380_main(). So remove the unused argument and the macro.

Signed-off-by: Finn Thain 

---
 drivers/scsi/NCR5380.c   |   29 +
 drivers/scsi/NCR5380.h   |   11 ---
 drivers/scsi/atari_NCR5380.c |   19 +--
 drivers/scsi/sun3_NCR5380.c  |   19 +--
 4 files changed, 27 insertions(+), 51 deletions(-)

Index: linux/drivers/scsi/atari_NCR5380.c
===
--- linux.orig/drivers/scsi/atari_NCR5380.c 2014-10-02 16:55:55.0 
+1000
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-02 16:55:57.0 +1000
@@ -316,10 +316,6 @@ static struct scsi_host_template *the_te
  * important: the tag bit must be cleared before 'nr_allocated' is decreased.
  */
 
-/* -1 for TAG_NONE is not possible with unsigned char cmd->tag */
-#undef TAG_NONE
-#define TAG_NONE 0xff
-
 typedef struct {
DECLARE_BITMAP(allocated, MAX_TAGS);
int nr_allocated;
@@ -1114,9 +1110,7 @@ static void NCR5380_main(struct work_str
 #ifdef SUPPORT_TAGS
cmd_get_tag(tmp, tmp->cmnd[0] != 
REQUEST_SENSE);
 #endif
-   if (!NCR5380_select(instance, tmp,
-   (tmp->cmnd[0] == REQUEST_SENSE) ? 
TAG_NONE :
-   TAG_NEXT)) {
+   if (!NCR5380_select(instance, tmp)) {
falcon_dont_release--;
/* release if target did not 
response! */

falcon_release_lock_if_possible(hostdata);
@@ -1347,17 +1341,14 @@ static void collect_stats(struct NCR5380
 #endif
 
 /*
- * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd,
- * int tag);
+ * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd)
  *
  * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command,
  * including ARBITRATION, SELECTION, and initial message out for
  * IDENTIFY and queue messages.
  *
  * Inputs : instance - instantiation of the 5380 driver on which this
- * target lives, cmd - SCSI command to execute, tag - set to TAG_NEXT for
- * new tag, TAG_NONE for untagged queueing, otherwise set to the tag for
- * the command that is presently connected.
+ * target lives, cmd - SCSI command to execute.
  *
  * Returns : -1 if selection could not execute for some reason,
  * 0 if selection succeeded or failed because the target
@@ -1377,7 +1368,7 @@ static void collect_stats(struct NCR5380
  * cmd->result host byte set to DID_BAD_TARGET.
  */
 
-static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag)
+static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd)
 {
SETUP_HOSTDATA(instance);
unsigned char tmp[3], phase;
@@ -2754,7 +2745,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
local_irq_restore(flags);
dprintk(NDEBUG_ABORT, "scsi%d: aborting disconnected 
command.\n", HOSTNO);
 
-   if (NCR5380_select(instance, cmd, (int)cmd->tag))
+   if (NCR5380_select(instance, cmd))
return FAILED;
 
dprintk(NDEBUG_ABORT, "scsi%d: nexus reestablished.\n", 
HOSTNO);
Index: linux/drivers/scsi/sun3_NCR5380.c
===
--- linux.orig/drivers/scsi/sun3_NCR5380.c  2014-10-02 16:55:55.0 
+1000
+++ linux/drivers/scsi/sun3_NCR5380.c   2014-10-02 16:55:57.0 +1000
@@ -305,10 +305,6 @@ static struct scsi_host_template *the_te
  * important: the tag bit must be cleared before 'nr_allocated' is decreased.
  */
 
-/* -1 for TAG_NONE is not possible with unsigned char cmd->tag */
-#undef TAG_NONE
-#define TAG_NONE 0xff
-
 /* For the m68k, the number of bits in 'allocated' must be a multiple of 32! */
 #if (MAX_TAGS % 32) != 0
 #error "MAX_TAGS must be a multiple of 32!"
@@ -1054,9 +1050,7 @@ static void NCR5380_main (struct work_st
 #ifdef SUPPORT_TAGS
cmd_get_tag( tmp, tmp->cmnd[0] != REQUEST_SENSE );
 #endif
-   if (!NCR5380_select(instance, tmp, 
-   (tmp->cmnd[0] == REQUEST_SENSE) ? TAG_NONE : 
-   TAG_NEXT)) {
+   if (!NCR5380_select(instance, tmp)) {
break;
} else {
local

[PATCH 11/29] ncr5380: Remove NCR5380_STATS

2014-10-02 Thread Finn Thain
The NCR5380_STATS option is only enabled by g_NCR5380 yet it adds
clutter to all three core drivers. The atari_NCR5380.c and sun3_NCR5380.c
core drivers have a slightly different implementation of the
NCR5380_STATS option.

Out of all ten NCR5380 drivers, only one of them (g_NCR5380) actually
has the code to report on the collected stats. Aside from being unreadable,
that code seems to be broken because there's no initialization of timebase.
sun3_NCR5380.c and atari_NCR5380.c have the timebase initialization but
lack the code to report the stats.

Remove all of this code to improve readability and reduce divergence
between the three core drivers.

This patch and the next one completely eliminate the PRINTP and ANDP
pre-processor abuse.

Signed-off-by: Finn Thain 

---
 drivers/scsi/NCR5380.c   |   64 ---
 drivers/scsi/NCR5380.h   |9 -
 drivers/scsi/atari_NCR5380.c |   65 
 drivers/scsi/g_NCR5380.c |   45 
 drivers/scsi/sun3_NCR5380.c  |   69 ---
 5 files changed, 252 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===
--- linux.orig/drivers/scsi/NCR5380.c   2014-10-02 16:56:02.0 +1000
+++ linux/drivers/scsi/NCR5380.c2014-10-02 16:56:04.0 +1000
@@ -833,18 +833,6 @@ static int NCR5380_init(struct Scsi_Host

INIT_DELAYED_WORK(&hostdata->coroutine, NCR5380_main);

-#ifdef NCR5380_STATS
-   for (i = 0; i < 8; ++i) {
-   hostdata->time_read[i] = 0;
-   hostdata->time_write[i] = 0;
-   hostdata->bytes_read[i] = 0;
-   hostdata->bytes_write[i] = 0;
-   }
-   hostdata->timebase = 0;
-   hostdata->pendingw = 0;
-   hostdata->pendingr = 0;
-#endif
-
/* The CHECK code seems to break the 53C400. Will check it later maybe 
*/
if (flags & FLAG_NCR53C400)
hostdata->flags = FLAG_HAS_LAST_BYTE_SENT | flags;
@@ -943,25 +931,6 @@ static int NCR5380_queue_command_lck(Scs
}
 #endif /* (NDEBUG & NDEBUG_NO_WRITE) */
 
-#ifdef NCR5380_STATS
-   switch (cmd->cmnd[0]) {
-   case WRITE:
-   case WRITE_6:
-   case WRITE_10:
-   hostdata->time_write[cmd->device->id] -= (jiffies - 
hostdata->timebase);
-   hostdata->bytes_write[cmd->device->id] += 
scsi_bufflen(cmd);
-   hostdata->pendingw++;
-   break;
-   case READ:
-   case READ_6:
-   case READ_10:
-   hostdata->time_read[cmd->device->id] -= (jiffies - 
hostdata->timebase);
-   hostdata->bytes_read[cmd->device->id] += 
scsi_bufflen(cmd);
-   hostdata->pendingr++;
-   break;
-   }
-#endif
-
/* 
 * We use the host_scribble field as a pointer to the next command  
 * in a queue 
@@ -1206,35 +1175,6 @@ static irqreturn_t NCR5380_intr(int dumm
 
 #endif 
 
-/**
- * collect_stats   -   collect stats on a scsi command
- * @hostdata: adapter 
- * @cmd: command being issued
- *
- * Update the statistical data by parsing the command in question
- */
- 
-static void collect_stats(struct NCR5380_hostdata *hostdata, Scsi_Cmnd * cmd) 
-{
-#ifdef NCR5380_STATS
-   switch (cmd->cmnd[0]) {
-   case WRITE:
-   case WRITE_6:
-   case WRITE_10:
-   hostdata->time_write[scmd_id(cmd)] += (jiffies - 
hostdata->timebase);
-   hostdata->pendingw--;
-   break;
-   case READ:
-   case READ_6:
-   case READ_10:
-   hostdata->time_read[scmd_id(cmd)] += (jiffies - 
hostdata->timebase);
-   hostdata->pendingr--;
-   break;
-   }
-#endif
-}
-
-
 /* 
  * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd)
  *
@@ -1463,7 +1403,6 @@ part2:
return -1;
}
cmd->result = DID_BAD_TARGET << 16;
-   collect_stats(hostdata, cmd);
cmd->scsi_done(cmd);
NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
dprintk(NDEBUG_SELECTION, "scsi%d : target did not respond 
within 250ms\n", instance->host_no);
@@ -2215,7 +2154,6 @@ static void NCR5380_information_transfer
cmd->next_link->tag = cmd->tag;
cmd->result = cmd->SCp.Status | 
(cmd->SCp.Message << 8);
dprintk(NDEBUG_LINKED, "scsi%d : target 
%d lun %d linked request done, calling scsi_done().\n", instance->host_no, 
cmd->device->id, cmd->device->lun);
-   collect_stats(hostdata, cmd);
   

[PATCH 12/29] ncr5380: Cleanup host info() methods

2014-10-02 Thread Finn Thain
If the host->info() method is not set, then host->name is used by default.
For atari_scsi, that is exactly the same text. So remove the redundant
info() method. Keep sun3_scsi.c in line with atari_scsi.

Some NCR5380 drivers return an empty string from the info() method
(arm/cumana_1.c arm/oak.c mac_scsi.c) while other drivers use the default
(dmx3191d dtc.c g_NCR5380.c pas16.c t128.c).

Implement a common info() method to replace a lot of duplicated code which
the various drivers use to announce the same information.

This replaces most of the (deprecated) show_info() output and all of the
NCR5380_print_info() output. This also eliminates a bunch of code in
g_NCR5380 which just duplicates functionality in the core driver.

Signed-off-by: Finn Thain 

---
 drivers/scsi/NCR5380.c   |   75 ++-
 drivers/scsi/NCR5380.h   |3 
 drivers/scsi/arm/cumana_1.c  |   14 
 drivers/scsi/arm/oak.c   |   14 
 drivers/scsi/atari_NCR5380.c |   58 +++---
 drivers/scsi/atari_scsi.c|   24 ---
 drivers/scsi/atari_scsi.h|1 
 drivers/scsi/dmx3191d.c  |1 
 drivers/scsi/dtc.c   |   10 ---
 drivers/scsi/dtc.h   |1 
 drivers/scsi/g_NCR5380.c |  135 ---
 drivers/scsi/g_NCR5380.h |2 
 drivers/scsi/mac_scsi.c  |   14 
 drivers/scsi/mac_scsi.h  |1 
 drivers/scsi/pas16.c |   12 ---
 drivers/scsi/pas16.h |1 
 drivers/scsi/sun3_NCR5380.c  |   60 +++
 drivers/scsi/sun3_scsi.c |   18 -
 drivers/scsi/sun3_scsi.h |1 
 drivers/scsi/t128.c  |   11 ---
 drivers/scsi/t128.h  |1 
 21 files changed, 137 insertions(+), 320 deletions(-)

Index: linux/drivers/scsi/arm/cumana_1.c
===
--- linux.orig/drivers/scsi/arm/cumana_1.c  2014-10-02 16:55:58.0 
+1000
+++ linux/drivers/scsi/arm/cumana_1.c   2014-10-02 16:56:05.0 +1000
@@ -29,6 +29,7 @@
 #define NCR5380_write(reg, value)  cumanascsi_write(_instance, reg, value)
 #define NCR5380_intr   cumanascsi_intr
 #define NCR5380_queue_command  cumanascsi_queue_command
+#define NCR5380_info   cumanascsi_info
 
 #define NCR5380_implementation_fields  \
unsigned ctrl;  \
@@ -41,11 +42,6 @@ void cumanascsi_setup(char *str, int *in
 {
 }
 
-const char *cumanascsi_info(struct Scsi_Host *spnt)
-{
-   return "";
-}
-
 #define CTRL   0x16fc
 #define STAT   0x2004
 #define L(v)   (((v)<<16)|((v) & 0x))
@@ -266,14 +262,6 @@ static int cumanascsi1_probe(struct expa
goto out_unmap;
}
 
-   printk("scsi%d: at port 0x%08lx irq %d",
-   host->host_no, host->io_port, host->irq);
-   printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
-   host->can_queue, host->cmd_per_lun, CUMANASCSI_PUBLIC_RELEASE);
-   printk("\nscsi%d:", host->host_no);
-   NCR5380_print_options(host);
-   printk("\n");
-
ret = scsi_add_host(host, &ec->dev);
if (ret)
goto out_free_irq;
Index: linux/drivers/scsi/arm/oak.c
===
--- linux.orig/drivers/scsi/arm/oak.c   2014-10-02 16:55:58.0 +1000
+++ linux/drivers/scsi/arm/oak.c2014-10-02 16:56:05.0 +1000
@@ -29,6 +29,7 @@
 #define NCR5380_read(reg)  readb(_base + ((reg) << 2))
 #define NCR5380_write(reg, value)  writeb(value, _base + ((reg) << 2))
 #define NCR5380_queue_command  oakscsi_queue_command
+#define NCR5380_info   oakscsi_info
 #define NCR5380_show_info  oakscsi_show_info
 #define NCR5380_write_info oakscsi_write_info
 
@@ -40,11 +41,6 @@
 #undef START_DMA_INITIATOR_RECEIVE_REG
 #define START_DMA_INITIATOR_RECEIVE_REG(128 + 7)
 
-const char * oakscsi_info (struct Scsi_Host *spnt)
-{
-   return "";
-}
-
 #define STAT   ((128 + 16) << 2)
 #define DATA   ((128 + 8) << 2)
 
@@ -153,14 +149,6 @@ static int oakscsi_probe(struct expansio
 
NCR5380_init(host, 0);
 
-   printk("scsi%d: at port 0x%08lx irqs disabled",
-   host->host_no, host->io_port);
-   printk(" options CAN_QUEUE=%d  CMD_PER_LUN=%d release=%d",
-   host->can_queue, host->cmd_per_lun, OAKSCSI_PUBLIC_RELEASE);
-   printk("\nscsi%d:", host->host_no);
-   NCR5380_print_options(host);
-   printk("\n");
-
ret = scsi_add_host(host, &ec->dev);
if (ret)
goto out_unmap;
Index: linux/drivers/scsi/atari_scsi.c
===
--- linux.orig/drivers/scsi/atari_scsi.c2014-10-02 16:55:58.0 
+1000
+++ linux/drivers/scsi/atari_scsi.c 2014-10-02 16:56:05.0 +1000
@@ -699,21 +699,6 @@ static int __init atari_scsi_detect(stru
 #endif
}

[PATCH 21/29] mac_scsi: Convert to platform device

2014-10-02 Thread Finn Thain
Convert mac_scsi to platform device and eliminate scsi_register().

Platform resources for chip registers now follow the documentation. This
should fix issues with the Mac IIci (and possibly other models too).

Signed-off-by: Finn Thain 

---

The new hwreg_present() call is not protected by local_irq_save/restore.
This assumes Geert's patch, "Disable/restore interrupts in
hwreg_present()/hwreg_write()":
http://marc.info/?l=linux-kernel&m=141189640826704&w=2

---
 arch/m68k/include/asm/macintosh.h |3 
 arch/m68k/mac/config.c|  101 +--
 drivers/scsi/mac_scsi.c   |  248 +++---
 3 files changed, 221 insertions(+), 131 deletions(-)

Index: linux/drivers/scsi/mac_scsi.c
===
--- linux.orig/drivers/scsi/mac_scsi.c  2014-10-02 16:56:18.0 +1000
+++ linux/drivers/scsi/mac_scsi.c   2014-10-02 16:56:19.0 +1000
@@ -12,23 +12,18 @@
  */
 
 #include 
-#include 
-#include 
 #include 
-
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
+#include 
 #include 
-#include 
-
-#include 
 #include 
-#include 
+#include 
 
 #include 
 
@@ -36,7 +31,7 @@
 
 #define PSEUDO_DMA
 
-#define NCR5380_implementation_fields   /* none */
+#define NCR5380_implementation_fields   unsigned char *pdma_base
 #define NCR5380_local_declare() struct Scsi_Host *_instance
 #define NCR5380_setup(instance) _instance = instance
 
@@ -58,10 +53,6 @@
 
 #define RESET_BOOT
 
-#ifdef RESET_BOOT
-static void mac_scsi_reset_boot(struct Scsi_Host *instance);
-#endif
-
 static int setup_can_queue = -1;
 module_param(setup_can_queue, int, 0);
 static int setup_cmd_per_lun = -1;
@@ -86,23 +77,18 @@ module_param(setup_hostid, int, 0);
 #defineAFTER_RESET_DELAY   (HZ/2)
 #endif
 
-static unsigned char *mac_scsi_regp;
-static unsigned char *mac_scsi_drq;
-static unsigned char *mac_scsi_nodrq;
-
-
 /*
  * NCR 5380 register access functions
  */
 
-static __inline__ char macscsi_read(struct Scsi_Host *instance, int reg)
+static inline char macscsi_read(struct Scsi_Host *instance, int reg)
 {
-  return in_8(instance->io_port + (reg<<4));
+   return in_8(instance->base + (reg << 4));
 }
 
-static __inline__ void macscsi_write(struct Scsi_Host *instance, int reg, int 
value)
+static inline void macscsi_write(struct Scsi_Host *instance, int reg, int 
value)
 {
-  out_8(instance->io_port + (reg<<4), value);
+   out_8(instance->base + (reg << 4), value);
 }
 
 #ifndef MODULE
@@ -134,96 +120,6 @@ static int __init mac_scsi_setup(char *s
 __setup("mac5380=", mac_scsi_setup);
 #endif /* !MODULE */
 
-/*
- * Function : int macscsi_detect(struct scsi_host_template * tpnt)
- *
- * Purpose : initializes mac NCR5380 driver based on the
- * command line / compile time port and irq definitions.
- *
- * Inputs : tpnt - template for this SCSI adapter.
- *
- * Returns : 1 if a host adapter was found, 0 if not.
- *
- */
- 
-int __init macscsi_detect(struct scsi_host_template * tpnt)
-{
-static int called = 0;
-int flags = 0;
-struct Scsi_Host *instance;
-
-if (!MACH_IS_MAC || called)
-   return( 0 );
-
-if (macintosh_config->scsi_type != MAC_SCSI_OLD)
-   return( 0 );
-
-   if (setup_can_queue > 0)
-   tpnt->can_queue = setup_can_queue;
-   if (setup_cmd_per_lun > 0)
-   tpnt->cmd_per_lun = setup_cmd_per_lun;
-   if (setup_sg_tablesize >= 0)
-   tpnt->sg_tablesize = setup_sg_tablesize;
-   if (setup_hostid >= 0)
-   tpnt->this_id = setup_hostid & 7;
-
-#ifdef SUPPORT_TAGS
-if (setup_use_tagged_queuing < 0)
-   setup_use_tagged_queuing = 0;
-#endif
-
-/* Once we support multiple 5380s (e.g. DuoDock) we'll do
-   something different here */
-instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
-if (instance == NULL)
-   return 0;
-
-if (macintosh_config->ident == MAC_MODEL_IIFX) {
-   mac_scsi_regp  = (unsigned char *) VIA1_BASE + 0x8000;
-   mac_scsi_drq   = (unsigned char *) VIA1_BASE + 0xE000;
-   mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0xC000;
-   /* The IIFX should be able to do true DMA, but pseudo-dma doesn't work 
*/
-   flags = FLAG_NO_PSEUDO_DMA;
-} else {
-   mac_scsi_regp  = (unsigned char *) VIA1_BASE + 0x1;
-   mac_scsi_drq   = (unsigned char *) VIA1_BASE + 0x6000;
-   mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0x12000;
-}
-
-if (! setup_use_pdma)
-   flags = FLAG_NO_PSEUDO_DMA;
-   
-instance->io_port = (unsigned long) mac_scsi_regp;
-instance->irq = IRQ_MAC_SCSI;
-
-#ifdef RESET_BOOT   
-mac_scsi_reset_boot(instance);
-#endif
-
-NCR5380_init(instance, flags);
-
-instance->n_io_port = 255;
-
-if (instance->irq != IRQ_NONE)
-   if (request_irq(instance->irq, NCR5380_intr, 0, "ncr5380", instance)) {
-   printk(KERN_WARNI

[PATCH 25/29] sun3_scsi: Convert to platform device

2014-10-02 Thread Finn Thain
Convert sun3_scsi to platform device and eliminate scsi_register().

Signed-off-by: Finn Thain 

---
 arch/m68k/sun3/config.c  |   11 +
 drivers/scsi/sun3_scsi.c |  405 +++
 drivers/scsi/sun3_scsi.h |8 
 3 files changed, 214 insertions(+), 210 deletions(-)

Index: linux/arch/m68k/sun3/config.c
===
--- linux.orig/arch/m68k/sun3/config.c  2014-10-02 16:55:28.0 +1000
+++ linux/arch/m68k/sun3/config.c   2014-10-02 16:56:22.0 +1000
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -169,3 +170,13 @@ static void __init sun3_sched_init(irq_h
 intersil_clear();
 }
 
+#ifdef CONFIG_SUN3_SCSI
+int __init sun3_platform_init(void)
+{
+   platform_device_register_simple("sun3_scsi", -1, NULL, 0);
+   platform_device_register_simple("sun3_scsi_vme", -1, NULL, 0);
+   return 0;
+}
+
+arch_initcall(sun3_platform_init);
+#endif
Index: linux/drivers/scsi/sun3_scsi.c
===
--- linux.orig/drivers/scsi/sun3_scsi.c 2014-10-02 16:56:14.0 +1000
+++ linux/drivers/scsi/sun3_scsi.c  2014-10-02 16:56:22.0 +1000
@@ -23,18 +23,14 @@
  */
 
 #include 
-#include 
-#include 
 #include 
-
 #include 
-#include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
-
 #include 
 #include 
 #include 
@@ -59,8 +55,6 @@ extern int sun3_map_test(unsigned long,
 #endif
 
 
-static irqreturn_t scsi_sun3_intr(int irq, void *dummy);
-
 static int setup_can_queue = -1;
 module_param(setup_can_queue, int, 0);
 static int setup_cmd_per_lun = -1;
@@ -89,15 +83,14 @@ static struct scsi_cmnd *sun3_dma_setup_
 /* minimum number of bytes to do dma on */
 #define SUN3_DMA_MINSIZE 128
 
-static volatile unsigned char *sun3_scsi_regp;
+static unsigned char *sun3_scsi_regp;
 static volatile struct sun3_dma_regs *dregs;
-#ifndef SUN3_SCSI_VME
-static struct sun3_udc_regs *udc_regs = NULL;
-#endif
+static struct sun3_udc_regs *udc_regs;
 static unsigned char *sun3_dma_orig_addr = NULL;
 static unsigned long sun3_dma_orig_count = 0;
 static int sun3_dma_active = 0;
 static unsigned long last_residual = 0;
+static struct Scsi_Host *default_instance;
 
 /*
  * NCR 5380 register access functions
@@ -105,12 +98,12 @@ static unsigned long last_residual = 0;
 
 static inline unsigned char sun3scsi_read(int reg)
 {
-   return( sun3_scsi_regp[reg] );
+   return in_8(sun3_scsi_regp + reg);
 }
 
 static inline void sun3scsi_write(int reg, int value)
 {
-   sun3_scsi_regp[reg] = value;
+   out_8(sun3_scsi_regp + reg, value);
 }
 
 #ifndef SUN3_SCSI_VME
@@ -137,192 +130,7 @@ static inline void sun3_udc_write(unsign
 }
 #endif
 
-/*
- * XXX: status debug
- */
-static struct Scsi_Host *default_instance;
-
-/*
- * Function : int sun3scsi_detect(struct scsi_host_template * tpnt)
- *
- * Purpose : initializes mac NCR5380 driver based on the
- * command line / compile time port and irq definitions.
- *
- * Inputs : tpnt - template for this SCSI adapter.
- *
- * Returns : 1 if a host adapter was found, 0 if not.
- *
- */
- 
-static int __init sun3scsi_detect(struct scsi_host_template *tpnt)
-{
-   unsigned long ioaddr, irq;
-   static int called = 0;
-   struct Scsi_Host *instance;
-#ifdef SUN3_SCSI_VME
-   int i;
-   unsigned long addrs[3] = { IOBASE_SUN3_VMESCSI,
-  IOBASE_SUN3_VMESCSI + 0x4000,
-  0 };
-   unsigned long vecs[3] = { SUN3_VEC_VMESCSI0,
- SUN3_VEC_VMESCSI1,
- 0 };
-#endif
-
-   /* check that this machine has an onboard 5380 */
-   switch(idprom->id_machtype) {
-#ifdef SUN3_SCSI_VME
-   case SM_SUN3|SM_3_160:
-   case SM_SUN3|SM_3_260:
-   break;
-#else
-   case SM_SUN3|SM_3_50:
-   case SM_SUN3|SM_3_60:
-   break;
-#endif
-
-   default:
-   return 0;
-   }
-
-   if(called)
-   return 0;
-
-#ifdef SUN3_SCSI_VME
-   tpnt->proc_name = "Sun3 5380 VME SCSI";
-#else
-   tpnt->proc_name = "Sun3 5380 SCSI";
-#endif
-
-   /* setup variables */
-   if (setup_can_queue > 0)
-   tpnt->can_queue = setup_can_queue;
-   if (setup_cmd_per_lun > 0)
-   tpnt->cmd_per_lun = setup_cmd_per_lun;
-   if (setup_sg_tablesize >= 0)
-   tpnt->sg_tablesize = setup_sg_tablesize;
-
-   if (setup_hostid >= 0)
-   tpnt->this_id = setup_hostid;
-   else {
-   /* use 7 as default */
-   tpnt->this_id = 7;
-   }
-
-#ifdef SUN3_SCSI_VME
-   ioaddr = 0;
-   for (i = 0; addrs[i] != 0; i++) {
-   unsigned char x;
-
-   ioaddr = (unsigned long)sun3_ioremap(addrs[i], PAGE_SIZE,
-SUN3_PAGE_TYPE_VME

[PATCH 09/29] ncr5380: Remove duplicate comments

2014-10-02 Thread Finn Thain
The LIMIT_TRANSFERSIZE, PSEUDO_DMA, PARITY and UNSAFE options are all
documented in the core drivers where they are used. The same goes for the
chip databook reference. Remove the duplicate comments.

Signed-off-by: Finn Thain 

---
 drivers/scsi/dtc.c   |   17 +
 drivers/scsi/dtc.h   |   16 
 drivers/scsi/g_NCR5380.c |   16 
 drivers/scsi/g_NCR5380.h |   12 
 drivers/scsi/mac_scsi.c  |   12 
 drivers/scsi/mac_scsi.h  |   12 
 drivers/scsi/pas16.c |   31 ---
 drivers/scsi/pas16.h |   12 
 drivers/scsi/sun3_scsi.c |   21 -
 drivers/scsi/sun3_scsi.h |   12 
 drivers/scsi/t128.c  |   23 ---
 drivers/scsi/t128.h  |   12 
 12 files changed, 1 insertion(+), 195 deletions(-)

Index: linux/drivers/scsi/dtc.c
===
--- linux.orig/drivers/scsi/dtc.c   2014-10-02 16:55:58.0 +1000
+++ linux/drivers/scsi/dtc.c2014-10-02 16:56:00.0 +1000
@@ -19,24 +19,9 @@
  *  +1 (303) 440-4894
  *
  * DISTRIBUTION RELEASE 1.
- *
- * For more information, please consult 
- *
- * NCR 5380 Family
- * SCSI Protocol Controller
- * Databook
-*/
+ */
 
 /*
- * Options : 
- * PSEUDO_DMA - enables PSEUDO-DMA hardware, should give a 3-4X performance
- * increase compared to polled I/O.
- *
- * PARITY - enable parity checking.  Not supported.
- *
- * UNSAFE - leave interrupts enabled during pseudo-DMA transfers. 
- * You probably want this.
- *
  * The card is detected and initialized in one of several ways : 
  * 1.  Autoprobe (default) - since the board is memory mapped, 
  * a BIOS signature is scanned for to locate the registers.
Index: linux/drivers/scsi/g_NCR5380.c
===
--- linux.orig/drivers/scsi/g_NCR5380.c 2014-10-02 16:55:58.0 +1000
+++ linux/drivers/scsi/g_NCR5380.c  2014-10-02 16:56:00.0 +1000
@@ -20,18 +20,6 @@
  * Thomas Sailer, sai...@ife.ee.ethz.ch
  *
  * ALPHA RELEASE 1. 
- *
- * For more information, please consult 
- *
- * NCR 5380 Family
- * SCSI Protocol Controller
- * Databook
- *
- * NCR Microelectronics
- * 1635 Aeroplaza Drive
- * Colorado Springs, CO 80916
- * 1+ (719) 578-3400
- * 1+ (800) 334-5454
  */
 
 /* 
@@ -40,10 +28,6 @@
  */
 
 /*
- * Options :
- *
- * PARITY - enable parity checking.  Not supported.
- *
  * The card is detected and initialized in one of several ways : 
  * 1.  With command line overrides - NCR5380=port,irq may be 
  * used on the LILO command line to override the defaults.
Index: linux/drivers/scsi/pas16.c
===
--- linux.orig/drivers/scsi/pas16.c 2014-10-02 16:55:58.0 +1000
+++ linux/drivers/scsi/pas16.c  2014-10-02 16:56:00.0 +1000
@@ -22,40 +22,9 @@
  * Media Vision
  * (510) 770-8600
  * (800) 348-7116
- * 
- * and 
- *
- * NCR 5380 Family
- * SCSI Protocol Controller
- * Databook
- *
- * NCR Microelectronics
- * 1635 Aeroplaza Drive
- * Colorado Springs, CO 80916
- * 1+ (719) 578-3400
- * 1+ (800) 334-5454
  */
 
 /*
- * Options : 
- * LIMIT_TRANSFERSIZE - if defined, limit the pseudo-dma transfers to 512
- *  bytes at a time.  Since interrupts are disabled by default during
- *  these transfers, we might need this to give reasonable interrupt
- *  service time if the transfer size gets too large.
- *
- * PSEUDO_DMA - enables PSEUDO-DMA hardware, should give a 3-4X performance
- * increase compared to polled I/O.
- *
- * PARITY - enable parity checking.  Not supported.
- *
- * UNSAFE - leave interrupts enabled during pseudo-DMA transfers.  This
- * parameter comes from the NCR5380 code.  It is NOT unsafe with
- * the PAS16 and you should use it.  If you don't you will have
- * a problem with dropped characters during high speed
- * communications during SCSI transfers.  If you really don't
- * want to use UNSAFE you can try defining LIMIT_TRANSFERSIZE or
- * twiddle with the transfer size in the high level code.
- *
  * The card is detected and initialized in one of several ways : 
  * 1.  Autoprobe (default) - There are many different models of
  * the Pro Audio Spectrum/Studio 16, and I only have one of
Index: linux/drivers/scsi/sun3_scsi.c
===
--- linux.orig/drivers/scsi/sun3_scsi.c 2014-10-02 16:55:58.0 +1000
+++ linux/drivers/scsi/sun3_scsi.c  2014-10-02 16:56:00.0 +1000
@@ -22,27 +22,6 @@
  * Copyright 1995, Russell King
  *
  * ALPHA RELEASE 1.
- *
- * For more information, please consult
- *
- * NCR 5380 Family
- * SCSI Protocol Controller
- * Databook
- *
- * NCR Microelectronics
- * 1635 Aeroplaza Drive
- * Colorado Springs, CO 80916
- * 1+ (719) 578-340

[PATCH 24/29] atari_scsi: Remove header

2014-10-02 Thread Finn Thain
The #defines in atari_scsi.h are intended to influence subsequent #includes
in atari_scsi.c. IMHO, that's too convoluted.

Remove atari_scsi.h by moving those macro definitions to atari_scsi.c,
consistent with other NCR5380 drivers.

Signed-off-by: Finn Thain 

---
 drivers/scsi/atari_scsi.c |   35 ++-
 drivers/scsi/atari_scsi.h |   40 
 2 files changed, 26 insertions(+), 49 deletions(-)

Index: linux/drivers/scsi/atari_scsi.c
===
--- linux.orig/drivers/scsi/atari_scsi.c2014-10-02 16:56:21.0 
+1000
+++ linux/drivers/scsi/atari_scsi.c 2014-10-02 16:56:22.0 +1000
@@ -64,15 +64,7 @@
 /**/
 
 
-
 #include 
-
-/* For the Atari version, use only polled IO or REAL_DMA */
-#defineREAL_DMA
-/* Support tagged queuing? (on devices that are able to... :-) */
-#defineSUPPORT_TAGS
-#defineMAX_TAGS 32
-
 #include 
 #include 
 #include 
@@ -92,9 +84,34 @@
 
 #include 
 
-#include "atari_scsi.h"
+/* Definitions for the core NCR5380 driver. */
+
+#define REAL_DMA
+#define SUPPORT_TAGS
+#define MAX_TAGS32
+
+#define NCR5380_implementation_fields   /* none */
+
+#define NCR5380_read(reg)   atari_scsi_reg_read(reg)
+#define NCR5380_write(reg, value)   atari_scsi_reg_write(reg, value)
+
+#define NCR5380_queue_command   atari_scsi_queue_command
+#define NCR5380_abort   atari_scsi_abort
+#define NCR5380_show_info   atari_scsi_show_info
+#define NCR5380_infoatari_scsi_info
+
+#define NCR5380_dma_read_setup(instance, data, count) \
+atari_scsi_dma_setup(instance, data, count, 0)
+#define NCR5380_dma_write_setup(instance, data, count) \
+atari_scsi_dma_setup(instance, data, count, 1)
+#define NCR5380_dma_residual(instance) \
+atari_scsi_dma_residual(instance)
+#define NCR5380_dma_xfer_len(instance, cmd, phase) \
+atari_dma_xfer_len(cmd->SCp.this_residual, cmd, !((phase) & SR_IO))
+
 #include "NCR5380.h"
 
+
 #defineIS_A_TT()   ATARIHW_PRESENT(TT_SCSI)
 
 #defineSCSI_DMA_WRITE_P(elt,val)   \
Index: linux/drivers/scsi/atari_scsi.h
===
--- linux.orig/drivers/scsi/atari_scsi.h2014-10-02 16:56:21.0 
+1000
+++ /dev/null   1970-01-01 00:00:00.0 +
@@ -1,40 +0,0 @@
-/*
- * atari_scsi.h -- Header file for the Atari native SCSI driver
- *
- * Copyright 1994 Roman Hodek 
- *
- * (Loosely based on the work of Robert De Vries' team)
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of this archive
- * for more details.
- *
- */
-
-
-#ifndef ATARI_SCSI_H
-#define ATARI_SCSI_H
-
-/* (I_HAVE_OVERRUNS stuff removed) */
-
-#ifndef ASM
-
-#defineNCR5380_implementation_fields   /* none */
-
-#define NCR5380_read(reg)atari_scsi_reg_read( reg )
-#define NCR5380_write(reg, value) atari_scsi_reg_write( reg, value )
-
-#define NCR5380_queue_command atari_scsi_queue_command
-#define NCR5380_abort atari_scsi_abort
-#define NCR5380_show_info atari_scsi_show_info
-#define NCR5380_info atari_scsi_info
-#define NCR5380_dma_read_setup(inst,d,c) atari_scsi_dma_setup (inst, d, c, 0)
-#define NCR5380_dma_write_setup(inst,d,c) atari_scsi_dma_setup (inst, d, c, 1)
-#define NCR5380_dma_residual(inst) atari_scsi_dma_residual( inst )
-#defineNCR5380_dma_xfer_len(i,cmd,phase) \
-   atari_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 : 1)
-
-#endif /* ndef ASM */
-#endif /* ATARI_SCSI_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 13/29] ncr5380: Move static PDMA spin counters to host data

2014-10-02 Thread Finn Thain
Static variables from dtc.c and pas16.c should not appear in the core
NCR5380.c driver. Aside from being a layering issue this worsens the
divergence between the three core driver variants (atari_NCR5380.c and
sun3_NCR5380.c don't support PSEUDO_DMA) and it can mean multiple hosts
share the same counters.

Fix this by making the pseudo DMA spin counters in the core more generic.
This also avoids the abuse of the {DTC,PAS16}_PUBLIC_RELEASE macros, so
they can be removed.

oak.c doesn't use PDMA and hence it doesn't use the counters and hence it
needs no write_info() method. Remove it.

Signed-off-by: Finn Thain 

---
 drivers/scsi/NCR5380.c |   22 ++
 drivers/scsi/NCR5380.h |4 
 drivers/scsi/arm/oak.c |2 --
 drivers/scsi/dtc.c |   13 ++---
 drivers/scsi/pas16.c   |   12 ++--
 5 files changed, 26 insertions(+), 27 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===
--- linux.orig/drivers/scsi/NCR5380.c   2014-10-02 16:56:05.0 +1000
+++ linux/drivers/scsi/NCR5380.c2014-10-02 16:56:09.0 +1000
@@ -693,6 +693,7 @@ static void NCR5380_print_status(struct
NCR5380_dprint_phase(NDEBUG_ANY, instance);
 }
 
+#ifdef PSEUDO_DMA
 /**/
 /*
  * /proc/scsi/[dtc pas16 t128 generic]/[0-ASC_NUM_BOARD_SUPPORTED]
@@ -710,14 +711,13 @@ static void NCR5380_print_status(struct
 static int __maybe_unused NCR5380_write_info(struct Scsi_Host *instance,
char *buffer, int length)
 {
-#ifdef DTC_PUBLIC_RELEASE
-   dtc_wmaxi = dtc_maxi = 0;
-#endif
-#ifdef PAS16_PUBLIC_RELEASE
-   pas_wmaxi = pas_maxi = 0;
-#endif
-   return (-ENOSYS);   /* Currently this is a no-op */
+   struct NCR5380_hostdata *hostdata = shost_priv(instance);
+
+   hostdata->spin_max_r = 0;
+   hostdata->spin_max_w = 0;
+   return 0;
 }
+#endif
 
 #undef SPRINTF
 #define SPRINTF(args...) seq_printf(m, ## args)
@@ -752,11 +752,9 @@ static int __maybe_unused NCR5380_show_i
SPRINTF("PAS16 release=%d", PAS16_PUBLIC_RELEASE);
 #endif
 
-#ifdef DTC_PUBLIC_RELEASE
-   SPRINTF("Highwater I/O busy_spin_counts -- write: %d  read: %d\n", 
dtc_wmaxi, dtc_maxi);
-#endif
-#ifdef PAS16_PUBLIC_RELEASE
-   SPRINTF("Highwater I/O busy_spin_counts -- write: %d  read: %d\n", 
pas_wmaxi, pas_maxi);
+#ifdef PSEUDO_DMA
+   SPRINTF("Highwater I/O busy spin counts: write %d, read %d\n",
+   hostdata->spin_max_w, hostdata->spin_max_r);
 #endif
spin_lock_irq(instance->host_lock);
if (!hostdata->connected)
Index: linux/drivers/scsi/NCR5380.h
===
--- linux.orig/drivers/scsi/NCR5380.h   2014-10-02 16:56:05.0 +1000
+++ linux/drivers/scsi/NCR5380.h2014-10-02 16:56:09.0 +1000
@@ -270,6 +270,10 @@ struct NCR5380_hostdata {
struct delayed_work coroutine;  /* our co-routine */
struct scsi_eh_save ses;
char info[256];
+#ifdef PSEUDO_DMA
+   unsigned spin_max_r;
+   unsigned spin_max_w;
+#endif
 };
 
 #ifdef __KERNEL__
Index: linux/drivers/scsi/dtc.c
===
--- linux.orig/drivers/scsi/dtc.c   2014-10-02 16:56:05.0 +1000
+++ linux/drivers/scsi/dtc.c2014-10-02 16:56:09.0 +1000
@@ -332,13 +332,11 @@ static int dtc_biosparam(struct scsi_dev
  * timeout.
 */
 
-static int dtc_maxi = 0;
-static int dtc_wmaxi = 0;
-
 static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char 
*dst, int len)
 {
unsigned char *d = dst;
int i;  /* For counting time spent in the poll-loop */
+   struct NCR5380_hostdata *hostdata = shost_priv(instance);
NCR5380_local_declare();
NCR5380_setup(instance);
 
@@ -369,8 +367,8 @@ static inline int NCR5380_pread(struct S
NCR5380_write(MODE_REG, 0); /* Clear the operating mode */
rtrc(0);
NCR5380_read(RESET_PARITY_INTERRUPT_REG);
-   if (i > dtc_maxi)
-   dtc_maxi = i;
+   if (i > hostdata->spin_max_r)
+   hostdata->spin_max_r = i;
return (0);
 }
 
@@ -390,6 +388,7 @@ static inline int NCR5380_pread(struct S
 static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char 
*src, int len)
 {
int i;
+   struct NCR5380_hostdata *hostdata = shost_priv(instance);
NCR5380_local_declare();
NCR5380_setup(instance);
 
@@ -422,8 +421,8 @@ static inline int NCR5380_pwrite(struct
/* Check for parity error here. fixme. */
NCR5380_write(MODE_REG, 0); /* Clear the operating mode */
rtrc(0);
-   if (i > dtc_wmaxi)
-   dtc_wmaxi = i;
+   if (i > hostdata->spin_max_w)
+   hostdata->spin_max_w = i;
return (0);
 }
 
Index: linux/drivers/scsi/pas16.c
===

[PATCH 14/29] ncr5380: Remove pointless compiler command line override macros

2014-10-02 Thread Finn Thain
Compile-time override of scsi host defaults is pointless for drivers that
provide module parameters and __setup options for that. Too many macros make
the code hard to read so remove them.

Signed-off-by: Finn Thain 

---
 drivers/scsi/atari_scsi.c |2 +-
 drivers/scsi/atari_scsi.h |3 ---
 drivers/scsi/mac_scsi.c   |   19 +--
 drivers/scsi/mac_scsi.h   |   16 
 drivers/scsi/sun3_scsi.c  |   20 ++--
 drivers/scsi/sun3_scsi.h  |   18 --
 6 files changed, 20 insertions(+), 58 deletions(-)

Index: linux/drivers/scsi/mac_scsi.c
===
--- linux.orig/drivers/scsi/mac_scsi.c  2014-10-02 16:56:05.0 +1000
+++ linux/drivers/scsi/mac_scsi.c   2014-10-02 16:56:10.0 +1000
@@ -177,13 +177,12 @@ int __init macscsi_detect(struct scsi_ho
 if (macintosh_config->scsi_type != MAC_SCSI_OLD)
return( 0 );
 
-/* setup variables */
-tpnt->can_queue =
-   (setup_can_queue > 0) ? setup_can_queue : CAN_QUEUE;
-tpnt->cmd_per_lun =
-   (setup_cmd_per_lun > 0) ? setup_cmd_per_lun : CMD_PER_LUN;
-tpnt->sg_tablesize = 
-   (setup_sg_tablesize >= 0) ? setup_sg_tablesize : SG_TABLESIZE;
+   if (setup_can_queue > 0)
+   tpnt->can_queue = setup_can_queue;
+   if (setup_cmd_per_lun > 0)
+   tpnt->cmd_per_lun = setup_cmd_per_lun;
+   if (setup_sg_tablesize >= 0)
+   tpnt->sg_tablesize = setup_sg_tablesize;
 
 if (setup_hostid >= 0)
tpnt->this_id = setup_hostid;
@@ -194,7 +193,7 @@ int __init macscsi_detect(struct scsi_ho
 
 #ifdef SUPPORT_TAGS
 if (setup_use_tagged_queuing < 0)
-   setup_use_tagged_queuing = USE_TAGGED_QUEUING;
+   setup_use_tagged_queuing = 0;
 #endif
 
 /* Once we support multiple 5380s (e.g. DuoDock) we'll do
@@ -496,10 +495,10 @@ static struct scsi_host_template driver_
.queuecommand   = macscsi_queue_command,
.eh_abort_handler   = macscsi_abort,
.eh_bus_reset_handler   = macscsi_bus_reset,
-   .can_queue  = CAN_QUEUE,
+   .can_queue  = 16,
.this_id= 7,
.sg_tablesize   = SG_ALL,
-   .cmd_per_lun= CMD_PER_LUN,
+   .cmd_per_lun= 2,
.use_clustering = DISABLE_CLUSTERING
 };
 
Index: linux/drivers/scsi/mac_scsi.h
===
--- linux.orig/drivers/scsi/mac_scsi.h  2014-10-02 16:56:05.0 +1000
+++ linux/drivers/scsi/mac_scsi.h   2014-10-02 16:56:10.0 +1000
@@ -17,22 +17,6 @@
 
 #ifndef ASM
 
-#ifndef CMD_PER_LUN
-#define CMD_PER_LUN 2
-#endif
-
-#ifndef CAN_QUEUE
-#define CAN_QUEUE 16
-#endif
-
-#ifndef SG_TABLESIZE
-#define SG_TABLESIZE SG_NONE
-#endif
-
-#ifndef USE_TAGGED_QUEUING
-#defineUSE_TAGGED_QUEUING 0
-#endif
-
 #include 
 
 #define NCR5380_implementation_fields /* none */
Index: linux/drivers/scsi/sun3_scsi.c
===
--- linux.orig/drivers/scsi/sun3_scsi.c 2014-10-02 16:56:05.0 +1000
+++ linux/drivers/scsi/sun3_scsi.c  2014-10-02 16:56:10.0 +1000
@@ -198,12 +198,12 @@ static int __init sun3scsi_detect(struct
 #endif
 
/* setup variables */
-   tpnt->can_queue =
-   (setup_can_queue > 0) ? setup_can_queue : CAN_QUEUE;
-   tpnt->cmd_per_lun =
-   (setup_cmd_per_lun > 0) ? setup_cmd_per_lun : CMD_PER_LUN;
-   tpnt->sg_tablesize = 
-   (setup_sg_tablesize >= 0) ? setup_sg_tablesize : SG_TABLESIZE;
+   if (setup_can_queue > 0)
+   tpnt->can_queue = setup_can_queue;
+   if (setup_cmd_per_lun > 0)
+   tpnt->cmd_per_lun = setup_cmd_per_lun;
+   if (setup_sg_tablesize >= 0)
+   tpnt->sg_tablesize = setup_sg_tablesize;
 
if (setup_hostid >= 0)
tpnt->this_id = setup_hostid;
@@ -257,7 +257,7 @@ static int __init sun3scsi_detect(struct
 #endif
 #ifdef SUPPORT_TAGS
if (setup_use_tagged_queuing < 0)
-   setup_use_tagged_queuing = USE_TAGGED_QUEUING;
+   setup_use_tagged_queuing = 1;
 #endif
 
instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
@@ -683,10 +683,10 @@ static struct scsi_host_template driver_
.queuecommand   = sun3scsi_queue_command,
.eh_abort_handler   = sun3scsi_abort,
.eh_bus_reset_handler   = sun3scsi_bus_reset,
-   .can_queue  = CAN_QUEUE,
+   .can_queue  = 16,
.this_id= 7,
-   .sg_tablesize   = SG_TABLESIZE,
-   .cmd_per_lun= CMD_PER_LUN,
+   .sg_tablesize   = SG_NONE,
+   .cmd_per_lun= 2,
.use_clustering = DISABLE_CLUSTE

[PATCH 27/29] ncr5380: Remove ENABLE_IRQ/DISABLE_IRQ macros

2014-10-02 Thread Finn Thain
atari_NCR5380.c enables its IRQ when it is already enabled. Sun3 doesn't
use the ENABLE_IRQ/DISABLE_IRQ cruft. Remove it.

Signed-off-by: Finn Thain 

---
 drivers/scsi/atari_NCR5380.c |2 --
 drivers/scsi/atari_scsi.c|   21 -
 drivers/scsi/sun3_NCR5380.c  |2 --
 drivers/scsi/sun3_scsi.c |7 ---
 4 files changed, 32 deletions(-)

Index: linux/drivers/scsi/atari_NCR5380.c
===
--- linux.orig/drivers/scsi/atari_NCR5380.c 2014-10-02 16:56:20.0 
+1000
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-02 16:56:24.0 +1000
@@ -1226,7 +1226,6 @@ static irqreturn_t NCR5380_intr(int irq,
NCR5380_dprint(NDEBUG_INTR, instance);
if ((NCR5380_read(STATUS_REG) & (SR_SEL|SR_IO)) == 
(SR_SEL|SR_IO)) {
done = 0;
-   ENABLE_IRQ();
dprintk(NDEBUG_INTR, "scsi%d: SEL interrupt\n", HOSTNO);
NCR5380_reselect(instance);
(void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
@@ -1256,7 +1255,6 @@ static irqreturn_t NCR5380_intr(int irq,
dprintk(NDEBUG_INTR, "scsi%d: PHASE MISM or EOP 
interrupt\n", HOSTNO);
NCR5380_dma_complete( instance );
done = 0;
-   ENABLE_IRQ();
} else
 #endif /* REAL_DMA */
{
Index: linux/drivers/scsi/atari_scsi.c
===
--- linux.orig/drivers/scsi/atari_scsi.c2014-10-02 16:56:22.0 
+1000
+++ linux/drivers/scsi/atari_scsi.c 2014-10-02 16:56:24.0 +1000
@@ -157,23 +157,6 @@ static inline unsigned long SCSI_DMA_GET
return adr;
 }
 
-static inline void ENABLE_IRQ(void)
-{
-   if (IS_A_TT())
-   atari_enable_irq(IRQ_TT_MFP_SCSI);
-   else
-   atari_enable_irq(IRQ_MFP_FSCSI);
-}
-
-static inline void DISABLE_IRQ(void)
-{
-   if (IS_A_TT())
-   atari_disable_irq(IRQ_TT_MFP_SCSI);
-   else
-   atari_disable_irq(IRQ_MFP_FSCSI);
-}
-
-
 #define HOSTDATA_DMALEN(((struct NCR5380_hostdata *) \
(atari_scsi_host->hostdata))->dma_len)
 
@@ -373,10 +356,6 @@ static irqreturn_t scsi_tt_intr(int irq,
 
NCR5380_intr(irq, dummy);
 
-#if 0
-   /* To be sure the int is not masked */
-   atari_enable_irq(IRQ_TT_MFP_SCSI);
-#endif
return IRQ_HANDLED;
 }
 
Index: linux/drivers/scsi/sun3_NCR5380.c
===
--- linux.orig/drivers/scsi/sun3_NCR5380.c  2014-10-02 16:56:14.0 
+1000
+++ linux/drivers/scsi/sun3_NCR5380.c   2014-10-02 16:56:24.0 +1000
@@ -1153,7 +1153,6 @@ static irqreturn_t NCR5380_intr (int irq
NCR5380_dprint(NDEBUG_INTR, instance);
if ((NCR5380_read(STATUS_REG) & (SR_SEL|SR_IO)) == (SR_SEL|SR_IO)) {
done = 0;
-// ENABLE_IRQ();
dprintk(NDEBUG_INTR, "scsi%d: SEL interrupt\n", HOSTNO);
NCR5380_reselect(instance);
(void) NCR5380_read(RESET_PARITY_INTERRUPT_REG);
@@ -1186,7 +1185,6 @@ static irqreturn_t NCR5380_intr (int irq
dprintk(NDEBUG_INTR, "scsi%d: PHASE MISM or EOP interrupt\n", 
HOSTNO);
NCR5380_dma_complete( instance );
done = 0;
-// ENABLE_IRQ();
} else
 #endif /* REAL_DMA */
{
Index: linux/drivers/scsi/sun3_scsi.c
===
--- linux.orig/drivers/scsi/sun3_scsi.c 2014-10-02 16:56:23.0 +1000
+++ linux/drivers/scsi/sun3_scsi.c  2014-10-02 16:56:24.0 +1000
@@ -72,13 +72,6 @@
 
 extern int sun3_map_test(unsigned long, char *);
 
-#ifdef SUN3_SCSI_VME
-#define ENABLE_IRQ()
-#else
-#defineENABLE_IRQ()enable_irq( IRQ_SUN3_SCSI ); 
-#endif
-
-
 static int setup_can_queue = -1;
 module_param(setup_can_queue, int, 0);
 static int setup_cmd_per_lun = -1;


--
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/29] mac_scsi: Cleanup PDMA code

2014-10-02 Thread Finn Thain
Fix whitespace, remove pointless volatile qualifiers and improve code style
by use of INPUT_DATA_REG and OUTPUT_DATA_REG macros.

Signed-off-by: Finn Thain 

---
 drivers/scsi/mac_scsi.c |  122 
 1 file changed, 62 insertions(+), 60 deletions(-)

Index: linux/drivers/scsi/mac_scsi.c
===
--- linux.orig/drivers/scsi/mac_scsi.c  2014-10-02 16:56:17.0 +1000
+++ linux/drivers/scsi/mac_scsi.c   2014-10-02 16:56:18.0 +1000
@@ -86,9 +86,9 @@ module_param(setup_hostid, int, 0);
 #defineAFTER_RESET_DELAY   (HZ/2)
 #endif
 
-static volatile unsigned char *mac_scsi_regp = NULL;
-static volatile unsigned char *mac_scsi_drq  = NULL;
-static volatile unsigned char *mac_scsi_nodrq = NULL;
+static unsigned char *mac_scsi_regp;
+static unsigned char *mac_scsi_drq;
+static unsigned char *mac_scsi_nodrq;
 
 
 /*
@@ -262,6 +262,7 @@ static void mac_scsi_reset_boot(struct S
 }
 #endif
 
+#ifdef PSEUDO_DMA
 /* 
Pseudo-DMA: (Ove Edlund)
The code attempts to catch bus errors that occur if one for example
@@ -331,38 +332,38 @@ __asm__ __volatile__  
\
  : "0"(s), "1"(d), "2"(len)\
  : "d0")
 
-
-static int macscsi_pread (struct Scsi_Host *instance,
- unsigned char *dst, int len)
+static int macscsi_pread(struct Scsi_Host *instance,
+ unsigned char *dst, int len)
 {
-   unsigned char *d;
-   volatile unsigned char *s;
+   unsigned char *d;
+   unsigned char *s;
+
+   NCR5380_local_declare();
+   NCR5380_setup(instance);
+
+   s = mac_scsi_drq + (INPUT_DATA_REG << 4);
+   d = dst;
 
-   NCR5380_local_declare();
-   NCR5380_setup(instance);
+   /* These conditions are derived from MacOS */
 
-   s = mac_scsi_drq+0x60;
-   d = dst;
+   while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) &&
+  !(NCR5380_read(STATUS_REG) & SR_REQ))
+   ;
+
+   if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) &&
+   (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH)) {
+   pr_err("Error in macscsi_pread\n");
+   return -1;
+   }
 
-/* These conditions are derived from MacOS */
-
-   while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) 
- && !(NCR5380_read(STATUS_REG) & SR_REQ))
-  ;
-   if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) 
- && (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH)) {
-  printk(KERN_ERR "Error in macscsi_pread\n");
-  return -1;
-   }
-
-   CP_IO_TO_MEM(s, d, len);
-   
-   if (len != 0) {
-  printk(KERN_NOTICE "Bus error in macscsi_pread\n");
-  return -1;
-   }
-   
-   return 0;
+   CP_IO_TO_MEM(s, d, len);
+
+   if (len != 0) {
+   pr_notice("Bus error in macscsi_pread\n");
+   return -1;
+   }
+
+   return 0;
 }
 
 
@@ -424,39 +425,40 @@ __asm__ __volatile__  
\
  : "0"(s), "1"(d), "2"(len)\
  : "d0")
 
-static int macscsi_pwrite (struct Scsi_Host *instance,
- unsigned char *src, int len)
+static int macscsi_pwrite(struct Scsi_Host *instance,
+  unsigned char *src, int len)
 {
-   unsigned char *s;
-   volatile unsigned char *d;
+   unsigned char *s;
+   unsigned char *d;
+
+   NCR5380_local_declare();
+   NCR5380_setup(instance);
 
-   NCR5380_local_declare();
-   NCR5380_setup(instance);
+   s = src;
+   d = mac_scsi_drq + (OUTPUT_DATA_REG << 4);
 
-   s = src;
-   d = mac_scsi_drq;
-   
-/* These conditions are derived from MacOS */
-
-   while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) 
- && (!(NCR5380_read(STATUS_REG) & SR_REQ) 
-|| (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH))) 
-  ;
-   if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ)) {
-  printk(KERN_ERR "Error in macscsi_pwrite\n");
-  return -1;
-   }
-
-   CP_MEM_TO_IO(s, d, len);   
-
-   if (len != 0) {
-  printk(KERN_NOTICE "Bus error in macscsi_pwrite\n");
-  return -1;
-   }
-   
-   return 0;
-}
+   /* These conditions are derived from MacOS */
+
+   while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) &&
+  (!(NCR5380_read(STATUS_REG) & SR_REQ) ||
+   (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH)))
+   ;
+
+   if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ)) {
+   pr_err("Error in macscsi_pwrite\n");
+   return -1;
+   }
+
+   CP_MEM_TO_IO(s, d, len);
 
+   if (len != 0) {
+   pr_notice("Bus error in macscsi_pwrite\n");
+   return -1;
+   }
+
+   return 0;
+}
+#endif
 
 #include "NCR5380.c"
 


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
t

[PATCH 23/29] atari_scsi: Convert to platform device

2014-10-02 Thread Finn Thain
Convert atari_scsi to platform device and eliminate scsi_register().

Validate __setup options later on so that module options are checked as well.

Remove the comment about the scsi mid-layer disabling the host irq as it
is no longer true (AFAICT). Also remove the obsolete slow interrupt stuff
(IRQ_TYPE_SLOW == 0 anyway).

Signed-off-by: Finn Thain 

---
 arch/m68k/atari/config.c  |5 
 drivers/scsi/atari_scsi.c |  426 ++
 drivers/scsi/atari_scsi.h |   17 -
 3 files changed, 217 insertions(+), 231 deletions(-)

Index: linux/arch/m68k/atari/config.c
===
--- linux.orig/arch/m68k/atari/config.c 2014-10-02 16:55:28.0 +1000
+++ linux/arch/m68k/atari/config.c  2014-10-02 16:56:21.0 +1000
@@ -892,6 +892,11 @@ int __init atari_platform_init(void)
}
 #endif
 
+#ifdef CONFIG_ATARI_SCSI
+   if (ATARIHW_PRESENT(ST_SCSI) || ATARIHW_PRESENT(TT_SCSI))
+   platform_device_register_simple("atari_scsi", -1, NULL, 0);
+#endif
+
return rv;
 }
 
Index: linux/drivers/scsi/atari_scsi.c
===
--- linux.orig/drivers/scsi/atari_scsi.c2014-10-02 16:56:20.0 
+1000
+++ linux/drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.0 +1000
@@ -74,33 +74,26 @@
 #defineMAX_TAGS 32
 
 #include 
-#include 
-#include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include "atari_scsi.h"
-#include "NCR5380.h"
 #include 
 #include 
 #include 
 
-#include 
+#include 
+
+#include "atari_scsi.h"
+#include "NCR5380.h"
 
 #defineIS_A_TT()   ATARIHW_PRESENT(TT_SCSI)
 
@@ -176,25 +169,9 @@ static inline void DISABLE_IRQ(void)
 #defineAFTER_RESET_DELAY   (5*HZ/2)
 #endif
 
-/* Prototypes */
-
 #ifdef REAL_DMA
 static void atari_scsi_fetch_restbytes(void);
 #endif
-static irqreturn_t scsi_tt_intr(int irq, void *dummy);
-static irqreturn_t scsi_falcon_intr(int irq, void *dummy);
-static void falcon_release_lock_if_possible(struct NCR5380_hostdata *hostdata);
-static int falcon_get_lock(void);
-#ifdef CONFIG_ATARI_SCSI_RESET_BOOT
-static void atari_scsi_reset_boot(void);
-#endif
-static unsigned char atari_scsi_tt_reg_read(unsigned char reg);
-static void atari_scsi_tt_reg_write(unsigned char reg, unsigned char value);
-static unsigned char atari_scsi_falcon_reg_read(unsigned char reg);
-static void atari_scsi_falcon_reg_write(unsigned char reg, unsigned char 
value);
-
-/* End of Prototypes **/
-
 
 static struct Scsi_Host *atari_scsi_host;
 static unsigned char (*atari_scsi_reg_read)(unsigned char reg);
@@ -518,160 +495,12 @@ static int falcon_get_lock(void)
}
 }
 
-
-static int __init atari_scsi_detect(struct scsi_host_template *host)
-{
-   static int called = 0;
-   struct Scsi_Host *instance;
-
-   if (!MACH_IS_ATARI ||
-   (!ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(TT_SCSI)) ||
-   called)
-   return 0;
-
-   host->proc_name = "Atari";
-
-   atari_scsi_reg_read  = IS_A_TT() ? atari_scsi_tt_reg_read :
-  atari_scsi_falcon_reg_read;
-   atari_scsi_reg_write = IS_A_TT() ? atari_scsi_tt_reg_write :
-  atari_scsi_falcon_reg_write;
-
-   /* setup variables */
-   host->can_queue =
-   (setup_can_queue > 0) ? setup_can_queue :
-   IS_A_TT() ? ATARI_TT_CAN_QUEUE : ATARI_FALCON_CAN_QUEUE;
-   host->cmd_per_lun =
-   (setup_cmd_per_lun > 0) ? setup_cmd_per_lun :
-   IS_A_TT() ? ATARI_TT_CMD_PER_LUN : ATARI_FALCON_CMD_PER_LUN;
-   /* Force sg_tablesize to 0 on a Falcon! */
-   host->sg_tablesize =
-   !IS_A_TT() ? ATARI_FALCON_SG_TABLESIZE :
-   (setup_sg_tablesize >= 0) ? setup_sg_tablesize : 
ATARI_TT_SG_TABLESIZE;
-
-   if (setup_hostid >= 0)
-   host->this_id = setup_hostid;
-   else {
-   /* use 7 as default */
-   host->this_id = 7;
-   /* Test if a host id is set in the NVRam */
-   if (ATARIHW_PRESENT(TT_CLK) && nvram_check_checksum()) {
-   unsigned char b = nvram_read_byte( 14 );
-   /* Arbitration enabled? (for TOS) If yes, use 
configured host ID */
-   if (b & 0x80)
-   host->this_id = b & 7;
-   }
-   }
-
-#ifdef SUPPORT_TAGS
-   if (setup_use_tagged_queuing < 0)
-   setup_use_tagged_queuing = 0;
-#endif
-#ifdef REAL_DMA
-   /* If running on a Falcon and if there's TT-Ram (i.e., more than one
-* memor

[PATCH 28/29] atari_NCR5380: Refactor Falcon special cases

2014-10-02 Thread Finn Thain
Make the atari_NCR5380.c core driver usable by sun3_scsi, mac_scsi and others
by moving some of the Falcon-specific code out of the core driver: !IS_A_TT,
atari_read_overruns and falcon_dont_release. Replace these with hostdata 
variables and flags. FLAG_CHECK_LAST_BYTE_SENT is unused in atari_NCR5380.c
so don't set it.

Signed-off-by: Finn Thain 

---
 drivers/scsi/NCR5380.h   |4 
 drivers/scsi/atari_NCR5380.c |   30 +++---
 drivers/scsi/atari_scsi.c|   21 -
 3 files changed, 31 insertions(+), 24 deletions(-)

Index: linux/drivers/scsi/atari_scsi.c
===
--- linux.orig/drivers/scsi/atari_scsi.c2014-10-02 16:56:24.0 
+1000
+++ linux/drivers/scsi/atari_scsi.c 2014-10-02 16:56:25.0 +1000
@@ -196,8 +196,6 @@ static char *atari_dma_orig_addr;
 /* mask for address bits that can't be used with the ST-DMA */
 static unsigned long   atari_dma_stram_mask;
 #define STRAM_ADDR(a)  (((a) & atari_dma_stram_mask) == 0)
-/* number of bytes to cut from a transfer to handle NCR overruns */
-static int atari_read_overruns;
 #endif
 
 static int setup_can_queue = -1;
@@ -446,8 +444,6 @@ static void atari_scsi_fetch_restbytes(v
 #endif /* REAL_DMA */
 
 
-static int falcon_dont_release = 0;
-
 /* This function releases the lock on the DMA chip if there is no
  * connected command and the disconnected queue is empty.
  */
@@ -464,7 +460,7 @@ static void falcon_release_lock_if_possi
if (!hostdata->disconnected_queue &&
!hostdata->issue_queue &&
!hostdata->connected &&
-   !falcon_dont_release &&
+   !hostdata->retain_dma_intr &&
stdma_is_locked_by(scsi_falcon_intr))
stdma_release();
 
@@ -846,6 +842,7 @@ static int __init atari_scsi_probe(struc
 {
struct Scsi_Host *instance;
int error;
+   int host_flags = 0;
 
if (!MACH_IS_ATARI)
return -ENODEV;
@@ -945,7 +942,9 @@ static int __init atari_scsi_probe(struc
else
instance->irq = IRQ_NONE;
 
-   NCR5380_init(instance, 0);
+   host_flags |= IS_A_TT() ? 0 : FLAG_LATE_DMA_SETUP;
+
+   NCR5380_init(instance, host_flags);
 
if (IS_A_TT()) {
error = request_irq(instance->irq, scsi_tt_intr, 0,
@@ -968,12 +967,16 @@ static int __init atari_scsi_probe(struc
 *
 * In principle it should be sufficient to do max. 1 byte with
 * PIO, but there is another problem on the Medusa with the DMA
-* rest data register. So 'atari_read_overruns' is currently set
+* rest data register. So read_overruns is currently set
 * to 4 to avoid having transfers that aren't a multiple of 4.
 * If the rest data bug is fixed, this can be lowered to 1.
 */
-   if (MACH_IS_MEDUSA)
-   atari_read_overruns = 4;
+   if (MACH_IS_MEDUSA) {
+   struct NCR5380_hostdata *hostdata =
+   shost_priv(instance);
+
+   hostdata->read_overruns = 4;
+   }
 #endif
} else {
/* Nothing to do for the interrupt: the ST-DMA is initialized
Index: linux/drivers/scsi/NCR5380.h
===
--- linux.orig/drivers/scsi/NCR5380.h   2014-10-02 16:56:14.0 +1000
+++ linux/drivers/scsi/NCR5380.h2014-10-02 16:56:25.0 +1000
@@ -237,6 +237,7 @@
 #define FLAG_NCR53C400 4   /* NCR53c400 */
 #define FLAG_NO_PSEUDO_DMA 8   /* Inhibit DMA */
 #define FLAG_DTC3181E  16  /* DTC3181E */
+#define FLAG_LATE_DMA_SETUP32  /* Setup NCR before DMA H/W */
 
 #ifndef ASM
 struct NCR5380_hostdata {
@@ -265,6 +266,9 @@ struct NCR5380_hostdata {
struct delayed_work coroutine;  /* our co-routine */
struct scsi_eh_save ses;
char info[256];
+   int read_overruns;/* number of bytes to cut from a
+  * transfer to handle chip overruns */
+   int retain_dma_intr;
 #ifdef PSEUDO_DMA
unsigned spin_max_r;
unsigned spin_max_w;
Index: linux/drivers/scsi/atari_NCR5380.c
===
--- linux.orig/drivers/scsi/atari_NCR5380.c 2014-10-02 16:56:24.0 
+1000
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-02 16:56:25.0 +1000
@@ -837,7 +837,7 @@ static int __init NCR5380_init(struct Sc
hostdata->connected = NULL;
hostdata->issue_queue = NULL;
hostdata->disconnected_queue = NULL;
-   hostdata->flags = FLAG_CHECK_LAST_BYTE_SENT;
+   hostdata->flags = flags;
 
if (!the_template) {
the_template = instanc

[PATCH 17/29] dmx3191d: Use IRQ_NONE

2014-10-02 Thread Finn Thain
Testing shows that the Domex 3191D card never asserts its IRQ. Hence it is
non-functional with Linux (worse, the EH bugs in the core driver are fatal but
that's a problem for another patch). Perhaps the DT-536 chip needs special
setup? I can't find documentation for it. The NetBSD driver uses polling
apparently because of this issue.

Set host->irq = IRQ_NONE so the core driver will prevent targets from
disconnecting. Don't request the irq.

Signed-off-by: Finn Thain 

---
 drivers/scsi/dmx3191d.c |   25 -
 1 file changed, 8 insertions(+), 17 deletions(-)

Index: linux/drivers/scsi/dmx3191d.c
===
--- linux.orig/drivers/scsi/dmx3191d.c  2014-10-02 16:56:14.0 +1000
+++ linux/drivers/scsi/dmx3191d.c   2014-10-02 16:56:16.0 +1000
@@ -34,6 +34,8 @@
  * Definitions for the generic 5380 driver.
  */
 
+#define DONT_USE_INTR
+
 #define NCR5380_read(reg)  inb(port + reg)
 #define NCR5380_write(reg, value)  outb(value, port + reg)
 
@@ -89,32 +91,23 @@ static int dmx3191d_probe_one(struct pci
if (!shost)
goto out_release_region;   
shost->io_port = io;
-   shost->irq = pdev->irq;
 
-   NCR5380_init(shost, FLAG_NO_PSEUDO_DMA | FLAG_DTC3181E);
+   /* This card does not seem to raise an interrupt on pdev->irq.
+* Steam-powered SCSI controllers run without an IRQ anyway.
+*/
+   shost->irq = IRQ_NONE;
 
-   if (request_irq(pdev->irq, NCR5380_intr, IRQF_SHARED,
-   DMX3191D_DRIVER_NAME, shost)) {
-   /*
-* Steam powered scsi controllers run without an IRQ anyway
-*/
-   printk(KERN_WARNING "dmx3191: IRQ %d not available - "
-   "switching to polled mode.\n", pdev->irq);
-   shost->irq = IRQ_NONE;
-   }
+   NCR5380_init(shost, FLAG_NO_PSEUDO_DMA | FLAG_DTC3181E);
 
pci_set_drvdata(pdev, shost);
 
error = scsi_add_host(shost, &pdev->dev);
if (error)
-   goto out_free_irq;
+   goto out_release_region;
 
scsi_scan_host(shost);
return 0;
 
- out_free_irq:
-   if (shost->irq != IRQ_NONE)
-   free_irq(shost->irq, shost);
  out_release_region:
release_region(io, DMX3191D_REGION_LEN);
  out_disable_device:
@@ -131,8 +124,6 @@ static void dmx3191d_remove_one(struct p
 
NCR5380_exit(shost);
 
-   if (shost->irq != IRQ_NONE)
-   free_irq(shost->irq, shost);
release_region(shost->io_port, DMX3191D_REGION_LEN);
pci_disable_device(pdev);
 


--
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 26/29] sun3_scsi: Move macro definitions

2014-10-02 Thread Finn Thain
The #defines in sun3_scsi.h are intended to influence subsequent #includes
in sun3_scsi.c. IMHO, that's too convoluted.

Move sun3_scsi.h macro definitions to sun3_scsi.c, consistent with other
NCR5380 drivers.

Omit the unused NCR5380_local_declare() and NCR5380_setup() macros.

Signed-off-by: Finn Thain 

---
 drivers/scsi/sun3_scsi.c |   45 -
 drivers/scsi/sun3_scsi.h |   25 -
 2 files changed, 32 insertions(+), 38 deletions(-)

Index: linux/drivers/scsi/sun3_scsi.c
===
--- linux.orig/drivers/scsi/sun3_scsi.c 2014-10-02 16:56:22.0 +1000
+++ linux/drivers/scsi/sun3_scsi.c  2014-10-02 16:56:23.0 +1000
@@ -36,18 +36,42 @@
 #include 
 #include 
 
-/* dma on! */
-#define REAL_DMA
-
 #include 
 #include "sun3_scsi.h"
-#include "NCR5380.h"
 
-extern int sun3_map_test(unsigned long, char *);
+/* Definitions for the core NCR5380 driver. */
 
-/*#define RESET_BOOT */
+#define REAL_DMA
+#define RESET_RUN_DONE
 /* #define SUPPORT_TAGS */
 
+/* #define MAX_TAGS 32 */
+
+#define NCR5380_implementation_fields   /* none */
+
+#define NCR5380_read(reg)   sun3scsi_read(reg)
+#define NCR5380_write(reg, value)   sun3scsi_write(reg, value)
+
+#define NCR5380_queue_command   sun3scsi_queue_command
+#define NCR5380_bus_reset   sun3scsi_bus_reset
+#define NCR5380_abort   sun3scsi_abort
+#define NCR5380_show_info   sun3scsi_show_info
+#define NCR5380_infosun3scsi_info
+
+#define NCR5380_dma_read_setup(instance, data, count) \
+sun3scsi_dma_setup(data, count, 0)
+#define NCR5380_dma_write_setup(instance, data, count) \
+sun3scsi_dma_setup(data, count, 1)
+#define NCR5380_dma_residual(instance) \
+sun3scsi_dma_residual(instance)
+#define NCR5380_dma_xfer_len(instance, cmd, phase) \
+sun3scsi_dma_xfer_len(cmd->SCp.this_residual, cmd, !((phase) & SR_IO))
+
+#include "NCR5380.h"
+
+
+extern int sun3_map_test(unsigned long, char *);
+
 #ifdef SUN3_SCSI_VME
 #define ENABLE_IRQ()
 #else
@@ -68,9 +92,7 @@ module_param(setup_use_tagged_queuing, i
 static int setup_hostid = -1;
 module_param(setup_hostid, int, 0);
 
-static struct scsi_cmnd *sun3_dma_setup_done = NULL;
-
-#defineRESET_RUN_DONE
+/* #define RESET_BOOT */
 
 #defineAFTER_RESET_DELAY   (HZ/2)
 
@@ -83,6 +105,7 @@ static struct scsi_cmnd *sun3_dma_setup_
 /* minimum number of bytes to do dma on */
 #define SUN3_DMA_MINSIZE 128
 
+static struct scsi_cmnd *sun3_dma_setup_done;
 static unsigned char *sun3_scsi_regp;
 static volatile struct sun3_dma_regs *dregs;
 static struct sun3_udc_regs *udc_regs;
@@ -134,9 +157,6 @@ static inline void sun3_udc_write(unsign
 static void sun3_scsi_reset_boot(struct Scsi_Host *instance)
 {
unsigned long end;
-
-   NCR5380_local_declare();
-   NCR5380_setup(instance);

/*
 * Do a SCSI reset to clean up the bus during initialization. No
@@ -213,7 +233,6 @@ static irqreturn_t scsi_sun3_intr(int ir
 void sun3_sun3_debug (void)
 {
unsigned long flags;
-   NCR5380_local_declare();
 
if (default_instance) {
local_irq_save(flags);
Index: linux/drivers/scsi/sun3_scsi.h
===
--- linux.orig/drivers/scsi/sun3_scsi.h 2014-10-02 16:56:22.0 +1000
+++ linux/drivers/scsi/sun3_scsi.h  2014-10-02 16:56:23.0 +1000
@@ -27,31 +27,6 @@
 
 #define IOBASE_SUN3_VMESCSI 0xff20
 
-#define MAX_TAGS 32
-
-#define NCR5380_implementation_fields /* none */
-
-#define NCR5380_local_declare() \
-struct Scsi_Host *_instance
-
-#define NCR5380_setup(instance) \
-_instance = instance
-
-#define NCR5380_read(reg) sun3scsi_read(reg)
-#define NCR5380_write(reg, value) sun3scsi_write(reg, value)
-
-#define NCR5380_queue_command sun3scsi_queue_command
-#define NCR5380_bus_reset sun3scsi_bus_reset
-#define NCR5380_abort sun3scsi_abort
-#define NCR5380_show_info sun3scsi_show_info
-#define NCR5380_info sun3scsi_info
-#define NCR5380_dma_xfer_len(i, cmd, phase) \
-sun3scsi_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 
: 1)
-
-#define NCR5380_dma_write_setup(instance, data, count) 
sun3scsi_dma_setup(data, count, 1)
-#define NCR5380_dma_read_setup(instance, data, count) sun3scsi_dma_setup(data, 
count, 0)
-#define NCR5380_dma_residual sun3scsi_dma_residual
-
 /* additional registers - mainly DMA control regs */
 /* these start at regbase + 8 -- directly after the NCR regs */
 struct sun3_dma_regs {


--
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/29] atari_NCR5380: Refactor Falcon locking

2014-10-02 Thread Finn Thain
Simplify falcon_release_lock_if_possible() by making callers responsible for
disabling local IRQ's, which they must do anyway to correctly synchronize
the ST DMA "lock" with core driver data structures. Move this synchronization
logic to the core driver with which it is tightly coupled.

Other LLD's like sun3_scsi and mac_scsi that can make use of this core driver
can just stub out the NCR5380_acquire_dma_irq() and NCR5380_release_dma_irq()
calls so the compiler will eliminate the ST DMA code.

Remove a redundant local_irq_save/restore pair (irq's are disabled for
interrupt handlers these days). Revise the locking for atari_scsi_bus_reset():
use local_irq_save/restore() instead of atari_turnoff/turnon_irq(). There is
no guarantee that atari_scsi still holds the ST DMA "lock" during EH, so
atari_turnoff/turnon_irq() could end up dropping an IDE or floppy interrupt.

Signed-off-by: Finn Thain 

---
 drivers/scsi/atari_NCR5380.c |   72 ++-
 drivers/scsi/atari_scsi.c|   47 ++--
 2 files changed, 62 insertions(+), 57 deletions(-)

Index: linux/drivers/scsi/atari_NCR5380.c
===
--- linux.orig/drivers/scsi/atari_NCR5380.c 2014-10-02 16:56:25.0 
+1000
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-02 16:56:26.0 +1000
@@ -924,7 +924,7 @@ static int NCR5380_queue_command(struct
 * alter queues and touch the lock.
 */
/* perhaps stop command timer here */
-   if (!falcon_get_lock())
+   if (!NCR5380_acquire_dma_irq(instance))
return SCSI_MLQUEUE_HOST_BUSY;
/* perhaps restart command timer here */
 
@@ -960,6 +960,18 @@ static int NCR5380_queue_command(struct
return 0;
 }
 
+static inline void maybe_release_dma_irq(struct Scsi_Host *instance)
+{
+   struct NCR5380_hostdata *hostdata = shost_priv(instance);
+
+   /* Caller does the locking needed to set & test these data atomically */
+   if (!hostdata->disconnected_queue &&
+   !hostdata->issue_queue &&
+   !hostdata->connected &&
+   !hostdata->retain_dma_intr)
+   NCR5380_release_dma_irq(instance);
+}
+
 /*
  * Function : NCR5380_main (void)
  *
@@ -1081,9 +1093,11 @@ static void NCR5380_main(struct work_str
cmd_get_tag(tmp, tmp->cmnd[0] != 
REQUEST_SENSE);
 #endif
if (!NCR5380_select(instance, tmp)) {
+   local_irq_disable();
hostdata->retain_dma_intr--;
/* release if target did not 
response! */
-   
falcon_release_lock_if_possible(hostdata);
+   maybe_release_dma_irq(instance);
+   local_irq_restore(flags);
break;
} else {
local_irq_disable();
@@ -2082,11 +2096,12 @@ static void NCR5380_information_transfer
case COMMAND_COMPLETE:
/* Accept message by clearing ACK */
NCR5380_write(INITIATOR_COMMAND_REG, 
ICR_BASE);
-   /* ++guenther: possible race with 
Falcon locking */
-   hostdata->retain_dma_intr++;
-   hostdata->connected = NULL;
dprintk(NDEBUG_QUEUES, "scsi%d: command 
for target %d, lun %d "
  "completed\n", HOSTNO, 
cmd->device->id, cmd->device->lun);
+
+   local_irq_save(flags);
+   hostdata->retain_dma_intr++;
+   hostdata->connected = NULL;
 #ifdef SUPPORT_TAGS
cmd_free_tag(cmd);
if (status_byte(cmd->SCp.Status) == 
QUEUE_FULL) {
@@ -2145,17 +2160,17 @@ static void NCR5380_information_transfer
 
dprintk(NDEBUG_AUTOSENSE, 
"scsi%d: performing request sense\n", HOSTNO);
 
-   local_irq_save(flags);
LIST(cmd,hostdata->issue_queue);
SET_NEXT(cmd, 
hostdata->issue_queue);
hostdata->issue_queue = (struct 
scsi_cmnd *) cmd;
-   local_irq_restore(flags);
dprintk(NDEBUG_QUEUES, "scsi%d: 
REQUEST SENSE added to head o

[PATCH 22/29] atari_scsi: Fix atari_scsi deadlocks on Falcon

2014-10-02 Thread Finn Thain
Don't disable irqs when waiting for the ST DMA lock; its release may
require an interrupt.

Introduce stdma_try_lock() for use in soft irq context. atari_scsi now tells
the SCSI mid-layer to defer queueing a command if the ST DMA "lock" is not
available, as per Michael's patch:
http://marc.info/?l=linux-m68k&m=139095335824863&w=2

The falcon_got_lock variable is race prone: we can't disable IRQs while
waiting to acquire the lock so after acquiring it there has to be some
interval during which falcon_got_lock remains false. Introduce
stdma_is_locked_by() to replace falcon_got_lock.

The falcon_got_lock tests in EH handlers are not correct these days. It can
happen that an EH handler is called after a command completes normally.
Remove these checks along with falcon_got_lock.

Also remove the complicated and racy fairness wait queues. If fairness is an
issue (when SCSI competes with IDE for the ST DMA interrupt), the solution
is likely to be a lower value for host->can_queue.

Signed-off-by: Finn Thain 

---
 arch/m68k/atari/stdma.c |   62 +++--
 arch/m68k/include/asm/atari_stdma.h |4 -
 drivers/scsi/atari_NCR5380.c|   35 +---
 drivers/scsi/atari_scsi.c   |   76 +++-
 4 files changed, 70 insertions(+), 107 deletions(-)

Index: linux/arch/m68k/atari/stdma.c
===
--- linux.orig/arch/m68k/atari/stdma.c  2014-10-02 16:55:28.0 +1000
+++ linux/arch/m68k/atari/stdma.c   2014-10-02 16:56:20.0 +1000
@@ -59,6 +59,31 @@ static irqreturn_t stdma_int (int irq, v
 /* End of Prototypes **/
 
 
+/**
+ * stdma_try_lock - attempt to acquire ST DMA interrupt "lock"
+ * @handler: interrupt handler to use after acquisition
+ *
+ * Returns !0 if lock was acquired; otherwise 0.
+ */
+
+int stdma_try_lock(irq_handler_t handler, void *data)
+{
+   unsigned long flags;
+
+   local_irq_save(flags);
+   if (stdma_locked) {
+   local_irq_restore(flags);
+   return 0;
+   }
+
+   stdma_locked   = 1;
+   stdma_isr  = handler;
+   stdma_isr_data = data;
+   local_irq_restore(flags);
+   return 1;
+}
+EXPORT_SYMBOL(stdma_try_lock);
+
 
 /*
  * Function: void stdma_lock( isrfunc isr, void *data )
@@ -78,19 +103,10 @@ static irqreturn_t stdma_int (int irq, v
 
 void stdma_lock(irq_handler_t handler, void *data)
 {
-   unsigned long flags;
-
-   local_irq_save(flags);  /* protect lock */
-
/* Since the DMA is used for file system purposes, we
 have to sleep uninterruptible (there may be locked
 buffers) */
-   wait_event(stdma_wait, !stdma_locked);
-
-   stdma_locked   = 1;
-   stdma_isr  = handler;
-   stdma_isr_data = data;
-   local_irq_restore(flags);
+   wait_event(stdma_wait, stdma_try_lock(handler, data));
 }
 EXPORT_SYMBOL(stdma_lock);
 
@@ -122,22 +138,26 @@ void stdma_release(void)
 EXPORT_SYMBOL(stdma_release);
 
 
-/*
- * Function: int stdma_others_waiting( void )
- *
- * Purpose: Check if someone waits for the ST-DMA lock.
- *
- * Inputs: none
- *
- * Returns: 0 if no one is waiting, != 0 otherwise
+/**
+ * stdma_is_locked_by - allow lock holder to check whether it needs to release.
+ * @handler: interrupt handler previously used to acquire lock.
  *
+ * Returns !0 if locked for the given handler; 0 otherwise.
  */
 
-int stdma_others_waiting(void)
+int stdma_is_locked_by(irq_handler_t handler)
 {
-   return waitqueue_active(&stdma_wait);
+   unsigned long flags;
+
+   local_irq_save(flags);
+   if (stdma_locked && (stdma_isr == handler)) {
+   local_irq_restore(flags);
+   return 1;
+   }
+   local_irq_restore(flags);
+   return 0;
 }
-EXPORT_SYMBOL(stdma_others_waiting);
+EXPORT_SYMBOL(stdma_is_locked_by);
 
 
 /*
Index: linux/arch/m68k/include/asm/atari_stdma.h
===
--- linux.orig/arch/m68k/include/asm/atari_stdma.h  2014-10-02 
16:55:28.0 +1000
+++ linux/arch/m68k/include/asm/atari_stdma.h   2014-10-02 16:56:20.0 
+1000
@@ -8,11 +8,11 @@
 
 /* Prototypes */
 
+int stdma_try_lock(irq_handler_t, void *);
 void stdma_lock(irq_handler_t handler, void *data);
 void stdma_release( void );
-int stdma_others_waiting( void );
 int stdma_islocked( void );
-void *stdma_locked_by( void );
+int stdma_is_locked_by(irq_handler_t);
 void stdma_init( void );
 
 /* End of Prototypes **/
Index: linux/drivers/scsi/atari_NCR5380.c
===
--- linux.orig/drivers/scsi/atari_NCR5380.c 2014-10-02 16:56:14.0 
+1000
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-02 16:56:20.0 +1000
@

[PATCH 16/29] ncr5380: Drop legacy scsi.h include

2014-10-02 Thread Finn Thain
Convert Scsi_Cmnd to struct scsi_cmnd and drop the #include "scsi.h".
The sun3_NCR5380.c core driver already uses struct scsi_cmnd so converting
the other core drivers reduces the diff which makes them easier to unify.

Signed-off-by: Finn Thain 

---

Line length issues have not been addressed here because comparison of the
three core drivers (NCR5380.c, atari_NCR5380.c and sun3_NCR5380.c) becomes
too messy. These lines get shorter once the type casting is fixed (work in
progress).

---
 drivers/scsi/NCR5380.c   |   70 +++--
 drivers/scsi/NCR5380.h   |   10 ++--
 drivers/scsi/arm/cumana_1.c  |1 
 drivers/scsi/arm/oak.c   |1 
 drivers/scsi/atari_NCR5380.c |  102 +--
 drivers/scsi/atari_scsi.c|5 --
 drivers/scsi/dmx3191d.c  |1 
 drivers/scsi/dtc.c   |1 
 drivers/scsi/g_NCR5380.c |1 
 drivers/scsi/mac_scsi.c  |1 
 drivers/scsi/pas16.c |1 
 drivers/scsi/sun3_NCR5380.c  |   20 
 drivers/scsi/sun3_scsi.c |1 
 drivers/scsi/t128.c  |1 
 14 files changed, 105 insertions(+), 111 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===
--- linux.orig/drivers/scsi/NCR5380.c   2014-10-02 16:56:11.0 +1000
+++ linux/drivers/scsi/NCR5380.c2014-10-02 16:56:14.0 +1000
@@ -277,7 +277,7 @@ static void do_reset(struct Scsi_Host *h
  * Set up the internal fields in the SCSI command.
  */
 
-static __inline__ void initialize_SCp(Scsi_Cmnd * cmd)
+static inline void initialize_SCp(struct scsi_cmnd *cmd)
 {
/* 
 * Initialize the Scsi Pointer field so that all of the commands in the 
@@ -720,7 +720,7 @@ static int __maybe_unused NCR5380_write_
 #undef SPRINTF
 #define SPRINTF(args...) seq_printf(m, ## args)
 static
-void lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, struct seq_file *m);
+void lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, struct seq_file *m);
 static
 void lprint_command(unsigned char *cmd, struct seq_file *m);
 static
@@ -730,7 +730,7 @@ static int __maybe_unused NCR5380_show_i
struct Scsi_Host *instance)
 {
struct NCR5380_hostdata *hostdata;
-   Scsi_Cmnd *ptr;
+   struct scsi_cmnd *ptr;
 
hostdata = (struct NCR5380_hostdata *) instance->hostdata;
 
@@ -742,19 +742,19 @@ static int __maybe_unused NCR5380_show_i
if (!hostdata->connected)
SPRINTF("scsi%d: no currently connected command\n", 
instance->host_no);
else
-   lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, m);
+   lprint_Scsi_Cmnd((struct scsi_cmnd *) hostdata->connected, m);
SPRINTF("scsi%d: issue_queue\n", instance->host_no);
-   for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = (Scsi_Cmnd 
*) ptr->host_scribble)
+   for (ptr = (struct scsi_cmnd *) hostdata->issue_queue; ptr; ptr = 
(struct scsi_cmnd *) ptr->host_scribble)
lprint_Scsi_Cmnd(ptr, m);
 
SPRINTF("scsi%d: disconnected_queue\n", instance->host_no);
-   for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; ptr = 
(Scsi_Cmnd *) ptr->host_scribble)
+   for (ptr = (struct scsi_cmnd *) hostdata->disconnected_queue; ptr; ptr 
= (struct scsi_cmnd *) ptr->host_scribble)
lprint_Scsi_Cmnd(ptr, m);
spin_unlock_irq(instance->host_lock);
return 0;
 }
 
-static void lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, struct seq_file *m)
+static void lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, struct seq_file *m)
 {
SPRINTF("scsi%d : destination target %d, lun %d\n", 
cmd->device->host->host_no, cmd->device->id, cmd->device->lun);
SPRINTF("command = ");
@@ -913,11 +913,11 @@ static void NCR5380_exit(struct Scsi_Hos
  * Locks: host lock taken by caller
  */
 
-static int NCR5380_queue_command_lck(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd 
*))
+static int NCR5380_queue_command_lck(struct scsi_cmnd *cmd, void (*done) 
(struct scsi_cmnd *))
 {
struct Scsi_Host *instance = cmd->device->host;
struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) 
instance->hostdata;
-   Scsi_Cmnd *tmp;
+   struct scsi_cmnd *tmp;
 
 #if (NDEBUG & NDEBUG_NO_WRITE)
switch (cmd->cmnd[0]) {
@@ -951,7 +951,7 @@ static int NCR5380_queue_command_lck(Scs
cmd->host_scribble = (unsigned char *) hostdata->issue_queue;
hostdata->issue_queue = cmd;
} else {
-   for (tmp = (Scsi_Cmnd *) hostdata->issue_queue; 
tmp->host_scribble; tmp = (Scsi_Cmnd *) tmp->host_scribble);
+   for (tmp = (struct scsi_cmnd *) hostdata->issue_queue; 
tmp->host_scribble; tmp = (struct scsi_cmnd *) tmp->host_scribble);
LIST(cmd, tmp);
tmp->host_scribble = (unsigned char *) cmd;
}
@@ -982,7 +982,7 @@ static void NCR5380_main(struct work_str
struct NCR5380_hostdata *hostdata =
   

[PATCH 19/29] mac_scsi: Add module option to Kconfig

2014-10-02 Thread Finn Thain
Allow mac_scsi to be built as a module. Replace the old validation of
__setup options with code that validates both module and __setup options.

Signed-off-by: Finn Thain 

---
 drivers/scsi/Kconfig|2 
 drivers/scsi/mac_scsi.c |  112 +++-
 2 files changed, 38 insertions(+), 76 deletions(-)

Index: linux/drivers/scsi/Kconfig
===
--- linux.orig/drivers/scsi/Kconfig 2014-10-02 16:55:28.0 +1000
+++ linux/drivers/scsi/Kconfig  2014-10-02 16:56:17.0 +1000
@@ -1644,7 +1644,7 @@ config ATARI_SCSI_RESET_BOOT
  that leave the devices with SCSI operations partway completed.
 
 config MAC_SCSI
-   bool "Macintosh NCR5380 SCSI"
+   tristate "Macintosh NCR5380 SCSI"
depends on MAC && SCSI=y
select SCSI_SPI_ATTRS
help
Index: linux/drivers/scsi/mac_scsi.c
===
--- linux.orig/drivers/scsi/mac_scsi.c  2014-10-02 16:56:17.0 +1000
+++ linux/drivers/scsi/mac_scsi.c   2014-10-02 16:56:17.0 +1000
@@ -62,15 +62,18 @@
 static void mac_scsi_reset_boot(struct Scsi_Host *instance);
 #endif
 
-static int setup_called = 0;
 static int setup_can_queue = -1;
+module_param(setup_can_queue, int, 0);
 static int setup_cmd_per_lun = -1;
+module_param(setup_cmd_per_lun, int, 0);
 static int setup_sg_tablesize = -1;
+module_param(setup_sg_tablesize, int, 0);
 static int setup_use_pdma = -1;
-#ifdef SUPPORT_TAGS
+module_param(setup_use_pdma, int, 0);
 static int setup_use_tagged_queuing = -1;
-#endif
+module_param(setup_use_tagged_queuing, int, 0);
 static int setup_hostid = -1;
+module_param(setup_hostid, int, 0);
 
 /* Time (in jiffies) to wait after a reset; the SCSI standard calls for 250ms,
  * we usually do 0.5s to be on the safe side. But Toshiba CD-ROMs once more
@@ -102,72 +105,34 @@ static __inline__ void macscsi_write(str
   out_8(instance->io_port + (reg<<4), value);
 }
 
-/*
- * Function : mac_scsi_setup(char *str)
- *
- * Purpose : booter command line initialization of the overrides array,
- *
- * Inputs : str - comma delimited list of options
- *
- */
-
-static int __init mac_scsi_setup(char *str) {
+#ifndef MODULE
+static int __init mac_scsi_setup(char *str)
+{
int ints[7];
-   
-   (void)get_options( str, ARRAY_SIZE(ints), ints);
-   
-   if (setup_called++ || ints[0] < 1 || ints[0] > 6) {
-   printk(KERN_WARNING "scsi: "
-   " Usage: 
mac5380=[,]\n");
-   printk(KERN_ALERT "scsi:  Bad Penguin parameters?\n");
-   return 0;
-   }
-   
-   if (ints[0] >= 1) {
-   if (ints[1] > 0)
-   /* no limits on this, just > 0 */
-   setup_can_queue = ints[1];
-   }
-   if (ints[0] >= 2) {
-   if (ints[2] > 0)
-   setup_cmd_per_lun = ints[2];
-   }
-   if (ints[0] >= 3) {
-   if (ints[3] >= 0) {
-   setup_sg_tablesize = ints[3];
-   /* Must be <= SG_ALL (255) */
-   if (setup_sg_tablesize > SG_ALL)
-   setup_sg_tablesize = SG_ALL;
-   }
-   }
-   if (ints[0] >= 4) {
-   /* Must be between 0 and 7 */
-   if (ints[4] >= 0 && ints[4] <= 7)
-   setup_hostid = ints[4];
-   else if (ints[4] > 7)
-   printk(KERN_WARNING "mac_scsi_setup: invalid host ID %d 
!\n", ints[4] );
-   }
-#ifdef SUPPORT_TAGS
-   if (ints[0] >= 5) {
-   if (ints[5] >= 0)
-   setup_use_tagged_queuing = !!ints[5];
+
+   (void)get_options(str, ARRAY_SIZE(ints), ints);
+
+   if (ints[0] < 1 || ints[0] > 6) {
+   pr_err("Usage: 
mac5380=[,[,[,[,[,]\n");
+   return 0;
}
-   
-   if (ints[0] == 6) {
-   if (ints[6] >= 0)
+   if (ints[0] >= 1)
+   setup_can_queue = ints[1];
+   if (ints[0] >= 2)
+   setup_cmd_per_lun = ints[2];
+   if (ints[0] >= 3)
+   setup_sg_tablesize = ints[3];
+   if (ints[0] >= 4)
+   setup_hostid = ints[4];
+   if (ints[0] >= 5)
+   setup_use_tagged_queuing = ints[5];
+   if (ints[0] >= 6)
setup_use_pdma = ints[6];
-   }
-#else
-   if (ints[0] == 5) {
-   if (ints[5] >= 0)
-   setup_use_pdma = ints[5];
-   }
-#endif /* SUPPORT_TAGS */
-   
return 1;
 }
 
 __setup("mac5380=", mac_scsi_setup);
+#endif /* !MODULE */
 
 /*
  * Function : int macscsi_detect(struct scsi_host_template * tpnt)
@@ -199,13 +164,8 @@ int __init macscsi_detect(struct scsi_ho
tpnt->cmd_per_lun = setup_cmd_per_lun;
if (setup_sg_tablesize >= 0)
tpnt->sg_tablesize = setup_sg_tablesize;

[PATCH 06/29] ncr5380: Remove more useless prototypes

2014-10-02 Thread Finn Thain
Make use of the host template static initializer instead of assigning
handlers at run-time. Move __maybe_unused qualifiers from declarations
to definitions. Move the atari_scsi_bus_reset() wrapper after the
definition of NCR5380_bus_reset(). All of the host template handler
prototypes are now redundant so remove them.

The write_info() handler is only relevant to drivers using PSEUDO_DMA so
this patch fixes the compiler warning in atari_NCR5380.c and sun3_NCR5380.c:

  CC  drivers/scsi/atari_scsi.o
  drivers/scsi/NCR5380.h:329: warning: 'NCR5380_write_info' declared 'static' 
but never defined

Signed-off-by: Finn Thain 

---
 drivers/scsi/NCR5380.h   |8 
 drivers/scsi/atari_NCR5380.c |3 +
 drivers/scsi/atari_scsi.c|   76 ---
 drivers/scsi/dtc.c   |7 +--
 drivers/scsi/pas16.c |7 +--
 drivers/scsi/sun3_NCR5380.c  |3 +
 drivers/scsi/t128.c  |7 +--
 7 files changed, 50 insertions(+), 61 deletions(-)

Index: linux/drivers/scsi/NCR5380.h
===
--- linux.orig/drivers/scsi/NCR5380.h   2014-10-02 16:55:49.0 +1000
+++ linux/drivers/scsi/NCR5380.h2014-10-02 16:55:55.0 +1000
@@ -322,14 +322,6 @@ static irqreturn_t NCR5380_intr(int irq,
 #endif
 static void NCR5380_main(struct work_struct *work);
 static void __maybe_unused NCR5380_print_options(struct Scsi_Host *instance);
-static int NCR5380_abort(Scsi_Cmnd * cmd);
-static int NCR5380_bus_reset(Scsi_Cmnd * cmd);
-static int NCR5380_queue_command(struct Scsi_Host *, struct scsi_cmnd *);
-static int __maybe_unused NCR5380_show_info(struct seq_file *,
-   struct Scsi_Host *);
-static int __maybe_unused NCR5380_write_info(struct Scsi_Host *instance,
-   char *buffer, int length);
-
 static void NCR5380_reselect(struct Scsi_Host *instance);
 static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int 
tag);
 #if defined(PSEUDO_DMA) || defined(REAL_DMA) || defined(REAL_DMA_POLL)
Index: linux/drivers/scsi/dtc.c
===
--- linux.orig/drivers/scsi/dtc.c   2014-10-02 16:55:51.0 +1000
+++ linux/drivers/scsi/dtc.c2014-10-02 16:55:55.0 +1000
@@ -219,10 +219,6 @@ static int __init dtc_detect(struct scsi
void __iomem *base;
int sig, count;
 
-   tpnt->proc_name = "dtc3x80";
-   tpnt->show_info = dtc_show_info;
-   tpnt->write_info = dtc_write_info;
-
for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
addr = 0;
base = NULL;
@@ -477,6 +473,9 @@ static struct scsi_host_template driver_
.name   = "DTC 3180/3280 ",
.detect = dtc_detect,
.release= dtc_release,
+   .proc_name  = "dtc3x80",
+   .show_info  = dtc_show_info,
+   .write_info = dtc_write_info,
.queuecommand   = dtc_queue_command,
.eh_abort_handler   = dtc_abort,
.eh_bus_reset_handler   = dtc_bus_reset,
Index: linux/drivers/scsi/pas16.c
===
--- linux.orig/drivers/scsi/pas16.c 2014-10-02 16:55:53.0 +1000
+++ linux/drivers/scsi/pas16.c  2014-10-02 16:55:55.0 +1000
@@ -390,10 +390,6 @@ static int __init pas16_detect(struct sc
 unsigned short io_port;
 int  count;
 
-tpnt->proc_name = "pas16";
-tpnt->show_info = pas16_show_info;
-tpnt->write_info = pas16_write_info;
-
 if (pas16_addr != 0) {
overrides[0].io_port = pas16_addr;
/*
@@ -622,6 +618,9 @@ static struct scsi_host_template driver_
.name   = "Pro Audio Spectrum-16 SCSI",
.detect = pas16_detect,
.release= pas16_release,
+   .proc_name  = "pas16",
+   .show_info  = pas16_show_info,
+   .write_info = pas16_write_info,
.queuecommand   = pas16_queue_command,
.eh_abort_handler = pas16_abort,
.eh_bus_reset_handler = pas16_bus_reset,
Index: linux/drivers/scsi/t128.c
===
--- linux.orig/drivers/scsi/t128.c  2014-10-02 16:55:53.0 +1000
+++ linux/drivers/scsi/t128.c   2014-10-02 16:55:55.0 +1000
@@ -201,10 +201,6 @@ static int __init t128_detect(struct scs
 void __iomem *p;
 int sig, count;
 
-tpnt->proc_name = "t128";
-tpnt->show_info = t128_show_info;
-tpnt->write_info = t128_write_info;
-
 for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
base = 0;
p = NULL;
@@ -435,6 +431,9 @@ static struct scsi_host_template driver_
.name   = "Trantor T128/T128F/T228",
.detect = t128_detect,
.relea

[PATCH 05/29] ncr5380: Remove useless prototypes

2014-10-02 Thread Finn Thain
Add missing static qualifiers and remove the now pointless prototypes. The
NCR5380_* prototypes are all declared in NCR5380.h and renamed using macros.
Further declarations are redundant (some are completely unused). Remove them.

Signed-off-by: Finn Thain 

---
 drivers/scsi/atari_scsi.c |5 -
 drivers/scsi/dtc.h|7 ---
 drivers/scsi/g_NCR5380.c  |6 +++---
 drivers/scsi/g_NCR5380.h  |6 --
 drivers/scsi/mac_scsi.c   |2 --
 drivers/scsi/pas16.c  |6 +++---
 drivers/scsi/pas16.h  |6 --
 drivers/scsi/sun3_scsi.c  |4 +---
 drivers/scsi/sun3_scsi.h  |7 ---
 drivers/scsi/t128.c   |7 ---
 drivers/scsi/t128.h   |6 --
 11 files changed, 11 insertions(+), 51 deletions(-)

Index: linux/drivers/scsi/g_NCR5380.c
===
--- linux.orig/drivers/scsi/g_NCR5380.c 2014-10-02 16:55:52.0 +1000
+++ linux/drivers/scsi/g_NCR5380.c  2014-10-02 16:55:53.0 +1000
@@ -272,7 +272,7 @@ static int __init do_DTC3181E_setup(char
  * Locks: none
  */
 
-int __init generic_NCR5380_detect(struct scsi_host_template * tpnt)
+static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt)
 {
static int current_override = 0;
int count;
@@ -484,7 +484,7 @@ int __init generic_NCR5380_detect(struct
  * Report driver information for the NCR5380
  */

-const char *generic_NCR5380_info(struct Scsi_Host *host)
+static const char *generic_NCR5380_info(struct Scsi_Host *host)
 {
static const char string[] = "Generic NCR5380/53C400 Driver";
return string;
@@ -499,7 +499,7 @@ const char *generic_NCR5380_info(struct
  * Locks: none
  */
  
-int generic_NCR5380_release_resources(struct Scsi_Host *instance)
+static int generic_NCR5380_release_resources(struct Scsi_Host *instance)
 {
NCR5380_local_declare();
NCR5380_setup(instance);
Index: linux/drivers/scsi/pas16.c
===
--- linux.orig/drivers/scsi/pas16.c 2014-10-02 16:55:52.0 +1000
+++ linux/drivers/scsi/pas16.c  2014-10-02 16:55:53.0 +1000
@@ -382,7 +382,7 @@ __setup("pas16=", pas16_setup);
  *
  */
 
-int __init pas16_detect(struct scsi_host_template * tpnt)
+static int __init pas16_detect(struct scsi_host_template *tpnt)
 {
 static int current_override = 0;
 static unsigned short current_base = 0;
@@ -512,8 +512,8 @@ int __init pas16_detect(struct scsi_host
  * and matching the H_C_S coordinates to what DOS uses.
  */
 
-int pas16_biosparam(struct scsi_device *sdev, struct block_device *dev,
-   sector_t capacity, int * ip)
+static int pas16_biosparam(struct scsi_device *sdev, struct block_device *dev,
+   sector_t capacity, int *ip)
 {
   int size = capacity;
   ip[0] = 64;
Index: linux/drivers/scsi/sun3_scsi.c
===
--- linux.orig/drivers/scsi/sun3_scsi.c 2014-10-02 16:55:52.0 +1000
+++ linux/drivers/scsi/sun3_scsi.c  2014-10-02 16:55:53.0 +1000
@@ -86,8 +86,6 @@ extern int sun3_map_test(unsigned long,
 
 
 static irqreturn_t scsi_sun3_intr(int irq, void *dummy);
-static inline unsigned char sun3scsi_read(int reg);
-static inline void sun3scsi_write(int reg, int value);
 
 static int setup_can_queue = -1;
 module_param(setup_can_queue, int, 0);
@@ -348,7 +346,7 @@ static int __init sun3scsi_detect(struct
return 1;
 }
 
-int sun3scsi_release (struct Scsi_Host *shpnt)
+static int sun3scsi_release(struct Scsi_Host *shpnt)
 {
if (shpnt->irq != SCSI_IRQ_NONE)
free_irq(shpnt->irq, shpnt);
Index: linux/drivers/scsi/t128.c
===
--- linux.orig/drivers/scsi/t128.c  2014-10-02 16:55:52.0 +1000
+++ linux/drivers/scsi/t128.c   2014-10-02 16:55:53.0 +1000
@@ -193,7 +193,8 @@ __setup("t128=", t128_setup);
  *
  */
 
-int __init t128_detect(struct scsi_host_template * tpnt){
+static int __init t128_detect(struct scsi_host_template *tpnt)
+{
 static int current_override = 0, current_base = 0;
 struct Scsi_Host *instance;
 unsigned long base;
@@ -325,8 +326,8 @@ static int t128_release(struct Scsi_Host
  * and matching the H_C_S coordinates to what DOS uses.
  */
 
-int t128_biosparam(struct scsi_device *sdev, struct block_device *bdev,
-   sector_t capacity, int * ip)
+static int t128_biosparam(struct scsi_device *sdev, struct block_device *bdev,
+  sector_t capacity, int *ip)
 {
   ip[0] = 64;
   ip[1] = 32;
Index: linux/drivers/scsi/dtc.h
===
--- linux.orig/drivers/scsi/dtc.h   2014-10-02 16:55:28.0 +1000
+++ linux/drivers/scsi/dtc.h2014-10-02 16:55:53.0 +1000
@@ -32,13 +32,6 @@
 #define DTCDEBUG_INIT  0x1
 #define DTCDE

Re: [PATCH] megaraid_sas: Enable shared tag map

2014-10-02 Thread James Bottomley
On Thu, 2014-10-02 at 14:14 +0200, Hannes Reinecke wrote:
> On 10/02/2014 02:05 PM, James Bottomley wrote:
> > On Thu, 2014-10-02 at 08:51 +0200, Hannes Reinecke wrote:
> >> On 10/01/2014 11:10 PM, Christoph Hellwig wrote:
> >>> On Wed, Oct 01, 2014 at 02:51:31PM -0400, Webb Scales wrote:
>  Hannes,
> 
>  In megasas_change_queue_type(), is it possible for sdev->queue_depth to 
>  be
>  greater than 256?
> 
>  Unless I'm misunderstanding the SCSI code, we can request a
>  queue-depth/tag-map-size which is greater than 256, but, since the
>  scsi_cmnd::tag field is an unsigned char, depths greater than 256 may
>  overflow the field when high-numbered tags are used...do I have that 
>  right?
> >>>
> >>> Yes, we really need to increase the size of the tag field.  SAM allows
> >>> a transport specific limit of up to 64 _bytes_ for it, although I don't
> >>> know implementation that large.  Given that the block layer can generate
> >>> up to 32-bit tags both for the old blk-tag.c code and the new
> >>> blk-mq-tag.c version it would be good to use a u32 there.  Can you send
> >>> me a patch?
> >>>
> >> Weeelll ...
> >>
> >> I'm afraid it's not _that_ easy.
> >> SCSI-II tagged queueing has some specific tag values:
> >>
> >> #define SIMPLE_QUEUE_TAG0x20
> >> #define HEAD_OF_QUEUE_TAG   0x21
> >> #define ORDERED_QUEUE_TAG   0x22
> >>
> >> drivers/scsi/vmw_pvscsi.c:
> >>e->tag = SIMPLE_QUEUE_TAG;
> >>if (sdev->tagged_supported &&
> >>(cmd->tag == HEAD_OF_QUEUE_TAG ||
> >> cmd->tag == ORDERED_QUEUE_TAG))
> >>e->tag = cmd->tag;
> > 
> > A SCSI-2 tag is a SPI two byte message.  The first byte is the message
> > type.  The values you have above identify the message type for simple,
> > ordered and head of queue tags.  The *second* byte is the tag value.
> > 
> > See page 55 and 56 of the SCSI-2 standard.  There's no connection (or
> > shouldn't be) between the message type and the tag value, so it looks
> > like a bug in the pvscsi driver.
> > 
> It is. I've already sent a patch.
> 
> But that just proves the scmd->tag is essentially a duplicate
> and we should be removing it.

Yes, it was the original tag field, which then got replaced by the block
one and the accessor commands.  scsi_populate_tag_msg (which is really
an SPI construct) meant that drivers fully adopting the model didn't
even need to look at cmd->tag any more.  I'm fine with dropping it in
favour of req->tag.

James

N�r��yb�X��ǧv�^�)޺{.n�+{���"�{ay�ʇڙ�,j��f���h���z��w���
���j:+v���w�j�mzZ+�ݢj"��!�i

Re: [PATCH 2/2] uas: Make uas work with blk-mq

2014-10-02 Thread Christoph Hellwig
On Thu, Oct 02, 2014 at 02:35:10PM +0200, Hans de Goede wrote:
> This patch sits on top of a whole bunch of uas cleanups / fixes which
> are going into 3.18, and which are to big of a change to backport.

Can add a patch to set disable_blk_mq for uas on 3.17 then?

--
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 2/2] uas: Make uas work with blk-mq

2014-10-02 Thread Hans de Goede
Hi,

On 10/02/2014 03:06 PM, Christoph Hellwig wrote:
> On Thu, Oct 02, 2014 at 02:35:10PM +0200, Hans de Goede wrote:
>> This patch sits on top of a whole bunch of uas cleanups / fixes which
>> are going into 3.18, and which are to big of a change to backport.
> 
> Can add a patch to set disable_blk_mq for uas on 3.17 then?

Yes, although that likely would need to go through stable, without
going into 3.18 .

Greg, is this ok with you and how do I get a patch in stable which
is not in upstream (because upstream will get a better fix) ?

Regards,

Hans
--
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 2/2] uas: Make uas work with blk-mq

2014-10-02 Thread Christoph Hellwig
On Thu, Oct 02, 2014 at 03:08:40PM +0200, Hans de Goede wrote:
> Yes, although that likely would need to go through stable, without
> going into 3.18 .
> 
> Greg, is this ok with you and how do I get a patch in stable which
> is not in upstream (because upstream will get a better fix) ?

This is a trivial one liner and 3.17 isn't released yet, so can you just
send it to Linus now?

--
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 2/2] uas: Make uas work with blk-mq

2014-10-02 Thread Hans de Goede
Hi,

On 10/02/2014 03:12 PM, Christoph Hellwig wrote:
> On Thu, Oct 02, 2014 at 03:08:40PM +0200, Hans de Goede wrote:
>> Yes, although that likely would need to go through stable, without
>> going into 3.18 .
>>
>> Greg, is this ok with you and how do I get a patch in stable which
>> is not in upstream (because upstream will get a better fix) ?
> 
> This is a trivial one liner and 3.17 isn't released yet, so can you just
> send it to Linus now?

I don't think it is that urgent, given that block-mq is disabled by default
in 3.17 AFAIK. But feel free to send such a patch directly to Linus with my:

Acked-by: Hans de Goede 

Added, if that gets in, I guess I then need to do a v2 of the patch
from $subject, reverting it.

Regards,

Hans
--
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 2/2] uas: Make uas work with blk-mq

2014-10-02 Thread James Bottomley
On Thu, 2014-10-02 at 15:18 +0200, Hans de Goede wrote:
> Hi,
> 
> On 10/02/2014 03:12 PM, Christoph Hellwig wrote:
> > On Thu, Oct 02, 2014 at 03:08:40PM +0200, Hans de Goede wrote:
> >> Yes, although that likely would need to go through stable, without
> >> going into 3.18 .
> >>
> >> Greg, is this ok with you and how do I get a patch in stable which
> >> is not in upstream (because upstream will get a better fix) ?
> > 
> > This is a trivial one liner and 3.17 isn't released yet, so can you just
> > send it to Linus now?
> 
> I don't think it is that urgent, given that block-mq is disabled by default
> in 3.17 AFAIK. But feel free to send such a patch directly to Linus with my:
> 
> Acked-by: Hans de Goede 
> 
> Added, if that gets in, I guess I then need to do a v2 of the patch
> from $subject, reverting it.

OK, so 3.17 should be on sunday giving three days or so to sort this
out.  If you're happy with blk-mq being disabled so the bug never
triggers unless the user activates it, doing nothing is my preferred
outcome ... but that also means no need to backport to stable.  

If you want a it fixed in 3.17, then we need a patch from you now.
Ultimately you have to judge the necessity for us, since it's your
driver.

James


--
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 2/2] uas: Make uas work with blk-mq

2014-10-02 Thread Hans de Goede
Hi,

On 10/02/2014 03:25 PM, James Bottomley wrote:
> On Thu, 2014-10-02 at 15:18 +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 10/02/2014 03:12 PM, Christoph Hellwig wrote:
>>> On Thu, Oct 02, 2014 at 03:08:40PM +0200, Hans de Goede wrote:
 Yes, although that likely would need to go through stable, without
 going into 3.18 .

 Greg, is this ok with you and how do I get a patch in stable which
 is not in upstream (because upstream will get a better fix) ?
>>>
>>> This is a trivial one liner and 3.17 isn't released yet, so can you just
>>> send it to Linus now?
>>
>> I don't think it is that urgent, given that block-mq is disabled by default
>> in 3.17 AFAIK. But feel free to send such a patch directly to Linus with my:
>>
>> Acked-by: Hans de Goede 
>>
>> Added, if that gets in, I guess I then need to do a v2 of the patch
>> from $subject, reverting it.
> 
> OK, so 3.17 should be on sunday giving three days or so to sort this
> out.  If you're happy with blk-mq being disabled so the bug never
> triggers unless the user activates it, doing nothing is my preferred
> outcome ... but that also means no need to backport to stable.  
> 
> If you want a it fixed in 3.17, then we need a patch from you now.
> Ultimately you have to judge the necessity for us, since it's your
> driver.

Fair enough. Given that this only triggers if the user enables an experimental
option, and then mixes that with uas usage, my preferred way to deal with this
is also doing nothing.

Regards,

Hans
--
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 2/2] uas: Make uas work with blk-mq

2014-10-02 Thread Greg Kroah-Hartman
On Thu, Oct 02, 2014 at 06:12:59AM -0700, Christoph Hellwig wrote:
> On Thu, Oct 02, 2014 at 03:08:40PM +0200, Hans de Goede wrote:
> > Yes, although that likely would need to go through stable, without
> > going into 3.18 .
> > 
> > Greg, is this ok with you and how do I get a patch in stable which
> > is not in upstream (because upstream will get a better fix) ?
> 
> This is a trivial one liner and 3.17 isn't released yet, so can you just
> send it to Linus now?

Let's just wait for these patches to get into 3.18-rc1, and then, Hans,
you can send me a patch just for 3.17-stable with a note saying why it
is different from what is in Linus's tree.

Or send me that patch now and I can queue it up at the proper time.

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: PR registration on LIO iscsi returns sense key not ready

2014-10-02 Thread Christophe Vu-Brugier
Dear Luigi,

On Thu, 02 Oct 2014 12:47:09 +0200, Luigi Tarenga wrote :
> I have a little problem with LIO iscsi target and SPC-3 persistent 
> reservation.
> The summary of my setup is:
> host:
>centos 6.5 x86_64 with custom kernel 3.16.3 + scst patches
>targetcli (-fb) 2.1.fb37
>this host is configured to export a lun0 to the guest via iscsi
> 
> guest:
>centos 7 x64_64 with stock kernel 3.10.0-123.6.3.el7.x86_64
>iscsi-initiator-utils-6.2.0.873-21.el7.x86_64
>sg3_utils-1.37-5.el7.x86_64
> 
> [snip]
> 
> the guest virtualization is done with qemu-2.0.0+kvm, NIC is virt-io and 
> the guest
> connect to the host via a tap device.
> 
> The guest can connect to the iSCSI target and i see the device as /dev/sda.
> I partitioned, formatted and mounted it successfully.
> 
> My problem that every PR Out command return a sense key not ready
> even if the command run successfully, see this sequence:

I think I already experienced these errors. Could you check the
output of `dmesg` and look for errors like:

  filp_open(/var/target/pr/aptpl_1a4f52f5-1036-498a-a14f-8818d28de1bb) for 
APTPL metadata failed
  SPC-3 PR REGISTER: Received res_key: 0x does not match 
existing SA REGISTER res_key: 0x2e5f2049
  filp_open(/var/target/pr/aptpl_1a4f52f5-1036-498a-a14f-8818d28de1bb) for 
APTPL metadata failed

You can fix this issue by creating the /var/target/pr directory.
You should also create the /var/target/alua directory whih is
expected by LIO too.

Best regards,

> [root@centos7 ~]# ll 
> /dev/disk/by-path/ip-172.24.49.193\:3260-iscsi-iqn.2003-01.org.linux-iscsi.lizard.x8664\:sn.15df8aa9db1d-lun-0
> lrwxrwxrwx. 1 root root 9 Oct  2 12:29 
> /dev/disk/by-path/ip-172.24.49.193:3260-iscsi-iqn.2003-01.org.linux-iscsi.lizard.x8664:sn.15df8aa9db1d-lun-0
>  
> -> ../../sda
> 
> [root@centos7 ~]# sg_persist -n --read-keys --device=/dev/sda
>PR generation=0x0, there are NO registered reservation keys
> 
> [root@centos7 ~]# sg_persist -n -v --out --register 
> --param-sark=ac1831c2 --device=/dev/sda
>  Persistent Reservation Out cmd: 5f 00 00 00 00 00 00 00 18 00
> persistent reserve out:  Fixed format, current;  Sense key: Not Ready
>   Additional sense: Logical unit communication failure
> PR out: command failed
> 
> [root@centos7 ~]# sg_persist -n --read-keys --device=/dev/sda
>PR generation=0x1, 1 registered reservation key follows:
>  0xac1831c2
> 
> [root@centos7 ~]# sg_persist -n -v --out --register --param-rk=ac1831c2 
> --device=/dev/sda
>  Persistent Reservation Out cmd: 5f 00 00 00 00 00 00 00 18 00
> persistent reserve out:  Fixed format, current;  Sense key: Not Ready
>   Additional sense: Logical unit communication failure
> PR out: command failed
> 
> [root@centos7 ~]# sg_persist -n --read-keys --device=/dev/sda
>PR generation=0x1, there are NO registered reservation keys
> 
> [root@centos7 ~]# dmesg | tail
> [  170.695433] scsi 3:0:0:0: alua: port group 00 rel port 01
> [  170.695626] scsi 3:0:0:0: alua: port group 00 state A non-preferred 
> supports TOlUSNA
> [  170.695629] scsi 3:0:0:0: alua: Attached
> [  170.698855] scsi 3:0:0:0: Attached scsi generic sg1 type 0
> [  170.738866] sd 3:0:0:0: [sda] 20480 512-byte logical blocks: (10.4 
> MB/10.0 MiB)
> [  170.740658] sd 3:0:0:0: [sda] Write Protect is off
> [  170.740664] sd 3:0:0:0: [sda] Mode Sense: 43 00 10 08
> [  170.741107] sd 3:0:0:0: [sda] Write cache: enabled, read cache: 
> enabled, supports DPO and FUA
> [  170.745222]  sda: sda1
> [  170.747875] sd 3:0:0:0: [sda] Attached SCSI disk
> 
> 
> With the same setup I tryed to switch from LIO to scst and it works as 
> expected, sg_persist
> can register and reserve keys without getting a sense key not ready.
> 
> My tought are about a little bug in LIO but maybe is it my fault that I 
> added some patches to
> vanilla kernel that broke LIO?
> the patches I added are:
> scst_exec_req_fifo-3.16.patch
> put_page_callback-3.16.patch
> 
> as documented here:
> http://scst.sourceforge.net/iscsi-scst-howto.txt
> 
> regards
> Luigi
> --
> To unsubscribe from this list: send the line "unsubscribe target-devel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 
Christophe Vu-Brugier
--
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 1/2] be2iscsi : Fix kernel panic during reboot/shutdown

2014-10-02 Thread Ewan Milne
On Fri, 2014-09-26 at 15:13 -0400, John Soni Jose wrote:
> In the reboot/shutdown path, workqueue was destroyed after the
>  adapter resource were freed. The task associated with workqueue
>  was getting executed after resources were freed. This lead to
>  kernel panic.
> 
> Signed-off-by: John Soni Jose 
> Signed-off-by: Jayamohan Kallickal 
> ---
>  drivers/scsi/be2iscsi/be_main.c |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> index db2bd4d..30d74a0 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -5223,6 +5223,7 @@ static void beiscsi_quiesce(struct beiscsi_hba *phba,
>   free_irq(phba->pcidev->irq, phba);
>   }
>   pci_disable_msix(phba->pcidev);
> + cancel_delayed_work_sync(&phba->beiscsi_hw_check_task);
>  
>   for (i = 0; i < phba->num_cpus; i++) {
>   pbe_eq = &phwi_context->be_eq[i];
> @@ -5244,7 +5245,6 @@ static void beiscsi_quiesce(struct beiscsi_hba *phba,
>   hwi_cleanup(phba);
>   }
>  
> - cancel_delayed_work_sync(&phba->beiscsi_hw_check_task);
>  }
>  
>  static void beiscsi_remove(struct pci_dev *pcidev)

Reviewed-by: Ewan D. Milne 


--
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: PR registration on LIO iscsi returns sense key not ready

2014-10-02 Thread Luigi Tarenga


On 10/02/2014 04:11 PM, Christophe Vu-Brugier wrote:

Dear Luigi,

On Thu, 02 Oct 2014 12:47:09 +0200, Luigi Tarenga wrote :

I have a little problem with LIO iscsi target and SPC-3 persistent
reservation.
The summary of my setup is:
host:
centos 6.5 x86_64 with custom kernel 3.16.3 + scst patches
targetcli (-fb) 2.1.fb37
this host is configured to export a lun0 to the guest via iscsi

guest:
centos 7 x64_64 with stock kernel 3.10.0-123.6.3.el7.x86_64
iscsi-initiator-utils-6.2.0.873-21.el7.x86_64
sg3_utils-1.37-5.el7.x86_64

[snip]

the guest virtualization is done with qemu-2.0.0+kvm, NIC is virt-io and
the guest
connect to the host via a tap device.

The guest can connect to the iSCSI target and i see the device as /dev/sda.
I partitioned, formatted and mounted it successfully.

My problem that every PR Out command return a sense key not ready
even if the command run successfully, see this sequence:

I think I already experienced these errors. Could you check the
output of `dmesg` and look for errors like:

   filp_open(/var/target/pr/aptpl_1a4f52f5-1036-498a-a14f-8818d28de1bb) for 
APTPL metadata failed
   SPC-3 PR REGISTER: Received res_key: 0x does not match 
existing SA REGISTER res_key: 0x2e5f2049
   filp_open(/var/target/pr/aptpl_1a4f52f5-1036-498a-a14f-8818d28de1bb) for 
APTPL metadata failed

You can fix this issue by creating the /var/target/pr directory.
You should also create the /var/target/alua directory whih is
expected by LIO too.

Best regards,


Oh yeah! that was the problem! my bad I didn't checked dmesg on host :(
I didn't thought about aptpl because I ask for reservation without aptpl 
bit on

(-Z flag in sg_persist).

I created the 2 directories and now PR works like a charm :)

thank you very much!
Luigi

--
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] megaraid_sas: Enable shared tag map

2014-10-02 Thread Christoph Hellwig
On Thu, Oct 02, 2014 at 02:00:32PM +0200, Hannes Reinecke wrote:
> Actually, I've hit a similar issue for megaraid_sas (and I guess
> others which implement a host-wide tag map might suffer here, too):
> tags need to be used even for internal commands.
> But tag allocation is done exclusively in the block layer, so one
> cannot readily influence this.
> (Or, if you do, you'll end up with code duplication like the fnic
> driver).
> Thing is, for internal commands we typically do not _need_ a fully
> formed request, we just need to tag number.

blk-mq allows a driver to reserve tags, and allocate them using
blk_mq_alloc_request with the reserved flag.  Take a look at the
mtip32xx driver, which is using that feature.

The lockless hpsa series has a patch to expose the nr of reserved
tags to scsi, but there is no equivalent in the old blk code yet.

Another issue is that we only setup the tag allocator at scsi_add_host
time, and to fully support drivers that needs tags during initialization
we need move it to scsi_host_alloc time, which doesn't sound like a
major problem.

--
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: ufs: Add freq-table-hz property for UFS device

2014-10-02 Thread Dan Carpenter
Hello Sahitya Tummala,

The patch 4cff6d991e4a: "ufs: Add freq-table-hz property for UFS
device" from Sep 25, 2014, leads to the following static checker
warning:

drivers/scsi/ufs/ufshcd-pltfrm.c:138 ufshcd_parse_clock_info()
warn: passing devm_ allocated variable to kfree. 'clkfreq'

drivers/scsi/ufs/ufshcd-pltfrm.c
   102  clkfreq = devm_kzalloc(dev, sz * sizeof(*clkfreq),
   103  GFP_KERNEL);
  ^
   104  if (!clkfreq) {
   105  dev_err(dev, "%s: no memory\n", "freq-table-hz");

Don't print an error.  It just wastes ram.  Error messages are often
buggy.  If we delete it then the code is shorter and easier to read.
Kmalloc() has its own more useful error message already.

   106  ret = -ENOMEM;
   107  goto out;

Out labels are the worst.  The name is too vague.  They are a sign of
either One Err type error handling where you have one label handle
everything or they are a just a do-nothing goto where it returns
directly.

One Err type error handling causes bugs.

Do-nothing gotos are just annoying.  You're reading the code and you see
a "goto out;" and you think "What does "out" do?"  But the name doesn't
provide any hints.  You scroll down to the bottom of the function.  "Oh
it was just a waste of time."  Now you have lost your place and your
train of thought.

Also people constantly forget to set "ret" before the goto out.  If you
just write:


if (!of_get_property(np, "freq-table-hz", &len)) {
dev_info(dev, "freq-table-hz property not specified\n");
return 0;
}

if (len <= 0)
return 0;

Then it's totally clear what we intended to return.  But in the current
code it's ambiguous because maybe we just forgot to set ret?  Who
knows.  Out labels make the code hard to understand.

Anyway, in this case, originally "out" was doing One Err error handling
but now it's just there to waste our time and cause bugs when this code
is modified in the future.

   108  }
   109  
   110  ret = of_property_read_u32_array(np, "freq-table-hz",
   111  clkfreq, sz);
   112  if (ret && (ret != -EINVAL)) {
   113  dev_err(dev, "%s: error reading array %d\n",
   114  "freq-table-hz", ret);
   115  goto free_clkfreq;
   116  }
   117  
   118  for (i = 0; i < sz; i += 2) {
   119  ret = of_property_read_string_index(np,
   120  "clock-names", i/2, (const char 
**)&name);
   121  if (ret)
   122  goto free_clkfreq;
   123  
   124  clki = devm_kzalloc(dev, sizeof(*clki), GFP_KERNEL);
   125  if (!clki) {
   126  ret = -ENOMEM;
   127  goto free_clkfreq;
   128  }
   129  
   130  clki->min_freq = clkfreq[i];
   131  clki->max_freq = clkfreq[i+1];
   132  clki->name = kstrdup(name, GFP_KERNEL);

Where is name freed?  There are definitely certain error paths where it
is leaked.  Can we use devm_kstrdup() here?

   133  dev_dbg(dev, "%s: min %u max %u name %s\n", 
"freq-table-hz",
   134  clki->min_freq, clki->max_freq, 
clki->name);
   135  list_add_tail(&clki->list, &hba->clk_list_head);
   136  }
   137  free_clkfreq:
   138  kfree(clkfreq);
^
Just delete this.

   139  out:
   140  return ret;
   141  }

regards,
dan carpenter
--
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: ufs: Add regulator enable support

2014-10-02 Thread Dan Carpenter
Hello Sujit Reddy Thumma,

The patch aa4976130934: "ufs: Add regulator enable support" from Sep
25, 2014, leads to the following static checker warning:

drivers/scsi/ufs/ufshcd-pltfrm.c:167 ufshcd_populate_vreg()
warn: missing error code here? 'devm_kzalloc()' failed. 'ret' = '0'

drivers/scsi/ufs/ufshcd-pltfrm.c
   144  static int ufshcd_populate_vreg(struct device *dev, const char *name,
   145  struct ufs_vreg **out_vreg)
   146  {
   147  int ret = 0;
   148  char prop_name[MAX_PROP_SIZE];
   149  struct ufs_vreg *vreg = NULL;
   150  struct device_node *np = dev->of_node;
   151  
   152  if (!np) {
   153  dev_err(dev, "%s: non DT initialization\n", __func__);
   154  goto out;
   155  }
   156  
   157  snprintf(prop_name, MAX_PROP_SIZE, "%s-supply", name);
   158  if (!of_parse_phandle(np, prop_name, 0)) {
   159  dev_info(dev, "%s: Unable to find %s regulator, 
assuming enabled\n",
   160  __func__, prop_name);
   161  goto out;
   162  }
   163  
   164  vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL);
   165  if (!vreg) {
   166  dev_err(dev, "No memory for %s regulator\n", name);
   167  goto out;

Don't print an error message.
Don't use a goto out.
Don't forget to set an error code.

   168  }
   169  

regards,
dan carpenter
--
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: ufs: add UFS power management support

2014-10-02 Thread Dan Carpenter
Hello Subhash Jadavani,

The patch 57d104c153d3: "ufs: add UFS power management support" from
Sep 25, 2014, leads to the following static checker warning:

drivers/scsi/ufs/ufshcd.c:4746 ufshcd_link_state_transition()
warn: we tested 'check_for_bkops' before and it was 'true'

drivers/scsi/ufs/ufshcd.c
  4734  if (req_link_state == UIC_LINK_HIBERN8_STATE) {
  4735  ret = ufshcd_uic_hibern8_enter(hba);
  4736  if (!ret)
  4737  ufshcd_set_link_hibern8(hba);
  4738  else
  4739  goto out;
  4740  }
  4741  /*
  4742   * If autobkops is enabled, link can't be turned off because
  4743   * turning off the link would also turn off the device.
  4744   */
  4745  else if ((req_link_state == UIC_LINK_OFF_STATE) &&
  4746 (!check_for_bkops || (check_for_bkops &&
 ^^^
Not needed.

  4747  !hba->auto_bkops_enabled))) {
  4748  /*
  4749   * Change controller state to "reset state" which
  4750   * should also put the link in off/reset state
  4751   */
  4752  ufshcd_hba_stop(hba);
  4753  /*
  4754   * TODO: Check if we need any delay to make sure that
  4755   * controller is reset
  4756   */
  4757  ufshcd_set_link_off(hba);
  4758  }
  4759  
  4760  out:
  4761  return ret;
  4762  }

regards,
dan carpenter
--
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: ufs: Add support for clock gating

2014-10-02 Thread Dan Carpenter
Hello Sahitya Tummala,

The patch 1ab27c9cf8b6: "ufs: Add support for clock gating" from Sep
25, 2014, leads to the following static checker warning:

drivers/scsi/ufs/ufshcd.c:4474 __ufshcd_setup_clocks()
warn: we tested 'ret' before and it was 'false'

drivers/scsi/ufs/ufshcd.c
  4467  ret = hba->vops->setup_clocks(hba, on);
  4468  out:
  4469  if (ret) {
  4470  list_for_each_entry(clki, head, list) {
  4471  if (!IS_ERR_OR_NULL(clki->clk) && clki->enabled)
  4472  clk_disable_unprepare(clki->clk);
  4473  }
  4474  } else if (!ret && on) {
   
Not needed.

  4475  spin_lock_irqsave(hba->host->host_lock, flags);
  4476  hba->clk_gating.state = CLKS_ON;
  4477  spin_unlock_irqrestore(hba->host->host_lock, flags);
  4478  }
  4479  return ret;
  4480  }


regards,
dan carpenter
--
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: ufs: definitions for phy interface

2014-10-02 Thread Dan Carpenter
Hello Dolev Raviv,

This is a semi-automatic email about new static checker warnings.

The patch e785060ea3a1: "ufs: definitions for phy interface" from Sep 
25, 2014, leads to the following Smatch complaint:

drivers/scsi/ufs/ufshcd.c:5118 ufshcd_system_suspend()
 error: we previously assumed 'hba' could be null (see line 5089)

drivers/scsi/ufs/ufshcd.c
  5088  
  5089  if (!hba || !hba->is_powered)

Existing check for NULL.

  5090  goto out;
  5091  

[ snip ]

  5115  ret = ufshcd_suspend(hba, UFS_SYSTEM_PM);
  5116  out:
  5117  if (!ret)
  5118  hba->is_sys_suspended = true;
^
New unchecked dereference.  This is a One Err Bug caused by "out" label
style error handling.

  5119  return ret;
  5120  }

regards,
dan carpenter
--
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 8/8] IB/srp: Add multichannel support

2014-10-02 Thread Bart Van Assche
On 10/01/14 18:54, Jens Axboe wrote:
> Lets get rid of the blk_mq_tag struct and just have it be an u32 or 
> something. We could potentially typedef it, but I'd prefer to just have 
> it be an unsigned 32-bit int.
> 
> Probably also need some init time safety checks that 16-bits is enough 
> to hold BLK_MQ_MAX_DEPTH. Just in case that is ever bumped, or the queue 
> prefixing changes.
> 
> And I think we need to name this better. Your comment correctly 
> describes that this generates a unique tag queue wide, but the name of 
> the function implies that we just return the request tag. Most drivers 
> wont use this. Perhaps add a queue flag that tells us that we should 
> generate these tags and have it setup ala:
> 
> u32 blk_mq_unique_rq_tag(struct request *rq)
> {
>  struct request_queue *q = rq->q;
>  u32 tag = rq->tag & ((1 << 16) - 1);
>  struct blk_mq_hw_ctx *hctx;
> 
>  hctx = q->mq_ops->map_queue(q, rq->mq_ctx->cpu);
>  return tag | (hctx->queue_num << 16);
> }
> 
> u32 blk_mq_rq_tag(struct request *rq)
> {
>  struct request_queue *q = rq->q;
> 
>  if (q->mq_ops &&
>  test_bit(QUEUE_FLAG_UNIQUE_TAGS, &q->queue_flags))
>  return blk_mq_unique_rq_tag(rq);
> 
>  return rq->tag;
> }

Would it be acceptable to let blk_mq_rq_tag() always return the
hardware context number and the per-hctx tag ? Block and SCSI LLD 
drivers that do not need the hardware context number can still use 
rq->tag. Drivers that need both can use blk_mq_rq_tag(). That way we do 
not have to introduce a new queue flag. How about the patch below 
(which is still missing a BLK_MQ_MAX_DEPTH check):

diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index c1b9242..8cfbc7b 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -595,6 +595,30 @@ int blk_mq_tag_update_depth(struct blk_mq_tags *tags, 
unsigned int tdepth)
return 0;
 }
 
+/**
+ * blk_mq_rq_tag() - return a tag that is unique queue-wide
+ *
+ * The tag field in struct request is unique per hardware queue but not
+ * queue-wide. Hence this function.
+ *
+ * Note: When called for a non-multiqueue request queue, the hardware context
+ * index is set to zero.
+ */
+u32 blk_mq_rq_tag(struct request *rq)
+{
+   struct request_queue *q = rq->q;
+   struct blk_mq_hw_ctx *hctx;
+   int hwq = 0;
+
+   if (q->mq_ops) {
+   hctx = q->mq_ops->map_queue(q, rq->mq_ctx->cpu);
+   hwq = hctx->queue_num;
+   }
+
+   return blk_mq_build_rq_tag(hwq, rq->tag);
+}
+EXPORT_SYMBOL(blk_mq_rq_tag);
+
 ssize_t blk_mq_tag_sysfs_show(struct blk_mq_tags *tags, char *page)
 {
char *orig_page = page;
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index eac4f31..c5be535 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -166,6 +166,19 @@ bool blk_mq_can_queue(struct blk_mq_hw_ctx *);
 struct request *blk_mq_alloc_request(struct request_queue *q, int rw,
gfp_t gfp, bool reserved);
 struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag);
+u32 blk_mq_rq_tag(struct request *rq);
+static inline u32 blk_mq_build_rq_tag(int hwq, int tag)
+{
+   return (hwq << 16) | (tag & ((1 << 16) - 1));
+}
+static inline u16 blk_mq_rq_tag_to_hwq(u32 rq_tag)
+{
+   return rq_tag >> 16;
+}
+static inline u16 blk_mq_rq_tag_to_tag(u32 rq_tag)
+{
+   return rq_tag & ((1 << 16) - 1);
+}
 
 struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *, const int 
ctx_index);
 struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_tag_set *, 
unsigned int, int);
-- 
1.8.4.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


Re: [PATCH 8/8] IB/srp: Add multichannel support

2014-10-02 Thread Jens Axboe
On 10/02/2014 10:45 AM, Bart Van Assche wrote:
> On 10/01/14 18:54, Jens Axboe wrote:
>> Lets get rid of the blk_mq_tag struct and just have it be an u32 or 
>> something. We could potentially typedef it, but I'd prefer to just have 
>> it be an unsigned 32-bit int.
>>
>> Probably also need some init time safety checks that 16-bits is enough 
>> to hold BLK_MQ_MAX_DEPTH. Just in case that is ever bumped, or the queue 
>> prefixing changes.
>>
>> And I think we need to name this better. Your comment correctly 
>> describes that this generates a unique tag queue wide, but the name of 
>> the function implies that we just return the request tag. Most drivers 
>> wont use this. Perhaps add a queue flag that tells us that we should 
>> generate these tags and have it setup ala:
>>
>> u32 blk_mq_unique_rq_tag(struct request *rq)
>> {
>>  struct request_queue *q = rq->q;
>>  u32 tag = rq->tag & ((1 << 16) - 1);
>>  struct blk_mq_hw_ctx *hctx;
>>
>>  hctx = q->mq_ops->map_queue(q, rq->mq_ctx->cpu);
>>  return tag | (hctx->queue_num << 16);
>> }
>>
>> u32 blk_mq_rq_tag(struct request *rq)
>> {
>>  struct request_queue *q = rq->q;
>>
>>  if (q->mq_ops &&
>>  test_bit(QUEUE_FLAG_UNIQUE_TAGS, &q->queue_flags))
>>  return blk_mq_unique_rq_tag(rq);
>>
>>  return rq->tag;
>> }
> 
> Would it be acceptable to let blk_mq_rq_tag() always return the
> hardware context number and the per-hctx tag ? Block and SCSI LLD 

Sure, that's fine as well, but the function needs a more descriptive
name. I try to think of it like I have never looked at the code and need
to write a driver, it's a lot easier if the functions are named
appropriately. Seeing blk_mq_rq_tag() and even with reading the function
comment, I'm really none the wiser and would assume I need to use this
function to get the tag.

So we can do the single function, but lets call it
blk_mq_unique_rq_tag(). That's special enough that people will know this
is something that doesn't just return the request tag. Then add an extra
sentence to the comment you already have on when this is needed.

And lets roll those bitshift values and masks into a define or enum so
it's collected in one place.

-- 
Jens Axboe

--
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 8/8] IB/srp: Add multichannel support

2014-10-02 Thread Christoph Hellwig
On Thu, Oct 02, 2014 at 06:45:55PM +0200, Bart Van Assche wrote:
> Would it be acceptable to let blk_mq_rq_tag() always return the
> hardware context number and the per-hctx tag ? Block and SCSI LLD 
> drivers that do not need the hardware context number can still use 
> rq->tag. Drivers that need both can use blk_mq_rq_tag(). That way we do 
> not have to introduce a new queue flag. How about the patch below 
> (which is still missing a BLK_MQ_MAX_DEPTH check):

I'd add the unique_ part to the name that Jens added, and fix up the
comment to be valid kerneldoc, but otherwise this looks fine to me.

Also if we want to merge scsi LLDDs that can take advantage of
multiqueue support it would probably be best if I take this via the SCSI
tree.
--
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 04/24] scsi: introduce sdev_prefix_printk()

2014-10-02 Thread Elliott, Robert (Server Storage)
> -Original Message-
> From: Hannes Reinecke [mailto:h...@suse.de]
...
> diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
> index 4c3ab83..c01dc89 100644
> --- a/drivers/scsi/sd.h
> +++ b/drivers/scsi/sd.h
> @@ -103,9 +103,10 @@ static inline struct scsi_disk *scsi_disk(struct gendisk
> *disk)
> 
>  #define sd_printk(prefix, sdsk, fmt, a...)   \
>  (sdsk)->disk ?   
> \
> - sdev_printk(prefix, (sdsk)->device, "[%s] " fmt,\
> - (sdsk)->disk->disk_name, ##a) : \
> - sdev_printk(prefix, (sdsk)->device, fmt, ##a)
> +   sdev_prefix_printk(prefix, (sdsk)->device,\
> +  (sdsk)->disk->disk_name, fmt, ##a) :   \
> +   sdev_prefix_printk(prefix, (sdsk)->device,\
> +  NULL, fmt, ##a)
> 
>  #define sd_first_printk(prefix, sdsk, fmt, a...) \
>   do {\
...
> diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
> index 27ecee7..0b18a09 100644
> --- a/include/scsi/scsi_device.h
> +++ b/include/scsi/scsi_device.h
> @@ -244,6 +244,15 @@ struct scsi_dh_data {
>  #define sdev_dbg(sdev, fmt, a...) \
>   dev_dbg(&(sdev)->sdev_gendev, fmt, ##a)
> 
> +/*
> + * like scmd_printk, but the device name is passed in
> + * as a string pointer
> + */
> +#define sdev_prefix_printk(l, sdev, p, fmt, a...)\
> + (p) ?   \
> + sdev_printk(l, sdev, "[%s] " fmt, p, ##a) : \
> + sdev_printk(l, sdev, fmt, ##a)
> +
>  #define scmd_printk(prefix, scmd, fmt, a...) \
>  (scmd)->request->rq_disk ?   \
>   sdev_printk(prefix, (scmd)->device, "[%s] " fmt,\
> --
> 1.8.5.2

This triggers lots of compiler warnings with gcc 4.4.7 like:

drivers/scsi/sd.c: In function 'sd_open':
drivers/scsi/sd.c:1179: warning: reading through null pointer (argument 4)
drivers/scsi/sd.c:1179: warning: format '%s' expects type 'char *', but 
argument 4 has type 'void *'


That is from:
SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_open\n"));

Since:
#define NULL ((void *)0)

gcc probably doesn't realize the (p)? prevents the NULL (a void *) 
from being passed to sdev_printk.

Passing "" rather than NULL eliminates the compiler warnings.

There should probably be a () around p in the sdev_printk call, too.


---
Rob ElliottHP Server Storage



--
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: [PATCHv5 00/24] scsi logging update (the boring part)

2014-10-02 Thread Elliott, Robert (Server Storage)

> -Original Message-
> From: Hannes Reinecke [mailto:h...@suse.de]
> Sent: Wednesday, 01 October, 2014 1:23 AM
> To: James Bottomley
> Cc: Christoph Hellwig; linux-scsi@vger.kernel.org; Elliott, Robert (Server
> Storage); Hannes Reinecke
> Subject: [PATCHv5 00/24] scsi logging update (the boring part)
> 
> This is the next iteration of my scsi logging patchset.
> The patchset just contains some logging updates, code
> reshuffling and sanity fixes. Nothing major.
> 
> The second part of this patchset (the printk bit)
> has been vetoed for the moment, so I'll have to
> work on that. But in any case this patchset is
> pretty much independent.
> 
> Difference to v4:
> - Add 'Reviewed-by' tags from hch where applicable
> - Split off the fas216 patch into two different patches
> - Added a patch to document scsi_try_to_abort_cmd
> 
> Hannes Reinecke (24):
>   Remove scsi_cmd_print_sense_hdr()
>   sd: Remove scsi_print_sense() in sd_done()
>   aha152x: Debug output update and whitespace cleanup
>   scsi: introduce sdev_prefix_printk()
>   scsi: Use sdev as argument for sense code printing
>   acornscsi: use scsi_print_command()
>   fas216: Return DID_ERROR for incomplete data transfer
>   fas216: Update logging messages
>   53c700: remove scsi_print_sense() usage
>   scsi: stop decoding if scsi_normalize_sense() fails
>   scsi: do not decode sense extras
>   scsi: use 'bool' as return value for scsi_normalize_sense()
>   scsi: remove scsi_print_status()
>   Implement scsi_opcode_sa_name
>   scsi: merge print_opcode_name()
>   scsi: consolidate opcode lookup in scsi_opcode_sa_name()
>   scsi: remove last argument from print_opcode_name()
>   scsi: Remove scsi_print_command when calling abort
>   scsi: separate out scsi_(host|driver)byte_string()
>   sd: Cleanup logging
>   scsi: simplify scsi_log_(send|completion)
>   scsi: fixup logging messages in scsi_error.c
>   scsi: use shost argument in scsi_eh_prt_fail_stats
>   scsi_error: document scsi_try_to_abort_cmd

With this 24-part series applied to 3.17rc7, with the 
kernel set to print timestamps (e.g., printk.time=y on the kernel
command line), the prints still end up trickling out a byte
at a time, interleaved from different threads, when the system 
is overloaded.

Maybe that's addressed by the part that is deferred?

Example serial log excerpt:

[74465.705193] sd 2:0:0:0: [sdr] CDB:
[74465.705194] :
[74465.705196]  0
 [74465.705196] sd 2:0:0:0: [sdr] (null)FAILED Result: 
hostbyte=DID_OK driverbyte=DRIVER_SENSE
[74465.705197]  00
[74465.705198] :
[74465.705198] :
[74465.705199]  00
[74465.705200] Read(10)
[74465.705201]  28
[74465.705202]  f4
[74465.705202] sd 2:0:0:0: [sdr] Sense Key : Hardware Error [current]
[74465.705204]  b2
[74465.705204]  28
[74465.705205]  28
[74465.705206]  01
[74465.705207] :
[74465.705207]  00
[74465.705208]  70
[74465.705209]  f8
[74465.705210] sd 2:0:0:0: [sdr] Add. Sense: Logical unit failure
[74465.705211]  00
[74465.705211]  00
[74465.705212]  2f
[74465.705213]  28
[74465.705214]  00
[74465.705215]  00
[74465.705215]  00
[74465.705217]  00
[74465.705217] sd 2:0:0:0: [sdr] CDB:
[74465.705218]  00
[74465.705219]  70
[74465.705219]  00
[74465.705220]  00
[74465.705221]  00
[74465.705221]  00
[74465.705222]  01
[74465.705223] Read(10)
[74465.705223]  01
[74465.705224]  00
[74465.705225]  00
[74465.705226]  9c
[74465.705227]  08
[74465.705227]  08
[74465.705228]  81
[74465.705229] :
[74465.705229]  9d
[74465.705230]  00
[74465.705231]  01
[74465.705232]  70
[74465.705232]  00
[74465.705233]  00
[74465.705234]  50
[74465.705234]  28
[74465.705235]  e8
[74465.705236]  08
[74465.705237]  9f
[74465.705237]  00
[74465.705238]
[74465.705238]
[74465.705239]  00
[74465.705240]  00
[74465.705240]  00
[74465.705241]  00
[74465.705242]  68
[74465.705243]  00
[74465.705243]  00
[74465.705244]  00
[74465.705245]  00
[74465.705245]
[74465.705246]  00
[74465.705247]  08
[74465.705247]  08
[74465.705248]  01
[74465.705249]  08
[74465.705250]  00
[74465.705250]  00
[74465.705251]  00
[74465.705253]  33
[74465.705253] sd 2:0:0:0: [sdr] Done: SUCCESS Result: 
hostbyte=DID_TARGET_FAILURE driverbyte=DRIVER_OK


--
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 22/24] scsi: fixup logging messages in scsi_error.c

2014-10-02 Thread Ewan Milne
On Wed, 2014-10-01 at 08:22 +0200, Hannes Reinecke wrote:
> Use the matching scope for logging messages to allow for
> better command tracing.
> 
> Suggested-by: Robert Elliott 
> Reviewed-by: Christoph Hellwig 
> Signed-off-by: Hannes Reinecke 
> ---
>  drivers/scsi/hosts.c  |  4 +--
>  drivers/scsi/scsi_error.c | 82 
> +--
>  2 files changed, 45 insertions(+), 41 deletions(-)

See below.  I think there is another line that needs to be changed.

Reviewed-by: Ewan D. Milne 

> 
> diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
> index 6de80e3..06030e1 100644
> --- a/drivers/scsi/hosts.c
> +++ b/drivers/scsi/hosts.c
> @@ -485,8 +485,8 @@ struct Scsi_Host *scsi_host_alloc(struct 
> scsi_host_template *sht, int privsize)
>   WQ_UNBOUND | WQ_MEM_RECLAIM,
>  1, shost->host_no);
>   if (!shost->tmf_work_q) {
> - printk(KERN_WARNING "scsi%d: failed to create tmf workq\n",
> -shost->host_no);
> + shost_printk(KERN_WARNING, shost,
> +  "failed to create tmf workq\n");
>   goto fail_kthread;
>   }
>   scsi_proc_hostdir_add(shost->hostt);
> diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
> index 554f885..7e1e190 100644
> --- a/drivers/scsi/scsi_error.c
> +++ b/drivers/scsi/scsi_error.c
> @@ -1156,9 +1156,10 @@ int scsi_eh_get_sense(struct list_head *work_q,
>   shost = scmd->device->host;
>   if (scsi_host_eh_past_deadline(shost)) {
>   SCSI_LOG_ERROR_RECOVERY(3,
> - shost_printk(KERN_INFO, shost,
> - "skip %s, past eh deadline\n",
> -  __func__));
> + scmd_printk(KERN_INFO, scmd,
> + "%s: skip request sense, "
> +  "past eh deadline\n",
> +  current->comm));
>   break;
>   }
>   if (status_byte(scmd->result) != CHECK_CONDITION)
> @@ -1265,9 +1266,10 @@ static int scsi_eh_test_devices(struct list_head 
> *cmd_list,
>   /* Push items back onto work_q */
>   list_splice_init(cmd_list, work_q);
>   SCSI_LOG_ERROR_RECOVERY(3,
> - shost_printk(KERN_INFO, sdev->host,
> -  "skip %s, past eh 
> deadline",
> -  __func__));
> + sdev_printk(KERN_INFO, sdev,
> + "%s: skip test device, "
> + "past eh deadline",
> + current->comm));
>   break;
>   }
>   }
> @@ -1318,21 +1320,22 @@ static int scsi_eh_abort_cmds(struct list_head 
> *work_q,
>   if (scsi_host_eh_past_deadline(shost)) {
>   list_splice_init(&check_list, work_q);
>   SCSI_LOG_ERROR_RECOVERY(3,
> - shost_printk(KERN_INFO, shost,
> - "skip %s, past eh deadline\n",
> -  __func__));
> + scmd_printk(KERN_INFO, scmd,
> + "%s: skip aborting cmd, "
> + "past eh deadline\n",
> + current->comm));
>   return list_empty(work_q);
>   }
>   SCSI_LOG_ERROR_RECOVERY(3,
> - shost_printk(KERN_INFO, shost,
> -  "%s: aborting cmd: 0x%p\n",
> + scmd_printk(KERN_INFO, scmd,
> +  "%s: aborting cmd\n",
>current->comm, scmd));

I got a compile error on this, I think you need to change the above line
to be " current->comm));", removing scmd

>   rtn = scsi_try_to_abort_cmd(shost->hostt, scmd);
>   if (rtn == FAILED) {
>   SCSI_LOG_ERROR_RECOVERY(3,
> - shost_printk(KERN_INFO, shost,
> -  "%s: aborting cmd failed: 0x%p\n",
> -  current->comm, scmd));
> + scmd_printk(KERN_INFO, scmd,
> + "%s: aborting cmd failed\n",
> +  current->comm));
>   list_splice_init(&check_list, work_q);

Re: [PATCH v1 5/5] driver-core: add driver asynchronous probe support

2014-10-02 Thread Luis R. Rodriguez
As per Tom, adding systemd-devel for advice / review / of the request to avoid
the sigkill for kmod workers. Keeping others on Cc as its a discussion that
I think can help if both camps are involved. Specially since we've been
ping ponging back and forth on this particular topic for a long time now.

On Thu, Oct 02, 2014 at 08:12:37AM +0200, Tom Gundersen wrote:
> On Tue, Sep 30, 2014 at 5:24 PM, Luis R. Rodriguez  wrote:
> >> > commit e64fae5573e566ce4fd9b23c68ac8f3096603314
> >> > Author: Kay Sievers 
> >> > Date:   Wed Jan 18 05:06:18 2012 +0100
> >> >
> >> > udevd: kill hanging event processes after 30 seconds
> >> >
> >> > Some broken kernel drivers load firmware synchronously in the module 
> >> > init
> >> > path and block modprobe until the firmware request is fulfilled.
> >> > <...>
> >>
> >> This was a workaround to avoid a deadlock between udev and the kernel.
> >> The 180 s timeout was already in place before this change, and was not
> >> motivated by firmware loading. Also note that this patch was not about
> >> "tracking device drivers", just about avoiding dead-lock.
> >
> > Thanks, can you elaborate on how a deadlock can occur if the kmod
> > worker is not at some point sigkilled?
> 
> This was only relevant whet udev did the firmware loading. modprobe
> would wait for the kernel, which would wait for the firmware loading,
> which would wait for modprobe. This is no longer a problem as udev
> does not do firmware loading any more.

Thanks for clarifying. So the deadlock concern is no longer there, therefore
it is not a reason to keep the sigkill for kmod.

> > Is the issue that if there is no extra worker available and all are
> > idling on sleep / synchronous long work boot will potentially hang
> > unless a new worker becomes available to do more work?
> 
> Correct.

Ok.

> > If so I can
> > see the sigkill helping for hanging tasks but it doesn't necessarily
> > mean its a good idea to kill modules loading taking a while. Also
> > what if the sigkill is just avoided for *just* kmod workers?
> 
> Depending on the number of devices you have, I suppose we could still
> exhaust the workers.

Ok can systemd dynamically create a worker or set of workers per device
that creeps up? Async probe for most drivers will help with this but
having it dynamic should help as well, specially since there are drivers
that will require probe synchronously -- and the fact that async probe
mechanism is not yet merged.

> >> The way I see it, the current status from systemd's side is: our
> >> short-term work-around is to increase the timeout, and at the moment
> >> it appears no long-term solution is needed (i.e., it seems like the
> >> right thing to do is to make sure insmod can be near instantaneous, it
> >> appears people are working towards this goal, and so far no examples
> >> have cropped up showing that it is fundamentally impossible (once/if
> >> they do, we should of course revisit the problem)).
> >
> > That again would be reactive behaviour, what would prevent avoiding the
> > sigkill only for kmod workers? Is it known the deadlock is immiment?
> > If the amount of workers for kmod that would hit the timeout is
> > considered low I don't see how that's possible and why not just lift
> > the sigkill.
> 
> Making kmod a special case is of course possible. However, as long as
> there is no fundamental reason why kmod should get this special
> treatment, this just looks like a work-around to me. 

I've mentioned a series of five reasons why its a bad idea right now to
sigkill modules [0], we're reviewed them each and still at least
items 2-4 remain particularly valid fundamental reasons to avoid it
specially if the deadlock is no longer possible. Running out of
workers because they are loading modules and that is taking a while
is not really a good standing reason to be killing them, specially
if the timeout already is set to a high value. All we're doing there is
limiting Linux / number of devices arbitrarily just to help free
workers, and it seems that should be dealt with differently. Killing
module loading arbitrarily in the middle is not advisable and can cause
more issue than help in any way.

Async probe mechanism will help free workers faster but this patch series is
still being evolved, we should still address the sigkill for kmod workers
separately and see what remaining reasons we have for it in light of the
possible issues highlighted that it can introduce if kept. If we want to
capture drivers taking long on probe each subsystem should handle that and WARN
/ pick up on it, we cannot however assume that this a generally bad things as
discussed before. We will also not be able to async probe *every* driver,
which is why the series allows a flag to specify for this.

[0] https://lkml.org/lkml/2014/9/26/879

> We already have a
> work-around, which is to increase the global timeout. If you still
> think we should do something different in systemd, it is probably best
> to take

[PATCH] cxgb4i : fix rtnl lock assertion

2014-10-02 Thread Anish Bhatt
We should have been calling netdev_master_upper_dev_get_rcu() instead of
netdev_master_upper_dev_get() all along since this is called with an 
rcu_read_lock()

Please queue up for the next set of fixes for 3.17 as well.
-Anish

Signed-off-by: Anish Bhatt 
Signed-off-by: Karen Xie 

Fixes: 759a0cc5a3e1 ("cxgb4i: Add ipv6 code to driver, call into libcxgbi")
---
 drivers/scsi/cxgbi/cxgb4i/cxgb4i.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c 
b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
index 79788a1..963c764 100644
--- a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
+++ b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
@@ -1720,7 +1720,7 @@ static int update_root_dev_clip(struct net_device *dev)
return ret;
 
/* Parse all bond and vlan devices layered on top of the physical dev */
-   root_dev = netdev_master_upper_dev_get(dev);
+   root_dev = netdev_master_upper_dev_get_rcu(dev);
if (root_dev) {
ret = update_dev_clip(root_dev, dev);
if (ret)
-- 
2.1.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 20/24] sd: Cleanup logging

2014-10-02 Thread Elliott, Robert (Server Storage)
> From: Hannes Reinecke [mailto:h...@suse.de]
...
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 848b17d..2cc8703 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -116,7 +116,7 @@ static int sd_eh_action(struct scsi_cmnd *, int);
>  static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
>  static void scsi_disk_release(struct device *cdev);
>  static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
> -static void sd_print_result(struct scsi_disk *, int);
> +static void sd_print_result(struct scsi_disk *, const char *, int);
> 
>  static DEFINE_SPINLOCK(sd_index_lock);
>  static DEFINE_IDA(sd_index_ida);
> @@ -1479,7 +1479,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp)
>   }
> 
>   if (res) {
> - sd_print_result(sdkp, res);
> + sd_print_result(sdkp, "SYNCHRONIZE_CACHE failed", res);

The cdb_byte0_names[] array in constants.c capitalizes
the candidates as:
Synchronize Cache(10)
Synchronize cache(16)

Here, it's specifically the 10 byte version (so far), so
Synchronize Cache(10) failed
might be a better string.  Or, if following SCSI standards,
SYNCHRONIZE CACHE(10)
without the _ would be better.

Consider changing cdb_byte0_names to Synchronize Cache(16) too.
(it has a lot of inconsistent capitalization)

> 
>   if (driver_byte(res) & DRIVER_SENSE)
>   sd_print_sense_hdr(sdkp, &sshdr);
> @@ -1700,17 +1700,9 @@ static int sd_done(struct scsi_cmnd *SCpnt)
>   if (sense_valid)
>   sense_deferred = scsi_sense_is_deferred(&sshdr);
>   }
> -#ifdef CONFIG_SCSI_LOGGING
> - SCSI_LOG_HLCOMPLETE(1, scsi_print_result(SCpnt));
> - if (sense_valid) {
> - SCSI_LOG_HLCOMPLETE(1, scmd_printk(KERN_INFO, SCpnt,
> -"sd_done: sb[respc,sk,asc,"
> -"ascq]=%x,%x,%x,%x\n",
> -sshdr.response_code,
> -sshdr.sense_key, sshdr.asc,
> -sshdr.ascq));
> - }
> -#endif
> + SCSI_LOG_HLCOMPLETE(1, scmd_printk(KERN_INFO, SCpnt,
> +"sd_done: completed %d bytes\n",
> +good_bytes));

Printing good_bytes here is misleading, because it is 
subsequently changed from 0 to nonzero in these cases:
* HARDWARE ERROR sense key
* MEDIUM ERROR sense key
* RECOVERED ERROR sense key
* ABORTED COMMAND sense key for ASC 0x10
* ILLEGAL REQUEST sense key for ASC 0x10
* ILLEGAL REQUEST sense key for ASC/ASCQ 0x20/0x24 
for WRITE SAME without the UNMAP bit

Suggestions:
1. Move the print down after the out: label, when good_bytes
has reached its final value.

2. Indicate if the command was able to transfer all the bytes
by adding:
"%d of %d bytes" good_bytes, scsi_bufflen(SCpnt) 

>   sdkp->medium_access_timed_out = 0;
> 
>   if (driver_byte(result) != DRIVER_SENSE &&
> @@ -1820,12 +1812,12 @@ sd_spinup_disk(struct scsi_disk *sdkp)
>   /* no sense, TUR either succeeded or failed
>* with a status error */
>   if(!spintime && !scsi_status_is_good(the_result)) {
> - sd_printk(KERN_NOTICE, sdkp, "Unit Not 
> Ready\n");
> - sd_print_result(sdkp, the_result);
> + sd_print_result(sdkp, "Unit Not Ready",
> + the_result);

"unit" by itself is not a real SCSI term.  "Logical Unit Not 
Ready" would be better, but this is printed for all non-GOOD 
status values, not just CHECK CONDITION status with a sense 
key of NOT READY and one of many additional sense codes with 
"LOGICAL UNIT NOT READY" in their names.

Following the other prints in this patch, how about this?
"TEST UNIT READY failed"

>   }
>   break;
>   }
> -
> +
>   /*
>* The device does not want the automatic start to be issued.
>*/
> @@ -1941,7 +1933,7 @@ static void read_capacity_error(struct scsi_disk *sdkp,
> struct scsi_device *sdp,
>   struct scsi_sense_hdr *sshdr, int sense_valid,
>   int the_result)
>  {
> - sd_print_result(sdkp, the_result);
> + sd_print_result(sdkp, "READ CAPACITY failed", the_result);

The cdb_byte0_names[] array in constants.c capitalizes
the candidates as:
Read Capacity(10)
Read capacity(16)

The two callers to this function already print the opcode
name, using all caps and not printing "(10)", at the
KERN_NOTICE level:
sd_printk(KERN_NOTICE, sdkp, "READ CAPACITY(16) failed\n");
read_capacity_error(sdkp, sdp, &sshdr, sense_valid, t

Re: [PATCH v1 5/5] driver-core: add driver asynchronous probe support

2014-10-02 Thread Luis R. Rodriguez
On Tue, Sep 30, 2014 at 09:21:59AM +0200, Luis R. Rodriguez wrote:
> On Mon, Sep 29, 2014 at 05:26:01PM -0400, Tejun Heo wrote:
> > Hello, Luis.
> > 
> > On Mon, Sep 29, 2014 at 11:22:08PM +0200, Luis R. Rodriguez wrote:
> > > > > + /* For now lets avoid stupid bug reports */
> > > > > + if (!strcmp(bus->name, "pci") ||
> > > > > + !strcmp(bus->name, "pci_express") ||
> > > > > + !strcmp(bus->name, "hid") ||
> > > > > + !strcmp(bus->name, "sdio") ||
> > > > > + !strcmp(bus->name, "gameport") ||
> > > > > + !strcmp(bus->name, "mmc") ||
> > > > > + !strcmp(bus->name, "i2c") ||
> > > > > + !strcmp(bus->name, "platform") ||
> > > > > + !strcmp(bus->name, "usb"))
> > > > > + return true;
> > > > 
> > > > Ugh... things like this tend to become permanent.  Do we really need
> > > > this?  And how are we gonna find out what's broken why w/o bug
> > > > reports?
> > > 
> > > Yeah... well we have two options, one is have something like this to
> > > at least make it generally useful or remove this and let folks who
> > > care start fixing async for all modules. The downside to removing
> > > this is it makes async probe pretty much useless on most systems
> > > right now, it would mean systemd would have to probably consider
> > > the list above if they wanted to start using this without expecting
> > > systems to not work.
> > 
> > So, I'd much prefer blacklist approach if something like this is a
> > necessity.  That way, we'd at least know what doesn't work.
> 
> For buses? Or do you mean you'd want to wait until we have a decent
> list of drivers with the sync probe flag set? If the later it may take
> a while to get that list for this to be somewhat useful.

OK I'm removing this part and it works well for me now on my laptop
and an AMD server without a white list, so all the junk above will
be removed in the next series.

  Luis
--
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 v1 5/5] driver-core: add driver asynchronous probe support

2014-10-02 Thread Luis R. Rodriguez
On Tue, Sep 30, 2014 at 09:15:55AM +0200, Luis R. Rodriguez wrote:
> Can you provide an example code path hit here? I'll certainly like to address
> that as well.

I managed to enable built-in driver support on top of this series,
I'll send them as part of the next series but I suspect we'll want
to discuss blacklist/whitelist a bit more there.

 Luis
--
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 03/24] aha152x: Debug output update and whitespace cleanup

2014-10-02 Thread Elliott, Robert (Server Storage)
> -Original Message-
> From: Hannes Reinecke [mailto:h...@suse.de]
...
> diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
> index e77b72f..e1aba73 100644
> --- a/drivers/scsi/aha152x.c
> +++ b/drivers/scsi/aha152x.c
...
> @@ -345,10 +311,10 @@ CMD_INC_RESID(struct scsi_cmnd *cmd, int inc)
> 
>  enum {
>   not_issued  = 0x0001,   /* command not yet issued */
> - selecting   = 0x0002,   /* target is beeing selected */
> + selecting   = 0x0002,   /* target is beeing selected */

You might want to fix the spelling of "being" 
while modifying that line.


--
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 05/24] scsi: Use sdev as argument for sense code printing

2014-10-02 Thread Elliott, Robert (Server Storage)


> -Original Message-
> From: Hannes Reinecke [mailto:h...@suse.de]
...
> @@ -1369,49 +1372,53 @@ scsi_extd_sense_format(unsigned char asc, unsigned
> char ascq) {
>  EXPORT_SYMBOL(scsi_extd_sense_format);
> 
>  void
> -scsi_show_extd_sense(unsigned char asc, unsigned char ascq)
> +scsi_show_extd_sense(struct scsi_device *sdev, const char *name,
> +  unsigned char asc, unsigned char ascq)

Since what sdev points to is not modified, that could be
const struct scsi_device *sdev.

(also adjust the function prototype in scsi_dbg.h to match)


>  {
> -const char *extd_sense_fmt = scsi_extd_sense_format(asc, ascq);
> + const char *extd_sense_fmt = NULL;
> + const char *extd_sense_str = scsi_extd_sense_format(asc, ascq,
> + &extd_sense_fmt);
> +
> + if (extd_sense_str) {
> + if (extd_sense_fmt)
> + sdev_prefix_printk(KERN_INFO, sdev, name,
> +"Add. Sense: %s (%s%x)",
> +extd_sense_str, extd_sense_fmt,
> +ascq);
> + else
> + sdev_prefix_printk(KERN_INFO, sdev, name,
> +"Add. Sense: %s", extd_sense_str);
> 
> - if (extd_sense_fmt) {
> - if (strstr(extd_sense_fmt, "%x")) {
> - printk("Add. Sense: ");
> - printk(extd_sense_fmt, ascq);
> - } else
> - printk("Add. Sense: %s", extd_sense_fmt);
>   } else {
> - if (asc >= 0x80)
> - printk("<> ASC=0x%x ASCQ=0x%x", asc,
> -ascq);
> - if (ascq >= 0x80)
> - printk("ASC=0x%x <> ASCQ=0x%x", asc,
> -ascq);
> - else
> - printk("ASC=0x%x ASCQ=0x%x", asc, ascq);
> + sdev_prefix_printk(KERN_INFO, sdev, name,
> +"%sASC=0x%x %sASCQ=0x%x\n",
> +asc >= 0x80 ? "<> " : "", asc,
> +ascq >= 0x80 ? "<> " : "", ascq);
>   }
> -
> - printk("\n");
>  }
>  EXPORT_SYMBOL(scsi_show_extd_sense);
> 
>  void
> -scsi_show_sense_hdr(struct scsi_sense_hdr *sshdr)
> +scsi_show_sense_hdr(struct scsi_device *sdev, const char *name,
> + struct scsi_sense_hdr *sshdr)

Add const for *sdev and *sshdr.

The latter requires also adding const to the argument in
scsi_sense_is_deferred() in scsi_eh.h.


...
> @@ -1419,12 +1426,11 @@ EXPORT_SYMBOL(scsi_show_sense_hdr);
>   * Print normalized SCSI sense header with a prefix.
>   */
>  void
> -scsi_print_sense_hdr(const char *name, struct scsi_sense_hdr *sshdr)
> +scsi_print_sense_hdr(struct scsi_device *sdev, const char *name,
> +  struct scsi_sense_hdr *sshdr)

Add const for *sdev and *sshdr.

...
> @@ -1513,33 +1519,26 @@ scsi_decode_sense_extras(const unsigned char
> *sense_buffer, int sense_len,
>  }
> 
>  /* Normalize and print sense buffer with name prefix */
> -void __scsi_print_sense(const char *name, const unsigned char *sense_buffer,
> - int sense_len)
> +void __scsi_print_sense(struct scsi_device *sdev, const char *name,
> + const unsigned char *sense_buffer, int sense_len)

Add const for *sdev.

>  {
>   struct scsi_sense_hdr sshdr;
> 
> - printk(KERN_INFO "%s: ", name);
>   scsi_decode_sense_buffer(sense_buffer, sense_len, &sshdr);
> - scsi_show_sense_hdr(&sshdr);
> + scsi_show_sense_hdr(sdev, name, &sshdr);
>   scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr);
> - printk(KERN_INFO "%s: ", name);
> - scsi_show_extd_sense(sshdr.asc, sshdr.ascq);
> + scsi_show_extd_sense(sdev, name, sshdr.asc, sshdr.ascq);
>  }
>  EXPORT_SYMBOL(__scsi_print_sense);
> 
>  /* Normalize and print sense buffer in SCSI command */
> -void scsi_print_sense(char *name, struct scsi_cmnd *cmd)
> +void scsi_print_sense(struct scsi_cmnd *cmd)
...

Add const for *cmd.


---
Rob ElliottHP Server Storage





--
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 08/24] fas216: Update logging messages

2014-10-02 Thread Elliott, Robert (Server Storage)


> -Original Message-
> From: Hannes Reinecke [mailto:h...@suse.de]
...
> @@ -2079,12 +2078,12 @@ fas216_std_done(FAS216_Info *info, struct scsi_cmnd
> *SCpnt, unsigned int result)
>   break;
> 
>   default:
> - printk(KERN_ERR "scsi%d.%c: incomplete data transfer "
> - "detected: res=%08X ptr=%p len=%X CDB: ",
> - info->host->host_no, '0' + SCpnt->device->id,
> - SCpnt->result, info->scsi.SCp.ptr,
> - info->scsi.SCp.this_residual);
> - __scsi_print_command(SCpnt->cmnd);
> + scmd_printk(KERN_ERR, SCpnt,
> + "incomplete data transfer "
> + "detected: res=%08X ptr=%p len=%X\n",

checkpatch lets you keep strings on one line even if the code
exceeds 80 characters.

> + SCpnt->result, info->scsi.SCp.ptr,
> + info->scsi.SCp.this_residual);
> + scsi_print_command(SCpnt);
>   set_host_byte(SCpnt, DID_ERROR);
>   goto request_sense;
>   }
> @@ -2157,12 +2156,12 @@ static void fas216_done(FAS216_Info *info, unsigned
> int result)
>* to transfer, we should not have a valid pointer.
>*/
>   if (info->scsi.SCp.ptr && info->scsi.SCp.this_residual == 0) {
> - printk("scsi%d.%c: zero bytes left to transfer, but "
> -"buffer pointer still valid: ptr=%p len=%08x CDB: ",
> -info->host->host_no, '0' + SCpnt->device->id,
> -info->scsi.SCp.ptr, info->scsi.SCp.this_residual);
> + scmd_printk(KERN_INFO, SCpnt,
> + "zero bytes left to transfer, but "
> + "buffer pointer still valid: ptr=%p len=%08x\n",

checkpatch lets you keep strings on one line even if the code
exceeds 80 characters.


---
Rob ElliottHP Server Storage



--
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 12/24] scsi: use 'bool' as return value for scsi_normalize_sense()

2014-10-02 Thread Elliott, Robert (Server Storage)


> -Original Message-
> From: Hannes Reinecke [mailto:h...@suse.de]
> Sent: Wednesday, 01 October, 2014 1:23 AM
> To: James Bottomley
> Cc: Christoph Hellwig; linux-scsi@vger.kernel.org; Elliott, Robert (Server
> Storage); Hannes Reinecke
> Subject: [PATCH 12/24] scsi: use 'bool' as return value for
> scsi_normalize_sense()
> 
> Convert scsi_normalize_sense() and frieds to return 'bool'
> instead of an integer.

frieds should be friends

...
> -int scsi_command_normalize_sense(struct scsi_cmnd *cmd,
> +bool scsi_command_normalize_sense(struct scsi_cmnd *cmd,
>struct scsi_sense_hdr *sshdr)

Add const for *cmd since what it points to is not
modified.  (prototype in scsi_eh.h)

...
> -static inline int scsi_sense_valid(struct scsi_sense_hdr *sshdr)
> +static inline bool scsi_sense_valid(struct scsi_sense_hdr *sshdr)
>  {
>   if (!sshdr)
> - return 0;
> + return false;
> 
>   return (sshdr->response_code & 0x70) == 0x70;
>  }

Add const to the argument, since what it points to is not
changed by this function:
const struct scsi_sense_hdr *sshdr


> -static inline int scsi_sense_is_deferred(struct scsi_sense_hdr *sshdr)
> +static inline bool scsi_sense_is_deferred(struct scsi_sense_hdr *sshdr)
>  {
>   return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1));
>  }

Add const to the argument, since what it points to is not
changed by this function:
const struct scsi_sense_hdr *sshdr

(also mentioned in reply to PATCH 4)


---
Rob ElliottHP Server Storage



--
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 14/24] Implement scsi_opcode_sa_name

2014-10-02 Thread Elliott, Robert (Server Storage)


> -Original Message-
> From: Hannes Reinecke [mailto:h...@suse.de]
...
> +struct sa_name_list {
> + int cmd;
> + const struct value_name_pair *arr;
> + int arr_sz;
> +};

cmd usually refers to a whole structure and is usually 
a pointer variable.  grep searches will be easier if 
you name that field "opcode".

> +
> +static struct sa_name_list sa_names_arr[] = {
> + {VARIABLE_LENGTH_CMD, variable_length_arr, VARIABLE_LENGTH_SZ},
> + {MAINTENANCE_IN, maint_in_arr, MAINT_IN_SZ},
> + {MAINTENANCE_OUT, maint_out_arr, MAINT_OUT_SZ},
> + {PERSISTENT_RESERVE_IN, pr_in_arr, PR_IN_SZ},
> + {PERSISTENT_RESERVE_OUT, pr_out_arr, PR_OUT_SZ},
> + {SERVICE_ACTION_IN_12, serv_in12_arr, SERV_IN12_SZ},
> + {SERVICE_ACTION_OUT_12, serv_out12_arr, SERV_OUT12_SZ},
> + {SERVICE_ACTION_BIDIRECTIONAL, serv_bidi_arr, SERV_BIDI_SZ},
> + {SERVICE_ACTION_IN_16, serv_in16_arr, SERV_IN16_SZ},
> + {SERVICE_ACTION_OUT_16, serv_out16_arr, SERV_OUT16_SZ},
> + {THIRD_PARTY_COPY_IN, tpc_in_arr, TPC_IN_SZ},
> + {THIRD_PARTY_COPY_OUT, tpc_out_arr, TPC_OUT_SZ},
> + {0, NULL, 0},
> +};
> +
> +static bool scsi_opcode_sa_name(int cmd, int service_action,
> + const char **sa_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


RE: [PATCH 15/24] scsi: merge print_opcode_name()

2014-10-02 Thread Elliott, Robert (Server Storage)


> -Original Message-
> From: Hannes Reinecke [mailto:h...@suse.de]
> +struct sa_name_list {
> + int cmd;
> + const struct value_name_pair *arr;
> + int arr_sz;
> +};

The suggestion to rename cmd to opcode in patch 14 would
follow the movements here.

...
> @@ -273,7 +292,7 @@ static bool scsi_opcode_sa_name(int cmd, int
> service_action,
>   const struct value_name_pair *arr = NULL;
>   int arr_sz, k;
> 
> - for (k = 0; sa_name_ptr->arr; ++k, ++sa_name_ptr) {
> + for (k = 0; k < ARRAY_SIZE(sa_names_arr); ++k, ++sa_name_ptr) {
>   if (sa_name_ptr->cmd == cmd) {
>   arr = sa_name_ptr->arr;
>   arr_sz = sa_name_ptr->arr_sz;
> @@ -315,11 +334,14 @@ static void print_opcode_name(unsigned char * cdbp, int
> cdb_len)
> 
>   if (!scsi_opcode_sa_name(cdb0, sa, &name)) {
>   if (cdb0 < 0xc0) {
> - name = cdb_byte0_names[cdb0];
> - if (name)
> - printk("%s", name);
> - else
> - printk("cdb[0]=0x%x (reserved)", cdb0);
> + if (ARRAY_SIZE(cdb_byte0_names)) {
> + name = cdb_byte0_names[cdb0];
> + if (name)
> + printk("%s", name);
> + else
> + printk("cdb[0]=0x%x (reserved)", cdb0);
> + } else
> + printk("cdb[0]=0x%x", cdb0);

Just ARRAY_SIZE(cdb_byte0_names) is not right - that array 
is always defined and the statement is always true.

Patch 16 replaces that block of code and eliminates that
issue.


---
Rob ElliottHP Server Storage



--
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: Fix "choir" and "beeing" malaprops

2014-10-02 Thread Finn Thain

Signed-off-by: Finn Thain 

---
 Documentation/scsi/scsi_eh.txt |4 ++--
 drivers/scsi/aha152x.c |2 +-
 drivers/scsi/mac_scsi.c|2 +-
 include/scsi/scsi_host.h   |2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

Index: linux/Documentation/scsi/scsi_eh.txt
===
--- linux.orig/Documentation/scsi/scsi_eh.txt   2014-09-29 10:55:44.0 
+1000
+++ linux/Documentation/scsi/scsi_eh.txt2014-10-01 16:33:24.0 
+1000
@@ -172,7 +172,7 @@ ways.
 
  - eh_strategy_handler() callback
This is one big callback which should perform whole error
-   handling.  As such, it should do all choirs SCSI midlayer
+   handling.  As such, it should do all chores the SCSI midlayer
performs during recovery.  This will be discussed in [2-2].
 
  Once recovery is complete, SCSI EH resumes normal operation by
@@ -428,7 +428,7 @@ scmd->allowed.
 scsi_unjam_host() and it is responsible for whole recovery process.
 On completion, the handler should have made lower layers forget about
 all failed scmds and either ready for new commands or offline.  Also,
-it should perform SCSI EH maintenance choirs to maintain integrity of
+it should perform SCSI EH maintenance chores to maintain integrity of
 SCSI midlayer.  IOW, of the steps described in [2-1-2], all steps
 except for #1 must be implemented by eh_strategy_handler().
 
Index: linux/drivers/scsi/aha152x.c
===
--- linux.orig/drivers/scsi/aha152x.c   2014-09-29 10:55:44.0 +1000
+++ linux/drivers/scsi/aha152x.c2014-10-01 16:33:24.0 +1000
@@ -345,7 +345,7 @@ CMD_INC_RESID(struct scsi_cmnd *cmd, int
 
 enum {
not_issued  = 0x0001,   /* command not yet issued */
-   selecting   = 0x0002,   /* target is beeing selected */
+   selecting   = 0x0002,   /* target is being selected */
identified  = 0x0004,   /* IDENTIFY was sent */
disconnected= 0x0008,   /* target disconnected */
completed   = 0x0010,   /* target sent COMMAND COMPLETE */ 
Index: linux/drivers/scsi/mac_scsi.c
===
--- linux.orig/drivers/scsi/mac_scsi.c  2014-10-01 16:32:58.0 +1000
+++ linux/drivers/scsi/mac_scsi.c   2014-10-01 16:33:24.0 +1000
@@ -360,7 +360,7 @@ const char * macscsi_info (struct Scsi_H
XXX: Since bus errors in the PDMA routines never happen on my 
computer, the bus error code is untested. 
If the code works as intended, a bus error results in Pseudo-DMA 
-   beeing disabled, meaning that the driver switches to slow handshake. 
+   being disabled, meaning that the driver switches to slow handshake.
If bus errors are NOT extremely rare, this has to be changed. 
 */
 
Index: linux/include/scsi/scsi_host.h
===
--- linux.orig/include/scsi/scsi_host.h 2014-09-29 10:55:44.0 +1000
+++ linux/include/scsi/scsi_host.h  2014-10-01 16:33:24.0 +1000
@@ -572,7 +572,7 @@ struct Scsi_Host {
 * __devices is protected by the host_lock, but you should
 * usually use scsi_device_lookup / shost_for_each_device
 * to access it and don't care about locking yourself.
-* In the rare case of beeing in irq context you can use
+* In the rare case of being in irq context you can use
 * their __ prefixed variants with the lock held. NEVER
 * access this list directly from a driver.
 */
--
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_debug: Error message should say scsi_host_alloc not scsi_register

2014-10-02 Thread Finn Thain

Signed-off-by: Finn Thain 

---
 drivers/scsi/scsi_debug.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux/drivers/scsi/scsi_debug.c
===
--- linux.orig/drivers/scsi/scsi_debug.c2014-09-29 10:55:44.0 
+1000
+++ linux/drivers/scsi/scsi_debug.c 2014-10-01 16:33:23.0 +1000
@@ -3967,7 +3967,7 @@ static int sdebug_driver_probe(struct de
sdebug_driver_template.use_clustering = ENABLE_CLUSTERING;
hpnt = scsi_host_alloc(&sdebug_driver_template, sizeof(sdbg_host));
if (NULL == hpnt) {
-   printk(KERN_ERR "%s: scsi_register failed\n", __func__);
+   pr_err("%s: scsi_host_alloc failed\n", __func__);
error = -ENODEV;
return error;
}
--
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] tmscim: Remove unused SCSI_IRQ_NONE macro definition

2014-10-02 Thread Finn Thain

Signed-off-by: Finn Thain 

---

This macro is only used in the NCR5380 drivers and they don't include
this header.

---
 drivers/scsi/tmscsim.h |2 --
 1 file changed, 2 deletions(-)

Index: linux/drivers/scsi/tmscsim.h
===
--- linux.orig/drivers/scsi/tmscsim.h   2014-09-29 10:55:44.0 +1000
+++ linux/drivers/scsi/tmscsim.h2014-10-01 16:33:25.0 +1000
@@ -10,8 +10,6 @@
 
 #include 
 
-#define SCSI_IRQ_NONE 255
-
 #define MAX_ADAPTER_NUM4
 #define MAX_SG_LIST_BUF16  /* Not used */
 #define MAX_SCSI_ID8
--
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 16/24] scsi: consolidate opcode lookup in scsi_opcode_sa_name()

2014-10-02 Thread Elliott, Robert (Server Storage)


> -Original Message-
> From: Hannes Reinecke [mailto:h...@suse.de]
...
> diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
...
> @@ -332,21 +340,20 @@ static void print_opcode_name(unsigned char * cdbp, int
> cdb_len)
>   len = cdb_len;
>   }
> 
> - if (!scsi_opcode_sa_name(cdb0, sa, &name)) {
> - if (cdb0 < 0xc0) {
> - if (ARRAY_SIZE(cdb_byte0_names)) {
> - name = cdb_byte0_names[cdb0];
> - if (name)
> - printk("%s", name);
> - else
> - printk("cdb[0]=0x%x (reserved)", cdb0);
> - } else
> - printk("cdb[0]=0x%x", cdb0);
> - } else
> + if (!scsi_opcode_sa_name(cdb0, sa, &cdb_name, &sa_name)) {
> + if (cdb_name)
> + printk("%s", cdb_name);
> + else if (cdb0 > VENDOR_SPECIFIC_CDB)
>   printk("cdb[0]=0x%x (vendor)", cdb0);
> + else if (cdb0 > 0x60 && cdb0 < 0x7e)
> + printk("cdb[0]=0x%x (reserved)", cdb0);
> + else
> + printk("cdb[0]=0x%x", cdb0);

Both of those > need to be >=, since the reserved
range starts at and includes 0x60, and the vendor
specific range starts at and includes 0xc0.

---
Rob ElliottHP Server Storage



--
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 17/24] scsi: remove last argument from print_opcode_name()

2014-10-02 Thread Elliott, Robert (Server Storage)


> -Original Message-
> From: Hannes Reinecke [mailto:h...@suse.de]
> Sent: Wednesday, 01 October, 2014 1:23 AM
> To: James Bottomley
> Cc: Christoph Hellwig; linux-scsi@vger.kernel.org; Elliott, Robert (Server
> Storage); Hannes Reinecke
> Subject: [PATCH 17/24] scsi: remove last argument from print_opcode_name()
> 
> print_opcode_name() was only ever called with a '0' argument
> from LLDDs and ULDs which were _not_ supporting variable length
> CDBs, so the 'if' clause was never triggered.
> 
> Reviewed-by: Christoph Hellwig 
> Signed-off-by: Hannes Reinecke 
> ---
>  drivers/scsi/constants.c | 21 +++--
>  1 file changed, 7 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
> index 2110d61..713e1e0 100644
> --- a/drivers/scsi/constants.c
> +++ b/drivers/scsi/constants.c
> @@ -320,25 +320,21 @@ static bool scsi_opcode_sa_name(int cmd, int
> service_action,
>   return true;
>  }
> 
> -/* attempt to guess cdb length if cdb_len==0 . No trailing linefeed. */
> -static void print_opcode_name(unsigned char * cdbp, int cdb_len)
> +static void print_opcode_name(unsigned char *cdbp)

Add const since what cdbp points to is not modified.

>  {
> - int sa, len, cdb0;
> + int sa, cdb0;
>   const char *cdb_name = NULL, *sa_name = NULL;
> 
>   cdb0 = cdbp[0];
>   if (cdb0 == VARIABLE_LENGTH_CMD) {
> - len = scsi_varlen_cdb_length(cdbp);
> + int len = scsi_varlen_cdb_length(cdbp);

cdbp must point to a buffer containing at least 8 valid
bytes for that to be safe. Is that guaranteed?

>   if (len < 10) {
> - printk("short variable length command, "
> -"len=%d ext_len=%d", len, cdb_len);
> + printk("short variable length command, len=%d", len);
>   return;
>   }
>   sa = (cdbp[8] << 8) + cdbp[9];
> - } else {
> + } else
>   sa = cdbp[1] & 0x1f;

cdbp must point to a buffer containing at least 2 valid
bytes for that to be safe. Is that guaranteed?

> - len = cdb_len;
> - }
> 
>   if (!scsi_opcode_sa_name(cdb0, sa, &cdb_name, &sa_name)) {
>   if (cdb_name)
> @@ -356,9 +352,6 @@ static void print_opcode_name(unsigned char * cdbp, int
> cdb_len)
>   printk("%s, sa=0x%x", cdb_name, sa);
>   else
>   printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
> -
> - if (cdb_len > 0 && len != cdb_len)
> - printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len);
>   }
>  }
> 
> @@ -366,7 +359,7 @@ void __scsi_print_command(unsigned char *cdb)
...
> @@ -383,7 +376,7 @@ void scsi_print_command(struct scsi_cmnd *cmd)

Add const to each of those, since what cdbp and cmd point 
to is not modified.

---
Rob ElliottHP Server Storage




--
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 18/24] scsi: Remove scsi_print_command when calling abort

2014-10-02 Thread Elliott, Robert (Server Storage)


> -Original Message-
> From: Hannes Reinecke [mailto:h...@suse.de]
> Sent: Wednesday, 01 October, 2014 1:23 AM
> To: James Bottomley
> Cc: Christoph Hellwig; linux-scsi@vger.kernel.org; Elliott, Robert (Server
> Storage); Hannes Reinecke
> Subject: [PATCH 18/24] scsi: Remove scsi_print_command when calling abort
> 
> Calling scsi_print_command should not be necessary during abort;
> if the information is required one should enable scsi logging.
> 
...
> diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
> index 45da3c8..50873bb 100644
> --- a/drivers/scsi/NCR5380.c
> +++ b/drivers/scsi/NCR5380.c
> @@ -2666,9 +2666,8 @@ static int NCR5380_abort(Scsi_Cmnd * cmd) {
>   struct Scsi_Host *instance = cmd->device->host;
>   struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)
> instance->hostdata;
>   Scsi_Cmnd *tmp, **prev;
> -
> - printk(KERN_WARNING "scsi%d : aborting command\n", instance->host_no);
> - scsi_print_command(cmd);
> +
> + scmd_printk(KERN_WARNING, cmd, "aborting command\n");
> 
>   NCR5380_print_status(instance);
> 
> diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
> index b2fd18e..c16aca1 100644
> --- a/drivers/scsi/arm/fas216.c
> +++ b/drivers/scsi/arm/fas216.c
> @@ -2425,14 +2425,11 @@ int fas216_eh_abort(struct scsi_cmnd *SCpnt)
> 
>   info->stats.aborts += 1;
> 
> - printk(KERN_WARNING "scsi%d: abort command ", info->host->host_no);
> - __scsi_print_command(SCpnt->cmnd);
> + sdev_printk(KERN_WARNING, SCpnt, "abort command\n");

That should be scmd_printk.

It'd be nice if the s*_printk macros could typecheck 
that pointer.

> 
>   print_debug_list();
>   fas216_dumpstate(info);
> 
> - printk(KERN_WARNING "scsi%d: abort %p ", info->host->host_no, SCpnt);
> -
>   switch (fas216_find_command(info, SCpnt)) {
>   /*
>* We found the command, and cleared it out.  Either
> @@ -2440,7 +2437,7 @@ int fas216_eh_abort(struct scsi_cmnd *SCpnt)
>* target, or the busylun bit is not set.
>*/
>   case res_success:
> - printk("success\n");
> + sdev_printk(KERN_WARNING, SCpnt, "abort %p success\n", SCpnt);

That should be scmd_printk, dropping the %p and the extra SCpnt
argument.

>   result = SUCCESS;
>   break;
> 
> @@ -2450,14 +2447,13 @@ int fas216_eh_abort(struct scsi_cmnd *SCpnt)
>* if the bus is free.
>*/
>   case res_hw_abort:
> -
> 
>   /*
>* We are unable to abort the command for some reason.
>*/
>   default:
>   case res_failed:
> - printk("failed\n");
> + sdev_printk(KERN_WARNING, SCpnt, "abort %p failed\n", SCpnt);

That should be scmd_printk, dropping the %p and the extra SCpnt
argument.

>   break;
>   }
> 
> diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c
> index 79e6f04..322f361 100644
> --- a/drivers/scsi/atari_NCR5380.c
> +++ b/drivers/scsi/atari_NCR5380.c
> @@ -2623,8 +2623,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
>   Scsi_Cmnd *tmp, **prev;
>   unsigned long flags;
> 
> - printk(KERN_NOTICE "scsi%d: aborting command\n", HOSTNO);
> - scsi_print_command(cmd);
> + sdev_printk(KERN_NOTICE, cmd, "aborting command\n");

That should be scmd_printk.

...
> diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c
> index 1a2367a..68d0e1a 100644
> --- a/drivers/scsi/sun3_NCR5380.c
> +++ b/drivers/scsi/sun3_NCR5380.c
> @@ -2608,8 +2608,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
>  struct scsi_cmnd *tmp, **prev;
>  unsigned long flags;
> 
> -printk(KERN_NOTICE "scsi%d: aborting command\n", HOSTNO);
> -scsi_print_command(cmd);
> +sdev_printk(KERN_NOTICE, cmd, "aborting command\n");

That should be scmd_printk.


---
Rob ElliottHP Server Storage



--
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 20/24] sd: Cleanup logging

2014-10-02 Thread Elliott, Robert (Server Storage)


> -Original Message-
> From: Hannes Reinecke [mailto:h...@suse.de]
...
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
...
> @@ -3328,9 +3319,19 @@ static void sd_print_sense_hdr(struct scsi_disk *sdkp,
>sshdr->asc, sshdr->ascq);
>  }
> 
> -static void sd_print_result(struct scsi_disk *sdkp, int result)
> +static void sd_print_result(struct scsi_disk *sdkp, const char *msg,
> + int result)
>  {
> - sd_printk(KERN_INFO, sdkp, " ");
> - scsi_show_result(result);
> + const char *hb_string = scsi_hostbyte_string(result);
> + const char *db_string = scsi_driverbyte_string(result);
> +
> + if (hb_string && db_string)
> + sd_printk(KERN_INFO, sdkp,
> +   "%s: Result: hostbyte=%s driverbyte=%s\n",
> +   msg, hb_string, db_string);
> + else
> + sd_printk(KERN_INFO, sdkp,
> +   "%s: Result: hostbyte=0x%02x driverbyte=0x%02x\n",
> +   msg, host_byte(result), driver_byte(result));

In a similar construct, patch 19 used || in scsi_print_result
to choose the string path, and printed "invalid" if one
of the strings was NULL.  They should probably match.


---
Rob ElliottHP Server Storage



--
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


  1   2   >