Product Inquiry

2017-06-26 Thread Julian Smith
Hello, 

My name is Ms Julian Smith and i am from Sinara Group Co.
We are glad to know about your company from the web and we are interested in
your products.Please send us your Latest catalog and price list for our
trial order. 

Julian Smith, 
Purchasing Manager
Sinara Group Co.
7 Krasnogo Znameni Ave.
Vladivostok,690106,Ukraine




Re: [PATCH v3 0/4] g_NCR5380: PDMA fixes and cleanup

2017-06-26 Thread Finn Thain
On Mon, 26 Jun 2017, Ondrej Zary wrote:

> 
> No apparent change in behavior, the first write test resulted in:
> [  842.830802] sd 2:0:1:0: [sdb] tag#0 53c80 registers not accessible, device 
> will be reset
> [  842.830802] sd 2:0:1:0: [sdb] tag#0 switching to slow handshake
> 
> Checking for IRQ after poll_politely2 does not seem right because we can 
> miss the buffer ready signal.
> 

How so? As long as there's no gated IRQ, we poll for buffer readiness 
until timeout. And when there is a gated IRQ, we break both the polling 
loop and the transfer loop immediately. Your code and mine are basically 
in agreement here.

> According to my tests, buffer ready signal is most important - if there 
> is any data to read/write, do the transfer. If not, only then check why 
> - maybe we got an IRQ (that terminated PDMA). Or no IRQ, sometimes the 
> wait for buffer ready times out - we need to terminate PDMA manually 
> then (reset).
> 
> Then 53C80 registers should become ready.
> 

You seem to be saying that we should ignore the IRQ signal if the buffers 
have become ready. Maybe so. Can we try simply resetting the block 
counter? (I could imagine that the 53c400 core might leave the 53c80 
registers inaccessible unless we keep accessing the buffers in the 53c400 
core until the transfer is done.)

BTW, with regard to your patch, note that this construct is race prone:

while (1) { /* monitor IRQ while waiting for host buffer */
csr = NCR5380_read(hostdata->c400_ctl_status);
if (!(csr & CSR_HOST_BUF_NOT_RDY))
break;
if (csr & CSR_GATED_53C80_IRQ) {
basr = NCR5380_read(BUS_AND_STATUS_REG);
if (!(basr & BASR_PHASE_MATCH) ||
   (basr & BASR_BUSY_ERROR)) {
printk("basr=0x%02x csr=0x%02x at start=%d\n", basr, 
csr, start);
goto out_wait;
}
}
if (retries-- < 1) {
shost_printk(KERN_ERR, hostdata->host, "53C400r: host buffer 
not ready in time\n");
NCR5380_write(hostdata->c400_ctl_status, CSR_RESET);
NCR5380_write(hostdata->c400_ctl_status, CSR_BASE);
goto out_wait;
}
}

This code can "goto out_wait" when !(csr & CSR_HOST_BUF_NOT_RDY). It 
depends on timing. This would seem to be contrary to your stated aim.

Moreover, this code can also "break" when (csr & CSR_GATED_53C80_IRQ). 
That depends on timing too. But this may be an improvement on my code if 
it allows the 53c80 registers to become accessible, by allowing the block 
counter to be decremented.

The uncertainty here was one of the reasons I reworked this code.

> This is a log from writing 230 MB file using my code with some debug 
> prints, on a NCR53C400. No 53C80 timeouts, only disconnects and some 
> host buffer timeouts (maybe the drive sometimes just slows down without 
> disconnecting?)
> 
> [ 3378.503828] basr=0x10 csr=0xd5 at start=512
> [ 3461.257973] w basr=0x10 csr=0x95 at start=3840
> [ 3461.838225] w basr=0x10 csr=0x95 at start=3840
> [ 3462.683446] w basr=0x10 csr=0x95 at start=3840
> [ 3463.416911] w basr=0x10 csr=0x95 at start=3840
> [ 3465.117804] scsi host2: 53C400w: host buffer not ready in time
> [ 3465.276375] w basr=0x10 csr=0x95 at start=3328
> [ 3466.457701] w basr=0x10 csr=0x95 at start=1792
> [ 3467.019643] scsi host2: 53C400w: host buffer not ready in time
> [ 3467.619058] scsi host2: 53C400w: host buffer not ready in time
> [ 3467.799619] w basr=0x10 csr=0x95 at start=3840
> [ 3552.123501] w basr=0x10 csr=0x95 at start=2304
> [ 3552.771223] w basr=0x10 csr=0x95 at start=1280
> [ 3554.556451] w basr=0x10 csr=0x95 at start=2816
> [ 3555.229646] w basr=0x10 csr=0x95 at start=1792
> [ 3555.630632] scsi host2: 53C400w: host buffer not ready in time
> [ 3555.774560] w basr=0x10 csr=0x95 at start=768
> [ 3625.541608] w basr=0x10 csr=0x95 at start=3328
> [ 3640.099861] w basr=0x10 csr=0x95 at start=1792
> [ 3641.442671] w basr=0x10 csr=0x95 at start=2816
> [ 3641.865469] w basr=0x10 csr=0x95 at start=768
> [ 3642.939223] w basr=0x10 csr=0x95 at start=1280
> [ 3643.356858] w basr=0x10 csr=0x95 at start=3328
> [ 3643.701636] w basr=0x10 csr=0x95 at start=3840
> [ 3645.153405] w basr=0x10 csr=0x95 at start=2304
> [ 3646.135642] w basr=0x10 csr=0x95 at start=1280
> [ 3647.007321] w basr=0x10 csr=0x95 at start=2816
> [ 3648.065874] w basr=0x10 csr=0x95 at start=3328
> [ 3650.071961] w basr=0x10 csr=0x95 at start=1280
> [ 3650.827630] w basr=0x10 csr=0x95 at start=1792
> [ 3651.827011] w basr=0x10 csr=0x95 at start=2816
> [ 3652.559984] w basr=0x10 csr=0x95 at start=2816
> [ 3653.203566] w basr=0x10 csr=0x95 at start=3328
> [ 3653.594376] w basr=0x10 csr=0x95 at start=1280
> [ 3653.903437] w basr=0x10 csr=0x95 at start=3840
> [ 3654.305753] w basr=0x10 csr=0x95 at start=1792
> [ 3654.676009] w basr=0x10 csr=0x95 at start=2304
> [ 3655.367686] w basr=0x10 csr=0x95 at start=2816
> [ 3655.733854] w 

[PATCH 1/1] fnic:correct speed display and add support for 25,40 and 100G

2017-06-26 Thread Satish Kharat
Setting speed based on the vinc device parameter read during
linkup. Also adding support to display 25,40 and 100G

Signed-off-by: Satish Kharat 
Signed-off-by: Sesidhar Baddela 
---
 drivers/scsi/fnic/fnic_fcs.c  | 24 
 drivers/scsi/fnic/fnic_io.h   |  9 +
 drivers/scsi/fnic/fnic_main.c | 14 --
 3 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
index 245dcd9..d212eb5 100644
--- a/drivers/scsi/fnic/fnic_fcs.c
+++ b/drivers/scsi/fnic/fnic_fcs.c
@@ -65,6 +65,30 @@ void fnic_handle_link(struct work_struct *work)
fnic->link_status = vnic_dev_link_status(fnic->vdev);
fnic->link_down_cnt = vnic_dev_link_down_cnt(fnic->vdev);
 
+   switch (vnic_dev_port_speed(fnic->vdev)) {
+   case DCEM_PORTSPEED_10G:
+   fc_host_speed(fnic->lport->host)   = FC_PORTSPEED_10GBIT;
+   fnic->lport->link_supported_speeds = FC_PORTSPEED_10GBIT;
+   break;
+   case DCEM_PORTSPEED_25G:
+   fc_host_speed(fnic->lport->host)   = FC_PORTSPEED_25GBIT;
+   fnic->lport->link_supported_speeds = FC_PORTSPEED_25GBIT;
+   break;
+   case DCEM_PORTSPEED_40G:
+   case DCEM_PORTSPEED_4x10G:
+   fc_host_speed(fnic->lport->host)   = FC_PORTSPEED_40GBIT;
+   fnic->lport->link_supported_speeds = FC_PORTSPEED_40GBIT;
+   break;
+   case DCEM_PORTSPEED_100G:
+   fc_host_speed(fnic->lport->host)   = FC_PORTSPEED_100GBIT;
+   fnic->lport->link_supported_speeds = FC_PORTSPEED_100GBIT;
+   break;
+   default:
+   fc_host_speed(fnic->lport->host)   = FC_PORTSPEED_UNKNOWN;
+   fnic->lport->link_supported_speeds = FC_PORTSPEED_UNKNOWN;
+   break;
+   }
+
if (old_link_status == fnic->link_status) {
if (!fnic->link_status) {
/* DOWN -> DOWN */
diff --git a/drivers/scsi/fnic/fnic_io.h b/drivers/scsi/fnic/fnic_io.h
index c35b8f1..e0bc659 100644
--- a/drivers/scsi/fnic/fnic_io.h
+++ b/drivers/scsi/fnic/fnic_io.h
@@ -66,4 +66,13 @@ struct fnic_io_req {
struct completion *dr_done; /* completion for device reset */
 };
 
+enum fnic_port_speeds {
+   DCEM_PORTSPEED_NONE = 0,
+   DCEM_PORTSPEED_1G= 1000,
+   DCEM_PORTSPEED_10G   = 1,
+   DCEM_PORTSPEED_40G   = 4,
+   DCEM_PORTSPEED_4x10G = 41000,
+   DCEM_PORTSPEED_25G   = 25000,
+   DCEM_PORTSPEED_100G  = 10,
+};
 #endif /* _FNIC_IO_H_ */
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index ba58b79..aacadbf 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -176,11 +176,21 @@ static void fnic_get_host_speed(struct Scsi_Host *shost)
 
/* Add in other values as they get defined in fw */
switch (port_speed) {
-   case 1:
+   case DCEM_PORTSPEED_10G:
fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
break;
+   case DCEM_PORTSPEED_25G:
+   fc_host_speed(shost) = FC_PORTSPEED_25GBIT;
+   break;
+   case DCEM_PORTSPEED_40G:
+   case DCEM_PORTSPEED_4x10G:
+   fc_host_speed(shost) = FC_PORTSPEED_40GBIT;
+   break;
+   case DCEM_PORTSPEED_100G:
+   fc_host_speed(shost) = FC_PORTSPEED_100GBIT;
+   break;
default:
-   fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
+   fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
break;
}
 }
-- 
2.7.4



[PATCH 1/1] fnic: Zero io_cmpl_skip on fw reset completion

2017-06-26 Thread Satish Kharat
io_cmpl_skip keep track of number of completions to skip when
stats are reset. If a fw_reset happens immediately after stats
reset it could put it out of sync so need to reset io_cmpl_skip
when fw reset is completed.

Signed-off-by: Satish Kharat 
Signed-off-by: Sesidhar Baddela 
---
 drivers/scsi/fnic/fnic_scsi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index d048f3b..beea14c 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -633,6 +633,7 @@ static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic 
*fnic,
 
atomic64_set(>fnic_stats.fw_stats.active_fw_reqs, 0);
atomic64_set(>fnic_stats.io_stats.active_ios, 0);
+   atomic64_set(>io_cmpl_skip, 0);
 
spin_lock_irqsave(>fnic_lock, flags);
 
-- 
2.7.4



[PATCH 1/1] fnic:added timestamp reporting in fnic debug stats

2017-06-26 Thread Satish Kharat
Added the timestamps for
1. current timestamp
2. last fnic stats read timestamp
3. last fnic stats reset timestamp
and the deltas since last stats read and last reset in fnic stats.
fnic stats uses debugfs

Signed-off-by: Sesidhar Baddela 
Signed-off-by: Satish Kharat 
---
 drivers/scsi/fnic/fnic_debugfs.c |  1 +
 drivers/scsi/fnic/fnic_stats.h   |  7 +++
 drivers/scsi/fnic/fnic_trace.c   | 24 
 3 files changed, 32 insertions(+)

diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c
index d6498fa..5e3d909 100644
--- a/drivers/scsi/fnic/fnic_debugfs.c
+++ b/drivers/scsi/fnic/fnic_debugfs.c
@@ -632,6 +632,7 @@ static ssize_t fnic_reset_stats_write(struct file *file,
sizeof(struct io_path_stats) - sizeof(u64));
memset(fw_stats_p+1, 0,
sizeof(struct fw_stats) - sizeof(u64));
+   getnstimeofday(>stats_timestamps.last_reset_time);
}
 
(*ppos)++;
diff --git a/drivers/scsi/fnic/fnic_stats.h b/drivers/scsi/fnic/fnic_stats.h
index 88c73cc..e007fee 100644
--- a/drivers/scsi/fnic/fnic_stats.h
+++ b/drivers/scsi/fnic/fnic_stats.h
@@ -16,6 +16,12 @@
  */
 #ifndef _FNIC_STATS_H_
 #define _FNIC_STATS_H_
+
+struct stats_timestamps {
+   struct timespec last_reset_time;
+   struct timespec last_read_time;
+};
+
 struct io_path_stats {
atomic64_t active_ios;
atomic64_t max_active_ios;
@@ -110,6 +116,7 @@ struct misc_stats {
 };
 
 struct fnic_stats {
+   struct stats_timestamps stats_timestamps;
struct io_path_stats io_stats;
struct abort_stats abts_stats;
struct terminate_stats term_stats;
diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c
index b5ac538..4826f59 100644
--- a/drivers/scsi/fnic/fnic_trace.c
+++ b/drivers/scsi/fnic/fnic_trace.c
@@ -219,7 +219,31 @@ int fnic_get_stats_data(struct stats_debug_info *debug,
int buf_size = debug->buf_size;
struct timespec val1, val2;
 
+   getnstimeofday();
len = snprintf(debug->debug_buffer + len, buf_size - len,
+   "--\n"
+"\t\tTime\n"
+   "--\n");
+
+   len += snprintf(debug->debug_buffer + len, buf_size - len,
+   "Current time :  [%ld:%ld]\n"
+   "Last stats reset time:  [%ld:%ld]\n"
+   "Last stats read time:   [%ld:%ld]\n"
+   "delta since last reset: [%ld:%ld]\n"
+   "delta since last read:  [%ld:%ld]\n",
+   val1.tv_sec, val1.tv_nsec,
+   stats->stats_timestamps.last_reset_time.tv_sec,
+   stats->stats_timestamps.last_reset_time.tv_nsec,
+   stats->stats_timestamps.last_read_time.tv_sec,
+   stats->stats_timestamps.last_read_time.tv_nsec,
+   timespec_sub(val1, stats->stats_timestamps.last_reset_time).tv_sec,
+   timespec_sub(val1, stats->stats_timestamps.last_reset_time).tv_nsec,
+   timespec_sub(val1, stats->stats_timestamps.last_read_time).tv_sec,
+   timespec_sub(val1, stats->stats_timestamps.last_read_time).tv_nsec);
+
+   stats->stats_timestamps.last_read_time = val1;
+
+   len += snprintf(debug->debug_buffer + len, buf_size - len,
  "--\n"
  "\t\tIO Statistics\n"
  "--\n");
-- 
2.7.4



[PATCH 1/1] fnic:changing queue command to return result DID_IMM_RETRY when rport is init

2017-06-26 Thread Satish Kharat
Currently the queue command returns DID_NO_CONNECT anytime the rport
is not in RPORT_ST_READY state. Changing it to return DID_NO_CONNECT
only when the rport is in RPORT_ST_DELETE state. When the rport is
in one of the init states retruning DID_IMM_RETRY.

Signed-off-by: Sesidhar Baddela 
Signed-off-by: Satish Kharat 
---
 drivers/scsi/fnic/fnic_scsi.c | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index d048f3b..cc48cb8 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -466,15 +466,27 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, 
void (*done)(struct scsi_
}
 
rp = rport->dd_data;
-   if (!rp || rp->rp_state != RPORT_ST_READY) {
+   if (!rp || rp->rp_state == RPORT_ST_DELETE) {
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
-   "returning DID_NO_CONNECT for IO as rport is 
removed\n");
+   "rport 0x%x removed, returning DID_NO_CONNECT\n",
+   rport->port_id);
+
atomic64_inc(_stats->misc_stats.rport_not_ready);
sc->result = DID_NO_CONNECT<<16;
done(sc);
return 0;
}
 
+   if (rp->rp_state != RPORT_ST_READY) {
+   FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+   "rport 0x%x in state 0x%x, returning DID_IMM_RETRY\n",
+   rport->port_id, rp->rp_state);
+
+   sc->result = DID_IMM_RETRY << 16;
+   done(sc);
+   return 0;
+   }
+
if (lp->state != LPORT_ST_READY || !(lp->link_up))
return SCSI_MLQUEUE_HOST_BUSY;
 
-- 
2.7.4



Re: [PATCH 02/11] dma-mapping: replace dmam_alloc_noncoherent with dmam_alloc_attrs

2017-06-26 Thread Tejun Heo
On Mon, Jun 26, 2017 at 12:07:30AM -0700, Christoph Hellwig wrote:
> Tejun, does this look ok to you?

Acked-by: Tejun Heo 

Thanks.

-- 
tejun


Re: [PATCH 01/11] dma-mapping: remove dmam_free_noncoherent

2017-06-26 Thread Tejun Heo
On Mon, Jun 26, 2017 at 12:07:15AM -0700, Christoph Hellwig wrote:
> Tejun, does this look ok to you?

Sure,

Acked-by: Tejun Heo 

Thanks.

-- 
tejun


Re: [PATCH] sd: add support for TCG OPAL self encrypting disks

2017-06-26 Thread Tejun Heo
On Mon, Jun 26, 2017 at 12:43:27PM -0400, Martin K. Petersen wrote:
> 
> Christoph,
> 
> > ping?
> 
> Looks good to me. I'll queue it up for 4.13 as soon as Linus has pulled
> in the ata bits.

I can route it through libata tree w/ your ack if that's more convenient.

Thanks.

-- 
tejun


Re: [PATCH v3 0/4] g_NCR5380: PDMA fixes and cleanup

2017-06-26 Thread Ondrej Zary
On Monday 26 June 2017 09:30:33 Finn Thain wrote:
> Ondrej, would you please test this new series?
>
> Changed since v1:
> - PDMA transfer residual is calculated earlier.
> - End of DMA flag check is now polled (if there is any residual).
>
> Changed since v2:
> - Bail out of transfer loops when Gated IRQ gets asserted.
> - Make udelay conditional on board type.
> - Drop sg_tablesize patch due to performance regression.
>
>
> Finn Thain (1):
>   g_NCR5380: Cleanup comments and whitespace
>
> Ondrej Zary (3):
>   g_NCR5380: Fix PDMA transfer size
>   g_NCR5380: End PDMA transfer correctly on target disconnection
>   g_NCR5380: Re-work PDMA loops
>
>  drivers/scsi/g_NCR5380.c | 239
> +++ 1 file changed, 116
> insertions(+), 123 deletions(-)

No apparent change in behavior, the first write test resulted in:
[  842.830802] sd 2:0:1:0: [sdb] tag#0 53c80 registers not accessible, device 
will be reset
[  842.830802] sd 2:0:1:0: [sdb] tag#0 switching to slow handshake

Checking for IRQ after poll_politely2 does not seem right because we can
miss the buffer ready signal.

According to my tests, buffer ready signal is most important - if there is
any data to read/write, do the transfer. If not, only then check why - maybe
we got an IRQ (that terminated PDMA). Or no IRQ, sometimes the wait for buffer
ready times out - we need to terminate PDMA manually then (reset).

Then 53C80 registers should become ready.

This is a log from writing 230 MB file using my code with some debug
prints, on a NCR53C400. No 53C80 timeouts, only disconnects and some host
buffer timeouts (maybe the drive sometimes just slows down without
disconnecting?)
[ 3378.503828] basr=0x10 csr=0xd5 at start=512
[ 3461.257973] w basr=0x10 csr=0x95 at start=3840
[ 3461.838225] w basr=0x10 csr=0x95 at start=3840
[ 3462.683446] w basr=0x10 csr=0x95 at start=3840
[ 3463.416911] w basr=0x10 csr=0x95 at start=3840
[ 3465.117804] scsi host2: 53C400w: host buffer not ready in time
[ 3465.276375] w basr=0x10 csr=0x95 at start=3328
[ 3466.457701] w basr=0x10 csr=0x95 at start=1792
[ 3467.019643] scsi host2: 53C400w: host buffer not ready in time
[ 3467.619058] scsi host2: 53C400w: host buffer not ready in time
[ 3467.799619] w basr=0x10 csr=0x95 at start=3840
[ 3552.123501] w basr=0x10 csr=0x95 at start=2304
[ 3552.771223] w basr=0x10 csr=0x95 at start=1280
[ 3554.556451] w basr=0x10 csr=0x95 at start=2816
[ 3555.229646] w basr=0x10 csr=0x95 at start=1792
[ 3555.630632] scsi host2: 53C400w: host buffer not ready in time
[ 3555.774560] w basr=0x10 csr=0x95 at start=768
[ 3625.541608] w basr=0x10 csr=0x95 at start=3328
[ 3640.099861] w basr=0x10 csr=0x95 at start=1792
[ 3641.442671] w basr=0x10 csr=0x95 at start=2816
[ 3641.865469] w basr=0x10 csr=0x95 at start=768
[ 3642.939223] w basr=0x10 csr=0x95 at start=1280
[ 3643.356858] w basr=0x10 csr=0x95 at start=3328
[ 3643.701636] w basr=0x10 csr=0x95 at start=3840
[ 3645.153405] w basr=0x10 csr=0x95 at start=2304
[ 3646.135642] w basr=0x10 csr=0x95 at start=1280
[ 3647.007321] w basr=0x10 csr=0x95 at start=2816
[ 3648.065874] w basr=0x10 csr=0x95 at start=3328
[ 3650.071961] w basr=0x10 csr=0x95 at start=1280
[ 3650.827630] w basr=0x10 csr=0x95 at start=1792
[ 3651.827011] w basr=0x10 csr=0x95 at start=2816
[ 3652.559984] w basr=0x10 csr=0x95 at start=2816
[ 3653.203566] w basr=0x10 csr=0x95 at start=3328
[ 3653.594376] w basr=0x10 csr=0x95 at start=1280
[ 3653.903437] w basr=0x10 csr=0x95 at start=3840
[ 3654.305753] w basr=0x10 csr=0x95 at start=1792
[ 3654.676009] w basr=0x10 csr=0x95 at start=2304
[ 3655.367686] w basr=0x10 csr=0x95 at start=2816
[ 3655.733854] w basr=0x10 csr=0x95 at start=768
[ 3656.075023] w basr=0x10 csr=0x95 at start=3328
[ 3656.493046] w basr=0x10 csr=0x95 at start=2816
[ 3657.208089] w basr=0x10 csr=0x95 at start=1280
[ 3657.537223] w basr=0x10 csr=0x95 at start=1280

And this is from reading the file back:
[ 3799.053067] basr=0x10 csr=0xd5 at start=512
[ 3801.056337] basr=0x10 csr=0xd5 at start=3584
[ 3976.323836] scsi host2: 53C400r: host buffer not ready in time
[ 3976.404699] basr=0x10 csr=0xd5 at start=512
[ 3977.800647] basr=0x10 csr=0xd5 at start=512
[ 3979.240611] scsi host2: 53C400r: host buffer not ready in time
[ 3979.320698] basr=0x10 csr=0xd5 at start=512
[ 3980.040220] scsi host2: 53C400r: host buffer not ready in time
[ 3980.096401] basr=0x10 csr=0xd5 at start=512
[ 3980.394854] scsi host2: 53C400r: host buffer not ready in time


-- 
Ondrej Zary


Re: [PATCH] scsi: default to scsi-mq

2017-06-26 Thread Martin Wilck
Hi Bart,

On Mon, 2017-06-26 at 15:31 +, Bart Van Assche wrote:
> On Mon, 2017-06-26 at 12:13 +, Bart Van Assche wrote:
> > On Thu, 2017-06-22 at 17:05 +0200, Martin Wilck wrote:
> > > On Fri, 2017-06-16 at 10:27 +0200, Christoph Hellwig wrote:
> > > > Remove the SCSI_MQ_DEFAULT config option and default to the
> > > > blk-mq
> > > > I/O
> > > > path now that we had plenty of testing, and have I/O schedulers
> > > > for
> > > > blk-mq.  The module option to disable the blk-mq path is kept
> > > > around
> > > > for now.
> > > 
> > > Could you explain why you remove the option entirely rather than
> > > just
> > > changing the default? Some distributions may wish to keep the
> > > ability
> > > to choose the compiled-in default.
> > 
> > Hello Martin,
> > 
> > Would it work for you to keep this patch as a distro-private patch?
> 
> What I meant is: apply this patch to the upstream kernel and keep 
> CONFIG_SCSI_MQ_DEFAULT as a distro-private patch.

First, let me clarify that I was not speaking for SUSE when I asked
this question, just expressing my personal concerns, partly motivated
by my previous employment at a hardware manufacturer.

Of course distro-makers can deal with this in various ways, for example
the way you suggest, although that sounds like a rather painful route
to choose.

I personally find it odd that the compile-time choice goes away while
the run-time choice remains available. I understand what Christoph is
trying to achieve, but if it was up to me, I'd prefer to change the
default and mark the "n" setting as deprecated.

Again, please do not take this as an official SUSE statement. I just
happen to be subscribed to linux-scsi with my suse.com address.

Regards,
Martin

-- 
Dr. Martin Wilck , Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)



Re: [PATCH 00/17] cxlflash: LUN provisioning support and miscellaneous fixes

2017-06-26 Thread Martin K. Petersen

Uma,

> This patch series contains miscellaneous fixes and several
> enhancements such as LUN provisioning support, WS16 unmap and AFU
> debug capabilities.

Applied to 4.13/scsi-queue. Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 07/11] 53c700: switch to dma_alloc_attrs

2017-06-26 Thread Martin K. Petersen

Christoph,

> Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent
> wrapper.

Applied to 4.13/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 06/11] sigwd93: switch to dma_alloc_attrs

2017-06-26 Thread Martin K. Petersen

Christoph,

> Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent
> wrapper.

Fixed driver name typo and applied to 4.13/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: qedi: Remove comparison of u16 idx with zero.

2017-06-26 Thread Martin K. Petersen

Christos,

> Variable idx is defined as u16 thus statement (idx < 0) is always
> false and should be removed.

Applied to 4.13/scsi-queue, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: hpsa: fix spelling mistake: "encrypytion" -> "encryption"

2017-06-26 Thread Martin K. Petersen

Colin,

> Trivial fix to spelling mistake in dev_info message

Applied to 4.13/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: hisi_sas: redefine hisi_sas_phy.phy_type as u32

2017-06-26 Thread Martin K. Petersen

John,

> Element phy_type is a bitmask and it only ever has 2 bits possibly
> set, and it is overkill to define as a u64, so redefine as a u32.
>
> This change resolves static code check complaint that "phy->phy_type
> &= ~PORT_TYPE_SAS;" would unintentionally clear the high 32 bits as
> well.
>
> Structure hisi_sas_phy is also reordered to ensure packing efficiency.

Applied to 4.13/scsi-queue, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] Remove the definition of VLC_SA_RECEIVE_CREDENTIAL

2017-06-26 Thread Martin K. Petersen

Bart,

> The symbolic name VLC_SA_RECEIVE_CREDENTIAL is not used anywhere in
> the kernel. Additionally, since SPC 5 the RECEIVE CREDENTIAL command
> is obsolete. The VLC_SA_RECEIVE_CREDENTIAL definition is misleading
> since it occurs outside the list of other variable length CDB service
> action codes (READ_32, WRITE_32, ...). Hence remove this definition.

Applied to 4.13/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: aacraid: Don't copy uninitialized stack memory to userspace

2017-06-26 Thread Martin K. Petersen

Seth,

> Both aac_send_raw_srb() and aac_get_hba_info() may copy stack
> allocated structs to userspace without initializing all members of
> these structs. Clear out this memory to prevent information leaks.

Applied to 4.13/scsi-queue. Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH v2 1/2] hpsa: limit transfer length to 1MB

2017-06-26 Thread Martin K. Petersen

Don,

> The hpsa firmware will bypass the cache for any request larger than
> 1MB, so we should cap the request size to avoid any performance
> degradation in kernels later than v4.3

I assume you guys are OK with this change?

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] bnx2i: missing error code in bnx2i_ep_connect()

2017-06-26 Thread Martin K. Petersen

Dan,

> If bnx2i_map_ep_dbell_regs() then we accidentally return NULL instead
> of an error pointer.  It results in a NULL dereference in
> iscsi_if_ep_connect().

Applied to 4.13/scsi-queue, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: hptiop: make function hptiop_iop_request_callback_itl static

2017-06-26 Thread Martin K. Petersen

Colin,

> The function hptiop_iop_request_callback_itl does not need to be in
> global scope, so make it static.
>
> Cleans up sparse warning:
> "symbol 'hptiop_iop_request_callback_itl' was not declared. Should it
>  be static?"

Applied to 4.13/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: cxgb4i: assign rxqs in round robin mode

2017-06-26 Thread Martin K. Petersen

Varun,

> Assign rxq to TCP connections in round robin mode to use all available
> rxqs.

Applied to 4.13/scsi-queue. Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: fix typos and grammar in comments of scsi_transport_fc.c

2017-06-26 Thread Martin K. Petersen

Tyrel,

Applied to 4.13/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] lpfc: fix refcount error on node list

2017-06-26 Thread Martin K. Petersen

James,

> A change in remote port removal introduced a spurious put which can
> cause a premature structure teardown. The affects were most notable
> when the driver attempted to unload as a null pointer would be hit.
>
> Fix by removing the unnecessary put.

Applied to 4.13/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] lpfc: Fix nvme io stoppage after link bounce

2017-06-26 Thread Martin K. Petersen

James,

> On link down, transport is calling driver to abort outstanding ios.
> Driver erroneously rejects the abort if the port indicates it isn't
> logged in - which will be the case after the link down. Thus, the io
> can't clean up. This prevents reconnection at the transport level.
>
> Fix by allowing abort to proceed.

Applied to 4.13/scsi-queue, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] virtio_scsi: let host do exception handling

2017-06-26 Thread Martin K. Petersen

Paolo,

> virtio_scsi tries to do exception handling after the default 30
> seconds timeout expires.  However, it's better to let the host control
> the timeout, otherwise with a heavy I/O load it is likely that an
> abort will also timeout.  This leads to fatal errors like filesystems
> going offline.
>
> Disable the 'sd' timeout and allow the host to do exception handling,
> following the precedent of the storvsc driver.

Applied to 4.13/scsi-queue. Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] qla2xxx: don't include

2017-06-26 Thread Martin K. Petersen

Johannes,

> There's no need to use the static UTS_RELEASE string, since
> utsname()->release contains the same.
>
> This avoids rebuilding this file for every change of the
> release string.

Applied to 4.13/scsi-queue, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH resend] scsi: fc: drop residual tsk_mgmt_response and it_nexus_response

2017-06-26 Thread Martin K. Petersen

Kefeng,

> After commit 556e26a70b64 ("scsi: remove tsk_mgmt_response and
> it_nexus_response transport methods"), the target driver support was
> removed totally. Drop the residua.

Applied to 4.13/scsi-queue, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: csiostor: update module version

2017-06-26 Thread Martin K. Petersen

Varun,

> Add -ko to the module version similar to module version of other
> Chelsio drivers.

Applied to 4.13/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 1/1] qedi: Add support for offload iSCSI Boot

2017-06-26 Thread Martin K. Petersen

Nilesh,

> This patch adds support for offload iSCSI boot (Boot from SAN
> over iSCSI offload).
>
> The dependent qed patches for this support are,
> - qed: Support NVM-image reading API
> - qed: Share additional information with qedf

You had tagged this for 4.12/scsi-fixes but the above patches are not
present in 4.12. So I presume this would be a candidate for a second
stage 4.13 merge?

Patch looks OK to me, but please resubmit with a slightly more verbose
description of the changes and how they work.

Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 2/2] scsi_dh_alua: remove synchronous STPG support

2017-06-26 Thread Martin K. Petersen

Christoph,

> Since 9c58b395 ("scsi: scsi_devinfo: remove synchronous ALUA for
> NETAPP devices") this code is unused.

Applied to 4.13/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] sd: add support for TCG OPAL self encrypting disks

2017-06-26 Thread Martin K. Petersen

Christoph,

> ping?

Looks good to me. I'll queue it up for 4.13 as soon as Linus has pulled
in the ata bits.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 1/2] scsi: remove various unused blist flags

2017-06-26 Thread Martin K. Petersen

Christoph,

Applied to 4.13/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


[PATCH 6/7] bnx2fc: Make rport_terminate_io callback a NOOP.

2017-06-26 Thread Dupuis, Chad
Do not call the stock libfc terminate rport i/o handler so we won't reset
the libfc exchange manager and kill any outstanding discovery requests.

Signed-off-by: Chad Dupuis 
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 31aeb02..7dfe709 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -2573,6 +2573,11 @@ static void bnx2fc_ulp_exit(struct cnic_dev *dev)
bnx2fc_hba_destroy(hba);
 }
 
+static void bnx2fc_rport_terminate_io(struct fc_rport *rport)
+{
+   /* This is a no-op */
+}
+
 /**
  * bnx2fc_fcoe_reset - Resets the fcoe
  *
@@ -2909,7 +2914,7 @@ static void __exit bnx2fc_mod_exit(void)
 
.issue_fc_host_lip = bnx2fc_fcoe_reset,
 
-   .terminate_rport_io = fc_rport_terminate_io,
+   .terminate_rport_io = bnx2fc_rport_terminate_io,
 
.vport_create = bnx2fc_vport_create,
.vport_delete = bnx2fc_vport_destroy,
-- 
1.8.5.6



[PATCH 7/7] bnx2fc: Update version number to 2.11.8.

2017-06-26 Thread Dupuis, Chad
Signed-off-by: Chad Dupuis 
---
 drivers/scsi/bnx2fc/bnx2fc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h
index c192840..7e007e1 100644
--- a/drivers/scsi/bnx2fc/bnx2fc.h
+++ b/drivers/scsi/bnx2fc/bnx2fc.h
@@ -66,7 +66,7 @@
 #include "bnx2fc_constants.h"
 
 #define BNX2FC_NAME"bnx2fc"
-#define BNX2FC_VERSION "2.10.3"
+#define BNX2FC_VERSION "2.11.8"
 
 #define PFX"bnx2fc: "
 
-- 
1.8.5.6



[PATCH 5/7] bnx2fc: If IO is still in cleanup then do not return to SCSI layer.

2017-06-26 Thread Dupuis, Chad
In eh_abort, driver is calling scsi->done() for a IO for which cleanup is
pending. As the IO is outstanding with the firmware, it may do DMA
associated with the IO. This may lead to heap corruption.

Do not complete the IO for which cleanup is still pending. Return failure
from eh_abort and let the SCSI-ml retry the IO.

Signed-off-by: Chad Dupuis 
---
 drivers/scsi/bnx2fc/bnx2fc_io.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 6e8b9be..5b6153f 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -1167,16 +1167,11 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd)
printk(KERN_ERR PFX "eh_abort: io_req (xid = 0x%x) "
"not on active_q\n", io_req->xid);
/*
-* This condition can happen only due to the FW bug,
-* where we do not receive cleanup response from
-* the FW. Handle this case gracefully by erroring
-* back the IO request to SCSI-ml
+* The IO is still with the FW.
+* Return failure and let SCSI-ml retry eh_abort.
 */
-   bnx2fc_scsi_done(io_req, DID_ABORT);
-
-   kref_put(_req->refcount, bnx2fc_cmd_release);
spin_unlock_bh(>tgt_lock);
-   return SUCCESS;
+   return FAILED;
}
 
/*
-- 
1.8.5.6



[PATCH 4/7] bnx2fc: Adjust bnx2fc_npiv_create_vports for WWNNs from NVRAM that are zero.

2017-06-26 Thread Dupuis, Chad
Some vports addresses stored in NVRAM may have zero for the WWNN.  Adjust
the WWNN that we'll use to be the same as the WWPN.

Signed-off-by: Chad Dupuis 
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index d9f9c56..31aeb02 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -2139,6 +2139,9 @@ static uint bnx2fc_npiv_create_vports(struct fc_lport 
*lport,
 {
struct fc_vport_identifiers vpid;
uint i, created = 0;
+   u64 wwnn = 0;
+   char wwpn_str[32];
+   char wwnn_str[32];
 
if (npiv_tbl->count > MAX_NPIV_ENTRIES) {
BNX2FC_HBA_DBG(lport, "Exceeded count max of npiv table\n");
@@ -2157,11 +2160,23 @@ static uint bnx2fc_npiv_create_vports(struct fc_lport 
*lport,
vpid.disable = false;
 
for (i = 0; i < npiv_tbl->count; i++) {
-   vpid.node_name = wwn_to_u64(npiv_tbl->wwnn[i]);
+   wwnn = wwn_to_u64(npiv_tbl->wwnn[i]);
+   if (wwnn == 0) {
+   /*
+* If we get a 0 element from for the WWNN then assume
+* the WWNN should be the same as the physical port.
+*/
+   wwnn = lport->wwnn;
+   }
+   vpid.node_name = wwnn;
vpid.port_name = wwn_to_u64(npiv_tbl->wwpn[i]);
scnprintf(vpid.symbolic_name, sizeof(vpid.symbolic_name),
"NPIV[%u]:%016llx-%016llx",
created, vpid.port_name, vpid.node_name);
+   fcoe_wwn_to_str(vpid.node_name, wwnn_str, sizeof(wwnn_str));
+   fcoe_wwn_to_str(vpid.port_name, wwpn_str, sizeof(wwpn_str));
+   BNX2FC_HBA_DBG(lport, "Creating vport %s:%s.\n", wwnn_str,
+   wwpn_str);
if (fc_vport_create(lport->host, 0, ))
created++;
else
-- 
1.8.5.6



[PATCH 1/7] bnx2fc: Add filters to the non-offload FCoE receive path.

2017-06-26 Thread Dupuis, Chad
Add the following filters to bnx2fc_recv_frame():

1. Filter out invalid packets
- eth->dest_mac[3] matches FC frame's D_ID
2. Filter out packets that are not from our connected target
- In FIP_ST_ENABLED mode
- eth->src_mac matches fcoe_ctlr->dest_addr
3. Filter out packets where if d_id of the packet doesn't belong to
   the device when one is already assigned a port_id, only then this
   packet is dropped

Signed-off-by: Chad Dupuis 
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 35 ++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index b025ee5..2025510 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -522,10 +522,12 @@ static void bnx2fc_recv_frame(struct sk_buff *skb)
struct fcoe_crc_eof crc_eof;
struct fc_frame *fp;
struct fc_lport *vn_port;
-   struct fcoe_port *port;
+   struct fcoe_port *port, *phys_port;
u8 *mac = NULL;
u8 *dest_mac = NULL;
struct fcoe_hdr *hp;
+   struct bnx2fc_interface *interface;
+   struct fcoe_ctlr *ctlr;
 
fr = fcoe_dev_from_skb(skb);
lport = fr->fr_dev;
@@ -561,8 +563,19 @@ static void bnx2fc_recv_frame(struct sk_buff *skb)
return;
}
 
+   phys_port = lport_priv(lport);
+   interface = phys_port->priv;
+   ctlr = bnx2fc_to_ctlr(interface);
+
fh = fc_frame_header_get(fp);
 
+   if (ntoh24(_mac[3]) != ntoh24(fh->fh_d_id)) {
+   BNX2FC_HBA_DBG(lport, "FC frame d_id mismatch with MAC %pM.\n",
+   dest_mac);
+   kfree_skb(skb);
+   return;
+   }
+
vn_port = fc_vport_id_lookup(lport, ntoh24(fh->fh_d_id));
if (vn_port) {
port = lport_priv(vn_port);
@@ -572,6 +585,14 @@ static void bnx2fc_recv_frame(struct sk_buff *skb)
return;
}
}
+   if (ctlr->state) {
+   if (!ether_addr_equal(mac, ctlr->dest_addr)) {
+   BNX2FC_HBA_DBG(lport, "Wrong source address: mac:%pM 
dest_addr:%pM.\n",
+   mac, ctlr->dest_addr);
+   kfree_skb(skb);
+   return;
+   }
+   }
if (fh->fh_r_ctl == FC_RCTL_DD_SOL_DATA &&
fh->fh_type == FC_TYPE_FCP) {
/* Drop FCP data. We dont this in L2 path */
@@ -597,6 +618,18 @@ static void bnx2fc_recv_frame(struct sk_buff *skb)
return;
}
 
+   /*
+* If the destination ID from the frame header does not match what we
+* have on record for lport and the search for a NPIV port came up
+* empty then this is not addressed to our port so simply drop it.
+*/
+   if (lport->port_id != ntoh24(fh->fh_d_id) && !vn_port) {
+   BNX2FC_HBA_DBG(lport, "Dropping frame due to destination 
mismatch: lport->port_id=%x fh->d_id=%x.\n",
+   lport->port_id, ntoh24(fh->fh_d_id));
+   kfree_skb(skb);
+   return;
+   }
+
stats = per_cpu_ptr(lport->stats, smp_processor_id());
stats->RxFrames++;
stats->RxWords += fr_len / FCOE_WORD_TO_BYTE;
-- 
1.8.5.6



[PATCH 3/7] bnx2fc: Update copyright for 2017.

2017-06-26 Thread Dupuis, Chad
Signed-off-by: Chad Dupuis 
---
 drivers/scsi/bnx2fc/57xx_hsi_bnx2fc.h  | 3 ++-
 drivers/scsi/bnx2fc/bnx2fc.h   | 3 ++-
 drivers/scsi/bnx2fc/bnx2fc_constants.h | 3 ++-
 drivers/scsi/bnx2fc/bnx2fc_debug.c | 3 ++-
 drivers/scsi/bnx2fc/bnx2fc_debug.h | 3 ++-
 drivers/scsi/bnx2fc/bnx2fc_els.c   | 3 ++-
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c  | 3 ++-
 drivers/scsi/bnx2fc/bnx2fc_hwi.c   | 3 ++-
 drivers/scsi/bnx2fc/bnx2fc_io.c| 3 ++-
 drivers/scsi/bnx2fc/bnx2fc_tgt.c   | 3 ++-
 10 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/bnx2fc/57xx_hsi_bnx2fc.h 
b/drivers/scsi/bnx2fc/57xx_hsi_bnx2fc.h
index ac1c0b6..e4469df9 100644
--- a/drivers/scsi/bnx2fc/57xx_hsi_bnx2fc.h
+++ b/drivers/scsi/bnx2fc/57xx_hsi_bnx2fc.h
@@ -3,7 +3,8 @@
  * session resources such as connection id and qp resources.
  *
  * Copyright (c) 2008-2013 Broadcom Corporation
- * Copyright (c) 2014-2015 QLogic Corporation
+ * Copyright (c) 2014-2016 QLogic Corporation
+ * Copyright (c) 2016-2017 Cavium Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h
index 1f424e4..c192840 100644
--- a/drivers/scsi/bnx2fc/bnx2fc.h
+++ b/drivers/scsi/bnx2fc/bnx2fc.h
@@ -1,7 +1,8 @@
 /* bnx2fc.h: QLogic Linux FCoE offload driver.
  *
  * Copyright (c) 2008-2013 Broadcom Corporation
- * Copyright (c) 2014-2015 QLogic Corporation
+ * Copyright (c) 2014-2016 QLogic Corporation
+ * Copyright (c) 2016-2017 Cavium Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/bnx2fc/bnx2fc_constants.h 
b/drivers/scsi/bnx2fc/bnx2fc_constants.h
index 5b20efb..9ed1503 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_constants.h
+++ b/drivers/scsi/bnx2fc/bnx2fc_constants.h
@@ -3,7 +3,8 @@
  * session resources such as connection id and qp resources.
  *
  * Copyright (c) 2008-2013 Broadcom Corporation
- * Copyright (c) 2014-2015 QLogic Corporation
+ * Copyright (c) 2014-2016 QLogic Corporation
+ * Copyright (c) 2016-2017 Cavium Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/bnx2fc/bnx2fc_debug.c 
b/drivers/scsi/bnx2fc/bnx2fc_debug.c
index c9e0bc7..47ba3ba 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_debug.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_debug.c
@@ -3,7 +3,8 @@
  * session resources such as connection id and qp resources.
  *
  * Copyright (c) 2008-2013 Broadcom Corporation
- * Copyright (c) 2014-2015 QLogic Corporation
+ * Copyright (c) 2014-2016 QLogic Corporation
+ * Copyright (c) 2016-2017 Cavium Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/bnx2fc/bnx2fc_debug.h 
b/drivers/scsi/bnx2fc/bnx2fc_debug.h
index 34fda3e..76717ac 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_debug.h
+++ b/drivers/scsi/bnx2fc/bnx2fc_debug.h
@@ -3,7 +3,8 @@
  * session resources such as connection id and qp resources.
  *
  * Copyright (c) 2008-2013 Broadcom Corporation
- * Copyright (c) 2014-2015 QLogic Corporation
+ * Copyright (c) 2014-2016 QLogic Corporation
+ * Copyright (c) 2016-2017 Cavium Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/bnx2fc/bnx2fc_els.c b/drivers/scsi/bnx2fc/bnx2fc_els.c
index fee12c3..76e65a3 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_els.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_els.c
@@ -4,7 +4,8 @@
  * and responses.
  *
  * Copyright (c) 2008-2013 Broadcom Corporation
- * Copyright (c) 2014-2015 QLogic Corporation
+ * Copyright (c) 2014-2016 QLogic Corporation
+ * Copyright (c) 2016-2017 Cavium Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 2025510..d9f9c56 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -4,7 +4,8 @@
  * FIP/FCoE packets, listen to link events etc.
  *
  * Copyright (c) 2008-2013 Broadcom Corporation
- * Copyright (c) 2014-2015 QLogic Corporation
+ * Copyright (c) 2014-2016 QLogic Corporation
+ * Copyright (c) 2016-2017 Cavium Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/bnx2fc/bnx2fc_hwi.c b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
index 5ff9f89..913c750 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_hwi.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
@@ -3,7 

[PATCH 2/7] bnx2fc: Check for connection offload before sending RRQ.

2017-06-26 Thread Dupuis, Chad
If the connection is not offloaded then the backpointers from the tgt
pointer are undefined.

Signed-off-by: Chad Dupuis 
---
 drivers/scsi/bnx2fc/bnx2fc_els.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_els.c b/drivers/scsi/bnx2fc/bnx2fc_els.c
index 68ca518..fee12c3 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_els.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_els.c
@@ -61,13 +61,20 @@ int bnx2fc_send_rrq(struct bnx2fc_cmd *aborted_io_req)
 
struct fc_els_rrq rrq;
struct bnx2fc_rport *tgt = aborted_io_req->tgt;
-   struct fc_lport *lport = tgt->rdata->local_port;
+   struct fc_lport *lport = NULL;
struct bnx2fc_els_cb_arg *cb_arg = NULL;
-   u32 sid = tgt->sid;
-   u32 r_a_tov = lport->r_a_tov;
+   u32 sid = 0;
+   u32 r_a_tov = 0;
unsigned long start = jiffies;
int rc;
 
+   if (!test_bit(BNX2FC_FLAG_SESSION_READY, >flags))
+   return -EINVAL;
+
+   lport = tgt->rdata->local_port;
+   sid = tgt->sid;
+   r_a_tov = lport->r_a_tov;
+
BNX2FC_ELS_DBG("Sending RRQ orig_xid = 0x%x\n",
   aborted_io_req->xid);
memset(, 0, sizeof(rrq));
-- 
1.8.5.6



[PATCH 0/7] bnx2fc: Update driver to version 2.11.8.

2017-06-26 Thread Dupuis, Chad
Hi Martin,

Please apply the following patches at your earliest convenience.

Thanks,
Chad

Dupuis, Chad (7):
  bnx2fc: Add filters to the non-offload FCoE receive path.
  bnx2fc: Check for connection offload before sending RRQ.
  bnx2fc: Update copyright for 2017.
  bnx2fc: Adjust bnx2fc_npiv_create_vports for WWNNs from NVRAM that are
zero.
  bnx2fc: If IO is still in cleanup then do not return to SCSI layer.
  bnx2fc: Make rport_terminate_io callback a NOOP.
  bnx2fc: Update version number to 2.11.8.

 drivers/scsi/bnx2fc/57xx_hsi_bnx2fc.h  |  3 +-
 drivers/scsi/bnx2fc/bnx2fc.h   |  5 +--
 drivers/scsi/bnx2fc/bnx2fc_constants.h |  3 +-
 drivers/scsi/bnx2fc/bnx2fc_debug.c |  3 +-
 drivers/scsi/bnx2fc/bnx2fc_debug.h |  3 +-
 drivers/scsi/bnx2fc/bnx2fc_els.c   | 16 ++---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c  | 62 +++---
 drivers/scsi/bnx2fc/bnx2fc_hwi.c   |  3 +-
 drivers/scsi/bnx2fc/bnx2fc_io.c| 14 +++-
 drivers/scsi/bnx2fc/bnx2fc_tgt.c   |  3 +-
 10 files changed, 90 insertions(+), 25 deletions(-)

-- 
1.8.5.6



Re: [PATCH] scsi: default to scsi-mq

2017-06-26 Thread Bart Van Assche
On Mon, 2017-06-26 at 12:13 +, Bart Van Assche wrote:
> On Thu, 2017-06-22 at 17:05 +0200, Martin Wilck wrote:
> > On Fri, 2017-06-16 at 10:27 +0200, Christoph Hellwig wrote:
> > > Remove the SCSI_MQ_DEFAULT config option and default to the blk-mq
> > > I/O
> > > path now that we had plenty of testing, and have I/O schedulers for
> > > blk-mq.  The module option to disable the blk-mq path is kept around
> > > for now.
> > 
> > Could you explain why you remove the option entirely rather than just
> > changing the default? Some distributions may wish to keep the ability
> > to choose the compiled-in default.
> 
> Hello Martin,
> 
> Would it work for you to keep this patch as a distro-private patch?

What I meant is: apply this patch to the upstream kernel and keep 
CONFIG_SCSI_MQ_DEFAULT as a distro-private patch.

Bart.

Re: enclosure: fix sysfs symlinks creation when using multipath

2017-06-26 Thread Douglas Miller

On 06/20/2017 06:38 AM, Maurizio Lombardi wrote:


Dne 16.6.2017 v 18:08 Douglas Miller napsal(a):

Just to respond to James' question on the cause. What I observed was a race 
condition between udevd (ses_init()) and a worker thread (do_scan_async()),
where the worker thread is creating the directories that are the target of the 
symlinks being created by udevd.
Something was happening when udevd caught up with the worker thread (so the 
target directory did not exist) and it seemed the worker thread either got 
preempted or
else just could not stay ahead of udevd. This means that udevd started failing 
to create symlinks even though the worker thread eventually got them all 
created.
I did observe what appeared to be preemption, as the creation of directories 
stopped until udevd finished failing all the (rest of the) symlinks.
Although there may have been other explanations for what I saw.

I am able to pass my testing with this patch. I don't see an official submit of 
this patch, but will respond to it when I see one.

Thanks Douglas for testing it, I will resubmit the patch if no one has any 
objections.

Maurizio.

I did not see any additional comments, and no objections. Is it time to 
submit the new patch?


Thanks,
Doug



[PATCH] scsi: hpsa: fix spelling mistake: "encrypytion" -> "encryption"

2017-06-26 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake in dev_info message

Signed-off-by: Colin Ian King 
---
 drivers/scsi/hpsa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 9934947073e6..8914eab84337 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3127,7 +3127,7 @@ static void hpsa_debug_map_buff(struct ctlr_info *h, int 
rc,
le16_to_cpu(map_buff->layout_map_count));
dev_info(>pdev->dev, "flags = 0x%x\n",
le16_to_cpu(map_buff->flags));
-   dev_info(>pdev->dev, "encrypytion = %s\n",
+   dev_info(>pdev->dev, "encryption = %s\n",
le16_to_cpu(map_buff->flags) &
RAID_MAP_FLAG_ENCRYPT_ON ?  "ON" : "OFF");
dev_info(>pdev->dev, "dekindex = %u\n",
-- 
2.11.0



Re: [PATCH] scsi: default to scsi-mq

2017-06-26 Thread Bart Van Assche
On Thu, 2017-06-22 at 17:05 +0200, Martin Wilck wrote:
> On Fri, 2017-06-16 at 10:27 +0200, Christoph Hellwig wrote:
> > Remove the SCSI_MQ_DEFAULT config option and default to the blk-mq
> > I/O
> > path now that we had plenty of testing, and have I/O schedulers for
> > blk-mq.  The module option to disable the blk-mq path is kept around
> > for now.
> 
> Could you explain why you remove the option entirely rather than just
> changing the default? Some distributions may wish to keep the ability
> to choose the compiled-in default.

Hello Martin,

Would it work for you to keep this patch as a distro-private patch?

Bart.

[Bug 188061] On quad port QLE2564 can't add in target only 2 ports

2017-06-26 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=188061

--- Comment #10 from Anthony (anthony.blood...@gmail.com) ---
Problem does not change with kernel updates. Any news about firmware?

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


Re: [PATCH] sd: add support for TCG OPAL self encrypting disks

2017-06-26 Thread Christoph Hellwig
ping?

On Mon, Jun 19, 2017 at 02:26:46PM +0200, Christoph Hellwig wrote:
> Just wire up the generic TCG OPAL infrastructure to the SCSI disk driver
> and the Security In/Out commands.
> 
> Note that I don't know of any actual SCSI disks that do support TCG OPAL,
> but this is required to support ATA disks through libata.
> 
> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/ata/libata-scsi.c  |  3 +++
>  drivers/scsi/sd.c  | 53 
> +-
>  drivers/scsi/sd.h  |  2 ++
>  include/scsi/scsi_device.h |  1 +
>  4 files changed, 58 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index 0f788ad6f2f6..3e5ca2e894a4 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -1321,6 +1321,9 @@ static int ata_scsi_dev_config(struct scsi_device *sdev,
>  
>   blk_queue_flush_queueable(q, false);
>  
> + if (dev->flags & ATA_DFLAG_TRUSTED)
> + sdev->security_supported = 1;
> +
>   dev->sdev = sdev;
>   return 0;
>  }
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index f9d1432d7cc5..5d32fd7d3a3e 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -50,6 +50,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -643,6 +644,26 @@ static void scsi_disk_put(struct scsi_disk *sdkp)
>   mutex_unlock(_ref_mutex);
>  }
>  
> +#ifdef CONFIG_BLK_SED_OPAL
> +static int sd_sec_submit(void *data, u16 spsp, u8 secp, void *buffer,
> + size_t len, bool send)
> +{
> + struct scsi_device *sdev = data;
> + u8 cdb[12] = { 0, };
> + int ret;
> +
> + cdb[0] = send ? SECURITY_PROTOCOL_OUT : SECURITY_PROTOCOL_IN;
> + cdb[1] = secp;
> + put_unaligned_be16(spsp, [2]);
> + put_unaligned_be32(len, [6]);
> +
> + ret = scsi_execute_req(sdev, cdb,
> + send ? DMA_TO_DEVICE : DMA_FROM_DEVICE,
> + buffer, len, NULL, SD_TIMEOUT, SD_MAX_RETRIES, NULL);
> + return ret <= 0 ? ret : -EIO;
> +}
> +#endif /* CONFIG_BLK_SED_OPAL */
> +
>  static unsigned char sd_setup_protect_cmnd(struct scsi_cmnd *scmd,
>  unsigned int dix, unsigned int dif)
>  {
> @@ -1439,6 +1460,9 @@ static int sd_ioctl(struct block_device *bdev, fmode_t 
> mode,
>   if (error)
>   goto out;
>  
> + if (is_sed_ioctl(cmd))
> + return sed_ioctl(sdkp->opal_dev, cmd, p);
> +
>   /*
>* Send SCSI addressing ioctls directly to mid level, send other
>* ioctls to block level and then onto mid level if they can't be
> @@ -2994,6 +3018,20 @@ static void sd_read_write_same(struct scsi_disk *sdkp, 
> unsigned char *buffer)
>   sdkp->ws10 = 1;
>  }
>  
> +static void sd_read_security(struct scsi_disk *sdkp, unsigned char *buffer)
> +{
> + struct scsi_device *sdev = sdkp->device;
> +
> + if (!sdev->security_supported)
> + return;
> +
> + if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE,
> + SECURITY_PROTOCOL_IN) == 1 &&
> + scsi_report_opcode(sdev, buffer, SD_BUF_SIZE,
> + SECURITY_PROTOCOL_OUT) == 1)
> + sdkp->security = 1;
> +}
> +
>  /**
>   *   sd_revalidate_disk - called the first time a new disk is seen,
>   *   performs disk spin up, read_capacity, etc.
> @@ -3047,6 +3085,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
>   sd_read_cache_type(sdkp, buffer);
>   sd_read_app_tag_own(sdkp, buffer);
>   sd_read_write_same(sdkp, buffer);
> + sd_read_security(sdkp, buffer);
>   }
>  
>   sdkp->first_scan = 0;
> @@ -3207,6 +3246,12 @@ static void sd_probe_async(void *data, async_cookie_t 
> cookie)
>  
>   sd_revalidate_disk(gd);
>  
> + if (sdkp->security) {
> + sdkp->opal_dev = init_opal_dev(sdp, _sec_submit);
> + if (sdkp->opal_dev)
> + sd_printk(KERN_NOTICE, sdkp, "supports TCG Opal\n");
> + }
> +
>   sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
> sdp->removable ? "removable " : "");
>   scsi_autopm_put_device(sdp);
> @@ -3356,6 +3401,8 @@ static int sd_remove(struct device *dev)
>  
>   sd_zbc_remove(sdkp);
>  
> + free_opal_dev(sdkp->opal_dev);
> +
>   blk_register_region(devt, SD_MINORS, NULL,
>   sd_default_probe, NULL, NULL);
>  
> @@ -3497,6 +3544,7 @@ static int sd_suspend_runtime(struct device *dev)
>  static int sd_resume(struct device *dev)
>  {
>   struct scsi_disk *sdkp = dev_get_drvdata(dev);
> + int ret;
>  
>   if (!sdkp)  /* E.g.: runtime resume at the start of sd_probe() */
>   return 0;
> @@ -3505,7 +3553,10 @@ static int sd_resume(struct device *dev)
>   return 0;
>  
>   sd_printk(KERN_NOTICE, sdkp, "Starting disk\n");
> - return 

[PATCH] scsi: hisi_sas: redefine hisi_sas_phy.phy_type as u32

2017-06-26 Thread John Garry
Element phy_type is a bitmask and it only ever has 2
bits possibly set, and it is overkill to define as a u64,
so redefine as a u32.

This change resolves static code check complaint that
"phy->phy_type &= ~PORT_TYPE_SAS;" would
unintentionally clear the high 32 bits as well.

Structure hisi_sas_phy is also reordered to ensure
packing efficiency.

Reported-by: Dan Carpenter 
Signed-off-by: John Garry 

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 4fc2308..22dd48b 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -85,11 +85,11 @@ struct hisi_sas_phy {
struct work_struct  phyup_ws;
u64 port_id; /* from hw */
u64 dev_sas_addr;
-   u64 phy_type;
u64 frame_rcvd_size;
u8  frame_rcvd[32];
u8  phy_attached;
u8  reserved[3];
+   u32 phy_type;
enum sas_linkrate   minimum_linkrate;
enum sas_linkrate   maximum_linkrate;
 };
-- 
1.9.1



Re: [PATCH] scsi: default to scsi-mq

2017-06-26 Thread Christoph Hellwig
On Thu, Jun 22, 2017 at 05:05:33PM +0200, Martin Wilck wrote:
> Hello Christoph,
> 
> On Fri, 2017-06-16 at 10:27 +0200, Christoph Hellwig wrote:
> > Remove the SCSI_MQ_DEFAULT config option and default to the blk-mq
> > I/O
> > path now that we had plenty of testing, and have I/O schedulers for
> > blk-mq.  The module option to disable the blk-mq path is kept around
> > for now.
> 
> Could you explain why you remove the option entirely rather than just
> changing the default? Some distributions may wish to keep the ability
> to choose the compiled-in default.

Because the legacy code will go away, and I want people to prepare for
that.


Re: [PATCH v2 0/5] g_NCR5380: PDMA fixes and cleanup

2017-06-26 Thread Ondrej Zary
On Monday 26 June 2017, Finn Thain wrote:
> On Sun, 25 Jun 2017, Ondrej Zary wrote:
> > It mostly works, but there are some problems:
> >
> > It's not reliable - we continue the data transfer after poll_politely2
> > returns zero but we don't know if it returned because of host buffer
> > being ready of because of an IRQ. So if a device disconnects during
> > write, we continue to fill the buffer and only then find out that wait
> > for 53c80 registers timed out. Then PDMA gets disabled:
> > [ 3458.774251] sd 2:0:1:0: [sdb] tag#0 53c80 registers not accessible,
> > device will be reset [ 3458.774251] sd 2:0:1:0: [sdb] tag#0 switching to
> > slow handshake
>
> Sorry about that. I messed up the Gated-IRQ-is-asserted case when I
> changed the algorithm to avoid adding more polling loops.
>
> > We can just reset and continue with a new PDMA transfer.
>
> We should only reset the 53c400 logic when there is a real failure (like
> no access to 53c80 registers). If a reset is needed to handle normal
> target behaviour (like disconnection during a slow transfer) then we are
> doing something wrong.

The reset is probably the only way to terminate a PDMA transfer.

> > Found no problems with reads. But when this happens during a write, we
> > might have lost some data buffers that we need to transfer again. The
> > chip's PDMA block counter does not seem to be very helpful here -
> > testing shows that either one buffer is missing in the file or is
> > duplicated.
> >
> > That's why my code had separate host buffer ready and IRQ checks. Host
> > buffer first - if it's ready, transfer the data. If not, check for IRQ -
> > if it was an error, rollback 2 buffers (the same if the host buffer is
> > not ready in time).
>
> In v3 of the patch series I've fixed the Gated IRQ logic so the transfer
> loop will terminate early.
>
> > There's also a performance regression on DTC436 - the sg_tablesize limit
> > affects performance badly.
> > Before:
> > # hdparm -t --direct /dev/sdb
> >
> > /dev/sdb:
> >  Timing O_DIRECT disk reads:   4 MB in  3.21 seconds =   1.25 MB/sec
> >
> > Now:
> > # hdparm -t --direct /dev/sdb
> >
> > /dev/sdb:
> >  Timing O_DIRECT disk reads:   4 MB in  4.89 seconds = 837.69 kB/sec
>
> The lost throughput can perhaps be explained by extra kernel-mode CPU
> overhead. Next time maybe check for that with "time hdparm". Anyway, since
> you have a patch, we should try to avoid this regression.

I don't think the CPU is that slow. It probably decreases the SCSI read 
command length and we must wait for the drive to process each command (it 
probably does no read-ahead).

> > We should limit the transfer size instead:
> > --- a/drivers/scsi/g_NCR5380.c
> > +++ b/drivers/scsi/g_NCR5380.c
> > @@ -45,7 +45,8 @@
> > int c400_blk_cnt; \
> > int c400_host_buf; \
> > int io_width; \
> > -   int pdma_residual
> > +   int pdma_residual; \
> > +   int board;
> >
> >  #define NCR5380_dma_xfer_lengeneric_NCR5380_dma_xfer_len
> >  #define NCR5380_dma_recv_setup  generic_NCR5380_pread
> > @@ -247,7 +248,6 @@ static int generic_NCR5380_init_one(struct
> > scsi_host_template *tpnt, case BOARD_DTC3181E:
> > ports = dtc_3181e_ports;
> > magic = ncr_53c400a_magic;
> > -   tpnt->sg_tablesize = 1;
> > break;
> > }
>
> I've dropped my "sg_tablesize = 1" patch from the v3 series.
>
> > @@ -317,6 +317,7 @@ static int generic_NCR5380_init_one(struct
> > scsi_host_template *tpnt, }
> > hostdata = shost_priv(instance);
> >
> > +   hostdata->board = board;
> > hostdata->io = iomem;
> > hostdata->region_size = region_size;
>
> I've added the hostdata->board variable in v3. It looks like we are going
> to need it one way or another.
>
> > @@ -625,6 +626,9 @@ static int generic_NCR5380_dma_xfer_len(struct
> > NCR5380_hostdata *hostdata, /* 53C400 datasheet: non-modulo-128-byte
> > transfers should use PIO */ if (transfersize % 128)
> > transfersize = 0;
> > +   /* Limit transfers to 512B to prevent random write corruption on
> > DTC */ +   if (hostdata->board == BOARD_DTC3181E && transfersize >
> > 512) +   transfersize = 512;
> >
> > return min(transfersize, DMA_MAX_SIZE);
> >  }
> >
> >
> > No data corruption
>
> How did you confirm that? What about a 1024 byte limit? 2048? 4096? Does
> it make any difference?
>
> Do you have any theories that might explain the need for a 512 B limit?

Tested it by copying a large file (230 MB of random data) to a slow Quantum 
240MB HDD, then read it back and compare. No corruption with 512B, corruption 
with anything more.

My theory is that with 512 B size, no disconnect occurs during a transfer 
(because the drive has 512 B sectors).

> My theory about the "read overrun" issue doesn't seem applicable, given
> that this is actually the CMOS version, which has different errata than
> the NMOS version.
>
> The 

Re: [PATCH v2 0/5] g_NCR5380: PDMA fixes and cleanup

2017-06-26 Thread Finn Thain
On Sun, 25 Jun 2017, Ondrej Zary wrote:
> 
> It mostly works, but there are some problems:
> 
> It's not reliable - we continue the data transfer after poll_politely2
> returns zero but we don't know if it returned because of host buffer
> being ready of because of an IRQ. So if a device disconnects during write,
> we continue to fill the buffer and only then find out that wait for
> 53c80 registers timed out. Then PDMA gets disabled:
> [ 3458.774251] sd 2:0:1:0: [sdb] tag#0 53c80 registers not accessible, device 
> will be reset
> [ 3458.774251] sd 2:0:1:0: [sdb] tag#0 switching to slow handshake
> 

Sorry about that. I messed up the Gated-IRQ-is-asserted case when I 
changed the algorithm to avoid adding more polling loops.

> We can just reset and continue with a new PDMA transfer.

We should only reset the 53c400 logic when there is a real failure (like 
no access to 53c80 registers). If a reset is needed to handle normal 
target behaviour (like disconnection during a slow transfer) then we are 
doing something wrong.

> Found no problems with reads. But when this happens during a write, we 
> might have lost some data buffers that we need to transfer again. The 
> chip's PDMA block counter does not seem to be very helpful here - 
> testing shows that either one buffer is missing in the file or is 
> duplicated.
> 
> That's why my code had separate host buffer ready and IRQ checks. Host 
> buffer first - if it's ready, transfer the data. If not, check for IRQ - 
> if it was an error, rollback 2 buffers (the same if the host buffer is 
> not ready in time).
> 

In v3 of the patch series I've fixed the Gated IRQ logic so the transfer 
loop will terminate early.

> 
> There's also a performance regression on DTC436 - the sg_tablesize limit
> affects performance badly.
> Before:
> # hdparm -t --direct /dev/sdb
> 
> /dev/sdb:
>  Timing O_DIRECT disk reads:   4 MB in  3.21 seconds =   1.25 MB/sec
> 
> Now:
> # hdparm -t --direct /dev/sdb
> 
> /dev/sdb:
>  Timing O_DIRECT disk reads:   4 MB in  4.89 seconds = 837.69 kB/sec
> 

The lost throughput can perhaps be explained by extra kernel-mode CPU 
overhead. Next time maybe check for that with "time hdparm". Anyway, since 
you have a patch, we should try to avoid this regression.

> We should limit the transfer size instead:
> --- a/drivers/scsi/g_NCR5380.c
> +++ b/drivers/scsi/g_NCR5380.c
> @@ -45,7 +45,8 @@
> int c400_blk_cnt; \
> int c400_host_buf; \
> int io_width; \
> -   int pdma_residual
> +   int pdma_residual; \
> +   int board;
> 
>  #define NCR5380_dma_xfer_lengeneric_NCR5380_dma_xfer_len
>  #define NCR5380_dma_recv_setup  generic_NCR5380_pread
> @@ -247,7 +248,6 @@ static int generic_NCR5380_init_one(struct 
> scsi_host_template *tpnt,
> case BOARD_DTC3181E:
> ports = dtc_3181e_ports;
> magic = ncr_53c400a_magic;
> -   tpnt->sg_tablesize = 1;
> break;
> }
> 

I've dropped my "sg_tablesize = 1" patch from the v3 series.

> @@ -317,6 +317,7 @@ static int generic_NCR5380_init_one(struct 
> scsi_host_template *tpnt,
> }
> hostdata = shost_priv(instance);
> 
> +   hostdata->board = board;
> hostdata->io = iomem;
> hostdata->region_size = region_size;
> 

I've added the hostdata->board variable in v3. It looks like we are going 
to need it one way or another.

> @@ -625,6 +626,9 @@ static int generic_NCR5380_dma_xfer_len(struct 
> NCR5380_hostdata *hostdata,
> /* 53C400 datasheet: non-modulo-128-byte transfers should use PIO */
> if (transfersize % 128)
> transfersize = 0;
> +   /* Limit transfers to 512B to prevent random write corruption on DTC 
> */
> +   if (hostdata->board == BOARD_DTC3181E && transfersize > 512)
> +   transfersize = 512;
> 
> return min(transfersize, DMA_MAX_SIZE);
>  }
> 
> 
> No data corruption

How did you confirm that? What about a 1024 byte limit? 2048? 4096? Does 
it make any difference?

Do you have any theories that might explain the need for a 512 B limit?

My theory about the "read overrun" issue doesn't seem applicable, given 
that this is actually the CMOS version, which has different errata than 
the NMOS version.

The need for udelay(4) on this board does suggest timing issues. What 
happens if you add a udelay into the generic_NCR5380_pwrite() loop?

> and no performance regression:
> # hdparm -t --direct /dev/sdb
> 

Well, I'd still expect some added CPU overhead. The driver is being handed 
a 4096 byte transfer and is now splitting that up into eight separate 
transfers. That means eight times as many DMA setup and completion calls 
and presumably a similar increase in interrupts.

> /dev/sdb:
>  Timing O_DIRECT disk reads:   4 MB in  3.25 seconds =   1.23 MB/sec
> 
> As the data corruption affects only writes, we could keep transfersize
> unlimited for reads:
> +   /* Limit write 

[PATCH v3 4/4] g_NCR5380: Re-work PDMA loops

2017-06-26 Thread Finn Thain
From: Ondrej Zary 

The polling loops in pread() and pwrite() can easily become infinite
loops and hang the machine.

On DTC chips, IRQ can arrive late and we miss it because we only check
once. Merge the IRQ check into host buffer wait and add polling limit.

Also place a limit on polling for 53C80 registers accessibility.

[Use NCR5380_poll_politely2() for register polling. Rely on polling for
gated IRQ rather than polling for phase error, like the algorithm in the
datasheet. Calculate residual from block count register instead of the
loop counter. Factor-out common code as wait_for_53c80_access(). -- F.T.]

Signed-off-by: Ondrej Zary 
Signed-off-by: Finn Thain 
---
 drivers/scsi/g_NCR5380.c | 160 ++-
 1 file changed, 75 insertions(+), 85 deletions(-)

diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c
index 9f18082415c4..28233ec49fdc 100644
--- a/drivers/scsi/g_NCR5380.c
+++ b/drivers/scsi/g_NCR5380.c
@@ -45,7 +45,8 @@
int c400_blk_cnt; \
int c400_host_buf; \
int io_width; \
-   int pdma_residual
+   int pdma_residual; \
+   int board
 
 #define NCR5380_dma_xfer_lengeneric_NCR5380_dma_xfer_len
 #define NCR5380_dma_recv_setup  generic_NCR5380_pread
@@ -316,6 +317,7 @@ static int generic_NCR5380_init_one(struct 
scsi_host_template *tpnt,
}
hostdata = shost_priv(instance);
 
+   hostdata->board = board;
hostdata->io = iomem;
hostdata->region_size = region_size;
 
@@ -480,6 +482,31 @@ static void generic_NCR5380_release_resources(struct 
Scsi_Host *instance)
release_mem_region(base, region_size);
 }
 
+/* wait_for_53c80_access - wait for 53C80 registers to become accessible
+ * @hostdata: scsi host private data
+ *
+ * The registers within the 53C80 logic block are inaccessible until
+ * bit 7 in the 53C400 control status register gets asserted.
+ */
+
+static int wait_for_53c80_access(struct NCR5380_hostdata *hostdata)
+{
+   int count = 1;
+
+   do {
+   if (hostdata->board == BOARD_DTC3181E)
+   udelay(4); /* DTC436 chip hangs without this */
+   if (NCR5380_read(hostdata->c400_ctl_status) & CSR_53C80_REG)
+   return 0;
+   } while (--count > 0);
+
+   scmd_printk(KERN_ERR, hostdata->connected,
+   "53c80 registers not accessible, device will be reset\n");
+   NCR5380_write(hostdata->c400_ctl_status, CSR_RESET);
+   NCR5380_write(hostdata->c400_ctl_status, CSR_BASE);
+   return -1;
+}
+
 /**
  * generic_NCR5380_pread - pseudo DMA receive
  * @hostdata: scsi host private data
@@ -492,18 +519,23 @@ static void generic_NCR5380_release_resources(struct 
Scsi_Host *instance)
 static inline int generic_NCR5380_pread(struct NCR5380_hostdata *hostdata,
 unsigned char *dst, int len)
 {
-   int blocks = len / 128;
-   int start = 0;
+   int result;
+   int start;
 
NCR5380_write(hostdata->c400_ctl_status, CSR_BASE | CSR_TRANS_DIR);
-   NCR5380_write(hostdata->c400_blk_cnt, blocks);
-   while (1) {
-   if (NCR5380_read(hostdata->c400_blk_cnt) == 0)
+   NCR5380_write(hostdata->c400_blk_cnt, len / 128);
+
+   for (start = 0; start < len; start += 128) {
+   if (NCR5380_poll_politely2(hostdata, hostdata->c400_ctl_status,
+  CSR_HOST_BUF_NOT_RDY, 0,
+  hostdata->c400_ctl_status,
+  CSR_GATED_53C80_IRQ,
+  CSR_GATED_53C80_IRQ, HZ / 64) < 0)
+   break;
+
+   if (NCR5380_read(hostdata->c400_ctl_status) &
+   CSR_GATED_53C80_IRQ)
break;
-   if (NCR5380_read(hostdata->c400_ctl_status) & 
CSR_GATED_53C80_IRQ)
-   goto out_wait;
-   while (NCR5380_read(hostdata->c400_ctl_status) & 
CSR_HOST_BUF_NOT_RDY)
-   ; /* FIXME - no timeout */
 
if (hostdata->io_port && hostdata->io_width == 2)
insw(hostdata->io_port + hostdata->c400_host_buf,
@@ -514,46 +546,20 @@ static inline int generic_NCR5380_pread(struct 
NCR5380_hostdata *hostdata,
else
memcpy_fromio(dst + start,
hostdata->io + NCR53C400_host_buffer, 128);
-
-   start += 128;
-   blocks--;
-   }
-
-   if (blocks) {
-   while (NCR5380_read(hostdata->c400_ctl_status) & 
CSR_HOST_BUF_NOT_RDY)
-   ; /* FIXME - no timeout */
-
-   if (hostdata->io_port && hostdata->io_width == 2)
-   insw(hostdata->io_port + 

[PATCH v3 3/4] g_NCR5380: Cleanup comments and whitespace

2017-06-26 Thread Finn Thain
Signed-off-by: Finn Thain 
---
 drivers/scsi/g_NCR5380.c | 61 ++--
 1 file changed, 28 insertions(+), 33 deletions(-)

diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c
index 911a4300ea51..9f18082415c4 100644
--- a/drivers/scsi/g_NCR5380.c
+++ b/drivers/scsi/g_NCR5380.c
@@ -1,17 +1,17 @@
 /*
  * Generic Generic NCR5380 driver
- * 
+ *
  * Copyright 1993, Drew Eckhardt
- * Visionary Computing
- * (Unix and Linux consulting and custom programming)
- * d...@colorado.edu
- *  +1 (303) 440-4894
+ * Visionary Computing
+ * (Unix and Linux consulting and custom programming)
+ * d...@colorado.edu
+ * +1 (303) 440-4894
  *
  * NCR53C400 extensions (c) 1994,1995,1996, Kevin Lentin
- *k.len...@cs.monash.edu.au
+ * k.len...@cs.monash.edu.au
  *
  * NCR53C400A extensions (c) 1996, Ingmar Baumgart
- *ing...@gonzo.schwaben.de
+ * ing...@gonzo.schwaben.de
  *
  * DTC3181E extensions (c) 1997, Ronald van Cuijlenborg
  * ronald.van.cuijlenb...@tip.nl or nu...@dds.nl
@@ -481,15 +481,14 @@ static void generic_NCR5380_release_resources(struct 
Scsi_Host *instance)
 }
 
 /**
- * generic_NCR5380_pread - pseudo DMA read
- * @hostdata: scsi host private data
- * @dst: buffer to read into
- * @len: buffer length
+ * generic_NCR5380_pread - pseudo DMA receive
+ * @hostdata: scsi host private data
+ * @dst: buffer to write into
+ * @len: transfer size
  *
- * Perform a pseudo DMA mode read from an NCR53C400 or equivalent
- * controller
+ * Perform a pseudo DMA mode receive from a 53C400 or equivalent device.
  */
- 
+
 static inline int generic_NCR5380_pread(struct NCR5380_hostdata *hostdata,
 unsigned char *dst, int len)
 {
@@ -508,10 +507,10 @@ static inline int generic_NCR5380_pread(struct 
NCR5380_hostdata *hostdata,
 
if (hostdata->io_port && hostdata->io_width == 2)
insw(hostdata->io_port + hostdata->c400_host_buf,
-   dst + start, 64);
+dst + start, 64);
else if (hostdata->io_port)
insb(hostdata->io_port + hostdata->c400_host_buf,
-   dst + start, 128);
+dst + start, 128);
else
memcpy_fromio(dst + start,
hostdata->io + NCR53C400_host_buffer, 128);
@@ -558,13 +557,12 @@ static inline int generic_NCR5380_pread(struct 
NCR5380_hostdata *hostdata,
 }
 
 /**
- * generic_NCR5380_pwrite - pseudo DMA write
- * @hostdata: scsi host private data
- * @dst: buffer to read into
- * @len: buffer length
+ * generic_NCR5380_pwrite - pseudo DMA send
+ * @hostdata: scsi host private data
+ * @src: buffer to read from
+ * @len: transfer size
  *
- * Perform a pseudo DMA mode read from an NCR53C400 or equivalent
- * controller
+ * Perform a pseudo DMA mode send to a 53C400 or equivalent device.
  */
 
 static inline int generic_NCR5380_pwrite(struct NCR5380_hostdata *hostdata,
@@ -603,10 +601,10 @@ static inline int generic_NCR5380_pwrite(struct 
NCR5380_hostdata *hostdata,
 
if (hostdata->io_port && hostdata->io_width == 2)
outsw(hostdata->io_port + hostdata->c400_host_buf,
-   src + start, 64);
+ src + start, 64);
else if (hostdata->io_port)
outsb(hostdata->io_port + hostdata->c400_host_buf,
-   src + start, 128);
+ src + start, 128);
else
memcpy_toio(hostdata->io + NCR53C400_host_buffer,
src + start, 128);
@@ -656,10 +654,8 @@ static int generic_NCR5380_dma_residual(struct 
NCR5380_hostdata *hostdata)
return hostdata->pdma_residual;
 }
 
-/*
- * Include the NCR5380 core code that we build our driver around   
- */
- 
+/* Include the core driver code. */
+
 #include "NCR5380.c"
 
 static struct scsi_host_template driver_template = {
@@ -679,11 +675,10 @@ static struct scsi_host_template driver_template = {
.max_sectors= 128,
 };
 
-
 static int generic_NCR5380_isa_match(struct device *pdev, unsigned int ndev)
 {
int ret = generic_NCR5380_init_one(_template, pdev, base[ndev],
- irq[ndev], card[ndev]);
+  irq[ndev], card[ndev]);
if (ret) {
if (base[ndev])
printk(KERN_WARNING "Card not found at address 
0x%03x\n",
@@ -695,7 +690,7 @@ static int generic_NCR5380_isa_match(struct device *pdev, 
unsigned int ndev)
 }
 
 static int generic_NCR5380_isa_remove(struct device 

[PATCH v3 0/4] g_NCR5380: PDMA fixes and cleanup

2017-06-26 Thread Finn Thain
Ondrej, would you please test this new series?

Changed since v1:
- PDMA transfer residual is calculated earlier.
- End of DMA flag check is now polled (if there is any residual).

Changed since v2:
- Bail out of transfer loops when Gated IRQ gets asserted.
- Make udelay conditional on board type.
- Drop sg_tablesize patch due to performance regression.


Finn Thain (1):
  g_NCR5380: Cleanup comments and whitespace

Ondrej Zary (3):
  g_NCR5380: Fix PDMA transfer size
  g_NCR5380: End PDMA transfer correctly on target disconnection
  g_NCR5380: Re-work PDMA loops

 drivers/scsi/g_NCR5380.c | 239 +++
 1 file changed, 116 insertions(+), 123 deletions(-)

-- 
2.13.0



[PATCH v3 2/4] g_NCR5380: End PDMA transfer correctly on target disconnection

2017-06-26 Thread Finn Thain
From: Ondrej Zary 

When an IRQ arrives during PDMA transfer, pread() and pwrite() return
without waiting for the 53C80 registers to be ready and this ends up
messing up the chip state. This was observed with SONY CDU-55S which is
slow enough to disconnect during 4096-byte reads.

IRQ during PDMA is not an error so don't return -1. Instead, store the
remaining byte count for use by NCR5380_dma_residual().

[Poll for the BASR_END_DMA_TRANSFER condition rather than remove the
error message -- F.T.]

Signed-off-by: Ondrej Zary 
Signed-off-by: Finn Thain 
---
 drivers/scsi/g_NCR5380.c | 48 +++-
 1 file changed, 31 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c
index 14ef4e8c4713..911a4300ea51 100644
--- a/drivers/scsi/g_NCR5380.c
+++ b/drivers/scsi/g_NCR5380.c
@@ -44,12 +44,13 @@
int c400_ctl_status; \
int c400_blk_cnt; \
int c400_host_buf; \
-   int io_width
+   int io_width; \
+   int pdma_residual
 
 #define NCR5380_dma_xfer_lengeneric_NCR5380_dma_xfer_len
 #define NCR5380_dma_recv_setup  generic_NCR5380_pread
 #define NCR5380_dma_send_setup  generic_NCR5380_pwrite
-#define NCR5380_dma_residualNCR5380_dma_residual_none
+#define NCR5380_dma_residualgeneric_NCR5380_dma_residual
 
 #define NCR5380_intrgeneric_NCR5380_intr
 #define NCR5380_queue_command   generic_NCR5380_queue_command
@@ -500,10 +501,8 @@ static inline int generic_NCR5380_pread(struct 
NCR5380_hostdata *hostdata,
while (1) {
if (NCR5380_read(hostdata->c400_blk_cnt) == 0)
break;
-   if (NCR5380_read(hostdata->c400_ctl_status) & 
CSR_GATED_53C80_IRQ) {
-   printk(KERN_ERR "53C400r: Got 53C80_IRQ start=%d, 
blocks=%d\n", start, blocks);
-   return -1;
-   }
+   if (NCR5380_read(hostdata->c400_ctl_status) & 
CSR_GATED_53C80_IRQ)
+   goto out_wait;
while (NCR5380_read(hostdata->c400_ctl_status) & 
CSR_HOST_BUF_NOT_RDY)
; /* FIXME - no timeout */
 
@@ -542,13 +541,19 @@ static inline int generic_NCR5380_pread(struct 
NCR5380_hostdata *hostdata,
if (!(NCR5380_read(hostdata->c400_ctl_status) & CSR_GATED_53C80_IRQ))
printk("53C400r: no 53C80 gated irq after transfer");
 
+out_wait:
+   hostdata->pdma_residual = len - start;
+
/* wait for 53C80 registers to be available */
while (!(NCR5380_read(hostdata->c400_ctl_status) & CSR_53C80_REG))
;
 
-   if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_END_DMA_TRANSFER))
-   printk(KERN_ERR "53C400r: no end dma signal\n");
-   
+   if (NCR5380_poll_politely(hostdata, BUS_AND_STATUS_REG,
+ BASR_END_DMA_TRANSFER, BASR_END_DMA_TRANSFER,
+ HZ / 64) < 0)
+   scmd_printk(KERN_ERR, hostdata->connected, "%s: End of DMA 
timeout (%d)\n",
+   __func__, hostdata->pdma_residual);
+
return 0;
 }
 
@@ -571,10 +576,8 @@ static inline int generic_NCR5380_pwrite(struct 
NCR5380_hostdata *hostdata,
NCR5380_write(hostdata->c400_ctl_status, CSR_BASE);
NCR5380_write(hostdata->c400_blk_cnt, blocks);
while (1) {
-   if (NCR5380_read(hostdata->c400_ctl_status) & 
CSR_GATED_53C80_IRQ) {
-   printk(KERN_ERR "53C400w: Got 53C80_IRQ start=%d, 
blocks=%d\n", start, blocks);
-   return -1;
-   }
+   if (NCR5380_read(hostdata->c400_ctl_status) & 
CSR_GATED_53C80_IRQ)
+   goto out_wait;
 
if (NCR5380_read(hostdata->c400_blk_cnt) == 0)
break;
@@ -612,18 +615,24 @@ static inline int generic_NCR5380_pwrite(struct 
NCR5380_hostdata *hostdata,
blocks--;
}
 
+out_wait:
+   hostdata->pdma_residual = len - start;
+
/* wait for 53C80 registers to be available */
while (!(NCR5380_read(hostdata->c400_ctl_status) & CSR_53C80_REG)) {
udelay(4); /* DTC436 chip hangs without this */
/* FIXME - no timeout */
}
 
-   if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_END_DMA_TRANSFER)) {
-   printk(KERN_ERR "53C400w: no end dma signal\n");
-   }
-
while (!(NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT))
;   // TIMEOUT
+
+   if (NCR5380_poll_politely(hostdata, BUS_AND_STATUS_REG,
+ BASR_END_DMA_TRANSFER, BASR_END_DMA_TRANSFER,
+ HZ / 64) < 0)
+   scmd_printk(KERN_ERR, hostdata->connected, "%s: End of DMA 
timeout (%d)\n",
+

[PATCH v3 1/4] g_NCR5380: Fix PDMA transfer size

2017-06-26 Thread Finn Thain
From: Ondrej Zary 

generic_NCR5380_dma_xfer_len() incorrectly uses cmd->transfersize
which causes rescan-scsi-bus and CD-ROM access to hang the system.
Use cmd->SCp.this_residual instead, like other NCR5380 drivers.

Signed-off-by: Ondrej Zary 
Signed-off-by: Finn Thain 
---
 drivers/scsi/g_NCR5380.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c
index 67c8dac321ad..14ef4e8c4713 100644
--- a/drivers/scsi/g_NCR5380.c
+++ b/drivers/scsi/g_NCR5380.c
@@ -76,6 +76,7 @@
 #define IRQ_AUTO 254
 
 #define MAX_CARDS 8
+#define DMA_MAX_SIZE 32768
 
 /* old-style parameters for compatibility */
 static int ncr_irq = -1;
@@ -629,23 +630,16 @@ static inline int generic_NCR5380_pwrite(struct 
NCR5380_hostdata *hostdata,
 static int generic_NCR5380_dma_xfer_len(struct NCR5380_hostdata *hostdata,
 struct scsi_cmnd *cmd)
 {
-   int transfersize = cmd->transfersize;
+   int transfersize = cmd->SCp.this_residual;
 
if (hostdata->flags & FLAG_NO_PSEUDO_DMA)
return 0;
 
-   /* Limit transfers to 32K, for xx400 & xx406
-* pseudoDMA that transfers in 128 bytes blocks.
-*/
-   if (transfersize > 32 * 1024 && cmd->SCp.this_residual &&
-   !(cmd->SCp.this_residual % transfersize))
-   transfersize = 32 * 1024;
-
/* 53C400 datasheet: non-modulo-128-byte transfers should use PIO */
if (transfersize % 128)
transfersize = 0;
 
-   return transfersize;
+   return min(transfersize, DMA_MAX_SIZE);
 }
 
 /*
-- 
2.13.0



Re: [PATCH] scsi: qedi: Remove comparison of u16 idx with zero.

2017-06-26 Thread Rangankar, Manish


On 24/06/17 9:54 PM, "Christos Gkekas"  wrote:

>Variable idx is defined as u16 thus statement (idx < 0) is
>always false and should be removed.
>
>Signed-off-by: Christos Gkekas 
>---
> drivers/scsi/qedi/qedi_fw.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c
>index e937490..19254bd 100644
>--- a/drivers/scsi/qedi/qedi_fw.c
>+++ b/drivers/scsi/qedi/qedi_fw.c
>@@ -333,7 +333,7 @@ static void qedi_get_rq_bdq_buf(struct qedi_ctx *qedi,
> 
>   /* Obtain buffer address from rqe_opaque */
>   idx = cqe->rqe_opaque.lo;
>-  if ((idx < 0) || (idx > (QEDI_BDQ_NUM - 1))) {
>+  if (idx > (QEDI_BDQ_NUM - 1)) {
>   QEDI_INFO(>dbg_ctx, QEDI_LOG_CONN,
> "wrong idx %d returned by FW, dropping the 
> unsolicited pkt\n",
> idx);
>@@ -370,7 +370,7 @@ static void qedi_put_rq_bdq_buf(struct qedi_ctx *qedi,
> 
>   /* Obtain buffer address from rqe_opaque */
>   idx = cqe->rqe_opaque.lo;
>-  if ((idx < 0) || (idx > (QEDI_BDQ_NUM - 1))) {
>+  if (idx > (QEDI_BDQ_NUM - 1)) {
>   QEDI_INFO(>dbg_ctx, QEDI_LOG_CONN,
> "wrong idx %d returned by FW, dropping the 
> unsolicited pkt\n",
> idx);
>-- 
>2.7.4

Acked-by: Manish Rangankar 




Re: [PATCH] Remove the definition of VLC_SA_RECEIVE_CREDENTIAL

2017-06-26 Thread Johannes Thumshirn
On Fri, Jun 23, 2017 at 10:32:39AM -0700, Bart Van Assche wrote:
> The symbolic name VLC_SA_RECEIVE_CREDENTIAL is not used anywhere
> in the kernel. Additionally, since SPC 5 the RECEIVE CREDENTIAL
> command is obsolete. The VLC_SA_RECEIVE_CREDENTIAL definition is
> misleading since it occurs outside the list of other variable
> length CDB service action codes (READ_32, WRITE_32, ...). Hence
> remove this definition.
> 
> References: commit e9ccc998b70f ("[SCSI] Add missing SPC-4 CDB and 
> MAINTENANCE_[IN,OUT] service action definitions")
> Signed-off-by: Bart Van Assche 
> Cc: Christoph Hellwig 
> Cc: Hannes Reinecke 
> Cc: Johannes Thumshirn 
> ---

Thanks Bart,
Reviewed-by: Johannes Thumshirn 
-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH 02/11] dma-mapping: replace dmam_alloc_noncoherent with dmam_alloc_attrs

2017-06-26 Thread Christoph Hellwig
Tejun, does this look ok to you?

On Fri, Jun 16, 2017 at 09:17:07AM +0200, Christoph Hellwig wrote:
> dmam_alloc_noncoherent is a trivial wrapper around dmam_alloc_attrs,
> that hardcodes one particular flag.  Make the devres code more
> flexible by allowing the callers to pass arbitrary flags.
> 
> Signed-off-by: Christoph Hellwig 
> ---
>  Documentation/driver-model/devres.txt |  2 +-
>  drivers/base/dma-mapping.c| 36 
> ---
>  drivers/video/fbdev/au1200fb.c|  5 +++--
>  include/linux/dma-mapping.h   |  5 +++--
>  4 files changed, 23 insertions(+), 25 deletions(-)
> 
> diff --git a/Documentation/driver-model/devres.txt 
> b/Documentation/driver-model/devres.txt
> index 9070ff06b558..7e08c02b5393 100644
> --- a/Documentation/driver-model/devres.txt
> +++ b/Documentation/driver-model/devres.txt
> @@ -240,7 +240,7 @@ CLOCK
>  
>  DMA
>dmam_alloc_coherent()
> -  dmam_alloc_noncoherent()
> +  dmam_alloc_attrs()
>dmam_declare_coherent_memory()
>dmam_free_coherent()
>dmam_pool_create()
> diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
> index 5940c9dace36..10e7c022e8cf 100644
> --- a/drivers/base/dma-mapping.c
> +++ b/drivers/base/dma-mapping.c
> @@ -22,20 +22,15 @@ struct dma_devres {
>   size_t  size;
>   void*vaddr;
>   dma_addr_t  dma_handle;
> + unsigned long   attrs;
>  };
>  
> -static void dmam_coherent_release(struct device *dev, void *res)
> +static void dmam_release(struct device *dev, void *res)
>  {
>   struct dma_devres *this = res;
>  
> - dma_free_coherent(dev, this->size, this->vaddr, this->dma_handle);
> -}
> -
> -static void dmam_noncoherent_release(struct device *dev, void *res)
> -{
> - struct dma_devres *this = res;
> -
> - dma_free_noncoherent(dev, this->size, this->vaddr, this->dma_handle);
> + dma_free_attrs(dev, this->size, this->vaddr, this->dma_handle,
> + this->attrs);
>  }
>  
>  static int dmam_match(struct device *dev, void *res, void *match_data)
> @@ -69,7 +64,7 @@ void *dmam_alloc_coherent(struct device *dev, size_t size,
>   struct dma_devres *dr;
>   void *vaddr;
>  
> - dr = devres_alloc(dmam_coherent_release, sizeof(*dr), gfp);
> + dr = devres_alloc(dmam_release, sizeof(*dr), gfp);
>   if (!dr)
>   return NULL;
>  
> @@ -104,35 +99,35 @@ void dmam_free_coherent(struct device *dev, size_t size, 
> void *vaddr,
>   struct dma_devres match_data = { size, vaddr, dma_handle };
>  
>   dma_free_coherent(dev, size, vaddr, dma_handle);
> - WARN_ON(devres_destroy(dev, dmam_coherent_release, dmam_match,
> -_data));
> + WARN_ON(devres_destroy(dev, dmam_release, dmam_match, _data));
>  }
>  EXPORT_SYMBOL(dmam_free_coherent);
>  
>  /**
> - * dmam_alloc_non_coherent - Managed dma_alloc_noncoherent()
> + * dmam_alloc_attrs - Managed dma_alloc_attrs()
>   * @dev: Device to allocate non_coherent memory for
>   * @size: Size of allocation
>   * @dma_handle: Out argument for allocated DMA handle
>   * @gfp: Allocation flags
> + * @attrs: Flags in the DMA_ATTR_* namespace.
>   *
> - * Managed dma_alloc_noncoherent().  Memory allocated using this
> - * function will be automatically released on driver detach.
> + * Managed dma_alloc_attrs().  Memory allocated using this function will be
> + * automatically released on driver detach.
>   *
>   * RETURNS:
>   * Pointer to allocated memory on success, NULL on failure.
>   */
> -void *dmam_alloc_noncoherent(struct device *dev, size_t size,
> -  dma_addr_t *dma_handle, gfp_t gfp)
> +void *dmam_alloc_attrs(struct device *dev, size_t size, dma_addr_t 
> *dma_handle,
> + gfp_t gfp, unsigned long attrs)
>  {
>   struct dma_devres *dr;
>   void *vaddr;
>  
> - dr = devres_alloc(dmam_noncoherent_release, sizeof(*dr), gfp);
> + dr = devres_alloc(dmam_release, sizeof(*dr), gfp);
>   if (!dr)
>   return NULL;
>  
> - vaddr = dma_alloc_noncoherent(dev, size, dma_handle, gfp);
> + vaddr = dma_alloc_attrs(dev, size, dma_handle, gfp, attrs);
>   if (!vaddr) {
>   devres_free(dr);
>   return NULL;
> @@ -141,12 +136,13 @@ void *dmam_alloc_noncoherent(struct device *dev, size_t 
> size,
>   dr->vaddr = vaddr;
>   dr->dma_handle = *dma_handle;
>   dr->size = size;
> + dr->attrs = attrs;
>  
>   devres_add(dev, dr);
>  
>   return vaddr;
>  }
> -EXPORT_SYMBOL(dmam_alloc_noncoherent);
> +EXPORT_SYMBOL(dmam_alloc_attrs);
>  
>  #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT
>  
> diff --git a/drivers/video/fbdev/au1200fb.c b/drivers/video/fbdev/au1200fb.c
> index 6c2b2ca4a909..5f04b4096c42 100644
> --- a/drivers/video/fbdev/au1200fb.c
> +++ b/drivers/video/fbdev/au1200fb.c
> @@ -1694,9 +1694,10 @@ static int au1200fb_drv_probe(struct platform_device 
> *dev)
>   /* Allocate 

Re: [PATCH 01/11] dma-mapping: remove dmam_free_noncoherent

2017-06-26 Thread Christoph Hellwig
Tejun, does this look ok to you?

On Fri, Jun 16, 2017 at 09:17:06AM +0200, Christoph Hellwig wrote:
> This function was never used since it was added.
> 
> Signed-off-by: Christoph Hellwig 
> ---
>  Documentation/driver-model/devres.txt |  1 -
>  drivers/base/dma-mapping.c| 20 
>  include/linux/dma-mapping.h   |  2 --
>  3 files changed, 23 deletions(-)
> 
> diff --git a/Documentation/driver-model/devres.txt 
> b/Documentation/driver-model/devres.txt
> index e72587fe477d..9070ff06b558 100644
> --- a/Documentation/driver-model/devres.txt
> +++ b/Documentation/driver-model/devres.txt
> @@ -243,7 +243,6 @@ DMA
>dmam_alloc_noncoherent()
>dmam_declare_coherent_memory()
>dmam_free_coherent()
> -  dmam_free_noncoherent()
>dmam_pool_create()
>dmam_pool_destroy()
>  
> diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
> index f3deb6af42ad..5940c9dace36 100644
> --- a/drivers/base/dma-mapping.c
> +++ b/drivers/base/dma-mapping.c
> @@ -148,26 +148,6 @@ void *dmam_alloc_noncoherent(struct device *dev, size_t 
> size,
>  }
>  EXPORT_SYMBOL(dmam_alloc_noncoherent);
>  
> -/**
> - * dmam_free_coherent - Managed dma_free_noncoherent()
> - * @dev: Device to free noncoherent memory for
> - * @size: Size of allocation
> - * @vaddr: Virtual address of the memory to free
> - * @dma_handle: DMA handle of the memory to free
> - *
> - * Managed dma_free_noncoherent().
> - */
> -void dmam_free_noncoherent(struct device *dev, size_t size, void *vaddr,
> -dma_addr_t dma_handle)
> -{
> - struct dma_devres match_data = { size, vaddr, dma_handle };
> -
> - dma_free_noncoherent(dev, size, vaddr, dma_handle);
> - WARN_ON(!devres_destroy(dev, dmam_noncoherent_release, dmam_match,
> - _data));
> -}
> -EXPORT_SYMBOL(dmam_free_noncoherent);
> -
>  #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT
>  
>  static void dmam_coherent_decl_release(struct device *dev, void *res)
> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> index 4f3eecedca2d..830ec5f06a4f 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -749,8 +749,6 @@ extern void dmam_free_coherent(struct device *dev, size_t 
> size, void *vaddr,
>  dma_addr_t dma_handle);
>  extern void *dmam_alloc_noncoherent(struct device *dev, size_t size,
>   dma_addr_t *dma_handle, gfp_t gfp);
> -extern void dmam_free_noncoherent(struct device *dev, size_t size, void 
> *vaddr,
> -   dma_addr_t dma_handle);
>  #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT
>  extern int dmam_declare_coherent_memory(struct device *dev,
>   phys_addr_t phys_addr,
> -- 
> 2.11.0
> 
---end quoted text---