Re: [PATCH 3/3] cxlflash: Update debug prints in reset handlers

2017-06-28 Thread Hannes Reinecke
On 06/28/2017 07:14 PM, Matthew R. Ochs wrote:
> The device and host reset handler contain debug prints to help
> identify the entities being reset. Today these reset handlers
> are based on a SCSI EH design that uses a SCSI command reference
> as a means of identifying the target entity. As such, the debug
> trace includes the SCSI command pointer and associated CDB. This
> is not necessary as the SCSI command is simply the messenger in
> these scenarios.
> 
> Refactor the debug prints in the host and reset handlers to only
> present information that is applicable given the function scope.
> 
> Signed-off-by: Matthew R. Ochs 
> ---
>  drivers/scsi/cxlflash/main.c | 18 +++---
>  1 file changed, 3 insertions(+), 15 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries & Storage
h...@suse.com  +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 2/3] cxlflash: Update send_tmf() parameters

2017-06-28 Thread Hannes Reinecke
On 06/28/2017 07:14 PM, Matthew R. Ochs wrote:
> The current send_tmf() implementation is based on the caller providing
> a SCSI command reference. In reality all that is needed is a SCSI device
> reference as the routine uses a private command.
> 
> Refactor send_tmf() to pass the private adapter configuration reference
> and a SCSI device reference. As a nice side effect, this will ease the
> burden of converting caller routines to be based solely off of a SCSI
> device reference.
> 
> Signed-off-by: Matthew R. Ochs 
> ---
>  drivers/scsi/cxlflash/main.c | 27 +--
>  1 file changed, 13 insertions(+), 14 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries & Storage
h...@suse.com  +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 1/3] cxlflash: Avoid double free of character device

2017-06-28 Thread Hannes Reinecke
On 06/28/2017 07:14 PM, Matthew R. Ochs wrote:
> The device_unregister() service used when cleaning up the character
> device is already responsible for the internal state associated with
> the device upon successful creation. As the cxlflash driver does not
> obtain a second reference to the character device, the explicit call
> to put_device() is not required and can lead to an inconsistent sysfs
> among other issues as the reference is no longer valid after the first
> put_device() is performed.
> 
> Remove the unnecessary put_device() to remedy this issue.
> 
> Fixes: a834a36b57d9 ("scsi: cxlflash: Create character device to provide host 
> management interface")
> Signed-off-by: Matthew R. Ochs > ---
>  drivers/scsi/cxlflash/main.c | 1 -
>  1 file changed, 1 deletion(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries & Storage
h...@suse.com  +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 13/47] megaraid: pass in NULL scb for host reset

2017-06-28 Thread Hannes Reinecke
On 06/28/2017 07:40 PM, Kashyap Desai wrote:
>> -Original Message-
>> From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
>> ow...@vger.kernel.org] On Behalf Of Hannes Reinecke
>> Sent: Wednesday, June 28, 2017 9:00 PM
>> To: Sumit Saxena; Christoph Hellwig
>> Cc: Martin K. Petersen; James Bottomley; linux-scsi@vger.kernel.org;
>> Hannes
>> Reinecke
>> Subject: Re: [PATCH 13/47] megaraid: pass in NULL scb for host reset
>>
>> On 06/28/2017 03:41 PM, Sumit Saxena wrote:
 -Original Message-
 From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
 ow...@vger.kernel.org] On Behalf Of Hannes Reinecke
 Sent: Wednesday, June 28, 2017 2:03 PM
 To: Christoph Hellwig
 Cc: Martin K. Petersen; James Bottomley; linux-scsi@vger.kernel.org;
>>> Hannes
 Reinecke; Hannes Reinecke
 Subject: [PATCH 13/47] megaraid: pass in NULL scb for host reset

 When calling a host reset we shouldn't rely on the command triggering
 the reset, so allow megaraid_abort_and_reset() to be called with a NULL
>> scb.
 And drop the pointless 'bus_reset' and 'target_reset' handlers, which
>>> just call
 the same function as host_reset.
>>>
>>> If this patch address any functional issue, then we should consider
>>> this.
>>> If it's code optimization, can we ignore this as this is being very
>>> old driver and no more maintained by Broadcom/LSI ?
>>>
>> Sadly, ignoring is not an option.
>> I'm planning to update the calling convention for SCSI EH, to resolve the
>> long-
>> standing problem with sg_reset ioctls.
>> sg_reset ioctl will allocate an out-of-band SCSI command, which does no
>> longer
>> work with the new command allocation scheme in multiqueue.
>> So it's not possible to just 'ignore' it, as then SCSI EH will cease to
>> function with
>> that driver.
> 
> Hannes - We are in process of sending megaraid and 3ware driver removal as
> LSI/Broadcom  stopped supporting those products.
> I agree we should review this closely, but lack of test coverage and end of
> life cycle of product is requesting us to know the rational.
> For now, let's consider NACK for this patch. We will be removing old
> megaraid (mbox) driver and 3Ware drivers soon.
> 
Hmm.
Can't we do the removal now?
There is not a lot of testing involved with _that_, surely?

I'd be happy to do a patch if you like ...

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


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

2017-06-28 Thread Finn Thain
On Wed, 28 Jun 2017, Ondrej Zary wrote:

> 
> Now read seems to work on non-DTC chips. Writes continue in PDMA after 
> disconnect but there's a corruption - one 128 B block missing on 
> disconnect.
> 
> On DTC, the log is spammed with errors like this:
> sd 2:0:1:0: [sdb] tag#0 generic_NCR5380_pread: End of DMA timeout (0)
> 
> They're cause by read corruption on DTC: pread() is breaking at 
> start=3968 because of an end-of-DMA IRQ (BASR=0x98) but pdma_residual is 
> set to zero (block counter is zero because the data was read into the 
> buffer but we did not read it from there). So we lose one buffer of data 
> on each 4 KB read.
>

But the algorithm in the datasheet never reads from the buffer after the 
block counter reaches zero. (Of course, the only datasheet we have is for 
a 53c400 device not a DTC436 so all bets are off.)

Anyway, the corrupted data that you describe is telling. I think you're 
right, we have to drain the buffer even when Gated IRQ has been asserted 
(or find a better way to calculate the residual).

I can see a theoretical problem with the code I sent. If the 53c80 raises 
IRQ during the outsb() or insb(), we could still end up with start == end, 
which could mess up both the residual and the handling for an incomplete 
transfer.

> The PDMA is then reset which probably means BASR_END_DMA_TRANSFER will 
> not be asserted.
> 

But the BASR_END_DMA_TRANSFER flag is latched, and resetting the 53c400 
logic should not affect 53c80 registers (assuming they are accessible). So 
the reset does not explain the log messages.

Maybe your BASR=0x98 observations do not co-incide with the log messages. 
Or maybe we need to wait for registers to become accessible after the 
reset.

I've attempted to address all these issues in v5.

Thanks.

-- 


[PATCH v5 5/6] g_NCR5380: Re-work PDMA loops

2017-06-28 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 | 168 +--
 1 file changed, 88 insertions(+), 80 deletions(-)

diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c
index 5fd227bb1830..f7e50d2bca07 100644
--- a/drivers/scsi/g_NCR5380.c
+++ b/drivers/scsi/g_NCR5380.c
@@ -482,6 +482,30 @@ 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 void 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;
+   } 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);
+}
+
 /**
  * generic_NCR5380_pread - pseudo DMA read
  * @hostdata: scsi host private data
@@ -494,18 +518,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 residual;
int start = 0;
 
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);
+
+   while (start < len) {
+   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_HOST_BUF_NOT_RDY)
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,
@@ -516,44 +545,30 @@ 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 + hostdata->c400_host_buf,
-   dst + start, 64);
-   else if (hostdata->io_port)
-   insb(hostdata->io_port + hostdata->c400_host_buf,
-   dst + start, 128);
-   else
-   memcpy_fromio(dst + start,
-   hostdata->io + NCR53C400_host_buffer, 128);
-
-   start += 128;
-   blocks--;
+   if (NCR5380_read(hostdata->c400_ctl_status) &
+   CSR_GATED_53C80_IRQ)
+   break;
}
 

[PATCH v5 3/6] g_NCR5380: Cleanup comments and whitespace

2017-06-28 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..dedaed2d16e4 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 read
+ * @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 write
+ * @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 v5 4/6] g_NCR5380: Limit PDMA send to 512 B to avoid data corruption on DTC3181E

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

The corruption is always the same: one byte missing at the beginning of
a 128 B block. It happens only with slow Quantum LPS 240 drive, not with
faster IBM DORS-32160. It's not clear what causes this. Documentation
for the DTC436 chip has not been made available. Hence this workaround.

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

diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c
index dedaed2d16e4..5fd227bb1830 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;
 
@@ -644,7 +646,12 @@ 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;
+   return 0;
+
+   /* Limit PDMA send to 512 B to avoid random corruption on DTC3181E */
+   if (hostdata->board == BOARD_DTC3181E &&
+   cmd->sc_data_direction == DMA_TO_DEVICE)
+   transfersize = min(cmd->SCp.this_residual, 512);
 
return min(transfersize, DMA_MAX_SIZE);
 }
-- 
2.13.0



[PATCH v5 0/6] g_NCR5380: PDMA fixes and cleanup

2017-06-28 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.

Changed since v3:
- Add Ondrej's workaround for corrupt WRITE commands on DTC boards.
- Reset the 53c400 logic after any short PDMA transfer.
- Don't fail the transfer if the 53c400 logic got a reset.

Changed since v4:
- Bail out of transfer loops when Gated IRQ gets asserted. (Again.)
- Always call wait_for_53c80_registers() at end of transfer.
- Drain chip buffers after PDMA receive is interrupted.
- Rework residual calculation.
- Add new patch to correct DMA terminology.


Finn Thain (2):
  g_NCR5380: Cleanup comments and whitespace
  g_NCR5380: Use unambiguous terminology for PDMA send and receive

Ondrej Zary (4):
  g_NCR5380: Fix PDMA transfer size
  g_NCR5380: End PDMA transfer correctly on target disconnection
  g_NCR5380: Limit PDMA send to 512 B to avoid data corruption on
DTC3181E
  g_NCR5380: Re-work PDMA loops

 drivers/scsi/g_NCR5380.c | 260 +--
 1 file changed, 139 insertions(+), 121 deletions(-)

-- 
2.13.0



[PATCH v5 6/6] g_NCR5380: Use unambiguous terminology for PDMA send and receive

2017-06-28 Thread Finn Thain
The word "read" may be used to mean "DMA read operation" or
"SCSI READ command", though a READ command implies writing to memory.

Signed-off-by: Finn Thain 
---
 drivers/scsi/g_NCR5380.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c
index f7e50d2bca07..b8b1ed2806bb 100644
--- a/drivers/scsi/g_NCR5380.c
+++ b/drivers/scsi/g_NCR5380.c
@@ -49,8 +49,8 @@
int board
 
 #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_recv_setup  generic_NCR5380_precv
+#define NCR5380_dma_send_setup  generic_NCR5380_psend
 #define NCR5380_dma_residualgeneric_NCR5380_dma_residual
 
 #define NCR5380_intrgeneric_NCR5380_intr
@@ -507,7 +507,7 @@ static void wait_for_53c80_access(struct NCR5380_hostdata 
*hostdata)
 }
 
 /**
- * generic_NCR5380_pread - pseudo DMA read
+ * generic_NCR5380_precv - pseudo DMA receive
  * @hostdata: scsi host private data
  * @dst: buffer to write into
  * @len: transfer size
@@ -515,7 +515,7 @@ static void wait_for_53c80_access(struct NCR5380_hostdata 
*hostdata)
  * Perform a pseudo DMA mode receive from a 53C400 or equivalent device.
  */
 
-static inline int generic_NCR5380_pread(struct NCR5380_hostdata *hostdata,
+static inline int generic_NCR5380_precv(struct NCR5380_hostdata *hostdata,
 unsigned char *dst, int len)
 {
int residual;
@@ -574,7 +574,7 @@ static inline int generic_NCR5380_pread(struct 
NCR5380_hostdata *hostdata,
 }
 
 /**
- * generic_NCR5380_pwrite - pseudo DMA write
+ * generic_NCR5380_psend - pseudo DMA send
  * @hostdata: scsi host private data
  * @src: buffer to read from
  * @len: transfer size
@@ -582,8 +582,8 @@ static inline int generic_NCR5380_pread(struct 
NCR5380_hostdata *hostdata,
  * Perform a pseudo DMA mode send to a 53C400 or equivalent device.
  */
 
-static inline int generic_NCR5380_pwrite(struct NCR5380_hostdata *hostdata,
- unsigned char *src, int len)
+static inline int generic_NCR5380_psend(struct NCR5380_hostdata *hostdata,
+unsigned char *src, int len)
 {
int residual;
int start = 0;
-- 
2.13.0



[PATCH v5 1/6] g_NCR5380: Fix PDMA transfer size

2017-06-28 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



[PATCH v5 2/6] g_NCR5380: End PDMA transfer correctly on target disconnection

2017-06-28 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] aic7xxx: fix firmware build with O=path

2017-06-28 Thread Jakub Kicinski
Building firmware with O=path was apparently broken in aic7 for ever.
Message of the previous commit to the Makefile (from 2008) mentions
this unfortunate state of affairs already.  Fix this, mostly to make
randconfig builds more reliable.

Signed-off-by: Jakub Kicinski 
---
 drivers/scsi/aic7xxx/Makefile| 12 
 drivers/scsi/aic7xxx/aicasm/Makefile | 53 
 2 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/drivers/scsi/aic7xxx/Makefile b/drivers/scsi/aic7xxx/Makefile
index 741d81861d17..07b60a780c06 100644
--- a/drivers/scsi/aic7xxx/Makefile
+++ b/drivers/scsi/aic7xxx/Makefile
@@ -55,9 +55,9 @@ aicasm-7xxx-opts-$(CONFIG_AIC7XXX_REG_PRETTY_PRINT) := \
 
 ifeq ($(CONFIG_AIC7XXX_BUILD_FIRMWARE),y)
 $(obj)/aic7xxx_seq.h: $(src)/aic7xxx.seq $(src)/aic7xxx.reg 
$(obj)/aicasm/aicasm
-   $(obj)/aicasm/aicasm -I$(src) -r $(obj)/aic7xxx_reg.h \
+   $(obj)/aicasm/aicasm -I$(srctree)/$(src) -r $(obj)/aic7xxx_reg.h \
  $(aicasm-7xxx-opts-y) -o $(obj)/aic7xxx_seq.h \
- $(src)/aic7xxx.seq
+ $(srctree)/$(src)/aic7xxx.seq
 
 $(aic7xxx-gen-y): $(obj)/aic7xxx_seq.h
 else
@@ -72,14 +72,14 @@ aicasm-79xx-opts-$(CONFIG_AIC79XX_REG_PRETTY_PRINT) := \
 
 ifeq ($(CONFIG_AIC79XX_BUILD_FIRMWARE),y)
 $(obj)/aic79xx_seq.h: $(src)/aic79xx.seq $(src)/aic79xx.reg 
$(obj)/aicasm/aicasm
-   $(obj)/aicasm/aicasm -I$(src) -r $(obj)/aic79xx_reg.h \
+   $(obj)/aicasm/aicasm -I$(srctree)/$(src) -r $(obj)/aic79xx_reg.h \
  $(aicasm-79xx-opts-y) -o $(obj)/aic79xx_seq.h \
- $(src)/aic79xx.seq
+ $(srctree)/$(src)/aic79xx.seq
 
 $(aic79xx-gen-y): $(obj)/aic79xx_seq.h
 else
 $(obj)/aic79xx_reg_print.c: $(src)/aic79xx_reg_print.c_shipped
 endif
 
-$(obj)/aicasm/aicasm: $(src)/aicasm/*.[chyl]
-   $(MAKE) -C $(src)/aicasm
+$(obj)/aicasm/aicasm: $(srctree)/$(src)/aicasm/*.[chyl]
+   $(MAKE) -C $(srctree)/$(src)/aicasm OUTDIR=$(shell pwd)/$(obj)/aicasm/
diff --git a/drivers/scsi/aic7xxx/aicasm/Makefile 
b/drivers/scsi/aic7xxx/aicasm/Makefile
index b98c5c1056c3..45e2d49c1fff 100644
--- a/drivers/scsi/aic7xxx/aicasm/Makefile
+++ b/drivers/scsi/aic7xxx/aicasm/Makefile
@@ -1,19 +1,21 @@
 PROG=  aicasm
 
+OUTDIR ?= ./
+
 .SUFFIXES= .l .y .c .h
 
 CSRCS= aicasm.c aicasm_symbol.c
 YSRCS= aicasm_gram.y aicasm_macro_gram.y
 LSRCS= aicasm_scan.l aicasm_macro_scan.l
 
-GENHDRS=   aicdb.h $(YSRCS:.y=.h)
-GENSRCS=   $(YSRCS:.y=.c) $(LSRCS:.l=.c)
+GENHDRS=   $(addprefix ${OUTDIR}/,aicdb.h $(YSRCS:.y=.h))
+GENSRCS=   $(addprefix ${OUTDIR}/,$(YSRCS:.y=.c) $(LSRCS:.l=.c))
 
 SRCS=  ${CSRCS} ${GENSRCS}
 LIBS=  -ldb
 clean-files:= ${GENSRCS} ${GENHDRS} $(YSRCS:.y=.output) $(PROG)
 # Override default kernel CFLAGS.  This is a userland app.
-AICASM_CFLAGS:= -I/usr/include -I.
+AICASM_CFLAGS:= -I/usr/include -I. -I$(OUTDIR)
 LEX= flex
 YACC= bison
 YFLAGS= -d
@@ -32,22 +34,25 @@ YFLAGS+= -t -v
 LFLAGS= -d
 endif
 
-$(PROG):  ${GENHDRS} $(SRCS)
-   $(AICASM_CC) $(AICASM_CFLAGS) $(SRCS) -o $(PROG) $(LIBS)
+$(PROG):  $(OUTDIR) ${GENHDRS} $(SRCS)
+   $(AICASM_CC) $(AICASM_CFLAGS) $(SRCS) -o $(OUTDIR)/$(PROG) $(LIBS)
+
+$(OUTDIR):
+   mkdir -p $(OUTDIR)
 
-aicdb.h:
+$(OUTDIR)/aicdb.h:
@if [ -e "/usr/include/db4/db_185.h" ]; then\
-   echo "#include " > aicdb.h;   \
+   echo "#include " > $@;\
 elif [ -e "/usr/include/db3/db_185.h" ]; then  \
-   echo "#include " > aicdb.h;   \
+   echo "#include " > $@;\
 elif [ -e "/usr/include/db2/db_185.h" ]; then  \
-   echo "#include " > aicdb.h;   \
+   echo "#include " > $@;\
 elif [ -e "/usr/include/db1/db_185.h" ]; then  \
-   echo "#include " > aicdb.h;   \
+   echo "#include " > $@;\
 elif [ -e "/usr/include/db/db_185.h" ]; then   \
-   echo "#include " > aicdb.h;\
+   echo "#include " > $@; \
 elif [ -e "/usr/include/db_185.h" ]; then  \
-   echo "#include " > aicdb.h;   \
+   echo "#include " > $@;\
 else   \
echo "*** Install db development libraries";\
 fi
@@ -58,23 +63,23 @@ $(PROG):  ${GENHDRS} $(SRCS)
 # Create a dependency chain in generated files
 # to avoid concurrent invocations of the single
 # rule that builds them all.
-aicasm_gram.c: aicasm_gram.h
-aicasm_gram.c aicasm_gram.h: aicasm_gram.y
+$(OUTDIR)/aicasm_gram.c: $(OUTDIR)/aicasm_gram.h
+$(OUTDIR)/aicasm_gram.c $(OUTDIR)/aicasm_gram.h: aicasm_gram.y
$(YACC) $(YFLAGS) -b $(<:.y=) $<
-   mv $(<:.y=).tab.c $(<:.y=.c)
-   mv $(<:.y=).tab.h $(<:.y=.h)
+  

Re: [PATCH] scsi: ufs: check link active or not after switch to HS mode

2017-06-28 Thread Zang Leigang
On Wed, Jun 28, 2017 at 04:48:21PM -0700, Subhash Jadavani wrote:
> On 2017-06-24 04:44, Zang Leigang wrote:
> >Some device can successfully link and switch to HS mode. But failed
> >to do more. ufshcd_verify_dev_init can help to find this earlier.
> >
> >Signed-off-by: Zang Leigang 
> >
> >diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> >index ffe8d8608818..eb03388fc4bd 100644
> >--- a/drivers/scsi/ufs/ufshcd.c
> >+++ b/drivers/scsi/ufs/ufshcd.c
> >@@ -6373,6 +6373,14 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
> > __func__, ret);
> > goto out;
> > }
> >+
> >+/*
> >+ * Some device lost link after switch to HS mode. Check if
> >+ * connect is established here.
> >+ */
> 
> I have never across such failures. If this issue is limited to
> certain device vendors then I don't think if we want to do send NOP
> unconditionally for all the devices.
> We should probably add quirk for these failed devices and send NOP
> only for such devices.

I have double checked this issue, it's already fixed. This patch doesn't need
any more. Thanks.
> 
> 
> >+ret = ufshcd_verify_dev_init(hba);
> >+if (ret)
> >+goto out;
> > }
> >
> > /* set the state as operational after switching to desired gear */
> 
> -- 
> The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> a Linux Foundation Collaborative Project

-- 
Thanks,
Zang Leigang


本邮件及其附件含有华为公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件!
This e-mail and its attachments contain confidential information from HUAWEI, 
which is intended only for the person or entity whose address is listed above. 
Any use of the information contained herein in any way (including, but not 
limited to, total or partial disclosure, reproduction, or dissemination) by 
persons other than the intended recipient(s) is prohibited. If you receive this 
e-mail in error, please notify the sender by phone or email immediately and 
delete it!


Re: [PATCH] scsi: ufs: set host_byte to DID_REQUEUE when ocs = OCS_ABORTED

2017-06-28 Thread Zang Leigang
On Wed, Jun 28, 2017 at 04:42:36PM -0700, Subhash Jadavani wrote:
> On 2017-06-24 03:27, Zang Leigang wrote:
> >Host set ocs to OCS_ABORTED when clear a doorbell in err handler.
> 
> OCS field is valid after host controller has cleared the
> corresponding doorbell (UTRLDBR) bit to zero. And here HW would be
> clearing the doorbell bit, not the SW. So I am not sure what do you
> mean in sentence above? Can you please elaborate more on this?
> 
Err handler clear PENDING transfer requests with ufshcd_clear_cmd,
and host set these requests's ocs to 6(OCS_ABORTED). I think it's
better to let these request retry, because an err handler may fix
the err condition.
> 
> >Then scsi_decide_disposition return SUCCESS. This may cause some
> >filesystem panic because a FAILED REQUESET. Requeue and complete is
> >better.
> 
> Why do you think retrying this HW aborted request will succeed next
> time? Are we going to fix some request parameters before retrying?
> If not, it will most likely fail again.
> 
HW aborted request commonly comes from err handler with "ufshcd_clear_cmd",
In fact, I never seen that host aborted a request on host's own initiative.
If err handler successfully re-link and fix the host or device, retry will
most likely success.
> 
> >
> >Signed-off-by: Zang Leigang 
> >
> >diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> >index ffe8d8608818..e050dcea1bea 100644
> >--- a/drivers/scsi/ufs/ufshcd.c
> >+++ b/drivers/scsi/ufs/ufshcd.c
> >@@ -4545,8 +4545,6 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba,
> >struct ufshcd_lrb *lrbp)
> > }
> > break;
> > case OCS_ABORTED:
> >-result |= DID_ABORT << 16;
> >-break;
> > case OCS_INVALID_COMMAND_STATUS:
> > result |= DID_REQUEUE << 16;
> > break;
> 
> -- 
> The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> a Linux Foundation Collaborative Project

-- 
Thanks,
Zang Leigang


本邮件及其附件含有华为公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件!
This e-mail and its attachments contain confidential information from HUAWEI, 
which is intended only for the person or entity whose address is listed above. 
Any use of the information contained herein in any way (including, but not 
limited to, total or partial disclosure, reproduction, or dissemination) by 
persons other than the intended recipient(s) is prohibited. If you receive this 
e-mail in error, please notify the sender by phone or email immediately and 
delete it!


Re: [PATCH 4/5] target: user: Fix sense data handling

2017-06-28 Thread Damien Le Moal

On 6/29/17 02:44, Mike Christie wrote:
> On 06/28/2017 12:58 AM, Damien Le Moal wrote:
>> If the user request handler completed the request with a CHECK CONDITION
>> status, tcmu_handle_completion() copies the command entry sense data
>> into the session request structure sense data. However, the sense data
>> length indicated by the field scsi_sense_length is not set and equal to
>> 0, resulting in the copy being a no-op and failure to propagate the
>> sense data back to the initiator. To fix this, properly set the session
>> command sense data length and also set the session command
>> SCF_TRANSPORT_TASK_SENSE flag to indicate that the command has valid
>> sense data.
>>
>> Signed-off-by: Damien Le Moal 
>> ---
>>  drivers/target/target_core_user.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/target/target_core_user.c 
>> b/drivers/target/target_core_user.c
>> index beb5f09..7426b4c 100644
>> --- a/drivers/target/target_core_user.c
>> +++ b/drivers/target/target_core_user.c
>> @@ -831,7 +831,9 @@ static void tcmu_handle_completion(struct tcmu_cmd *cmd, 
>> struct tcmu_cmd_entry *
>>  entry->rsp.scsi_status = SAM_STAT_CHECK_CONDITION;
>>  } else if (entry->rsp.scsi_status == SAM_STAT_CHECK_CONDITION) {
>>  memcpy(se_cmd->sense_buffer, entry->rsp.sense_buffer,
>> -   se_cmd->scsi_sense_length);
>> +   TRANSPORT_SENSE_BUFFER);
>> +se_cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER;
>> +se_cmd->se_cmd_flags |= SCF_TRANSPORT_TASK_SENSE;
>>  } else if (se_cmd->se_cmd_flags & SCF_BIDI) {
>>  /* Get Data-In buffer before clean up */
>>  gather_data_area(udev, cmd, true);
>>
> 
> I have a patch similar to this and 5/5 in my set:
> 
> https://www.spinics.net/lists/target-devel/msg15430.html
> 
> If yours gets merged first then I will build my set over them, so patch
> looks ok to me.
> 
> Reviewed-by: Mike Christie 

Mike,

Thank you for the review. I checked your series and it looks like it
addressing all the sense data handling problems I detected. I will
retest with your patch set applied.

Thanks !

-- 
Damien Le Moal,
Western Digital


Re: [PATCH 0/5] target: Zoned block device support and bug fixes

2017-06-28 Thread Damien Le Moal


On 6/28/17 23:34, Bryant G. Ly wrote:
> 
>> This series introduce zoned block device support for the pscsi backstore and
>> also fixes several problems with sense data handling for failed requests.
>>
>> The first patch is only a cleanup, so not really necessary but nice to have I
>> think.
>>
>> Patch 2 and 3 introduce support for host managed zoned block device type 
>> (14h)
>> in the SCSI passthrough backstore and fixes sense data handling for commands
>> failed by the backstore device. With these fixes, a host zoned block device
>> exported with the iscsi or loopback transport pass libzbc ZBC specification
>> conformance tests.
>>
>> Finally, patch 4 and 5 fix sense data hadling with the user backstore code. A
>> prototype ZBC emulation tcmu-runner handler was used to test these fixes and
>> result in the emulated handler passing libzbc ZBC specification conformance
>> tests.
>>
>> (Note: the ZBC emulation tcmu-runner handler will be submitted to the
>> tcmu-runner project on github)
>>
>> Please consider these patches for inclusion with kernel 4.13.
>>
>> Damien Le Moal (5):
>>target: Use macro for WRITE_VERIFY_xx operation codes
>>target: pscsi: Introduce TYPE_ZBC support
>>target: pscsi: Fix sense data handling
>>target: user: Fix sense data handling
>>target: core: Fix failed command sense data handling
>>
>>   drivers/target/target_core_device.c|  4 ++--
>>   drivers/target/target_core_pscsi.c | 20 +---
>>   drivers/target/target_core_transport.c |  5 +++--
>>   drivers/target/target_core_user.c  |  4 +++-
>>   include/scsi/scsi_proto.h  |  1 +
>>   5 files changed, 22 insertions(+), 12 deletions(-)
> 
> Hi Damien,
> 
> You should take a look at the first two patches in this series to address 
> your sense data handling.
> 
> https://www.spinics.net/lists/target-devel/msg15430.html

Bryant,

Thank you for the pointer. I missed that.

-- 
Damien Le Moal,
Western Digital


Re: [PATCH] scsi: ufs: check link active or not after switch to HS mode

2017-06-28 Thread Subhash Jadavani

On 2017-06-24 04:44, Zang Leigang wrote:

Some device can successfully link and switch to HS mode. But failed
to do more. ufshcd_verify_dev_init can help to find this earlier.

Signed-off-by: Zang Leigang 

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index ffe8d8608818..eb03388fc4bd 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -6373,6 +6373,14 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
__func__, ret);
goto out;
}
+
+   /*
+* Some device lost link after switch to HS mode. Check if
+* connect is established here.
+*/


I have never across such failures. If this issue is limited to certain 
device vendors then I don't think if we want to do send NOP 
unconditionally for all the devices.
We should probably add quirk for these failed devices and send NOP only 
for such devices.




+   ret = ufshcd_verify_dev_init(hba);
+   if (ret)
+   goto out;
}

/* set the state as operational after switching to desired gear */


--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


Re: [PATCH] scsi: ufs: flush eh_work when eh_work scheduled.

2017-06-28 Thread Subhash Jadavani

On 2017-06-24 04:14, Zang Leigang wrote:

Forget a condition: eh_work scheduled but do not start to work.

Signed-off-by: Zang Leigang 

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index e050dcea1bea..a2dff12713fc 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -5807,7 +5807,8 @@ static int ufshcd_eh_host_reset_handler(struct
scsi_cmnd *cmd)
do {
spin_lock_irqsave(hba->host->host_lock, flags);
if (!(work_pending(>eh_work) ||
-   hba->ufshcd_state == UFSHCD_STATE_RESET))
+   hba->ufshcd_state == UFSHCD_STATE_RESET ||
+   hba->ufshcd_state == UFSHCD_STATE_EH_SCHEDULED))
break;
spin_unlock_irqrestore(hba->host->host_lock, flags);
dev_dbg(hba->dev, "%s: reset in progress\n", __func__);


Looks good to me.
Reviewed-by: Subhash Jadavani 

--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


Re: [PATCH] scsi: ufs: set host_byte to DID_REQUEUE when ocs = OCS_ABORTED

2017-06-28 Thread Subhash Jadavani

On 2017-06-24 03:27, Zang Leigang wrote:

Host set ocs to OCS_ABORTED when clear a doorbell in err handler.


OCS field is valid after host controller has cleared the corresponding 
doorbell (UTRLDBR) bit to zero. And here HW would be clearing the 
doorbell bit, not the SW. So I am not sure what do you mean in sentence 
above? Can you please elaborate more on this?



Then scsi_decide_disposition return SUCCESS. This may cause some
filesystem panic because a FAILED REQUESET. Requeue and complete is
better.


Why do you think retrying this HW aborted request will succeed next 
time? Are we going to fix some request parameters before retrying? If 
not, it will most likely fail again.





Signed-off-by: Zang Leigang 

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index ffe8d8608818..e050dcea1bea 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -4545,8 +4545,6 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba,
struct ufshcd_lrb *lrbp)
}
break;
case OCS_ABORTED:
-   result |= DID_ABORT << 16;
-   break;
case OCS_INVALID_COMMAND_STATUS:
result |= DID_REQUEUE << 16;
break;


--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


Re: [PATCH] qla2xxx: Fix compile warning

2017-06-28 Thread Madhani, Himanshu

> On Jun 28, 2017, at 3:12 PM, James Bottomley 
>  wrote:
> 
> On Wed, 2017-06-28 at 15:00 -0700, Himanshu Madhani wrote:
>> Fixes following warning
>> 
>> drivers/scsi/qla2xxx/qla_nvme.c: In function 'qla2x00_start_nvme_mq':
>> include/uapi/linux/byteorder/big_endian.h:32:26: warning: large
>> integer
>> implicitly truncated to unsigned type [-Woverflow]
>>  #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
>> 
>> Signed-off-by: Himanshu Madhani 
>> ---
>>  drivers/scsi/qla2xxx/qla_nvme.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/drivers/scsi/qla2xxx/qla_nvme.c
>> b/drivers/scsi/qla2xxx/qla_nvme.c
>> index 1da8fa8f641d..14e25e32e622 100644
>> --- a/drivers/scsi/qla2xxx/qla_nvme.c
>> +++ b/drivers/scsi/qla2xxx/qla_nvme.c
>> @@ -441,7 +441,7 @@ static int qla2x00_start_nvme_mq(srb_t *sp)
>>  req->ring_ptr++;
>>  }
>>  cont_pkt = (cont_a64_entry_t *)req-
>>> ring_ptr;
>> -cont_pkt->entry_type =
>> cpu_to_le32(CONTINUE_A64_TYPE);
>> +cont_pkt->entry_type = CONTINUE_A64_TYPE;
>>  
> 
> Well the code is definitely buggy, because it will load 0 on a BE
> system.  However, are you sure this is the right fix?  I thought the
> qlogic engine did groups of 32 bit words, which is why the pre-nvme
> code loads this field as:
> 
>   *((uint32_t *)(_pkt->entry_type)) = cpu_to_le32(CONTINUE_TYPE);
> 
> James

Agree. I need to go back and check which would be right fix. 

Once i’ve confirmed it works on both platform, I’ll send out new patch.

Thanks,
- Himanshu



Re: [PATCH] qla2xxx: Fix compile warning

2017-06-28 Thread James Bottomley
On Wed, 2017-06-28 at 15:00 -0700, Himanshu Madhani wrote:
> Fixes following warning
> 
> drivers/scsi/qla2xxx/qla_nvme.c: In function 'qla2x00_start_nvme_mq':
> include/uapi/linux/byteorder/big_endian.h:32:26: warning: large
> integer
> implicitly truncated to unsigned type [-Woverflow]
>  #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
> 
> Signed-off-by: Himanshu Madhani 
> ---
>  drivers/scsi/qla2xxx/qla_nvme.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_nvme.c
> b/drivers/scsi/qla2xxx/qla_nvme.c
> index 1da8fa8f641d..14e25e32e622 100644
> --- a/drivers/scsi/qla2xxx/qla_nvme.c
> +++ b/drivers/scsi/qla2xxx/qla_nvme.c
> @@ -441,7 +441,7 @@ static int qla2x00_start_nvme_mq(srb_t *sp)
>   req->ring_ptr++;
>   }
>   cont_pkt = (cont_a64_entry_t *)req-
> >ring_ptr;
> - cont_pkt->entry_type =
> cpu_to_le32(CONTINUE_A64_TYPE);
> + cont_pkt->entry_type = CONTINUE_A64_TYPE;
> 

Well the code is definitely buggy, because it will load 0 on a BE
system.  However, are you sure this is the right fix?  I thought the
qlogic engine did groups of 32 bit words, which is why the pre-nvme
code loads this field as:

*((uint32_t *)(_pkt->entry_type)) = cpu_to_le32(CONTINUE_TYPE);

James



[PATCH] qla2xxx: Fix compile warning

2017-06-28 Thread Himanshu Madhani
Fixes following warning

drivers/scsi/qla2xxx/qla_nvme.c: In function 'qla2x00_start_nvme_mq':
include/uapi/linux/byteorder/big_endian.h:32:26: warning: large integer
implicitly truncated to unsigned type [-Woverflow]
 #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))

Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_nvme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index 1da8fa8f641d..14e25e32e622 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -441,7 +441,7 @@ static int qla2x00_start_nvme_mq(srb_t *sp)
req->ring_ptr++;
}
cont_pkt = (cont_a64_entry_t *)req->ring_ptr;
-   cont_pkt->entry_type = cpu_to_le32(CONTINUE_A64_TYPE);
+   cont_pkt->entry_type = CONTINUE_A64_TYPE;
 
cur_dsd = (uint32_t *)cont_pkt->dseg_0_address;
avail_dsds = 5;
-- 
2.13.1.452.g97e2ff464



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

2017-06-28 Thread Ondrej Zary
On Wednesday 28 June 2017 06:04:36 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.
>
> Changed since v3:
> - Add Ondrej's workaround for corrupt WRITE commands on DTC boards.
> - Reset the 53c400 logic after any short PDMA transfer.
> - Don't fail the transfer if the 53c400 logic got a reset.
>
>
> Finn Thain (1):
>   g_NCR5380: Cleanup comments and whitespace
>
> Ondrej Zary (4):
>   g_NCR5380: Fix PDMA transfer size
>   g_NCR5380: End PDMA transfer correctly on target disconnection
>   g_NCR5380: Limit PDMA send to 512 B to avoid random corruption on
> DTC3181E
>   g_NCR5380: Re-work PDMA loops
>
>  drivers/scsi/g_NCR5380.c | 239
> --- 1 file changed, 120
> insertions(+), 119 deletions(-)

Now read seems to work on non-DTC chips.
Writes continue in PDMA after disconnect but there's a corruption - one 128 B 
block missing on disconnect.


On DTC, the log is spammed with errors like this:
sd 2:0:1:0: [sdb] tag#0 generic_NCR5380_pread: End of DMA timeout (0)

They're cause by read corruption on DTC:
pread() is breaking at start=3968 because of an end-of-DMA IRQ (BASR=0x98) but 
pdma_residual is set to zero (block counter is zero because the data was read 
into the buffer but we did not read it from there). So we lose one buffer of 
data on each 4 KB read.
The PDMA is then reset which probably means BASR_END_DMA_TRANSFER will not be 
asserted.


-- 
Ondrej Zary


Re: [PATCH v2 1/6] qla2xxx: Add FC-NVMe port discovery and PRLI handling

2017-06-28 Thread Madhani, Himanshu
Hi James,

> On Jun 28, 2017, at 2:15 PM, James Bottomley 
>  wrote:
> 
> On Wed, 2017-06-21 at 13:48 -0700, Madhani, Himanshu wrote:
>> From: Duane Grigsby 
>> 
>> Added logic to change the login process into an optional PRIL
>> step for FC-NVMe ports as a separate operation, such that we can
>> change type to 0x28 (NVMe).
>> 
>> Currently, the driver performs the PLOGI/PRLI together as one
>> operation, but if the discovered port is an NVMe port then we
>> first issue the PLOGI and then we issue the PRLI. Also, the
>> fabric discovery logic was changed to mark each discovered FC
>> NVMe port, so that we can register them with the FC-NVMe transport
>> later.
>> 
>> Signed-off-by: Darren Trapp 
>> Signed-off-by: Duane Grigsby 
>> Signed-off-by: Anil Gurumurthy 
> 
> I just got a whole load of bounces from this: you've misspelled Anil's
> email address (h and t transposed).  It looks like a generic cut and
> paste, so could you fix it for next time?
> 
> Thanks,
> 
> James
> 

Sorry about that. Will fix this up for next time.

Thanks,
- Himanshu



Re: [PATCH v2 1/6] qla2xxx: Add FC-NVMe port discovery and PRLI handling

2017-06-28 Thread James Bottomley
On Wed, 2017-06-21 at 13:48 -0700, Madhani, Himanshu wrote:
> From: Duane Grigsby 
> 
> Added logic to change the login process into an optional PRIL
> step for FC-NVMe ports as a separate operation, such that we can
> change type to 0x28 (NVMe).
> 
> Currently, the driver performs the PLOGI/PRLI together as one
> operation, but if the discovered port is an NVMe port then we
> first issue the PLOGI and then we issue the PRLI. Also, the
> fabric discovery logic was changed to mark each discovered FC
> NVMe port, so that we can register them with the FC-NVMe transport
> later.
> 
> Signed-off-by: Darren Trapp 
> Signed-off-by: Duane Grigsby 
> Signed-off-by: Anil Gurumurthy 

I just got a whole load of bounces from this: you've misspelled Anil's
email address (h and t transposed).  It looks like a generic cut and
paste, so could you fix it for next time?

Thanks,

James



RE: [PATCH 04/47] aacraid: use aac_tmf_callback for reset fib

2017-06-28 Thread Dave Carroll
> 
> 
> When sending a reset fib we shouldn't rely on the scsi command, but rather set
> the TMF status in the map_info->reset_state variable.
> That allows us to send a TMF independent on a scsi command.
> 
> Signed-off-by: Hannes Reinecke 
> ---

>  /*
>   * aac_eh_dev_reset- Device reset command handling
>   * @scsi_cmd:  SCSI command block causing the reset
> +921,19 @@ static int aac_eh_dev_reset(struct scsi_cmnd *cmd)

> 
> /* Wait up to 15 seconds for completion */
> for (count = 0; count < 15; ++count) {
> -   if (cmd->SCp.sent_command) {
> -   ret = SUCCESS;
> +   if (info->reset_state == 0) {

Should this be <= 0, as in target reset? Otherwise it will always be success ...

-Dave

> +   ret = info->reset_state == 0 ? SUCCESS : FAILED;
> break;



Re: [PATCH 13/47] megaraid: pass in NULL scb for host reset

2017-06-28 Thread Christoph Hellwig
On Wed, Jun 28, 2017 at 11:38:22AM -0700, adam radford wrote:
> LSI/Broadcom isn't the maintainer of the 3ware drivers.  See 'MAINTAINERS'.
>   Your attempts
> to remove them may get a NACK from the Maintainer since I believe there are
> still users of these controllers.

Same for the legacy megaraid driver, but we can just mark that as
orphan for now.


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

2017-06-28 Thread Tejun Heo
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 

Applied to libata/for-4.13 w/ Martin's ack added.

Thanks.

-- 
tejun


Re: [PATCH 5/5] target: core: Fix failed command sense data handling

2017-06-28 Thread Mike Christie
On 06/28/2017 12:59 AM, Damien Le Moal wrote:
> For a target device without a transport->transport_complete method
> defined (e.g. target_core_user), target_complete_cmd() will always
> result in a failed command completion being processed through target
> failure completion work even when the command failure comes from the
> target processing and has valid sense data (and hence does not require
> sense data emulation as done in the failure work processing). To ensure
> that the failed command sense data is propagated as indicated by the
> target, make sure that the normal "ok" work completion path is used by
> moving the command SCF_TRANSPORT_TASK_SENSE flag test out of the
> transport_complete defined conditional.
> 
> Signed-off-by: Damien Le Moal 
> ---
>  drivers/target/target_core_transport.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/target/target_core_transport.c 
> b/drivers/target/target_core_transport.c
> index f1b3a46..a18e4db 100644
> --- a/drivers/target/target_core_transport.c
> +++ b/drivers/target/target_core_transport.c
> @@ -719,10 +719,11 @@ void target_complete_cmd(struct se_cmd *cmd, u8 
> scsi_status)
>   dev->transport->transport_complete(cmd,
>   cmd->t_data_sg,
>   transport_get_sense_buffer(cmd));
> - if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE)
> - success = 1;
>   }
>  
> + if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE)
> + success = 1;
> +
>   /*
>* Check for case where an explicit ABORT_TASK has been received
>* and transport_wait_for_tasks() will be waiting for completion..
> 

Reviewed-by: Mike Christie 


Re: [PATCH 4/5] target: user: Fix sense data handling

2017-06-28 Thread Mike Christie
On 06/28/2017 12:58 AM, Damien Le Moal wrote:
> If the user request handler completed the request with a CHECK CONDITION
> status, tcmu_handle_completion() copies the command entry sense data
> into the session request structure sense data. However, the sense data
> length indicated by the field scsi_sense_length is not set and equal to
> 0, resulting in the copy being a no-op and failure to propagate the
> sense data back to the initiator. To fix this, properly set the session
> command sense data length and also set the session command
> SCF_TRANSPORT_TASK_SENSE flag to indicate that the command has valid
> sense data.
> 
> Signed-off-by: Damien Le Moal 
> ---
>  drivers/target/target_core_user.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/target/target_core_user.c 
> b/drivers/target/target_core_user.c
> index beb5f09..7426b4c 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -831,7 +831,9 @@ static void tcmu_handle_completion(struct tcmu_cmd *cmd, 
> struct tcmu_cmd_entry *
>   entry->rsp.scsi_status = SAM_STAT_CHECK_CONDITION;
>   } else if (entry->rsp.scsi_status == SAM_STAT_CHECK_CONDITION) {
>   memcpy(se_cmd->sense_buffer, entry->rsp.sense_buffer,
> -se_cmd->scsi_sense_length);
> +TRANSPORT_SENSE_BUFFER);
> + se_cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER;
> + se_cmd->se_cmd_flags |= SCF_TRANSPORT_TASK_SENSE;
>   } else if (se_cmd->se_cmd_flags & SCF_BIDI) {
>   /* Get Data-In buffer before clean up */
>   gather_data_area(udev, cmd, true);
> 

I have a patch similar to this and 5/5 in my set:

https://www.spinics.net/lists/target-devel/msg15430.html

If yours gets merged first then I will build my set over them, so patch
looks ok to me.

Reviewed-by: Mike Christie 



RE: [PATCH 13/47] megaraid: pass in NULL scb for host reset

2017-06-28 Thread Kashyap Desai
> -Original Message-
> From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
> ow...@vger.kernel.org] On Behalf Of Hannes Reinecke
> Sent: Wednesday, June 28, 2017 9:00 PM
> To: Sumit Saxena; Christoph Hellwig
> Cc: Martin K. Petersen; James Bottomley; linux-scsi@vger.kernel.org;
> Hannes
> Reinecke
> Subject: Re: [PATCH 13/47] megaraid: pass in NULL scb for host reset
>
> On 06/28/2017 03:41 PM, Sumit Saxena wrote:
> >> -Original Message-
> >> From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
> >> ow...@vger.kernel.org] On Behalf Of Hannes Reinecke
> >> Sent: Wednesday, June 28, 2017 2:03 PM
> >> To: Christoph Hellwig
> >> Cc: Martin K. Petersen; James Bottomley; linux-scsi@vger.kernel.org;
> > Hannes
> >> Reinecke; Hannes Reinecke
> >> Subject: [PATCH 13/47] megaraid: pass in NULL scb for host reset
> >>
> >> When calling a host reset we shouldn't rely on the command triggering
> >> the reset, so allow megaraid_abort_and_reset() to be called with a NULL
> scb.
> >> And drop the pointless 'bus_reset' and 'target_reset' handlers, which
> > just call
> >> the same function as host_reset.
> >
> > If this patch address any functional issue, then we should consider
> > this.
> > If it's code optimization, can we ignore this as this is being very
> > old driver and no more maintained by Broadcom/LSI ?
> >
> Sadly, ignoring is not an option.
> I'm planning to update the calling convention for SCSI EH, to resolve the
> long-
> standing problem with sg_reset ioctls.
> sg_reset ioctl will allocate an out-of-band SCSI command, which does no
> longer
> work with the new command allocation scheme in multiqueue.
> So it's not possible to just 'ignore' it, as then SCSI EH will cease to
> function with
> that driver.

Hannes - We are in process of sending megaraid and 3ware driver removal as
LSI/Broadcom  stopped supporting those products.
I agree we should review this closely, but lack of test coverage and end of
life cycle of product is requesting us to know the rational.
For now, let's consider NACK for this patch. We will be removing old
megaraid (mbox) driver and 3Ware drivers soon.

>
> Sorry.
>
> >>
> >> Signed-off-by: Hannes Reinecke 
> >> ---
> >> drivers/scsi/megaraid.c | 42
> >> --
> >> 1 file changed, 16 insertions(+), 26 deletions(-)
> >>
> >> diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index
> >> 3c63c29..7e504d3 100644
> >> --- a/drivers/scsi/megaraid.c
> >> +++ b/drivers/scsi/megaraid.c
> >> @@ -1909,7 +1909,7 @@ static DEF_SCSI_QCMD(megaraid_queue)
> >>
> >>spin_lock_irq(>lock);
> >>
> >> -  rval =  megaraid_abort_and_reset(adapter, cmd, SCB_RESET);
> >> +  rval =  megaraid_abort_and_reset(adapter, NULL, SCB_RESET);
> >
> > If cmd=NULL is passed, it will crash inside function
> > megaraid_abort_and_reset() while dereferencing "cmd" pointer.
> > Below is the code of function  megaraid_abort_and_reset() where it
> > will
> > crash-
> >
> > static int
> > megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor)
> > {
> > struct list_head*pos, *next;
> > scb_t   *scb;
> >
> > dev_warn(>dev->dev, "%s cmd=%x 

[PATCH 3/3] cxlflash: Update debug prints in reset handlers

2017-06-28 Thread Matthew R. Ochs
The device and host reset handler contain debug prints to help
identify the entities being reset. Today these reset handlers
are based on a SCSI EH design that uses a SCSI command reference
as a means of identifying the target entity. As such, the debug
trace includes the SCSI command pointer and associated CDB. This
is not necessary as the SCSI command is simply the messenger in
these scenarios.

Refactor the debug prints in the host and reset handlers to only
present information that is applicable given the function scope.

Signed-off-by: Matthew R. Ochs 
---
 drivers/scsi/cxlflash/main.c | 18 +++---
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index 7054e11..077f62e 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -2435,14 +2435,8 @@ static int cxlflash_eh_device_reset_handler(struct 
scsi_cmnd *scp)
struct device *dev = >dev->dev;
int rcr = 0;
 
-   dev_dbg(dev, "%s: (scp=%p) %d/%d/%d/%llu "
-   "cdb=(%08x-%08x-%08x-%08x)\n", __func__, scp, host->host_no,
-   sdev->channel, sdev->id, sdev->lun,
-   get_unaligned_be32(&((u32 *)scp->cmnd)[0]),
-   get_unaligned_be32(&((u32 *)scp->cmnd)[1]),
-   get_unaligned_be32(&((u32 *)scp->cmnd)[2]),
-   get_unaligned_be32(&((u32 *)scp->cmnd)[3]));
-
+   dev_dbg(dev, "%s: %d/%d/%d/%llu\n", __func__,
+   host->host_no, sdev->channel, sdev->id, sdev->lun);
 retry:
switch (cfg->state) {
case STATE_NORMAL:
@@ -2483,13 +2477,7 @@ static int cxlflash_eh_host_reset_handler(struct 
scsi_cmnd *scp)
struct cxlflash_cfg *cfg = shost_priv(host);
struct device *dev = >dev->dev;
 
-   dev_dbg(dev, "%s: (scp=%p) %d/%d/%d/%llu "
-   "cdb=(%08x-%08x-%08x-%08x)\n", __func__, scp, host->host_no,
-   scp->device->channel, scp->device->id, scp->device->lun,
-   get_unaligned_be32(&((u32 *)scp->cmnd)[0]),
-   get_unaligned_be32(&((u32 *)scp->cmnd)[1]),
-   get_unaligned_be32(&((u32 *)scp->cmnd)[2]),
-   get_unaligned_be32(&((u32 *)scp->cmnd)[3]));
+   dev_dbg(dev, "%s: %d\n", __func__, host->host_no);
 
switch (cfg->state) {
case STATE_NORMAL:
-- 
2.1.0



[PATCH 2/3] cxlflash: Update send_tmf() parameters

2017-06-28 Thread Matthew R. Ochs
The current send_tmf() implementation is based on the caller providing
a SCSI command reference. In reality all that is needed is a SCSI device
reference as the routine uses a private command.

Refactor send_tmf() to pass the private adapter configuration reference
and a SCSI device reference. As a nice side effect, this will ease the
burden of converting caller routines to be based solely off of a SCSI
device reference.

Signed-off-by: Matthew R. Ochs 
---
 drivers/scsi/cxlflash/main.c | 27 +--
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index 455564f..7054e11 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -459,21 +459,20 @@ static u32 cmd_to_target_hwq(struct Scsi_Host *host, 
struct scsi_cmnd *scp,
 
 /**
  * send_tmf() - sends a Task Management Function (TMF)
- * @afu:   AFU to checkout from.
- * @scp:   SCSI command from stack describing target.
+ * @cfg:   Internal structure associated with the host.
+ * @sdev:  SCSI device destined for TMF.
  * @tmfcmd:TMF command to send.
  *
  * Return:
  * 0 on success, SCSI_MLQUEUE_HOST_BUSY or -errno on failure
  */
-static int send_tmf(struct afu *afu, struct scsi_cmnd *scp, u64 tmfcmd)
+static int send_tmf(struct cxlflash_cfg *cfg, struct scsi_device *sdev,
+   u64 tmfcmd)
 {
-   struct Scsi_Host *host = scp->device->host;
-   struct cxlflash_cfg *cfg = shost_priv(host);
+   struct afu *afu = cfg->afu;
struct afu_cmd *cmd = NULL;
struct device *dev = >dev->dev;
-   int hwq_index = cmd_to_target_hwq(host, scp, afu);
-   struct hwq *hwq = get_hwq(afu, hwq_index);
+   struct hwq *hwq = get_hwq(afu, PRIMARY_HWQ);
char *buf = NULL;
ulong lock_flags;
int rc = 0;
@@ -500,12 +499,12 @@ static int send_tmf(struct afu *afu, struct scsi_cmnd 
*scp, u64 tmfcmd)
 
cmd->parent = afu;
cmd->cmd_tmf = true;
-   cmd->hwq_index = hwq_index;
+   cmd->hwq_index = hwq->index;
 
cmd->rcb.ctx_id = hwq->ctx_hndl;
cmd->rcb.msi = SISL_MSI_RRQ_UPDATED;
-   cmd->rcb.port_sel = CHAN2PORTMASK(scp->device->channel);
-   cmd->rcb.lun_id = lun_to_lunid(scp->device->lun);
+   cmd->rcb.port_sel = CHAN2PORTMASK(sdev->channel);
+   cmd->rcb.lun_id = lun_to_lunid(sdev->lun);
cmd->rcb.req_flags = (SISL_REQ_FLAGS_PORT_LUN_ID |
  SISL_REQ_FLAGS_SUP_UNDERRUN |
  SISL_REQ_FLAGS_TMF_CMD);
@@ -2430,15 +2429,15 @@ static int cxlflash_eh_abort_handler(struct scsi_cmnd 
*scp)
 static int cxlflash_eh_device_reset_handler(struct scsi_cmnd *scp)
 {
int rc = SUCCESS;
-   struct Scsi_Host *host = scp->device->host;
+   struct scsi_device *sdev = scp->device;
+   struct Scsi_Host *host = sdev->host;
struct cxlflash_cfg *cfg = shost_priv(host);
struct device *dev = >dev->dev;
-   struct afu *afu = cfg->afu;
int rcr = 0;
 
dev_dbg(dev, "%s: (scp=%p) %d/%d/%d/%llu "
"cdb=(%08x-%08x-%08x-%08x)\n", __func__, scp, host->host_no,
-   scp->device->channel, scp->device->id, scp->device->lun,
+   sdev->channel, sdev->id, sdev->lun,
get_unaligned_be32(&((u32 *)scp->cmnd)[0]),
get_unaligned_be32(&((u32 *)scp->cmnd)[1]),
get_unaligned_be32(&((u32 *)scp->cmnd)[2]),
@@ -2447,7 +2446,7 @@ static int cxlflash_eh_device_reset_handler(struct 
scsi_cmnd *scp)
 retry:
switch (cfg->state) {
case STATE_NORMAL:
-   rcr = send_tmf(afu, scp, TMF_LUN_RESET);
+   rcr = send_tmf(cfg, sdev, TMF_LUN_RESET);
if (unlikely(rcr))
rc = FAILED;
break;
-- 
2.1.0



[PATCH 1/3] cxlflash: Avoid double free of character device

2017-06-28 Thread Matthew R. Ochs
The device_unregister() service used when cleaning up the character
device is already responsible for the internal state associated with
the device upon successful creation. As the cxlflash driver does not
obtain a second reference to the character device, the explicit call
to put_device() is not required and can lead to an inconsistent sysfs
among other issues as the reference is no longer valid after the first
put_device() is performed.

Remove the unnecessary put_device() to remedy this issue.

Fixes: a834a36b57d9 ("scsi: cxlflash: Create character device to provide host 
management interface")
Signed-off-by: Matthew R. Ochs 
---
 drivers/scsi/cxlflash/main.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index 7a787b6..455564f 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -923,7 +923,6 @@ static void cxlflash_put_minor(int minor)
  */
 static void cxlflash_release_chrdev(struct cxlflash_cfg *cfg)
 {
-   put_device(cfg->chardev);
device_unregister(cfg->chardev);
cfg->chardev = NULL;
cdev_del(>cdev);
-- 
2.1.0



[PATCH 0/3] cxlflash: Minor fix and EH refactoring

2017-06-28 Thread Matthew R. Ochs
This small series fixes a recently injected double free and also includes
two patches to refactor the host and reset handlers to ease the burden of
making this driver compatible with an updated SCSI EH framework.

This series is intended for 4.13 and is bisectable.

Matthew R. Ochs (3):
  cxlflash: Avoid double free of character device
  cxlflash: Update send_tmf() parameters
  cxlflash: Update debug prints in reset handlers

 drivers/scsi/cxlflash/main.c | 44 +++-
 1 file changed, 15 insertions(+), 29 deletions(-)

-- 
2.1.0



Re: [PATCH v2] qla2xxx: Protect access to qpair members with qpair->qp_lock

2017-06-28 Thread Madhani, Himanshu

> On Jun 23, 2017, at 12:10 AM, Johannes Thumshirn  wrote:
> 
> In qla2xx_start_scsi_mq() and qla2xx_dif_start_scsi_mq() we grab the
> qpair->qp_lock but do access members of the qpair before having the lock.
> Re-order the locking sequence to have all read and write access to qpair
> members under the qpair->qp_lock.
> 
> Signed-off-by: Johannes Thumshirn 
> ---
> drivers/scsi/qla2xxx/qla_iocb.c | 23 +--
> 1 file changed, 13 insertions(+), 10 deletions(-)
> 
> Changes to v1:
> * Use __qla2x00_marker() instead of qla2x00_marker which is fit to be called
>  with the qp_lock held (John)
> * Don't protect qpair->online and qpair->difdix_supported as it's not
>  needed (Hannes)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
> index 8404f17f3c6c..c64036ddd365 100644
> --- a/drivers/scsi/qla2xxx/qla_iocb.c
> +++ b/drivers/scsi/qla2xxx/qla_iocb.c
> @@ -1770,6 +1770,9 @@ qla2xxx_start_scsi_mq(srb_t *sp)
>   struct qla_hw_data *ha = vha->hw;
>   struct qla_qpair *qpair = sp->qpair;
> 
> + /* Acquire qpair specific lock */
> + spin_lock_irqsave(>qp_lock, flags);
> +
>   /* Setup qpair pointers */
>   rsp = qpair->rsp;
>   req = qpair->req;
> @@ -1779,15 +1782,14 @@ qla2xxx_start_scsi_mq(srb_t *sp)
> 
>   /* Send marker if required */
>   if (vha->marker_needed != 0) {
> - if (qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL) !=
> - QLA_SUCCESS)
> + if (__qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL) !=
> + QLA_SUCCESS) {
> + spin_unlock_irqrestore(>qp_lock, flags);
>   return QLA_FUNCTION_FAILED;
> + }
>   vha->marker_needed = 0;
>   }
> 
> - /* Acquire qpair specific lock */
> - spin_lock_irqsave(>qp_lock, flags);
> -
>   /* Check for room in outstanding command list. */
>   handle = req->current_outstanding_cmd;
>   for (index = 1; index < req->num_outstanding_cmds; index++) {
> @@ -1942,6 +1944,8 @@ qla2xxx_dif_start_scsi_mq(srb_t *sp)
>   return qla2xxx_start_scsi_mq(sp);
>   }
> 
> + spin_lock_irqsave(>qp_lock, flags);
> +
>   /* Setup qpair pointers */
>   rsp = qpair->rsp;
>   req = qpair->req;
> @@ -1951,15 +1955,14 @@ qla2xxx_dif_start_scsi_mq(srb_t *sp)
> 
>   /* Send marker if required */
>   if (vha->marker_needed != 0) {
> - if (qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL) !=
> - QLA_SUCCESS)
> + if (__qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL) !=
> + QLA_SUCCESS) {
> + spin_unlock_irqrestore(>qp_lock, flags);
>   return QLA_FUNCTION_FAILED;
> + }
>   vha->marker_needed = 0;
>   }
> 
> - /* Acquire ring specific lock */
> - spin_lock_irqsave(>qp_lock, flags);
> -
>   /* Check for room in outstanding command list. */
>   handle = req->current_outstanding_cmd;
>   for (index = 1; index < req->num_outstanding_cmds; index++) {
> -- 
> 2.12.3
> 

Looks Good. 

Acked-By: Himanshu Madhani 




Re: [PATCH 33/47] cxlflash: use dedicated reset command in send_tmf()

2017-06-28 Thread Matthew R. Ochs
Hi Hannes,

We actually just reworked these paths in a series that
was pulled in on Monday. While testing, I came across a
bug in that series and was planning on sending out a fix
for it. I'll include some patches that will ease the burden
of incorporating your EH updates for cxlflash.

Many thanks for leading this effort, it really helps to clean
up the SCSI EH paths! =)


-matt

> On Jun 28, 2017, at 3:32 AM, Hannes Reinecke  wrote:
> 
> From: Hannes Reinecke 
> 
> Reduce the queue depth by 1, and use this command as a dedicated
> reset command send_tmf().
> 
> Signed-off-by: Hannes Reinecke 
> ---
> drivers/scsi/cxlflash/common.h |  3 ++-
> drivers/scsi/cxlflash/main.c   | 23 ---
> 2 files changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/scsi/cxlflash/common.h b/drivers/scsi/cxlflash/common.h
> index 6d95e8e..b2b3bdc 100644
> --- a/drivers/scsi/cxlflash/common.h
> +++ b/drivers/scsi/cxlflash/common.h
> @@ -54,7 +54,8 @@
> 
> /* Command management definitions */
> #define CXLFLASH_MAX_CMDS   256
> -#define CXLFLASH_MAX_CMDS_PER_LUN   CXLFLASH_MAX_CMDS
> +#define CXLFLASH_MAX_CMDS_PER_LUN   CXLFLASH_MAX_CMDS - 1
> +#define CXLFLASH_RESET_CMD  255
> 
> /* RRQ for master issued cmds */
> #define NUM_RRQ_ENTRY   CXLFLASH_MAX_CMDS
> diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
> index 462e8fc..b33e3e7 100644
> --- a/drivers/scsi/cxlflash/main.c
> +++ b/drivers/scsi/cxlflash/main.c
> @@ -23,6 +23,7 @@
> 
> #include 
> #include 
> +#include 
> #include 
> 
> #include "main.h"
> @@ -460,15 +461,16 @@ static u32 cmd_to_target_hwq(struct Scsi_Host *host, 
> struct scsi_cmnd *scp,
> /**
>  * send_tmf() - sends a Task Management Function (TMF)
>  * @afu:  AFU to checkout from.
> - * @scp: SCSI command from stack describing target.
> + * @sdev:SCSI device to reset.
>  * @tmfcmd:   TMF command to send.
>  *
>  * Return:
>  *0 on success, SCSI_MLQUEUE_HOST_BUSY or -errno on failure
>  */
> -static int send_tmf(struct afu *afu, struct scsi_cmnd *scp, u64 tmfcmd)
> +static int send_tmf(struct afu *afu, struct scsi_device *sdev, u64 tmfcmd)
> {
> - struct Scsi_Host *host = scp->device->host;
> + struct scsi_cmnd *scp;
> + struct Scsi_Host *host = sdev->host;
>   struct cxlflash_cfg *cfg = shost_priv(host);
>   struct afu_cmd *cmd = NULL;
>   struct device *dev = >dev->dev;
> @@ -498,14 +500,21 @@ static int send_tmf(struct afu *afu, struct scsi_cmnd 
> *scp, u64 tmfcmd)
>   cfg->tmf_active = true;
>   spin_unlock_irqrestore(>tmf_slock, lock_flags);
> 
> + scp = scsi_host_find_tag(host, CXLFLASH_RESET_CMD);
> + scp->device = sdev;
> + cmd = sc_to_afucz(scp);
> + hwq_index = cmd_to_target_hwq(host, scp, afu);
> + hwq = get_hwq(afu, hwq_index);
> +
> + cmd->scp = scp;
>   cmd->parent = afu;
>   cmd->cmd_tmf = true;
>   cmd->hwq_index = hwq_index;
> 
>   cmd->rcb.ctx_id = hwq->ctx_hndl;
>   cmd->rcb.msi = SISL_MSI_RRQ_UPDATED;
> - cmd->rcb.port_sel = CHAN2PORTMASK(scp->device->channel);
> - cmd->rcb.lun_id = lun_to_lunid(scp->device->lun);
> + cmd->rcb.port_sel = CHAN2PORTMASK(sdev->channel);
> + cmd->rcb.lun_id = lun_to_lunid(sdev->lun);
>   cmd->rcb.req_flags = (SISL_REQ_FLAGS_PORT_LUN_ID |
> SISL_REQ_FLAGS_SUP_UNDERRUN |
> SISL_REQ_FLAGS_TMF_CMD);
> @@ -2448,7 +2457,7 @@ static int cxlflash_eh_device_reset_handler(struct 
> scsi_cmnd *scp)
> retry:
>   switch (cfg->state) {
>   case STATE_NORMAL:
> - rcr = send_tmf(afu, scp, TMF_LUN_RESET);
> + rcr = send_tmf(afu, sdev, TMF_LUN_RESET);
>   if (unlikely(rcr))
>   rc = FAILED;
>   break;
> @@ -3139,7 +3148,7 @@ static ssize_t mode_show(struct device *dev,
>   .eh_host_reset_handler = cxlflash_eh_host_reset_handler,
>   .change_queue_depth = cxlflash_change_queue_depth,
>   .cmd_per_lun = CXLFLASH_MAX_CMDS_PER_LUN,
> - .can_queue = CXLFLASH_MAX_CMDS,
> + .can_queue = CXLFLASH_MAX_CMDS - 1,
>   .cmd_size = sizeof(struct afu_cmd) + __alignof__(struct afu_cmd) - 1,
>   .this_id = -1,
>   .sg_tablesize = 1,  /* No scatter gather support */
> -- 
> 1.8.5.6
> 



Re: [PATCH 13/47] megaraid: pass in NULL scb for host reset

2017-06-28 Thread Hannes Reinecke
On 06/28/2017 03:41 PM, Sumit Saxena wrote:
>> -Original Message-
>> From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
>> ow...@vger.kernel.org] On Behalf Of Hannes Reinecke
>> Sent: Wednesday, June 28, 2017 2:03 PM
>> To: Christoph Hellwig
>> Cc: Martin K. Petersen; James Bottomley; linux-scsi@vger.kernel.org;
> Hannes
>> Reinecke; Hannes Reinecke
>> Subject: [PATCH 13/47] megaraid: pass in NULL scb for host reset
>>
>> When calling a host reset we shouldn't rely on the command triggering the
>> reset, so allow megaraid_abort_and_reset() to be called with a NULL scb.
>> And drop the pointless 'bus_reset' and 'target_reset' handlers, which
> just call
>> the same function as host_reset.
> 
> If this patch address any functional issue, then we should consider this.
> If it's code optimization, can we ignore this as this is being very old
> driver
> and no more maintained by Broadcom/LSI ?
>
Sadly, ignoring is not an option.
I'm planning to update the calling convention for SCSI EH, to resolve
the long-standing problem with sg_reset ioctls.
sg_reset ioctl will allocate an out-of-band SCSI command, which does no
longer work with the new command allocation scheme in multiqueue.
So it's not possible to just 'ignore' it, as then SCSI EH will cease to
function with that driver.

Sorry.

>>
>> Signed-off-by: Hannes Reinecke 
>> ---
>> drivers/scsi/megaraid.c | 42 --
>> 1 file changed, 16 insertions(+), 26 deletions(-)
>>
>> diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index
>> 3c63c29..7e504d3 100644
>> --- a/drivers/scsi/megaraid.c
>> +++ b/drivers/scsi/megaraid.c
>> @@ -1909,7 +1909,7 @@ static DEF_SCSI_QCMD(megaraid_queue)
>>
>>  spin_lock_irq(>lock);
>>
>> -rval =  megaraid_abort_and_reset(adapter, cmd, SCB_RESET);
>> +rval =  megaraid_abort_and_reset(adapter, NULL, SCB_RESET);
> 
> If cmd=NULL is passed, it will crash inside function
> megaraid_abort_and_reset() while dereferencing "cmd" pointer.
> Below is the code of function  megaraid_abort_and_reset() where it will
> crash-
> 
> static int
> megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor)
> {
>   struct list_head*pos, *next;
>   scb_t   *scb;
> 
>   dev_warn(>dev->dev, "%s cmd=%x 

Re: [PATCH 19/28] qedf: drop bus reset handler

2017-06-28 Thread Chad Dupuis

On Wed, 28 Jun 2017, 10:37am, Christoph Hellwig wrote:

> 
> sg_reset / SG_SCSI_RESET are designed to escalatae to to the bigger
> hammers if the method isn't implemented or doesn't succeed.
> 
> Use the -N / --no-esc option to disable that.  I wish that behavior had
> been the default from the beginning, but we can't fix that anymore.
> 

Yeah, for a sg_reset prespective that would be the better behavior.  I 
removed the bus_reset handler and used the --no-esc parameter which causes 
sg_reset to behave more reasonably:

# sg_reset -b --no-esc /dev/sdj
sg_reset: reset (for value=0x102) may not be available

Given this I don't have an objection to this patch.

Tested-by: Chad Dupuis 


Re: [PATCH] scsi: hisi_sas: optimise DMA slot memory

2017-06-28 Thread Frans Klaver
On Wed, Jun 28, 2017 at 5:25 PM, John Garry  wrote:
> From: Xiaofei Tan 
>
> Currently we allocate 3 sets of DMA memories from separate
> pools for each slot. This is inefficient in terms of memory usage
> (buffers are less than 1 page in size, so we lose due to alignment),
> and also time spend in doing 3 allocations + de-allocations per slot,
> instead of 1.
>
> To optimise, combine the 3 DMA buffers into a single buffer from a
> single pool.
>
> Signed-off-by: John Garry 
> Signed-off-by: Xiaofei Tan 

I'm not sure how strictly this is done, but typically the author signs
off first.

Frans


[PATCH] scsi: hisi_sas: optimise DMA slot memory

2017-06-28 Thread John Garry
From: Xiaofei Tan 

Currently we allocate 3 sets of DMA memories from separate
pools for each slot. This is inefficient in terms of memory usage
(buffers are less than 1 page in size, so we lose due to alignment),
and also time spend in doing 3 allocations + de-allocations per slot,
instead of 1.

To optimise, combine the 3 DMA buffers into a single buffer from a
single pool.

Signed-off-by: John Garry 
Signed-off-by: Xiaofei Tan 

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 22dd48b..b78a4b8 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -34,10 +34,24 @@
 #define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES
 #define HISI_SAS_RESET_BIT 0
 
-#define HISI_SAS_STATUS_BUF_SZ \
-   (sizeof(struct hisi_sas_err_record) + 1024)
-#define HISI_SAS_COMMAND_TABLE_SZ \
-   (((sizeof(union hisi_sas_command_table)+3)/4)*4)
+#define HISI_SAS_STATUS_BUF_SZ (sizeof(struct hisi_sas_status_buffer))
+#define HISI_SAS_COMMAND_TABLE_SZ (sizeof(union hisi_sas_command_table))
+
+#define HISI_SAS_STATUS_BUF_ADDR(buf) \
+   (buf + offsetof(struct hisi_sas_slot_buf_table, status_buffer))
+#define HISI_SAS_STATUS_BUF_ADDR_MEM(slot) HISI_SAS_STATUS_BUF_ADDR(slot->buf)
+#define HISI_SAS_STATUS_BUF_ADDR_DMA(slot) \
+   HISI_SAS_STATUS_BUF_ADDR(slot->buf_dma)
+
+#define HISI_SAS_CMD_HDR_ADDR(buf) \
+   (buf + offsetof(struct hisi_sas_slot_buf_table, command_header))
+#define HISI_SAS_CMD_HDR_ADDR_MEM(slot) HISI_SAS_CMD_HDR_ADDR(slot->buf)
+#define HISI_SAS_CMD_HDR_ADDR_DMA(slot) HISI_SAS_CMD_HDR_ADDR(slot->buf_dma)
+
+#define HISI_SAS_SGE_ADDR(buf) \
+   (buf + offsetof(struct hisi_sas_slot_buf_table, sge_page))
+#define HISI_SAS_SGE_ADDR_MEM(slot) HISI_SAS_SGE_ADDR(slot->buf)
+#define HISI_SAS_SGE_ADDR_DMA(slot) HISI_SAS_SGE_ADDR(slot->buf_dma)
 
 #define HISI_SAS_MAX_SSP_RESP_SZ (sizeof(struct ssp_frame_hdr) + 1024)
 #define HISI_SAS_MAX_SMP_RESP_SZ 1028
@@ -139,14 +153,10 @@ struct hisi_sas_slot {
int cmplt_queue_slot;
int idx;
int abort;
+   void*buf;
+   dma_addr_t buf_dma;
void*cmd_hdr;
dma_addr_t cmd_hdr_dma;
-   void*status_buffer;
-   dma_addr_t status_buffer_dma;
-   void *command_table;
-   dma_addr_t command_table_dma;
-   struct hisi_sas_sge_page *sge_page;
-   dma_addr_t sge_page_dma;
struct work_struct abort_slot;
struct timer_list internal_abort_timer;
 };
@@ -232,10 +242,8 @@ struct hisi_hba {
 
int queue_count;
 
-   struct dma_pool *sge_page_pool;
+   struct dma_pool *buffer_pool;
struct hisi_sas_device  devices[HISI_SAS_MAX_DEVICES];
-   struct dma_pool *command_table_pool;
-   struct dma_pool *status_buffer_pool;
struct hisi_sas_cmd_hdr *cmd_hdr[HISI_SAS_MAX_QUEUES];
dma_addr_t cmd_hdr_dma[HISI_SAS_MAX_QUEUES];
void *complete_hdr[HISI_SAS_MAX_QUEUES];
@@ -347,7 +355,7 @@ struct hisi_sas_command_table_stp {
 #define HISI_SAS_SGE_PAGE_CNT SG_CHUNK_SIZE
 struct hisi_sas_sge_page {
struct hisi_sas_sge sge[HISI_SAS_SGE_PAGE_CNT];
-};
+}  __aligned(16);
 
 struct hisi_sas_command_table_ssp {
struct ssp_frame_hdr hdr;
@@ -366,6 +374,17 @@ struct hisi_sas_command_table_ssp {
struct hisi_sas_command_table_ssp ssp;
struct hisi_sas_command_table_smp smp;
struct hisi_sas_command_table_stp stp;
+}  __aligned(16);
+
+struct hisi_sas_status_buffer {
+   struct hisi_sas_err_record err;
+   u8  iu[1024];
+}  __aligned(16);
+
+struct hisi_sas_slot_buf_table {
+   struct hisi_sas_status_buffer status_buffer;
+   union hisi_sas_command_table command_header;
+   struct hisi_sas_sge_page sge_page;
 };
 
 extern struct scsi_transport_template *hisi_sas_stt;
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index e2f8d92..c875910 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -87,8 +87,10 @@ void hisi_sas_sata_done(struct sas_task *task,
 {
struct task_status_struct *ts = >task_status;
struct ata_task_resp *resp = (struct ata_task_resp *)ts->buf;
-   struct dev_to_host_fis *d2h = slot->status_buffer +
- sizeof(struct hisi_sas_err_record);
+   struct hisi_sas_status_buffer *status_buf =
+   HISI_SAS_STATUS_BUF_ADDR_MEM(slot);
+   u8 *iu = _buf->iu[0];
+   struct dev_to_host_fis *d2h =  (struct dev_to_host_fis *)iu;
 
resp->frame_len = sizeof(struct dev_to_host_fis);
memcpy(>ending_fis[0], d2h, sizeof(struct dev_to_host_fis));
@@ -183,17 +185,9 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, 
struct sas_task *task,
atomic64_dec(_dev->running_req);
}
 
-   if 

Re: [PATCH 19/28] qedf: drop bus reset handler

2017-06-28 Thread Christoph Hellwig
On Wed, Jun 28, 2017 at 10:07:50AM -0400, Chad Dupuis wrote:
> The test case this was meant to fix as using the sg_reset utility with the 
> -b option which forces a bus reset with NPIV ports attached.  What we were 
> finding is that some of the devices attached to the vport were being 
> brought offline after 5 seconds as escalating to the host reset handler in 
> this case was taking too long.

sg_reset / SG_SCSI_RESET are designed to escalatae to to the bigger
hammers if the method isn't implemented or doesn't succeed.

Use the -N / --no-esc option to disable that.  I wish that behavior had
been the default from the beginning, but we can't fix that anymore.


Re: [PATCH 0/5] target: Zoned block device support and bug fixes

2017-06-28 Thread Bryant G. Ly



This series introduce zoned block device support for the pscsi backstore and
also fixes several problems with sense data handling for failed requests.

The first patch is only a cleanup, so not really necessary but nice to have I
think.

Patch 2 and 3 introduce support for host managed zoned block device type (14h)
in the SCSI passthrough backstore and fixes sense data handling for commands
failed by the backstore device. With these fixes, a host zoned block device
exported with the iscsi or loopback transport pass libzbc ZBC specification
conformance tests.

Finally, patch 4 and 5 fix sense data hadling with the user backstore code. A
prototype ZBC emulation tcmu-runner handler was used to test these fixes and
result in the emulated handler passing libzbc ZBC specification conformance
tests.

(Note: the ZBC emulation tcmu-runner handler will be submitted to the
tcmu-runner project on github)

Please consider these patches for inclusion with kernel 4.13.

Damien Le Moal (5):
   target: Use macro for WRITE_VERIFY_xx operation codes
   target: pscsi: Introduce TYPE_ZBC support
   target: pscsi: Fix sense data handling
   target: user: Fix sense data handling
   target: core: Fix failed command sense data handling

  drivers/target/target_core_device.c|  4 ++--
  drivers/target/target_core_pscsi.c | 20 +---
  drivers/target/target_core_transport.c |  5 +++--
  drivers/target/target_core_user.c  |  4 +++-
  include/scsi/scsi_proto.h  |  1 +
  5 files changed, 22 insertions(+), 12 deletions(-)


Hi Damien,

You should take a look at the first two patches in this series to address your 
sense data handling.

https://www.spinics.net/lists/target-devel/msg15430.html

-Bryant





Re: [PATCH RESEND] scsi: Add STARGET_CREATED_REMOVE state to scsi_target_state

2017-06-28 Thread Ewan D. Milne
[ removed cc: stable from discussion ]

On Wed, 2017-06-28 at 09:38 +0200, Johannes Thumshirn wrote:
> 
> Looks good,
> Reviewed-by: Johannes Thumshirn 
> 
> Although we've been tampering with the target removal code for quite some
> time now, so I really have the gut feeling we haven't really fixed the
> root cause yet.
> 
> I once tried building a regression test for this (with qemu hot plugging UAS
> devices) but that didn't really go far. Maybe we should add a scsi_target
> to scsi_debug and add some methods to toggle remove it again. Just to have
> a sensible unit test for that code path.
> 
> Byte,
>   Johannes
> 

This specific crash is being encountered on systems connected to flaky
SANs, where the target rport repeatedly goes away.  I was able to
reproduce it by inserting a delay before the "Scan LUN 0" comment in
__scsi_scan_target() with a message, and disabling the FC switch port.

-Ewan




Re: [PATCH 19/28] qedf: drop bus reset handler

2017-06-28 Thread Chad Dupuis

On Wed, 28 Jun 2017, 9:58am, Christoph Hellwig wrote:

> On Wed, Jun 28, 2017 at 10:25:07AM +0200, Hannes Reinecke wrote:
> > qedf has a host reset handler, but as the bus reset handler is
> > a stub always returning SUCCESS the host reset is never invoked.
> > So drop the bus reset handler.
> 
> Given that comment this needs a lot more explanation, as the current
> behavior seems to be an odd/buggy workaround.
> 
> I hope this patch won't block the rest of the series, which all seems
> nice and simple material for this late merge window :(
> 

The test case this was meant to fix as using the sg_reset utility with the 
-b option which forces a bus reset with NPIV ports attached.  What we were 
finding is that some of the devices attached to the vport were being 
brought offline after 5 seconds as escalating to the host reset handler in 
this case was taking too long.

For this specific test case, returning SUCCESS allowed us to bypass the 
host reset escalation and force the SCSI error handler to send a TUR to 
the devices which of course would succeed since the device weren't 
physically offline keeping them from going offline.


Re: [PATCH 00/47] SCSI EH argument reshuffle part II

2017-06-28 Thread Christoph Hellwig
On Wed, Jun 28, 2017 at 10:32:26AM +0200, Hannes Reinecke wrote:
> Hi all,
> finally here's the patchset to revamp the SCSI EH callback arguments
> which I promised to do (some years ago ...).

Still looks like a way to big series to review.  Once we got the
first part 1 it might make sense to start resending just the various
prep patches..


Re: [PATCH 27/28] eata: remove 'arg_done' from eata2x_eh_host_reset()

2017-06-28 Thread Christoph Hellwig
Looks fine,

Reviewed-by: Christoph Hellwig 


Re: [PATCH 24/28] megaraid_mbox: drop duplicate bus reset and device reset function

2017-06-28 Thread Christoph Hellwig
Looks good,

Reviewed-by: Christoph Hellwig 


Re: [PATCH 22/28] 53c700: move bus reset to host reset

2017-06-28 Thread Christoph Hellwig
On Wed, Jun 28, 2017 at 10:25:10AM +0200, Hannes Reinecke wrote:
> bus reset always returns SUCCESS, meaning host reset was never
> tested. At the same time the only difference to the HBA is a
> missing call to NCR_700_chip_reset().
> So add the missing call to bus reset, drop host reset, and move
> bus reset to host reset.

Given that all the 53c700-based drivers only support a single channel
this looks correct:

Reviewed-by: Christoph Hellwig 


Re: [PATCH 21/28] aha152x: drop bus reset

2017-06-28 Thread Christoph Hellwig
On Wed, Jun 28, 2017 at 10:25:09AM +0200, Hannes Reinecke wrote:
> From: Hannes Reinecke 
> 
> The bus reset function is a subset of host reset, but will always
> return SUCCESS. But as the host reset also invokes a reset for
> all ports there is a possibility that the bus reset will not be
> able to fully reset the HBA, leading to a blocked system.
> So drop bus reset completely.

Wouldn't the more conservative option be to remove the host_reset
handler?  This driver is old and little used, and the existing
code will never have used the host_reset handler due to the fact
that the bus_reset handler always returns SUCCESS?


Re: [PATCH 20/28] nsp32: drop bus reset

2017-06-28 Thread Christoph Hellwig
On Wed, Jun 28, 2017 at 10:25:08AM +0200, Hannes Reinecke wrote:
> From: Hannes Reinecke 
> 
> bus reset is essentially identical to host reset, and will always
> return SUCCESS, thus disabling the use of host reset.
> So drop bus reset in favour of host reset.
> 
> Signed-off-by: Hannes Reinecke 

nsp32_eh_host_reset additionally calls nsp32hw_init, so they
don't really look "mostly" the same.  That being said I think
the bus_reset as-is is probably rather useless.


Re: [PATCH 19/28] qedf: drop bus reset handler

2017-06-28 Thread Christoph Hellwig
On Wed, Jun 28, 2017 at 10:25:07AM +0200, Hannes Reinecke wrote:
> qedf has a host reset handler, but as the bus reset handler is
> a stub always returning SUCCESS the host reset is never invoked.
> So drop the bus reset handler.

Given that comment this needs a lot more explanation, as the current
behavior seems to be an odd/buggy workaround.

I hope this patch won't block the rest of the series, which all seems
nice and simple material for this late merge window :(


Re: [PATCH 18/28] ppa: drop duplicate bus_reset handler

2017-06-28 Thread Christoph Hellwig
On Wed, Jun 28, 2017 at 10:25:06AM +0200, Hannes Reinecke wrote:
> bus_reset and host_reset are the same functions, so drop bus_reset.
> 
> Signed-off-by: Hannes Reinecke 

Looks good,

Reviewed-by: Christoph Hellwig 


Re: [PATCH 17/28] imm: drop duplicate bus_reset handler

2017-06-28 Thread Christoph Hellwig
On Wed, Jun 28, 2017 at 10:25:05AM +0200, Hannes Reinecke wrote:
> host_reset and bus_reset is the same function, so drop bus reset.
> 
> Signed-off-by: Hannes Reinecke 

Looks good,

Reviewed-by: Christoph Hellwig 


Re: [PATCH 15/28] NCR5380: Move bus reset to host reset

2017-06-28 Thread Christoph Hellwig
Looks good,

Reviewed-by: Christoph Hellwig 


Re: [PATCH 11/28] scsi: drop bus reset for wd33c93-compatible boards

2017-06-28 Thread Christoph Hellwig
On Wed, Jun 28, 2017 at 10:24:59AM +0200, Hannes Reinecke wrote:
> The bus reset function is just a wrapper calling host reset
> under the host lock. So move taking of the host lock into
> the host reset function and drop bus reset.

The changelog could be expanded a bit, especially about the
weird locking state before this patch, but except for that:

Reviewed-by: Christoph Hellwig 


Re: [PATCH 10/28] fdomain: move bus reset to host reset

2017-06-28 Thread Christoph Hellwig
Looks fine,

Reviewed-by: Christoph Hellwig 


Re: [PATCH 01/28] scsi: fix comment in scsi_device_set_state()

2017-06-28 Thread Christoph Hellwig
Looks fine,

Reviewed-by: Christoph Hellwig 

On Wed, Jun 28, 2017 at 10:24:49AM +0200, Hannes Reinecke wrote:
> The function returns '0' if successful; with the original comment
> the function doesn't have a way to indicate success ...
> 
> Signed-off-by: Hannes Reinecke 
> Reviewed-by: Bart van Assche 
> ---
>  drivers/scsi/scsi_lib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 41c19c7..1ff7d72 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -2547,7 +2547,7 @@ void scsi_exit_queue(void)
>   *   @sdev:  scsi device to change the state of.
>   *   @state: state to change to.
>   *
> - *   Returns zero if unsuccessful or an error if the requested 
> + *   Returns zero if successful or an error if the requested
>   *   transition is illegal.
>   */
>  int
> -- 
> 1.8.5.6
---end quoted text---


RE: [PATCH 13/47] megaraid: pass in NULL scb for host reset

2017-06-28 Thread Sumit Saxena
>-Original Message-
>From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
>ow...@vger.kernel.org] On Behalf Of Hannes Reinecke
>Sent: Wednesday, June 28, 2017 2:03 PM
>To: Christoph Hellwig
>Cc: Martin K. Petersen; James Bottomley; linux-scsi@vger.kernel.org;
Hannes
>Reinecke; Hannes Reinecke
>Subject: [PATCH 13/47] megaraid: pass in NULL scb for host reset
>
>When calling a host reset we shouldn't rely on the command triggering the
>reset, so allow megaraid_abort_and_reset() to be called with a NULL scb.
>And drop the pointless 'bus_reset' and 'target_reset' handlers, which
just call
>the same function as host_reset.

If this patch address any functional issue, then we should consider this.
If it's code optimization, can we ignore this as this is being very old
driver
and no more maintained by Broadcom/LSI ?

>
>Signed-off-by: Hannes Reinecke 
>---
> drivers/scsi/megaraid.c | 42 --
> 1 file changed, 16 insertions(+), 26 deletions(-)
>
>diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index
>3c63c29..7e504d3 100644
>--- a/drivers/scsi/megaraid.c
>+++ b/drivers/scsi/megaraid.c
>@@ -1909,7 +1909,7 @@ static DEF_SCSI_QCMD(megaraid_queue)
>
>   spin_lock_irq(>lock);
>
>-  rval =  megaraid_abort_and_reset(adapter, cmd, SCB_RESET);
>+  rval =  megaraid_abort_and_reset(adapter, NULL, SCB_RESET);

If cmd=NULL is passed, it will crash inside function
megaraid_abort_and_reset() while dereferencing "cmd" pointer.
Below is the code of function  megaraid_abort_and_reset() where it will
crash-

static int
megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor)
{
struct list_head*pos, *next;
scb_t   *scb;

dev_warn(>dev->dev, "%s cmd=%x 

Re: [PATCH 0/5] v3 block subsystem refcounter conversions

2017-06-28 Thread Jens Axboe
On 06/28/2017 05:58 AM, Reshetova, Elena wrote:
> 
>> Subject: Re: [PATCH 0/5] v3 block subsystem refcounter conversions
>>
>> On Tue, Jun 27, 2017 at 6:26 AM, Jens Axboe  wrote:
>>> On 06/27/2017 05:39 AM, Elena Reshetova wrote:
 Changes in v3:
 No changes in patches apart from trivial rebases, but now by
 default refcount_t = atomic_t and uses all atomic standard operations
 unless CONFIG_REFCOUNT_FULL is enabled. This is a compromize for the
 systems that are critical on performance and cannot accept even
 slight delay on the refcounter operations.
>>>
>>> Is that true in 4.12-rc, or is that true in a later release once
>>> Linus has pulled those changes in? If the latter, please resend
>>> this when those changes are in, thanks.
>>
>> It's in -next currently ("locking/refcount: Create unchecked atomic_t
>> implementation")
> 
> I would really like to start discussion on the these patches asap
> since it normally takes some adjustments etc. before they can be
> merged and we want many changes to go into next release round and not
> to miss the merge window. 

As far as I'm concerned, there's no need for a discussion on these. If
the other patches go in to make it as light weight as what we currently
have, then I'm fine with it. I can queue it up for post initial merge
submission.

-- 
Jens Axboe



RE: [PATCH 0/5] v3 block subsystem refcounter conversions

2017-06-28 Thread Reshetova, Elena

> Subject: Re: [PATCH 0/5] v3 block subsystem refcounter conversions
> 
> On Tue, Jun 27, 2017 at 6:26 AM, Jens Axboe  wrote:
> > On 06/27/2017 05:39 AM, Elena Reshetova wrote:
> >> Changes in v3:
> >> No changes in patches apart from trivial rebases, but now by
> >> default refcount_t = atomic_t and uses all atomic standard operations
> >> unless CONFIG_REFCOUNT_FULL is enabled. This is a compromize for the
> >> systems that are critical on performance and cannot accept even
> >> slight delay on the refcounter operations.
> >
> > Is that true in 4.12-rc, or is that true in a later release once
> > Linus has pulled those changes in? If the latter, please resend
> > this when those changes are in, thanks.
> 
> It's in -next currently ("locking/refcount: Create unchecked atomic_t
> implementation")

I would really like to start discussion on the these patches asap since it 
normally takes
 some adjustments etc. before they can be merged and we want many changes to go 
into
next release round and not to miss the merge window. 

Best Regards,
Elena.

> 
> -Kees
> 
> --
> Kees Cook
> Pixel Security


Re: [PATCH 13/47] megaraid: pass in NULL scb for host reset

2017-06-28 Thread Johannes Thumshirn

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 12/47] qla1280: separate out host reset function from qla1280_error_action()

2017-06-28 Thread Johannes Thumshirn

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 11/47] snic: reserve tag for TMF

2017-06-28 Thread Johannes Thumshirn

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 10/47] ips: Do not try to abort command from host reset

2017-06-28 Thread Johannes Thumshirn

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 08/47] sym53c8xx_2: split off bus reset from host reset

2017-06-28 Thread Johannes Thumshirn

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 08/47] sym53c8xx_2: split off bus reset from host reset

2017-06-28 Thread Johannes Thumshirn

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 07/47] aacraid: complete all commands during bus reset

2017-06-28 Thread Johannes Thumshirn

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 06/47] aacraid: add fib flag to mark scsi command callback

2017-06-28 Thread Johannes Thumshirn

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 05/47] aacraid: enable sending of TMFs from aac_hba_send()

2017-06-28 Thread Johannes Thumshirn

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 03/47] aacraid: split off device, target, and bus reset

2017-06-28 Thread Johannes Thumshirn

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/47] aacraid: split off host reset

2017-06-28 Thread Johannes Thumshirn
On Wed, Jun 28, 2017 at 10:32:28AM +0200, Hannes Reinecke wrote:
> + struct scsi_device * dev = cmd->device;
> + struct Scsi_Host * host = dev->host;
> + struct aac_dev * aac = (struct aac_dev *)host->hostdata;

Minor nit, if you happen to re-send, please remove the space between the
asterisk and the variable names.

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 01/47] aacraid: split off functions to generate reset FIB

2017-06-28 Thread Johannes Thumshirn

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 28/28] NCR5380: Clear all unissued commands on host reset

2017-06-28 Thread Johannes Thumshirn

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 27/28] eata: remove 'arg_done' from eata2x_eh_host_reset()

2017-06-28 Thread Johannes Thumshirn

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 23/28] bnx2fc: remove obsolete bnx2fc_eh_host_reset() definition

2017-06-28 Thread Johannes Thumshirn

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 24/28] megaraid_mbox: drop duplicate bus reset and device reset function

2017-06-28 Thread Johannes Thumshirn

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 21/28] aha152x: drop bus reset

2017-06-28 Thread Johannes Thumshirn

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 20/28] nsp32: drop bus reset

2017-06-28 Thread Johannes Thumshirn

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 18/28] ppa: drop duplicate bus_reset handler

2017-06-28 Thread Johannes Thumshirn

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 17/28] imm: drop duplicate bus_reset handler

2017-06-28 Thread Johannes Thumshirn

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 15/28] NCR5380: Move bus reset to host reset

2017-06-28 Thread Johannes Thumshirn

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 16/28] qlogicfas: move bus_reset to host_reset

2017-06-28 Thread Johannes Thumshirn

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 14/28] acornscsi: move bus reset to host reset

2017-06-28 Thread Johannes Thumshirn

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 13/28] qlogicpti: move bus reset to host reset

2017-06-28 Thread Johannes Thumshirn

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 12/28] rtsx: drop bus reset function

2017-06-28 Thread Johannes Thumshirn

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 11/28] scsi: drop bus reset for wd33c93-compatible boards

2017-06-28 Thread Johannes Thumshirn

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 09/28] hptiop: Simplify reset handling

2017-06-28 Thread Johannes Thumshirn

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 10/28] fdomain: move bus reset to host reset

2017-06-28 Thread Johannes Thumshirn

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 08/28] bfa: move bus reset to target reset

2017-06-28 Thread Johannes Thumshirn

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 07/28] libsas: move bus_reset_handler() to target_reset_handler()

2017-06-28 Thread Johannes Thumshirn

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 06/28] uas: move eh_bus_reset_handler to eh_device_reset_handler

2017-06-28 Thread Johannes Thumshirn

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 05/28] fnic: do not call host reset from command abort

2017-06-28 Thread Johannes Thumshirn

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 04/28] fc_fcp: do not call fc_block_scsi_eh() from host reset

2017-06-28 Thread Johannes Thumshirn

Acked-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 03/28] ibmvfc: Do not call fc_block_scsi_eh() on host reset

2017-06-28 Thread Johannes Thumshirn

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/28] mptfc: Do not call fc_block_scsi_eh() on host reset

2017-06-28 Thread Johannes Thumshirn

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 01/28] scsi: fix comment in scsi_device_set_state()

2017-06-28 Thread Johannes Thumshirn

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


[PATCH 43/47] fas216: Rework device reset to not rely on SCSI command pointer

2017-06-28 Thread Hannes Reinecke
The device reset code should not rely on the SCSI command pointer;
it will be going away with the device reset handler rework.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/arm/fas216.c | 51 +++
 1 file changed, 25 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
index c93ad3a..e3ff1c3 100644
--- a/drivers/scsi/arm/fas216.c
+++ b/drivers/scsi/arm/fas216.c
@@ -1985,8 +1985,7 @@ static void fas216_devicereset_done(FAS216_Info *info, 
struct scsi_cmnd *SCpnt,
 {
fas216_log(info, LOG_ERROR, "fas216 device reset complete");
 
-   info->rstSCpnt = NULL;
-   info->rst_dev_status = 1;
+   info->rst_dev_status = 0;
wake_up(>eh_wait);
 }
 
@@ -2139,12 +2138,12 @@ static void fas216_done(FAS216_Info *info, unsigned int 
result)
 
fas216_checkmagic(info);
 
-   if (!info->SCpnt)
+   if (!info->SCpnt && !info->rst_dev_status)
goto no_command;
 
SCpnt = info->SCpnt;
info->SCpnt = NULL;
-   info->scsi.phase = PHASE_IDLE;
+   info->scsi.phase = PHASE_IDLE;
 
if (info->scsi.aborting) {
fas216_log(info, 0, "uncaught abort - returning DID_ABORT");
@@ -2156,7 +2155,7 @@ static void fas216_done(FAS216_Info *info, unsigned int 
result)
 * Sanity check the completion - if we have zero bytes left
 * to transfer, we should not have a valid pointer.
 */
-   if (info->scsi.SCp.ptr && info->scsi.SCp.this_residual == 0) {
+   if (SCpnt && info->scsi.SCp.ptr && info->scsi.SCp.this_residual == 0) {
scmd_printk(KERN_INFO, SCpnt,
"zero bytes left to transfer, but buffer pointer 
still valid: ptr=%p len=%08x\n",
info->scsi.SCp.ptr, info->scsi.SCp.this_residual);
@@ -2169,12 +2168,18 @@ static void fas216_done(FAS216_Info *info, unsigned int 
result)
 * the sense information, fas216_kick will re-assert the busy
 * status.
 */
-   info->device[SCpnt->device->id].parity_check = 0;
-   clear_bit(SCpnt->device->id * 8 +
- (u8)(SCpnt->device->lun & 0x7), info->busyluns);
-
-   fn = (void (*)(FAS216_Info *, struct scsi_cmnd *, unsigned 
int))SCpnt->host_scribble;
-   fn(info, SCpnt, result);
+   if (SCpnt) {
+   info->device[SCpnt->device->id].parity_check = 0;
+   clear_bit(SCpnt->device->id * 8 +
+ (u8)(SCpnt->device->lun & 0x7), info->busyluns);
+   }
+   if (info->rst_dev_status) {
+   info->rst_dev_status = 0;
+   wake_up(>eh_wait);
+   } else {
+   fn = (void (*)(FAS216_Info *, struct scsi_cmnd *, unsigned 
int))SCpnt->host_scribble;
+   fn(info, SCpnt, result);
+   }
 
if (info->scsi.irq) {
spin_lock_irqsave(>host_lock, flags);
@@ -2326,9 +2331,9 @@ static void fas216_eh_timer(unsigned long data)
 
del_timer(>eh_timer);
 
-   if (info->rst_bus_status == 0)
+   if (info->rst_bus_status == 1)
info->rst_bus_status = -1;
-   if (info->rst_dev_status == 0)
+   if (info->rst_dev_status == 1)
info->rst_dev_status = -1;
 
wake_up(>eh_wait);
@@ -2471,9 +2476,10 @@ int fas216_eh_abort(struct scsi_cmnd *SCpnt)
  */
 int fas216_eh_device_reset(struct scsi_cmnd *SCpnt)
 {
-   FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata;
+   struct scsi_device *sdev = SCpnt->device;
+   FAS216_Info *info = (FAS216_Info *)sdev->host->hostdata;
unsigned long flags;
-   int i, res = FAILED, target = SCpnt->device->id;
+   int i, res = FAILED, target = sdev->id;
 
fas216_log(info, LOG_ERROR, "device reset for target %d", target);
 
@@ -2487,7 +2493,7 @@ int fas216_eh_device_reset(struct scsi_cmnd *SCpnt)
 * and we need a bus reset.
 */
if (info->SCpnt && !info->scsi.disconnectable &&
-   info->SCpnt->device->id == SCpnt->device->id)
+   info->SCpnt->device->id == sdev->id)
break;
 
/*
@@ -2505,14 +2511,7 @@ int fas216_eh_device_reset(struct scsi_cmnd *SCpnt)
for (i = 0; i < 8; i++)
clear_bit(target * 8 + i, info->busyluns);
 
-   /*
-* Hijack this SCSI command structure to send
-* a bus device reset message to this device.
-*/
-   SCpnt->host_scribble = (void *)fas216_devicereset_done;
-
-   info->rst_dev_status = 0;
-   info->rstSCpnt = SCpnt;
+   info->rst_dev_status = 1;
 
if (info->scsi.phase == PHASE_IDLE)
fas216_kick(info);
@@ -2523,13 +2522,13 @@ int fas216_eh_device_reset(struct scsi_cmnd *SCpnt)
/*
 

[PATCH 46/47] scsi: Move eh_device_reset_handler() to use scsi_device as argument

2017-06-28 Thread Hannes Reinecke
When resetting a device we shouldn't depend on an existing SCSI
device, so use 'struct scsi_device' as argument for
eh_device_reset_handler().

Signed-off-by: Hannes Reinecke 
---
 Documentation/scsi/scsi_eh.txt  |  2 +-
 Documentation/scsi/scsi_mid_low_api.txt |  4 +--
 drivers/block/cciss_scsi.c  | 14 +-
 drivers/infiniband/ulp/srp/ib_srp.c |  8 +++---
 drivers/message/fusion/mptfc.c  | 12 -
 drivers/message/fusion/mptscsih.c   | 19 ++
 drivers/message/fusion/mptscsih.h   |  2 +-
 drivers/s390/scsi/zfcp_scsi.c   |  4 +--
 drivers/scsi/a100u2w.c  |  7 +++--
 drivers/scsi/aacraid/linit.c|  9 +++
 drivers/scsi/aha152x.c  |  6 ++---
 drivers/scsi/aha1542.c  |  8 +++---
 drivers/scsi/aic7xxx/aic79xx_osm.c  | 27 ---
 drivers/scsi/aic7xxx/aic7xxx_osm.c  |  4 +--
 drivers/scsi/arm/fas216.c   |  5 ++--
 drivers/scsi/be2iscsi/be_main.c |  8 +++---
 drivers/scsi/bfa/bfad_im.c  |  3 +--
 drivers/scsi/bnx2fc/bnx2fc.h|  2 +-
 drivers/scsi/bnx2fc/bnx2fc_io.c |  6 ++---
 drivers/scsi/csiostor/csio_scsi.c   |  7 +++--
 drivers/scsi/cxlflash/main.c| 15 ---
 drivers/scsi/dpt_i2o.c  | 20 +++---
 drivers/scsi/dpti.h |  2 +-
 drivers/scsi/esas2r/esas2r.h|  2 +-
 drivers/scsi/esas2r/esas2r_main.c   |  3 +--
 drivers/scsi/fnic/fnic.h|  2 +-
 drivers/scsi/fnic/fnic_scsi.c   | 26 +-
 drivers/scsi/hpsa.c | 14 +-
 drivers/scsi/ibmvscsi/ibmvfc.c  |  5 ++--
 drivers/scsi/ibmvscsi/ibmvscsi.c| 19 +++---
 drivers/scsi/ipr.c  | 31 +++---
 drivers/scsi/libfc/fc_fcp.c |  8 +++---
 drivers/scsi/libiscsi.c | 15 +--
 drivers/scsi/libsas/sas_scsi_host.c | 12 -
 drivers/scsi/lpfc/lpfc_scsi.c   | 12 -
 drivers/scsi/mpt3sas/mpt3sas_scsih.c| 29 +---
 drivers/scsi/pmcraid.c  |  6 ++---
 drivers/scsi/qedf/qedf_main.c   |  6 ++---
 drivers/scsi/qla1280.c  | 21 +++
 drivers/scsi/qla2xxx/qla_os.c   |  5 ++--
 drivers/scsi/qla4xxx/ql4_os.c   | 28 +---
 drivers/scsi/scsi_debug.c   | 18 ++---
 drivers/scsi/scsi_error.c   | 35 +
 drivers/scsi/smartpqi/smartpqi_init.c   |  6 ++---
 drivers/scsi/snic/snic.h|  2 +-
 drivers/scsi/snic/snic_scsi.c   |  4 +--
 drivers/scsi/ufs/ufshcd.c   | 16 +--
 drivers/scsi/virtio_scsi.c  | 14 +-
 drivers/scsi/vmw_pvscsi.c   | 10 +++
 drivers/scsi/wd719x.c   |  6 ++---
 drivers/scsi/xen-scsifront.c|  4 +--
 drivers/staging/rts5208/rtsx.c  |  4 +--
 drivers/staging/unisys/visorhba/visorhba_main.c | 14 +++---
 drivers/target/loopback/tcm_loop.c  |  8 +++---
 drivers/usb/storage/scsiglue.c  |  4 +--
 drivers/usb/storage/uas.c   |  3 +--
 include/scsi/libfc.h|  2 +-
 include/scsi/libiscsi.h |  2 +-
 include/scsi/libsas.h   |  2 +-
 include/scsi/scsi_host.h|  2 +-
 60 files changed, 287 insertions(+), 307 deletions(-)

diff --git a/Documentation/scsi/scsi_eh.txt b/Documentation/scsi/scsi_eh.txt
index cb9f4bc22..f8a6566 100644
--- a/Documentation/scsi/scsi_eh.txt
+++ b/Documentation/scsi/scsi_eh.txt
@@ -206,7 +206,7 @@ hostt EH callbacks.  Callbacks may be omitted and omitted 
ones are
 considered to fail always.
 
 int (* eh_abort_handler)(struct scsi_cmnd *);
-int (* eh_device_reset_handler)(struct scsi_cmnd *);
+int (* eh_device_reset_handler)(struct scsi_device *);
 int (* eh_bus_reset_handler)(struct Scsi_Host *, int);
 int (* eh_host_reset_handler)(struct Scsi_Host *);
 
diff --git a/Documentation/scsi/scsi_mid_low_api.txt 
b/Documentation/scsi/scsi_mid_low_api.txt
index e2609a63..28dc029 100644
--- a/Documentation/scsi/scsi_mid_low_api.txt
+++ b/Documentation/scsi/scsi_mid_low_api.txt
@@ -874,7 +874,7 @@ Details:
 
 /**
  *  eh_device_reset_handler - issue SCSI device reset
- *  @scp: identifies SCSI device to be reset
+ *  @sdev: identifies SCSI device to be reset
  *
  *  Returns 

  1   2   >