[PATCH 4/4] scsi: arcmsr: Change driver version to v1.40.00.05-20180309

2018-03-14 Thread Ching Huang
From: Ching Huang 

Change driver version to v1.40.00.05-20180309

Signed-off-by: Ching Huang 
---

diff --git a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h
index 842b77a..2e51ccc 100755
--- a/drivers/scsi/arcmsr/arcmsr.h
+++ b/drivers/scsi/arcmsr/arcmsr.h
@@ -49,7 +49,7 @@ struct device_attribute;
 #define ARCMSR_MAX_OUTSTANDING_CMD 1024
 #define ARCMSR_DEFAULT_OUTSTANDING_CMD 128
 #define ARCMSR_MIN_OUTSTANDING_CMD 32
-#define ARCMSR_DRIVER_VERSION  "v1.40.00.04-20171130"
+#define ARCMSR_DRIVER_VERSION  "v1.40.00.05-20180309"
 #define ARCMSR_SCSI_INITIATOR_ID   255
 #define ARCMSR_MAX_XFER_SECTORS512
 #define ARCMSR_MAX_XFER_SECTORS_B  4096




[PATCH 3/4] scsi: arcmsr: Sleep to avoid CPU stuck too long for waiting adapter ready

2018-03-14 Thread Ching Huang
From: Ching Huang 

Sleep to avoid CPU stuck too long for waiting adapter ready.

Signed-off-by: Ching Huang 
---

diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index 2f52c53..732b5d9 100755
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -3807,6 +3807,8 @@ static void arcmsr_wait_firmware_ready(struct 
AdapterControlBlock *acb)
case ACB_ADAPTER_TYPE_A: {
struct MessageUnit_A __iomem *reg = acb->pmuA;
do {
+   if (!(acb->acb_flags & ACB_F_IOP_INITED))
+   msleep(20);
firmware_state = readl(®->outbound_msgaddr1);
} while ((firmware_state & ARCMSR_OUTBOUND_MESG1_FIRMWARE_OK) 
== 0);
}
@@ -3815,6 +3817,8 @@ static void arcmsr_wait_firmware_ready(struct 
AdapterControlBlock *acb)
case ACB_ADAPTER_TYPE_B: {
struct MessageUnit_B *reg = acb->pmuB;
do {
+   if (!(acb->acb_flags & ACB_F_IOP_INITED))
+   msleep(20);
firmware_state = readl(reg->iop2drv_doorbell);
} while ((firmware_state & ARCMSR_MESSAGE_FIRMWARE_OK) == 0);
writel(ARCMSR_DRV2IOP_END_OF_INTERRUPT, reg->drv2iop_doorbell);
@@ -3823,6 +3827,8 @@ static void arcmsr_wait_firmware_ready(struct 
AdapterControlBlock *acb)
case ACB_ADAPTER_TYPE_C: {
struct MessageUnit_C __iomem *reg = acb->pmuC;
do {
+   if (!(acb->acb_flags & ACB_F_IOP_INITED))
+   msleep(20);
firmware_state = readl(®->outbound_msgaddr1);
} while ((firmware_state & ARCMSR_HBCMU_MESSAGE_FIRMWARE_OK) == 
0);
}
@@ -3830,6 +3836,8 @@ static void arcmsr_wait_firmware_ready(struct 
AdapterControlBlock *acb)
case ACB_ADAPTER_TYPE_D: {
struct MessageUnit_D *reg = acb->pmuD;
do {
+   if (!(acb->acb_flags & ACB_F_IOP_INITED))
+   msleep(20);
firmware_state = readl(reg->outbound_msgaddr1);
} while ((firmware_state &
ARCMSR_ARC1214_MESSAGE_FIRMWARE_OK) == 0);
@@ -3838,6 +3846,8 @@ static void arcmsr_wait_firmware_ready(struct 
AdapterControlBlock *acb)
case ACB_ADAPTER_TYPE_E: {
struct MessageUnit_E __iomem *reg = acb->pmuE;
do {
+   if (!(acb->acb_flags & ACB_F_IOP_INITED))
+   msleep(20);
firmware_state = readl(®->outbound_msgaddr1);
} while ((firmware_state & ARCMSR_HBEMU_MESSAGE_FIRMWARE_OK) == 
0);
}




[PATCH 2/4] scsi: arcmsr: Handle adapter removed due to thunderbolt cable disconnection.

2018-03-14 Thread Ching Huang
From: Ching Huang 

Handle adapter removed due to thunderbolt cable disconnection.

Signed-off-by: Ching Huang 
---

diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index 75e828b..2f52c53 100755
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -1446,12 +1446,80 @@ static void arcmsr_done4abort_postqueue(struct 
AdapterControlBlock *acb)
}
 }
 
+static void arcmsr_remove_scsi_devices(struct AdapterControlBlock *acb)
+{
+   char *acb_dev_map = (char *)acb->device_map;
+   int target, lun, i;
+   struct scsi_device *psdev;
+   struct CommandControlBlock *ccb;
+   char temp;
+
+   for (i = 0; i < acb->maxFreeCCB; i++) {
+   ccb = acb->pccb_pool[i];
+   if (ccb->startdone == ARCMSR_CCB_START) {
+   ccb->pcmd->result = DID_NO_CONNECT << 16;
+   arcmsr_pci_unmap_dma(ccb);
+   ccb->pcmd->scsi_done(ccb->pcmd);
+   }
+   }
+   for (target = 0; target < ARCMSR_MAX_TARGETID; target++) {
+   temp = *acb_dev_map;
+   if (temp) {
+   for (lun = 0; lun < ARCMSR_MAX_TARGETLUN; lun++) {
+   if (temp & 1) {
+   psdev = scsi_device_lookup(acb->host,
+   0, target, lun);
+   if (psdev != NULL) {
+   scsi_remove_device(psdev);
+   scsi_device_put(psdev);
+   }
+   }
+   temp >>= 1;
+   }
+   *acb_dev_map = 0;
+   }
+   acb_dev_map++;
+   }
+}
+
+static void arcmsr_free_pcidev(struct AdapterControlBlock *acb)
+{
+   struct pci_dev *pdev;
+   struct Scsi_Host *host;
+
+   host = acb->host;
+   arcmsr_free_sysfs_attr(acb);
+   scsi_remove_host(host);
+   flush_work(&acb->arcmsr_do_message_isr_bh);
+   del_timer_sync(&acb->eternal_timer);
+   if (set_date_time)
+   del_timer_sync(&acb->refresh_timer);
+   pdev = acb->pdev;
+   arcmsr_free_irq(pdev, acb);
+   arcmsr_free_ccb_pool(acb);
+   arcmsr_free_mu(acb);
+   arcmsr_unmap_pciregion(acb);
+   pci_release_regions(pdev);
+   scsi_host_put(host);
+   pci_disable_device(pdev);
+}
+
 static void arcmsr_remove(struct pci_dev *pdev)
 {
struct Scsi_Host *host = pci_get_drvdata(pdev);
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
int poll_count = 0;
+   uint16_t dev_id;
+
+   pci_read_config_word(pdev, PCI_DEVICE_ID, &dev_id);
+   if (dev_id == 0x) {
+   acb->acb_flags &= ~ACB_F_IOP_INITED;
+   acb->acb_flags |= ACB_F_ADAPTER_REMOVED;
+   arcmsr_remove_scsi_devices(acb);
+   arcmsr_free_pcidev(acb);
+   return;
+   }
arcmsr_free_sysfs_attr(acb);
scsi_remove_host(host);
flush_work(&acb->arcmsr_do_message_isr_bh);
@@ -1499,6 +1567,8 @@ static void arcmsr_shutdown(struct pci_dev *pdev)
struct Scsi_Host *host = pci_get_drvdata(pdev);
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *)host->hostdata;
+   if (acb->acb_flags & ACB_F_ADAPTER_REMOVED)
+   return;
del_timer_sync(&acb->eternal_timer);
if (set_date_time)
del_timer_sync(&acb->refresh_timer);
@@ -2931,6 +3001,12 @@ static int arcmsr_queue_command_lck(struct scsi_cmnd 
*cmd,
struct AdapterControlBlock *acb = (struct AdapterControlBlock *) 
host->hostdata;
struct CommandControlBlock *ccb;
int target = cmd->device->id;
+
+   if (acb->acb_flags & ACB_F_ADAPTER_REMOVED) {
+   cmd->result = (DID_NO_CONNECT << 16);
+   cmd->scsi_done(cmd);
+   return 0;
+   }
cmd->scsi_done = done;
cmd->host_scribble = NULL;
cmd->result = 0;
@@ -4177,6 +4253,8 @@ static int arcmsr_bus_reset(struct scsi_cmnd *cmd)
int retry_count = 0;
int rtn = FAILED;
acb = (struct AdapterControlBlock *) cmd->device->host->hostdata;
+   if (acb->acb_flags & ACB_F_ADAPTER_REMOVED)
+   return SUCCESS;
pr_notice("arcmsr: executing bus reset eh.num_resets = %d,"
" num_aborts = %d \n", acb->num_resets, acb->num_aborts);
acb->num_resets++;
@@ -4243,6 +4321,8 @@ static int arcmsr_abort(struct scsi_cmnd *cmd)
int rtn = FAILED;
uint32_t intmask_org;
 
+   if (acb->acb_flags & ACB_F_ADAPTER_REMOVED)
+   return SUCCESS;
printk(KERN_NOTICE
"arcmsr%d: abort device command of scsi id = %d lun = %d\n",
 

[PATCH 1/4] scsi: arcmsr: Rename ACB_F_BUS_HANG_ON to ACB_F_ADAPTER_REMOVED for adapter hot-plug

2018-03-14 Thread Ching Huang
From: Ching Huang 

Rename ACB_F_BUS_HANG_ON to ACB_F_ADAPTER_REMOVED for adapter hot-plug.

Signed-off-by: Ching Huang 
---

diff --git a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h
index f375f35..842b77a 100755
--- a/drivers/scsi/arcmsr/arcmsr.h
+++ b/drivers/scsi/arcmsr/arcmsr.h
@@ -779,12 +779,12 @@ struct AdapterControlBlock
 /* message clear rqbuffer */
 #define ACB_F_MESSAGE_WQBUFFER_READED   0x0040
 #define ACB_F_BUS_RESET0x0080
-#define ACB_F_BUS_HANG_ON  0x0800/* need hardware reset bus */
 
 #define ACB_F_IOP_INITED   0x0100
 /* iop init */
 #define ACB_F_ABORT0x0200
 #define ACB_F_FIRMWARE_TRAP0x0400
+#define ACB_F_ADAPTER_REMOVED  0x0800
 #define ACB_F_MSG_GET_CONFIG   0x1000
struct CommandControlBlock *pccb_pool[ARCMSR_MAX_FREECCB_NUM];
/* used for memory free */




[PATCH 0/4] scsi: arcmsr: Support Areca thunderbolt devices hot-plug

2018-03-14 Thread Ching Huang
From: Ching Huang 

This patch series are against to mkp's 4.17/scsi-queue.

1. Rename ACB_F_BUS_HANG_ON to ACB_F_ADAPTER_REMOVED for adapter hot-plug
2. Handle adapter removed due to thunderbolt cable disconnection.
3. Sleep to avoid CPU stuck too long for waiting adapter ready
4. Change driver version to v1.40.00.05-20180309

---



Re: [PATCH] scsi: aic94xx: Use dma_pool_zalloc()

2018-03-14 Thread Souptick Joarder
On Thu, Mar 15, 2018 at 10:20 AM, Martin K. Petersen
 wrote:
>
> Souptick,
>
>> Any comment for this patch ?
>
> -ENOREVIEWS
>
> Also, you have not provided potential reviewers with a compelling reason
> why dma_pool_zalloc() is superior to alloc+memset.
>

dma_pool_zalloc() is the API which can replace dma_pool_alloc + memeset.
I have identified all the possible areas in kernel and send patches
for the same.
This patch is part of same change.

As there is no separate maintainer for /scsi/ aic94xx in Maintainer file, send
this patch to scsi mailing list.

Shall I request Andrew Morton to review this patch in case noone is
reviewing this patch?

> --
> Martin K. Petersen  Oracle Linux Engineering

-Souptick


Re: [PATCH] ibmvfc: Avoid unnecessary port relogin

2018-03-14 Thread Martin K. Petersen

Brian,

> Following an RSCN, ibmvfc will issue an ADISC to determine if the
> underlying target has changed, comparing the SCSI ID, WWPN, and WWNN
> to determine how to handle the rport in discovery. However, the
> comparison of the WWPN and WWNN was performing a memcmp between a big
> endian field against a CPU endian field, which resulted in the wrong
> answer on LE systems. This was observed as unexpected errors getting
> logged at boot time as targets were getting relogins when not needed.

Applied to 4.16/scsi-fixes, thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: aic94xx: Use dma_pool_zalloc()

2018-03-14 Thread Martin K. Petersen

Souptick,

> Any comment for this patch ?

-ENOREVIEWS

Also, you have not provided potential reviewers with a compelling reason
why dma_pool_zalloc() is superior to alloc+memset.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: csiostor: add support for 32 bit port capabilities

2018-03-14 Thread Martin K. Petersen

Varun,

> 32 bit port capabilities are required to support new speeds which can
> not be supported using 16 bit port capabilities.

Applied to 4.17/scsi-queue. Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH v2] aic7xxx/aic79xx: remove VLAs

2018-03-14 Thread Martin K. Petersen

Stephen,

> In preparation to enabling -Wvla, remove VLAs and replace them with
> fixed-length arrays instead.
>
> The arrays fixed here, using the number of constant sections, aren't
> really VLAs, but they appear so to the compiler. Replace the array
> sizes with a pre-processor-level constant instead using ARRAY_SIZE.

Applied to 4.17/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] bfa: remove VLA

2018-03-14 Thread Martin K. Petersen

Stephen,

> bfad_bsg.c uses a variable-length array declaration to measure the
> size of a putative array; this can be replaced by the product of the
> size of an element and the number of elements, avoiding the VLA
> altogether.
>
> - sizeof(wwn_t[iocmd->nports])) != BFA_STATUS_OK) {
> + sizeof(wwn_t) * iocmd->nports) != BFA_STATUS_OK) {

These parentheses made me blurry eyed but it's actually OK.

Applied to 4.17/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 12/12] scsi: remove ChangeLog.1992-1997

2018-03-14 Thread Martin K. Petersen

Christoph,

> This 20+ year old changelog has no useful information for kernel
> development or users, so remove it.

Applied to 4.17/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 01/12] dpt_i2o: stop using scsi_unregister

2018-03-14 Thread Martin K. Petersen

Christoph,

> dpt_i2o doesn't use scsi_register, so it should not use scsi_unregister
> either.  Also refactor the module exit path to make a little more sense.

Applied to 4.17/scsi-queue. Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 03/12] aha1740: stop using scsi_unregister

2018-03-14 Thread Martin K. Petersen

Christoph,

> aha1740 doesn't use scsi_register, so it should not use scsi_unregister
> either.

Applied to 4.17/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: scsi_dh_alua: Correct comment for alua_alloc_pg()

2018-03-14 Thread Martin K. Petersen

John,

> In the comment for function alua_alloc_pg() the argument '@h' is
> mistakenly referred to.  Fix this by replacing it with the correct
> argument reference, '@tpgs', and provide a short description.

Applied to 4.17/scsi-queue, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 02/12] ips: don't set .detect and .release in the host template

2018-03-14 Thread Martin K. Petersen

Christoph,

> Since moving away from using scsi_module.c these were never called.
> The implementations are called directly, though so they remain.

Applied to 4.17/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: iscsi_tcp: set BDI_CAP_STABLE_WRITES when data digest enabled

2018-03-14 Thread Martin K. Petersen

> iscsi tcp will first send out data, then calculate and send data
> digest. If we don't have BDI_CAP_STABLE_WRITES, the page cache will
> be written in spite of the on going writeback. Consequently, wrong
> digest will be got and sent to target.
>
> To fix this, set BDI_CAP_STABLE_WRITES when data digest is enabled
> in iscsi_tcp .slave_configure callback.

Lee, Chris: Please review!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: scsi_transport_iscsi: use put_device() instead of kfree()

2018-03-14 Thread Martin K. Petersen

> Never directly free @dev after calling device_register(), even
> if it returned an error! Always use put_device() to give up the
> reference initialized.

Lee, Chris: Please review!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: Debugging SCSI 'UNMAP' ("Logical Block Provisioning") failure on an SSD

2018-03-14 Thread Martin K. Petersen

Kashyap,

> Sorry, I didn't give you complete information — with the previous
> `dmesg` output, I actually attached the SSD (Samsung T5) via regular USB
> "A Cable".  
>
> Now, I re-attached the SSD via the "Thunderbolt" port on my other laptop
> (Lenovo T470s), it _does_ show "UAS".   Refer the arrow below:

Do you get different sg_readcap -l output when accessing it in UAS mode?
I.e. is lbpme=1?

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH][next] scsi: lpfc: make several unions static, fix non-ANSI prototype

2018-03-14 Thread Martin K. Petersen

Colin,

> There are several unions that are local to the source and do not need
> to be in global scope, so make them static. Also add in a missing void
> parameter to functions lpfc_nvme_cmd_template and
> lpfc_nvmet_cmd_template to clean up non-ANSI warning.

Applied to 4.17/scsi-queue. Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH V5 0/5] SCSI: fix selection of reply(hw) queue

2018-03-14 Thread Martin K. Petersen

Ming,

> The patches fixes reply queue(virt-queue on virtio-scsi) selection on
> hpsa, megaraid_sa and virtio-scsi, and IO hang can be caused easily by
> this issue.

I clarified all the commit descriptions. There were also a bunch of
duplicate review tags and other warnings. Please run checkpatch next
time!

Applied to 4.16/scsi-fixes. Thank you.

-- 
Martin K. Petersen  Oracle Linux Engineering


[PATCH v2 11/13] qla2xxx: Cleanup code to improve FC-NVMe error handling

2018-03-14 Thread Himanshu Madhani
From: Darren Trapp 

This patch cleans up ABTS handling for FC-NVMe by

- Removing allocation of sp, instead pass the sp pointer for abort IOCB
- Fix error handling from Transport failure
- set outstanding_cmds array to NULL for nvme completion

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/qla2xxx/qla_isr.c  | 78 +++--
 drivers/scsi/qla2xxx/qla_nvme.c |  2 +-
 2 files changed, 29 insertions(+), 51 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 07c98eb911fd..7cacdc3408fa 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1838,31 +1838,23 @@ qla24xx_tm_iocb_entry(scsi_qla_host_t *vha, struct 
req_que *req, void *tsk)
sp->done(sp, 0);
 }
 
-static void
-qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, void *tsk)
+static void qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
+void *tsk, srb_t *sp)
 {
-   const char func[] = "NVME-IOCB";
fc_port_t *fcport;
-   srb_t *sp;
struct srb_iocb *iocb;
struct sts_entry_24xx *sts = (struct sts_entry_24xx *)tsk;
uint16_tstate_flags;
struct nvmefc_fcp_req *fd;
uint16_tret = 0;
-   struct srb_iocb *nvme;
-
-   sp = qla2x00_get_sp_from_handle(vha, func, req, tsk);
-   if (!sp)
-   return;
 
iocb = &sp->u.iocb_cmd;
fcport = sp->fcport;
iocb->u.nvme.comp_status = le16_to_cpu(sts->comp_status);
state_flags  = le16_to_cpu(sts->state_flags);
fd = iocb->u.nvme.desc;
-   nvme = &sp->u.iocb_cmd;
 
-   if (unlikely(nvme->u.nvme.aen_op))
+   if (unlikely(iocb->u.nvme.aen_op))
atomic_dec(&sp->vha->hw->nvme_active_aen_cnt);
 
/*
@@ -1896,45 +1888,30 @@ qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct 
req_que *req, void *tsk)
fd->transferred_length = fd->payload_length -
le32_to_cpu(sts->residual_len);
 
-   /*
-* If transport error then Failure (HBA rejects request)
-* otherwise transport will handle.
-*/
-   if (sts->entry_status) {
-   ql_log(ql_log_warn, fcport->vha, 0x5038,
-   "NVME-%s error - hdl=%x entry-status(%x).\n",
-   sp->name, sp->handle, sts->entry_status);
+   switch (le16_to_cpu(sts->comp_status)) {
+   case CS_COMPLETE:
+   ret = QLA_SUCCESS;
+   break;
+   case CS_ABORTED:
+   case CS_RESET:
+   case CS_PORT_UNAVAILABLE:
+   case CS_PORT_LOGGED_OUT:
+   case CS_PORT_BUSY:
+   ql_log(ql_log_warn, fcport->vha, 0x5060,
+   "NVME-%s ERR Handling - hdl=%x completion status(%x) 
resid=%x  ox_id=%x\n",
+   sp->name, sp->handle, sts->comp_status,
+   le32_to_cpu(sts->residual_len), sts->ox_id);
+   fd->transferred_length = 0;
+   iocb->u.nvme.rsp_pyld_len = 0;
+   ret = QLA_ABORTED;
+   break;
+   default:
+   ql_log(ql_log_warn, fcport->vha, 0x5060,
+   "NVME-%s error - hdl=%x completion status(%x) resid=%x  
ox_id=%x\n",
+   sp->name, sp->handle, sts->comp_status,
+   le32_to_cpu(sts->residual_len), sts->ox_id);
ret = QLA_FUNCTION_FAILED;
-   } else  {
-   switch (le16_to_cpu(sts->comp_status)) {
-   case CS_COMPLETE:
-   ret = QLA_SUCCESS;
-   break;
-
-   case CS_RESET:
-   case CS_PORT_UNAVAILABLE:
-   fcport->nvme_flag |= NVME_FLAG_RESETTING;
-   /* fall through */
-   case CS_ABORTED:
-   case CS_PORT_LOGGED_OUT:
-   case CS_PORT_BUSY:
-   ql_log(ql_log_warn, fcport->vha, 0x5060,
-   "NVME-%s ERR Handling - hdl=%x completion 
status(%x) resid=%x  ox_id=%x\n",
-   sp->name, sp->handle, sts->comp_status,
-   le32_to_cpu(sts->residual_len), sts->ox_id);
-   fd->transferred_length = 0;
-   iocb->u.nvme.rsp_pyld_len = 0;
-   ret = QLA_ABORTED;
-   break;
-
-   default:
-   ql_log(ql_log_warn, fcport->vha, 0x5060,
-   "NVME-%s error - hdl=%x completion status(%x) 
resid=%x  ox_id=%x\n",
-   sp->name, sp->handle, sts->comp_status,
-   le32_to_cpu(sts->residual_len), sts->ox_id);
-   ret = QLA_FUNCTION_FAILED;
-   

[PATCH v2 13/13] qla2xxx: Update driver version to 10.00.00.06-k

2018-03-14 Thread Himanshu Madhani
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/qla_version.h 
b/drivers/scsi/qla2xxx/qla_version.h
index 549bef9afddd..0c55d7057280 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
 /*
  * Driver version
  */
-#define QLA2XXX_VERSION  "10.00.00.05-k"
+#define QLA2XXX_VERSION  "10.00.00.06-k"
 
 #define QLA_DRIVER_MAJOR_VER   10
 #define QLA_DRIVER_MINOR_VER   0
-- 
2.12.0



[PATCH v2 08/13] qla2xxx: Remove nvme_done_list

2018-03-14 Thread Himanshu Madhani
From: Darren Trapp 

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h  |  1 -
 drivers/scsi/qla2xxx/qla_gbl.h  |  2 --
 drivers/scsi/qla2xxx/qla_init.c |  1 -
 drivers/scsi/qla2xxx/qla_mid.c  |  6 --
 drivers/scsi/qla2xxx/qla_nvme.c | 13 ++---
 drivers/scsi/qla2xxx/qla_os.c   |  1 -
 6 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 944626cc84d9..576b72bef01d 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -3465,7 +3465,6 @@ struct qla_qpair {
struct work_struct q_work;
struct list_head qp_list_elem; /* vha->qp_list */
struct list_head hints_list;
-   struct list_head nvme_done_list;
uint16_t cpuid;
struct qla_tgt_counters tgt_counters;
 };
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index e9295398050c..19f44e12926b 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -896,6 +896,4 @@ void qlt_update_host_map(struct scsi_qla_host *, port_id_t);
 void qlt_remove_target_resources(struct qla_hw_data *);
 void qlt_clr_qp_table(struct scsi_qla_host *vha);
 
-void qla_nvme_cmpl_io(struct srb_iocb *);
-
 #endif /* _QLA_GBL_H */
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index dec3e2cdaffa..0805483645d7 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -8408,7 +8408,6 @@ struct qla_qpair *qla2xxx_create_qpair(struct 
scsi_qla_host *vha, int qos,
qpair->vp_idx = vp_idx;
qpair->fw_started = ha->flags.fw_started;
INIT_LIST_HEAD(&qpair->hints_list);
-   INIT_LIST_HEAD(&qpair->nvme_done_list);
qpair->chip_reset = ha->base_qpair->chip_reset;
qpair->enable_class_2 = ha->base_qpair->enable_class_2;
qpair->enable_explicit_conf =
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index e965b16f21e3..da85cd89639f 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -778,18 +778,12 @@ static void qla_do_work(struct work_struct *work)
struct qla_qpair *qpair = container_of(work, struct qla_qpair, q_work);
struct scsi_qla_host *vha;
struct qla_hw_data *ha = qpair->hw;
-   struct srb_iocb *nvme, *nxt_nvme;
 
spin_lock_irqsave(&qpair->qp_lock, flags);
vha = pci_get_drvdata(ha->pdev);
qla24xx_process_response_queue(vha, qpair->rsp);
spin_unlock_irqrestore(&qpair->qp_lock, flags);
 
-   list_for_each_entry_safe(nvme, nxt_nvme, &qpair->nvme_done_list,
-   u.nvme.entry) {
-   list_del_init(&nvme->u.nvme.entry);
-   qla_nvme_cmpl_io(nvme);
-   }
 }
 
 /* create response queue */
diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index adeda6a4e4fd..8c05df30c083 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -149,16 +149,6 @@ static void qla_nvme_sp_ls_done(void *ptr, int res)
qla2x00_rel_sp(sp);
 }
 
-void qla_nvme_cmpl_io(struct srb_iocb *nvme)
-{
-   srb_t *sp;
-   struct nvmefc_fcp_req *fd = nvme->u.nvme.desc;
-
-   sp = container_of(nvme, srb_t, u.iocb_cmd);
-   fd->done(fd);
-   qla2xxx_rel_qpair_sp(sp->qpair, sp);
-}
-
 static void qla_nvme_sp_done(void *ptr, int res)
 {
srb_t *sp = ptr;
@@ -177,7 +167,8 @@ static void qla_nvme_sp_done(void *ptr, int res)
fd->status = NVME_SC_INTERNAL;
 
fd->rcv_rsplen = nvme->u.nvme.rsp_pyld_len;
-   list_add_tail(&nvme->u.nvme.entry, &sp->qpair->nvme_done_list);
+   fd->done(fd);
+   qla2xxx_rel_qpair_sp(sp->qpair, sp);
 
return;
 }
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 5c5dcca4d1da..69b46c8b9dd2 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -397,7 +397,6 @@ static void qla_init_base_qpair(struct scsi_qla_host *vha, 
struct req_que *req,
ha->base_qpair->use_shadow_reg = IS_SHADOW_REG_CAPABLE(ha) ? 1 : 0;
ha->base_qpair->msix = &ha->msix_entries[QLA_MSIX_RSP_Q];
INIT_LIST_HEAD(&ha->base_qpair->hints_list);
-   INIT_LIST_HEAD(&ha->base_qpair->nvme_done_list);
ha->base_qpair->enable_class_2 = ql2xenableclass2;
/* init qpair to this cpu. Will adjust at run time. */
qla_cpu_update(rsp->qpair, raw_smp_processor_id());
-- 
2.12.0



[PATCH v2 12/13] qla2xxx: Fix Async GPN_FT for FCP and FC-NVMe scan

2018-03-14 Thread Himanshu Madhani
From: Quinn Tran 

This patch combines FCP and FC-NVMe scan into single scan when
driver detects FC-NVMe capability on same port.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h  |   7 +
 drivers/scsi/qla2xxx/qla_gbl.h  |   2 +-
 drivers/scsi/qla2xxx/qla_gs.c   | 274 ++--
 drivers/scsi/qla2xxx/qla_init.c |   8 +-
 drivers/scsi/qla2xxx/qla_os.c   |   8 +-
 5 files changed, 225 insertions(+), 74 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 576b72bef01d..eb2ec1fb07cb 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2983,8 +2983,14 @@ enum scan_flags_t {
SF_QUEUED = BIT_1,
 };
 
+enum fc4type_t {
+   FS_FC4TYPE_FCP  = BIT_0,
+   FS_FC4TYPE_NVME = BIT_1,
+};
+
 struct fab_scan_rp {
port_id_t id;
+   enum fc4type_t fc4type;
u8 port_name[8];
u8 node_name[8];
 };
@@ -3276,6 +3282,7 @@ struct qla_work_evt {
} nack;
struct {
u8 fc4_type;
+   srb_t *sp;
} gpnft;
 } u;
 };
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 19f44e12926b..3c4c84ed0f0f 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -658,7 +658,7 @@ void qla24xx_handle_gpsc_event(scsi_qla_host_t *, struct 
event_arg *);
 int qla2x00_mgmt_svr_login(scsi_qla_host_t *);
 void qla24xx_handle_gffid_event(scsi_qla_host_t *vha, struct event_arg *ea);
 int qla24xx_async_gffid(scsi_qla_host_t *vha, fc_port_t *fcport);
-int qla24xx_async_gpnft(scsi_qla_host_t *, u8);
+int qla24xx_async_gpnft(scsi_qla_host_t *, u8, srb_t *);
 void qla24xx_async_gpnft_done(scsi_qla_host_t *, srb_t *);
 void qla24xx_async_gnnft_done(scsi_qla_host_t *, srb_t *);
 int qla24xx_async_gnnid(scsi_qla_host_t *, fc_port_t *);
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index e6bb78e6f1d4..7ab93a0d19c1 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -3860,7 +3860,6 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t 
*sp)
fc_port_t *fcport;
u32 i, rc;
bool found;
-   u8 fc4type = sp->gen2;
struct fab_scan_rp *rp;
unsigned long flags;
 
@@ -3933,7 +3932,7 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t 
*sp)
"%s %d %8phC post new sess\n",
__func__, __LINE__, rp->port_name);
qla24xx_post_newsess_work(vha, &rp->id, rp->port_name,
-   rp->node_name, NULL, fc4type);
+   rp->node_name, NULL, rp->fc4type);
}
}
 
@@ -3972,23 +3971,114 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, 
srb_t *sp)
vha->scan.scan_flags &= ~SF_SCANNING;
spin_unlock_irqrestore(&vha->work_lock, flags);
 
-   if ((fc4type == FC4_TYPE_FCP_SCSI) && vha->flags.nvme_enabled)
-   qla24xx_async_gpnft(vha, FC4_TYPE_NVME);
 }
 
-static void qla2x00_async_gpnft_gnnft_sp_done(void *s, int res)
+static void qla2x00_find_free_fcp_nvme_slot(struct scsi_qla_host *vha,
+   struct srb *sp)
 {
-   struct srb *sp = s;
-   struct scsi_qla_host *vha = sp->vha;
-   struct qla_work_evt *e;
+   struct qla_hw_data *ha = vha->hw;
+   int num_fibre_dev = ha->max_fibre_devices;
struct ct_sns_req *ct_req =
(struct ct_sns_req *)sp->u.iocb_cmd.u.ctarg.req;
struct ct_sns_gpnft_rsp *ct_rsp =
(struct ct_sns_gpnft_rsp *)sp->u.iocb_cmd.u.ctarg.rsp;
struct ct_sns_gpn_ft_data *d;
struct fab_scan_rp *rp;
+   u16 cmd = be16_to_cpu(ct_req->command);
+   u8 fc4_type = sp->gen2;
int i, j, k;
+   port_id_t id;
+   u8 found;
+   u64 wwn;
+
+   j = 0;
+   for (i = 0; i < num_fibre_dev; i++) {
+   d  = &ct_rsp->entries[i];
+
+   id.b.rsvd_1 = 0;
+   id.b.domain = d->port_id[0];
+   id.b.area   = d->port_id[1];
+   id.b.al_pa  = d->port_id[2];
+   wwn = wwn_to_u64(d->port_name);
+
+   if (id.b24 == 0 || wwn == 0)
+   continue;
+
+   if (fc4_type == FC4_TYPE_FCP_SCSI) {
+   if (cmd == GPN_FT_CMD) {
+   rp = &vha->scan.l[j];
+   rp->id = id;
+   memcpy(rp->port_name, d->port_name, 8);
+   j++;
+   rp->fc4type = FS_FC4TYPE_FCP;
+   } else {
+   for (k = 0; k < num_fibre_dev; k++) {
+   rp = &vha->scan.l[k];
+   if (id.b24 == rp->id.b24) {
+

[PATCH v2 10/13] qla2xxx: Fix FC-NVMe IO abort during driver reset

2018-03-14 Thread Himanshu Madhani
From: Darren Trapp 

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/qla2xxx/qla_nvme.c | 17 -
 drivers/scsi/qla2xxx/qla_nvme.h |  2 +-
 drivers/scsi/qla2xxx/qla_os.c   |  2 +-
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index 8c05df30c083..57275bc9fe14 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -489,6 +489,9 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port 
*lport,
 
vha = fcport->vha;
 
+   if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))
+   return rval;
+
/*
 * If we know the dev is going away while the transport is still sending
 * IO's return busy back to stall the IO Q.  This happens when the
@@ -597,14 +600,18 @@ static int qla_nvme_wait_on_command(srb_t *sp)
return ret;
 }
 
-void qla_nvme_abort(struct qla_hw_data *ha, struct srb *sp)
+void qla_nvme_abort(struct qla_hw_data *ha, struct srb *sp, int res)
 {
int rval;
 
-   rval = ha->isp_ops->abort_command(sp);
-   if (!rval && !qla_nvme_wait_on_command(sp))
-   ql_log(ql_log_warn, NULL, 0x2112,
-   "nvme_wait_on_comand timed out waiting on sp=%p\n", sp);
+   if (!test_bit(ABORT_ISP_ACTIVE, &sp->vha->dpc_flags)) {
+   rval = ha->isp_ops->abort_command(sp);
+   if (!rval && !qla_nvme_wait_on_command(sp))
+   ql_log(ql_log_warn, NULL, 0x2112,
+   "timed out waiting on sp=%p\n", sp);
+   } else {
+   sp->done(sp, res);
+   }
 }
 
 static void qla_nvme_unregister_remote_port(struct work_struct *work)
diff --git a/drivers/scsi/qla2xxx/qla_nvme.h b/drivers/scsi/qla2xxx/qla_nvme.h
index 8df379478269..816854ada654 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.h
+++ b/drivers/scsi/qla2xxx/qla_nvme.h
@@ -145,7 +145,7 @@ struct pt_ls4_rx_unsol {
 void qla_nvme_register_hba(struct scsi_qla_host *);
 int  qla_nvme_register_remote(struct scsi_qla_host *, struct fc_port *);
 void qla_nvme_delete(struct scsi_qla_host *);
-void qla_nvme_abort(struct qla_hw_data *, struct srb *sp);
+void qla_nvme_abort(struct qla_hw_data *, struct srb *sp, int res);
 void qla24xx_nvme_ls4_iocb(struct scsi_qla_host *, struct pt_ls4_request *,
 struct req_que *);
 void qla24xx_async_gffid_sp_done(void *, int);
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 69b46c8b9dd2..7fe265aca617 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -1743,7 +1743,7 @@ __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res)
sp_get(sp);
spin_unlock_irqrestore(qp->qp_lock_ptr,
flags);
-   qla_nvme_abort(ha, sp);
+   qla_nvme_abort(ha, sp, res);
spin_lock_irqsave(qp->qp_lock_ptr,
flags);
} else if (GET_CMD_SP(sp) &&
-- 
2.12.0



[PATCH v2 02/13] qla2xxx: Set IIDMA and fcport state before qla_nvme_register_remote()

2018-03-14 Thread Himanshu Madhani
From: Darren Trapp 

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/qla2xxx/qla_init.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index cb182b102bfd..6caccc52376a 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -5110,13 +5110,14 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t 
*fcport)
fcport->deleted = 0;
fcport->logout_on_delete = 1;
 
+   qla2x00_set_fcport_state(fcport, FCS_ONLINE);
+   qla2x00_iidma_fcport(vha, fcport);
+
if (fcport->fc4f_nvme) {
qla_nvme_register_remote(vha, fcport);
return;
}
 
-   qla2x00_set_fcport_state(fcport, FCS_ONLINE);
-   qla2x00_iidma_fcport(vha, fcport);
qla24xx_update_fcport_fcp_prio(vha, fcport);
 
 reg_port:
-- 
2.12.0



[PATCH v2 04/13] qla2xxx: Restore ZIO threshold setting

2018-03-14 Thread Himanshu Madhani
From: Darren Trapp 

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/qla2xxx/qla_nvme.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index a8e81fc14c44..5ee447680ddd 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -464,11 +464,6 @@ static int qla2x00_start_nvme_mq(srb_t *sp)
/* Set chip new ring index. */
WRT_REG_DWORD(req->req_q_in, req->ring_index);
 
-   /* Manage unprocessed RIO/ZIO commands in response queue. */
-   if (vha->flags.process_response_queue &&
-   rsp->ring_ptr->signature != RESPONSE_PROCESSED)
-   qla24xx_process_response_queue(vha, rsp);
-
 queuing_error:
spin_unlock_irqrestore(&qpair->qp_lock, flags);
return rval;
-- 
2.12.0



[PATCH v2 05/13] qla2xxx: Add FC-NVMe abort processing

2018-03-14 Thread Himanshu Madhani
From: Darren Trapp 

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/qla2xxx/qla_nvme.c | 36 ++--
 drivers/scsi/qla2xxx/qla_nvme.h |  1 +
 2 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index 5ee447680ddd..951fbbab961f 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -181,24 +181,32 @@ static void qla_nvme_sp_done(void *ptr, int res)
return;
 }
 
-static void qla_nvme_ls_abort(struct nvme_fc_local_port *lport,
-struct nvme_fc_remote_port *rport, struct nvmefc_ls_req *fd)
+static void qla_nvme_abort_work(struct work_struct *work)
 {
-   struct nvme_private *priv = fd->private;
-   struct qla_nvme_rport *qla_rport = rport->private;
-   fc_port_t *fcport = qla_rport->fcport;
+   struct nvme_private *priv =
+   container_of(work, struct nvme_private, abort_work);
srb_t *sp = priv->sp;
-   int rval;
+   fc_port_t *fcport = sp->fcport;
struct qla_hw_data *ha = fcport->vha->hw;
+   int rval;
 
rval = ha->isp_ops->abort_command(sp);
 
ql_dbg(ql_dbg_io, fcport->vha, 0x212b,
-   "%s: %s LS command for sp=%p on fcport=%p rval=%x\n", __func__,
+   "%s: %s command for sp=%p on fcport=%p rval=%x\n", __func__,
(rval != QLA_SUCCESS) ? "Failed to abort" : "Aborted",
sp, fcport, rval);
 }
 
+static void qla_nvme_ls_abort(struct nvme_fc_local_port *lport,
+struct nvme_fc_remote_port *rport, struct nvmefc_ls_req *fd)
+{
+   struct nvme_private *priv = fd->private;
+
+   INIT_WORK(&priv->abort_work, qla_nvme_abort_work);
+   schedule_work(&priv->abort_work);
+}
+
 static void qla_nvme_ls_complete(struct work_struct *work)
 {
struct nvme_private *priv =
@@ -264,18 +272,9 @@ static void qla_nvme_fcp_abort(struct nvme_fc_local_port 
*lport,
 struct nvmefc_fcp_req *fd)
 {
struct nvme_private *priv = fd->private;
-   srb_t *sp = priv->sp;
-   int rval;
-   struct qla_nvme_rport *qla_rport = rport->private;
-   fc_port_t *fcport = qla_rport->fcport;
-   struct qla_hw_data *ha = fcport->vha->hw;
-
-   rval = ha->isp_ops->abort_command(sp);
 
-   ql_dbg(ql_dbg_io, fcport->vha, 0x2127,
-   "%s: %s command for sp=%p on fcport=%p rval=%x\n", __func__,
-   (rval != QLA_SUCCESS) ? "Failed to abort" : "Aborted",
-   sp, fcport, rval);
+   INIT_WORK(&priv->abort_work, qla_nvme_abort_work);
+   schedule_work(&priv->abort_work);
 }
 
 static void qla_nvme_poll(struct nvme_fc_local_port *lport, void 
*hw_queue_handle)
@@ -650,6 +649,7 @@ void qla_nvme_delete(struct scsi_qla_host *vha)
ql_log(ql_log_info, fcport->vha, 0x2114, "%s: fcport=%p\n",
__func__, fcport);
 
+   nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port, 0);
init_completion(&fcport->nvme_del_done);
nvme_fc_unregister_remoteport(fcport->nvme_remote_port);
wait_for_completion(&fcport->nvme_del_done);
diff --git a/drivers/scsi/qla2xxx/qla_nvme.h b/drivers/scsi/qla2xxx/qla_nvme.h
index 7becfc1b3e69..8df379478269 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.h
+++ b/drivers/scsi/qla2xxx/qla_nvme.h
@@ -31,6 +31,7 @@ struct nvme_private {
struct srb  *sp;
struct nvmefc_ls_req *fd;
struct work_struct ls_work;
+   struct work_struct abort_work;
int comp_status;
 };
 
-- 
2.12.0



[PATCH v2 00/13] qla2xxx: Fixes for FC-NVMe

2018-03-14 Thread Himanshu Madhani
Hi Martin,

This patch series addresses issue with FC-NVMe abort handling in the
driver. Code has been cleaned up and devloss timeout support has been
added in qla2xxx.

Please apply this series to 4.17/scsi-queue at your earliest convenience.

Hi Christoph, Sagi, Johannes, James,

Please review this series. I would however like this to be merged via
Martin's SCSI tree.

Changes from v1-> v2
- Added reviewed-by tags for Hannes.
- Fixes build warning reported by kbuild robot

Thanks,
Himanshu 


Darren Trapp (10):
  qla2xxx: Set IIDMA and fcport state before qla_nvme_register_remote()
  qla2xxx: Add changes for devloss timeout in driver
  qla2xxx: Restore ZIO threshold setting
  qla2xxx: Add FC-NVMe abort processing
  qla2xxx: Fix n2n_ae flag to prevent dev_loss on PDB change
  qla2xxx: Return busy if rport going away
  qla2xxx: Remove nvme_done_list
  qla2xxx: Fix retry for PRLI RJT with reason of BUSY
  qla2xxx: Fix FC-NVMe IO abort during driver reset
  qla2xxx: Cleanup code to improve FC-NVMe error handling

Himanshu Madhani (2):
  qla2xxx: Remove unneeded message and minor cleanup for FC-NVMe
  qla2xxx: Update driver version to 10.00.00.06-k

Quinn Tran (1):
  qla2xxx: Fix Async GPN_FT for FCP and FC-NVMe scan

 drivers/scsi/qla2xxx/qla_dbg.c |   2 +-
 drivers/scsi/qla2xxx/qla_def.h |  12 +-
 drivers/scsi/qla2xxx/qla_gbl.h |   4 +-
 drivers/scsi/qla2xxx/qla_gs.c  | 274 -
 drivers/scsi/qla2xxx/qla_init.c|  35 +++--
 drivers/scsi/qla2xxx/qla_isr.c |  78 ---
 drivers/scsi/qla2xxx/qla_mbx.c |  10 +-
 drivers/scsi/qla2xxx/qla_mid.c |   6 -
 drivers/scsi/qla2xxx/qla_nvme.c| 245 +++--
 drivers/scsi/qla2xxx/qla_nvme.h|   9 +-
 drivers/scsi/qla2xxx/qla_os.c  |  11 +-
 drivers/scsi/qla2xxx/qla_target.c  |  13 +-
 drivers/scsi/qla2xxx/qla_target.h  |   2 +-
 drivers/scsi/qla2xxx/qla_version.h |   2 +-
 14 files changed, 416 insertions(+), 287 deletions(-)

-- 
2.12.0



[PATCH v2 09/13] qla2xxx: Fix retry for PRLI RJT with reason of BUSY

2018-03-14 Thread Himanshu Madhani
From: Darren Trapp 

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/qla2xxx/qla_dbg.c  |  2 +-
 drivers/scsi/qla2xxx/qla_init.c | 13 -
 drivers/scsi/qla2xxx/qla_mbx.c  |  7 +--
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index 7e9d8f08b9d5..1abc8a9064b3 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -60,7 +60,7 @@
  * |  || 0xb13c-0xb140  |
  * |  || 0xb149
|
  * | MultiQ   |   0xc010   |   |
- * | Misc |   0xd302   | 0xd031-0xd0ff |
+ * | Misc |   0xd303   | 0xd031-0xd0ff |
  * |  || 0xd101-0xd1fe |
  * |  || 0xd214-0xd2fe |
  * | Target Mode |   0xe081   ||
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 0805483645d7..5520477a66d9 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -875,7 +875,6 @@ qla24xx_async_prli(struct scsi_qla_host *vha, fc_port_t 
*fcport)
return rval;
 
if (fcport->fw_login_state == DSC_LS_PLOGI_PEND ||
-   fcport->fw_login_state == DSC_LS_PLOGI_COMP ||
fcport->fw_login_state == DSC_LS_PRLI_PEND)
return rval;
 
@@ -1240,6 +1239,11 @@ int qla24xx_fcport_handle_login(struct scsi_qla_host 
*vha, fc_port_t *fcport)
qla2x00_post_async_adisc_work(vha, fcport, data);
break;
 
+   case DSC_LOGIN_PEND:
+   if (fcport->fw_login_state == DSC_LS_PLOGI_COMP)
+   qla24xx_post_prli_work(vha, fcport);
+   break;
+
default:
break;
}
@@ -1643,6 +1647,13 @@ qla24xx_handle_prli_done_event(struct scsi_qla_host 
*vha, struct event_arg *ea)
qla24xx_post_gpdb_work(vha, ea->fcport, 0);
break;
default:
+   if ((ea->iop[0] == LSC_SCODE_ELS_REJECT) &&
+   (ea->iop[1] == 0x5)) {   /* reson 5=busy expl:0x0 */
+   set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
+   ea->fcport->fw_login_state = DSC_LS_PLOGI_COMP;
+   break;
+   }
+
if (ea->fcport->n2n_flag) {
ql_dbg(ql_dbg_disc, vha, 0x2118,
"%s %d %8phC post fc4 prli\n",
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 735079ba691c..c9a134ae0d2b 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -1025,9 +1025,12 @@ qla2x00_get_fw_version(scsi_qla_host_t *vha)
 * FW supports nvme and driver load parameter requested nvme.
 * BIT 26 of fw_attributes indicates NVMe support.
 */
-   if ((ha->fw_attributes_h & 0x400) && ql2xnvmeenable)
+   if ((ha->fw_attributes_h & 0x400) && ql2xnvmeenable) {
vha->flags.nvme_enabled = 1;
-
+   ql_log(ql_log_info, vha, 0xd302,
+   "%s: FC-NVMe is Enabled (0x%x)\n",
+__func__, ha->fw_attributes_h);
+   }
}
 
if (IS_QLA27XX(ha)) {
-- 
2.12.0



[PATCH v2 01/13] qla2xxx: Remove unneeded message and minor cleanup for FC-NVMe

2018-03-14 Thread Himanshu Madhani
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/qla2xxx/qla_nvme.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index 6b33a1f24f56..162a523b985e 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -113,8 +113,6 @@ static int qla_nvme_alloc_queue(struct nvme_fc_local_port 
*lport,
return 0;
}
 
-   ql_log(ql_log_warn, vha, 0x,
-   "allocating q for idx=%x w/o cpu mask\n", qidx);
qpair = qla2xxx_create_qpair(vha, 5, vha->vp_idx, true);
if (qpair == NULL) {
ql_log(ql_log_warn, vha, 0x2122,
@@ -313,7 +311,6 @@ static int qla2x00_start_nvme_mq(srb_t *sp)
uint16_tavail_dsds;
uint32_t*cur_dsd;
struct req_que *req = NULL;
-   struct rsp_que *rsp = NULL;
struct scsi_qla_host *vha = sp->fcport->vha;
struct qla_hw_data *ha = vha->hw;
struct qla_qpair *qpair = sp->qpair;
@@ -322,15 +319,13 @@ static int qla2x00_start_nvme_mq(srb_t *sp)
struct nvmefc_fcp_req *fd = nvme->u.nvme.desc;
uint32_trval = QLA_SUCCESS;
 
+   /* Setup qpair pointers */
+   req = qpair->req;
tot_dsds = fd->sg_cnt;
 
/* Acquire qpair specific lock */
spin_lock_irqsave(&qpair->qp_lock, flags);
 
-   /* Setup qpair pointers */
-   req = qpair->req;
-   rsp = qpair->rsp;
-
/* Check for room in outstanding command list. */
handle = req->current_outstanding_cmd;
for (index = 1; index < req->num_outstanding_cmds; index++) {
@@ -365,7 +360,7 @@ static int qla2x00_start_nvme_mq(srb_t *sp)
struct nvme_fc_cmd_iu *cmd = fd->cmdaddr;
if (cmd->sqe.common.opcode == nvme_admin_async_event) {
nvme->u.nvme.aen_op = 1;
-   atomic_inc(&vha->hw->nvme_active_aen_cnt);
+   atomic_inc(&ha->nvme_active_aen_cnt);
}
}
 
-- 
2.12.0



[PATCH v2 06/13] qla2xxx: Fix n2n_ae flag to prevent dev_loss on PDB change

2018-03-14 Thread Himanshu Madhani
From: Darren Trapp 

On a port db changes, this patch will set n2n_ae flag for N2N
connection when requesting for Report ID Acquition MBX, instead
of Loop Initialization or point to point asynchronous events.

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/qla2xxx/qla_def.h | 2 --
 drivers/scsi/qla2xxx/qla_isr.c | 3 ---
 drivers/scsi/qla2xxx/qla_mbx.c | 3 +++
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 737492048d8a..745e6414b496 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -4282,8 +4282,6 @@ typedef struct scsi_qla_host {
struct  nvme_fc_local_port *nvme_local_port;
struct completion nvme_del_done;
struct list_head nvme_rport_list;
-   atomic_tnvme_active_aen_cnt;
-   uint16_tnvme_last_rptd_aen;
 
uint16_tfcoe_vlan_id;
uint16_tfcoe_fcf_idx;
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 011261a9d585..d973d0b5d8c3 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -768,7 +768,6 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que 
*rsp, uint16_t *mb)
 
case MBA_LIP_OCCURRED:  /* Loop Initialization Procedure */
ha->flags.lip_ae = 1;
-   ha->flags.n2n_ae = 0;
 
ql_dbg(ql_dbg_async, vha, 0x5009,
"LIP occurred (%x).\n", mb[1]);
@@ -812,7 +811,6 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que 
*rsp, uint16_t *mb)
 
case MBA_LOOP_DOWN: /* Loop Down Event */
SAVE_TOPO(ha);
-   ha->flags.n2n_ae = 0;
ha->flags.lip_ae = 0;
ha->current_topology = 0;
 
@@ -886,7 +884,6 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que 
*rsp, uint16_t *mb)
/* case MBA_DCBX_COMPLETE: */
case MBA_POINT_TO_POINT:/* Point-to-Point */
ha->flags.lip_ae = 0;
-   ha->flags.n2n_ae = 1;
 
if (IS_QLA2100(ha))
break;
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 41b0ee47c6a1..735079ba691c 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -3747,6 +3747,7 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
id.b.area   = rptid_entry->port_id[1];
id.b.al_pa  = rptid_entry->port_id[0];
id.b.rsvd_1 = 0;
+   ha->flags.n2n_ae = 0;
 
if (rptid_entry->format == 0) {
/* loop */
@@ -3799,6 +3800,7 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
set_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags);
set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags);
set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags);
+   ha->flags.n2n_ae = 1;
return;
}
 
@@ -3875,6 +3877,7 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
vha->d_id.b.area = rptid_entry->port_id[1];
vha->d_id.b.al_pa = rptid_entry->port_id[0];
 
+   ha->flags.n2n_ae = 1;
spin_lock_irqsave(&ha->vport_slock, flags);
qlt_update_vp_map(vha, SET_AL_PA);
spin_unlock_irqrestore(&ha->vport_slock, flags);
-- 
2.12.0



[PATCH v2 03/13] qla2xxx: Add changes for devloss timeout in driver

2018-03-14 Thread Himanshu Madhani
From: Darren Trapp 

Add support for error recovery within devloss timeout, now that
FC-NVMe transport support devloss timeout.

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/qla2xxx/qla_def.h|   1 +
 drivers/scsi/qla2xxx/qla_init.c   |   8 +++
 drivers/scsi/qla2xxx/qla_isr.c|   5 +-
 drivers/scsi/qla2xxx/qla_nvme.c   | 142 +-
 drivers/scsi/qla2xxx/qla_nvme.h   |   6 +-
 drivers/scsi/qla2xxx/qla_target.c |  13 ++--
 drivers/scsi/qla2xxx/qla_target.h |   2 +-
 7 files changed, 87 insertions(+), 90 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index c9689f97c307..737492048d8a 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2356,6 +2356,7 @@ typedef struct fc_port {
 #define NVME_PRLI_SP_DISCOVERY  BIT_3
uint8_t nvme_flag;
 #define NVME_FLAG_REGISTERED 4
+#define NVME_FLAG_DELETING 2
 
struct fc_port *conflict;
unsigned char logout_completed;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 6caccc52376a..dec3e2cdaffa 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -5520,6 +5520,14 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha)
break;
}
 
+   if (fcport->fc4f_nvme) {
+   if (fcport->disc_state == DSC_DELETE_PEND) {
+   fcport->disc_state = DSC_GNL;
+   vha->fcport_count--;
+   fcport->login_succ = 0;
+   }
+   }
+
if (found) {
spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
continue;
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 79f538448364..011261a9d585 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1911,7 +1911,7 @@ qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct 
req_que *req, void *tsk)
} else  {
switch (le16_to_cpu(sts->comp_status)) {
case CS_COMPLETE:
-   ret = 0;
+   ret = QLA_SUCCESS;
break;
 
case CS_ABORTED:
@@ -1923,7 +1923,8 @@ qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct 
req_que *req, void *tsk)
"NVME-%s ERR Handling - hdl=%x completion 
status(%x) resid=%x  ox_id=%x\n",
sp->name, sp->handle, sts->comp_status,
le32_to_cpu(sts->residual_len), sts->ox_id);
-   fd->transferred_length = fd->payload_length;
+   fd->transferred_length = 0;
+   iocb->u.nvme.rsp_pyld_len = 0;
ret = QLA_ABORTED;
break;
 
diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index 162a523b985e..a8e81fc14c44 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -16,15 +16,13 @@ static void qla_nvme_unregister_remote_port(struct 
work_struct *);
 
 int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport)
 {
-   struct nvme_rport *rport;
+   struct qla_nvme_rport *rport;
+   struct nvme_fc_port_info req;
int ret;
 
if (!IS_ENABLED(CONFIG_NVME_FC))
return 0;
 
-   if (fcport->nvme_flag & NVME_FLAG_REGISTERED)
-   return 0;
-
if (!vha->flags.nvme_enabled) {
ql_log(ql_log_info, vha, 0x2100,
"%s: Not registering target since Host NVME is not 
enabled\n",
@@ -33,38 +31,35 @@ int qla_nvme_register_remote(struct scsi_qla_host *vha, 
struct fc_port *fcport)
}
 
if (!(fcport->nvme_prli_service_param &
-   (NVME_PRLI_SP_TARGET | NVME_PRLI_SP_DISCOVERY)))
+   (NVME_PRLI_SP_TARGET | NVME_PRLI_SP_DISCOVERY)) ||
+   (fcport->nvme_flag & NVME_FLAG_REGISTERED))
return 0;
 
INIT_WORK(&fcport->nvme_del_work, qla_nvme_unregister_remote_port);
-   rport = kzalloc(sizeof(*rport), GFP_KERNEL);
-   if (!rport) {
-   ql_log(ql_log_warn, vha, 0x2101,
-   "%s: unable to alloc memory\n", __func__);
-   return -ENOMEM;
-   }
 
-   rport->req.port_name = wwn_to_u64(fcport->port_name);
-   rport->req.node_name = wwn_to_u64(fcport->node_name);
-   rport->req.port_role = 0;
+   memset(&req, 0, sizeof(struct nvme_fc_port_info));
+   req.port_name = wwn_to_u64(fcport->port_name);
+   req.node_name = wwn_to_u64(fcport->node_name);
+   req.port_role = 0;
+   req.dev_loss_tmo = NVME_FC_DEV_LOSS_TMO;
 
if (fcport

[PATCH v2 07/13] qla2xxx: Return busy if rport going away

2018-03-14 Thread Himanshu Madhani
From: Darren Trapp 

This patch adds mechanism to return EBUSY if rport is going away
to prevent exhausting FC-NVMe layer's retry counter.

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/qla2xxx/qla_def.h  |  1 +
 drivers/scsi/qla2xxx/qla_isr.c  |  4 +++-
 drivers/scsi/qla2xxx/qla_nvme.c | 31 ---
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 745e6414b496..944626cc84d9 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2357,6 +2357,7 @@ typedef struct fc_port {
uint8_t nvme_flag;
 #define NVME_FLAG_REGISTERED 4
 #define NVME_FLAG_DELETING 2
+#define NVME_FLAG_RESETTING 1
 
struct fc_port *conflict;
unsigned char logout_completed;
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index d973d0b5d8c3..07c98eb911fd 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1911,9 +1911,11 @@ qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct 
req_que *req, void *tsk)
ret = QLA_SUCCESS;
break;
 
-   case CS_ABORTED:
case CS_RESET:
case CS_PORT_UNAVAILABLE:
+   fcport->nvme_flag |= NVME_FLAG_RESETTING;
+   /* fall through */
+   case CS_ABORTED:
case CS_PORT_LOGGED_OUT:
case CS_PORT_BUSY:
ql_log(ql_log_warn, fcport->vha, 0x5060,
diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index 951fbbab961f..adeda6a4e4fd 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -36,6 +36,7 @@ int qla_nvme_register_remote(struct scsi_qla_host *vha, 
struct fc_port *fcport)
return 0;
 
INIT_WORK(&fcport->nvme_del_work, qla_nvme_unregister_remote_port);
+   fcport->nvme_flag &= ~NVME_FLAG_RESETTING;
 
memset(&req, 0, sizeof(struct nvme_fc_port_info));
req.port_name = wwn_to_u64(fcport->port_name);
@@ -193,9 +194,9 @@ static void qla_nvme_abort_work(struct work_struct *work)
rval = ha->isp_ops->abort_command(sp);
 
ql_dbg(ql_dbg_io, fcport->vha, 0x212b,
-   "%s: %s command for sp=%p on fcport=%p rval=%x\n", __func__,
-   (rval != QLA_SUCCESS) ? "Failed to abort" : "Aborted",
-   sp, fcport, rval);
+   "%s: %s command for sp=%p, handle=%x on fcport=%p rval=%x\n",
+   __func__, (rval != QLA_SUCCESS) ? "Failed to abort" : "Aborted",
+   sp, sp->handle, fcport, rval);
 }
 
 static void qla_nvme_ls_abort(struct nvme_fc_local_port *lport,
@@ -327,7 +328,7 @@ static int qla2x00_start_nvme_mq(srb_t *sp)
}
 
if (index == req->num_outstanding_cmds) {
-   rval = -1;
+   rval = -EBUSY;
goto queuing_error;
}
req_cnt = qla24xx_calc_iocbs(vha, tot_dsds);
@@ -341,7 +342,7 @@ static int qla2x00_start_nvme_mq(srb_t *sp)
req->cnt = req->length - (req->ring_index - cnt);
 
if (req->cnt < (req_cnt + 2)){
-   rval = -1;
+   rval = -EBUSY;
goto queuing_error;
}
}
@@ -476,14 +477,15 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port 
*lport,
fc_port_t *fcport;
struct srb_iocb *nvme;
struct scsi_qla_host *vha;
-   int rval = QLA_FUNCTION_FAILED;
+   int rval = -ENODEV;
srb_t *sp;
struct qla_qpair *qpair = hw_queue_handle;
struct nvme_private *priv;
struct qla_nvme_rport *qla_rport = rport->private;
 
-   if (!fd) {
-   ql_log(ql_log_warn, NULL, 0x2134, "NO NVMe FCP request\n");
+   if (!fd || !qpair) {
+   ql_log(ql_log_warn, NULL, 0x2134,
+   "NO NVMe request or Queue Handle\n");
return rval;
}
 
@@ -495,13 +497,21 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port 
*lport,
}
 
vha = fcport->vha;
-   if (!qpair)
+
+   /*
+* If we know the dev is going away while the transport is still sending
+* IO's return busy back to stall the IO Q.  This happens when the
+* link goes away and fw hasn't notified us yet, but IO's are being
+* returned. If the dev comes back quickly we won't exhaust the IO
+* retry count at the core.
+*/
+   if (fcport->nvme_flag & NVME_FLAG_RESETTING)
return -EBUSY;
 
/* Alloc SRB structure */
sp = qla2xxx_get_qpair_sp(qpair, fcport, GFP_ATOMIC);
if (!sp)
-   return -EIO;
+   return -EBUSY;
 
atomic_set(&sp->ref_count, 

Re: [GIT PULL] SCSI fixes for 4.16-rc5

2018-03-14 Thread Martin K. Petersen

Linus,

> I've pulled it, but I don't see why (and how) this kind of garbage got
> reviewed and acked by multiple people.

My bad. I actually did notice the superfluous ifs and meant to nuke them
when I committed the patch.

However, I had a freak accident with my fixes branch that day that
compelled me to reset to my latest public hash and redo several
commits. I completely forgot that I had intended to tweak this patch
when I finally got around to applying it. I should have looked closer,
but it was already in my "done" pile.

Botched it. Sorry about that!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [GIT PULL] SCSI fixes for 4.16-rc5

2018-03-14 Thread Linus Torvalds
On Wed, Mar 14, 2018 at 4:28 PM, James Bottomley
 wrote:
> -   vfree(ha->optrom_buffer);
> -   kfree(ha->nvram);
> -   kfree(ha->npiv_info);
> -   kfree(ha->swl);
> -   kfree(ha->loop_id_map);
> +
> +   if (ha->optrom_buffer)
> +   vfree(ha->optrom_buffer);
> +   if (ha->nvram)
> +   kfree(ha->nvram);
> +   if (ha->npiv_info)
> +   kfree(ha->npiv_info);
> +   if (ha->swl)
> +   kfree(ha->swl);
> +   if (ha->loop_id_map)
> +   kfree(ha->loop_id_map);

Why? This part is just garbage.

I've pulled it, but I don't see why (and how) this kind of garbage got
reviewed and acked by multiple people.

Both vfree and kfree are perfectly happy with NULL pointers, and there
doesn't seem to be any structural reason to have the test.

There *can* be valid reasons to do those kinds of things, if NULL is
the common fast-path case, and you have profiles that show that the
cost of just the call is noticeable. Then you probably also should
have an "unlikely()" there to document that fact.

But this is not one of those cases. This is just garbage and generates
less legible code.

  Linus


[GIT PULL] SCSI fixes for 4.16-rc5

2018-03-14 Thread James Bottomley
This is four patches, consisting of one regression from the merge
window (qla2xxx) one lonstanding memory leak (sd_zbc) one event queue
mislabelling which we want to eliminate to discourage the pattern
(mpt3sas) and one behaviour change because re-reading the partition
table shouldn't clear the ro flag.

The patch is available here:

git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git scsi-fixes

The short changelog is:

Bill Kuzeja (1):
  scsi: qla2xxx: Fix crashes in qla2x00_probe_one on probe failure

Damien Le Moal (1):
  scsi: sd_zbc: Fix potential memory leak

Hannes Reinecke (1):
  scsi: mpt3sas: Do not mark fw_event workqueue as WQ_MEM_RECLAIM

Jeremy Cline (1):
  scsi: sd: Keep disk read-only when re-reading partition

And the diffstat:

 drivers/scsi/mpt3sas/mpt3sas_scsih.c |  2 +-
 drivers/scsi/qla2xxx/qla_os.c| 59 ++--
 drivers/scsi/sd.c|  3 +-
 drivers/scsi/sd_zbc.c| 35 +
 4 files changed, 55 insertions(+), 44 deletions(-)

With full diff below.

James

---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index c2ea13c7e37e..a1cb0236c550 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -10558,7 +10558,7 @@ _scsih_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
snprintf(ioc->firmware_event_name, sizeof(ioc->firmware_event_name),
"fw_event_%s%d", ioc->driver_name, ioc->id);
ioc->firmware_event_thread = alloc_ordered_workqueue(
-   ioc->firmware_event_name, WQ_MEM_RECLAIM);
+   ioc->firmware_event_name, 0);
if (!ioc->firmware_event_thread) {
pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
ioc->name, __FILE__, __LINE__, __func__);
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 285911e81728..5c5dcca4d1da 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -454,7 +454,7 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, 
struct req_que *req,
ha->req_q_map[0] = req;
set_bit(0, ha->rsp_qid_map);
set_bit(0, ha->req_qid_map);
-   return 1;
+   return 0;
 
 fail_qpair_map:
kfree(ha->base_qpair);
@@ -471,6 +471,9 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, 
struct req_que *req,
 
 static void qla2x00_free_req_que(struct qla_hw_data *ha, struct req_que *req)
 {
+   if (!ha->req_q_map)
+   return;
+
if (IS_QLAFX00(ha)) {
if (req && req->ring_fx00)
dma_free_coherent(&ha->pdev->dev,
@@ -481,14 +484,17 @@ static void qla2x00_free_req_que(struct qla_hw_data *ha, 
struct req_que *req)
(req->length + 1) * sizeof(request_t),
req->ring, req->dma);
 
-   if (req)
+   if (req) {
kfree(req->outstanding_cmds);
-
-   kfree(req);
+   kfree(req);
+   }
 }
 
 static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp)
 {
+   if (!ha->rsp_q_map)
+   return;
+
if (IS_QLAFX00(ha)) {
if (rsp && rsp->ring)
dma_free_coherent(&ha->pdev->dev,
@@ -499,7 +505,8 @@ static void qla2x00_free_rsp_que(struct qla_hw_data *ha, 
struct rsp_que *rsp)
(rsp->length + 1) * sizeof(response_t),
rsp->ring, rsp->dma);
}
-   kfree(rsp);
+   if (rsp)
+   kfree(rsp);
 }
 
 static void qla2x00_free_queues(struct qla_hw_data *ha)
@@ -1723,6 +1730,8 @@ __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res)
struct qla_tgt_cmd *cmd;
uint8_t trace = 0;
 
+   if (!ha->req_q_map)
+   return;
spin_lock_irqsave(qp->qp_lock_ptr, flags);
req = qp->req;
for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) {
@@ -3095,14 +3104,14 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct 
pci_device_id *id)
/* Set up the irqs */
ret = qla2x00_request_irqs(ha, rsp);
if (ret)
-   goto probe_hw_failed;
+   goto probe_failed;
 
/* Alloc arrays of request and response ring ptrs */
-   if (!qla2x00_alloc_queues(ha, req, rsp)) {
+   if (qla2x00_alloc_queues(ha, req, rsp)) {
ql_log(ql_log_fatal, base_vha, 0x003d,
"Failed to allocate memory for queue pointers..."
"aborting.\n");
-   goto probe_init_failed;
+   goto probe_failed;
}
 
if (ha->mqenable && shost_use_blk_mq(host)) {
@@ -3387,15 +3396,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct 
pci_device_id *id)
 
return 0;
 
-probe_init_failed:
-   qla2x00_free_req_que(ha, req);
-   ha->req_q_map[0] = NULL;
-   clear_bit(0, ha->req_qid_map);
-   qla2x00_free_rsp_que(ha, rsp);

Re: [PATCH, resend] scsi: Avoid that .queuecommand() gets called for a quiesced SCSI device

2018-03-14 Thread James Bottomley
On Wed, 2018-03-14 at 15:45 -0700, Bart Van Assche wrote:
> Several SCSI transport and LLD drivers surround code that does not
> tolerate concurrent calls of .queuecommand() with scsi_target_block()
> /
> scsi_target_unblock(). These last two functions use
> blk_mq_quiesce_queue() / blk_mq_unquiesce_queue() for scsi-mq request
> queues to prevent concurrent .queuecommand() calls. However, that is
> not sufficient to prevent .queuecommand() calls from
> scsi_send_eh_cmnd().
> Hence surround the .queuecommand() call from the SCSI error handler
> with
> code that avoids that .queuecommand() gets called in the quiesced
> state.
> 
> Notes:
> - Converting the .queuecommand() call in scsi_send_eh_cmnd() into
>   code that calls blk_get_request() + blk_execute_rq() is not an
>   option since scsi_send_eh_cmnd() must be able to make forward
> progress
>   even if all requests are allocated.
> - Converting the .queuecommand() call in scsi_send_eh_cmnd() into a
>   blk_execute_rq() or blk_mq_requeue_request() call is not an option
> either
>   because that would require to change every individual function in
> the I/O
>   path. Each function in the I/O path would have to be modified such
> that it
>   handles requests received from the block layer core and request
> received
>   from the SCSI EH differently. Since struct scsi_cmnd is not
> initialized by
>   the block layer for filesystem requests, it is not possible to
> determine
>   in scsi_queue_rq() whether or not a request has been submitted by
> the
>   SCSI EH without modifying the block layer.
> 
> Signed-off-by: Bart Van Assche 
> Cc: Hannes Reinecke 
> Cc: Johannes Thumshirn 
> ---
>  drivers/scsi/scsi_error.c  | 13 +
>  drivers/scsi/scsi_lib.c|  2 ++
>  drivers/scsi/scsi_scan.c   |  1 +
>  include/scsi/scsi_device.h |  1 +
>  4 files changed, 17 insertions(+)
> 
> diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
> index 946039117bf4..cfc805851a2a 100644
> --- a/drivers/scsi/scsi_error.c
> +++ b/drivers/scsi/scsi_error.c
> @@ -1042,6 +1042,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd
> *scmd, unsigned char *cmnd,
>   unsigned long timeleft = timeout;
>   struct scsi_eh_save ses;
>   const unsigned long stall_for = msecs_to_jiffies(100);
> + DEFINE_WAIT(wait);
>   int rtn;
>  
>  retry:
> @@ -1050,7 +1051,19 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd
> *scmd, unsigned char *cmnd,
>  
>   scsi_log_send(scmd);
>   scmd->scsi_done = scsi_eh_done;
> + mutex_lock(&sdev->state_mutex);
> + while (sdev->sdev_state == SDEV_QUIESCE) {
> + prepare_to_wait(&sdev->state_wq, &wait,
> TASK_INTERRUPTIBLE);
> + mutex_unlock(&sdev->state_mutex);
> + SCSI_LOG_ERROR_RECOVERY(5, sdev_printk(KERN_DEBUG,
> sdev,
> + "%s: state %d <> %d\n", __func__, sdev-
> >sdev_state,
> + SDEV_QUIESCE));
> + schedule();
> + mutex_lock(&sdev->state_mutex);
> + }
> + finish_wait(&sdev->state_wq, &wait);
>   rtn = shost->hostt->queuecommand(shost, scmd);
> + mutex_unlock(&sdev->state_mutex);
>   if (rtn) {
>   if (timeleft > stall_for) {

This has got to be minutely rare: why not just use the existing
stall_for timeout infrastructure instead of adding a waitqueue to every
device?

James



[PATCH, resend] scsi: Avoid that .queuecommand() gets called for a quiesced SCSI device

2018-03-14 Thread Bart Van Assche
Several SCSI transport and LLD drivers surround code that does not
tolerate concurrent calls of .queuecommand() with scsi_target_block() /
scsi_target_unblock(). These last two functions use
blk_mq_quiesce_queue() / blk_mq_unquiesce_queue() for scsi-mq request
queues to prevent concurrent .queuecommand() calls. However, that is
not sufficient to prevent .queuecommand() calls from scsi_send_eh_cmnd().
Hence surround the .queuecommand() call from the SCSI error handler with
code that avoids that .queuecommand() gets called in the quiesced state.

Notes:
- Converting the .queuecommand() call in scsi_send_eh_cmnd() into
  code that calls blk_get_request() + blk_execute_rq() is not an
  option since scsi_send_eh_cmnd() must be able to make forward progress
  even if all requests are allocated.
- Converting the .queuecommand() call in scsi_send_eh_cmnd() into a
  blk_execute_rq() or blk_mq_requeue_request() call is not an option either
  because that would require to change every individual function in the I/O
  path. Each function in the I/O path would have to be modified such that it
  handles requests received from the block layer core and request received
  from the SCSI EH differently. Since struct scsi_cmnd is not initialized by
  the block layer for filesystem requests, it is not possible to determine
  in scsi_queue_rq() whether or not a request has been submitted by the
  SCSI EH without modifying the block layer.

Signed-off-by: Bart Van Assche 
Cc: Hannes Reinecke 
Cc: Johannes Thumshirn 
---
 drivers/scsi/scsi_error.c  | 13 +
 drivers/scsi/scsi_lib.c|  2 ++
 drivers/scsi/scsi_scan.c   |  1 +
 include/scsi/scsi_device.h |  1 +
 4 files changed, 17 insertions(+)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 946039117bf4..cfc805851a2a 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1042,6 +1042,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, 
unsigned char *cmnd,
unsigned long timeleft = timeout;
struct scsi_eh_save ses;
const unsigned long stall_for = msecs_to_jiffies(100);
+   DEFINE_WAIT(wait);
int rtn;
 
 retry:
@@ -1050,7 +1051,19 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, 
unsigned char *cmnd,
 
scsi_log_send(scmd);
scmd->scsi_done = scsi_eh_done;
+   mutex_lock(&sdev->state_mutex);
+   while (sdev->sdev_state == SDEV_QUIESCE) {
+   prepare_to_wait(&sdev->state_wq, &wait, TASK_INTERRUPTIBLE);
+   mutex_unlock(&sdev->state_mutex);
+   SCSI_LOG_ERROR_RECOVERY(5, sdev_printk(KERN_DEBUG, sdev,
+   "%s: state %d <> %d\n", __func__, sdev->sdev_state,
+   SDEV_QUIESCE));
+   schedule();
+   mutex_lock(&sdev->state_mutex);
+   }
+   finish_wait(&sdev->state_wq, &wait);
rtn = shost->hostt->queuecommand(shost, scmd);
+   mutex_unlock(&sdev->state_mutex);
if (rtn) {
if (timeleft > stall_for) {
scsi_eh_restore_cmnd(scmd, &ses);
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 1d83f29aee74..99741858b6da 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2757,6 +2757,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum 
scsi_device_state state)
 
}
sdev->sdev_state = state;
+   wake_up_all(&sdev->state_wq);
return 0;
 
  illegal:
@@ -3216,6 +3217,7 @@ int scsi_internal_device_unblock_nowait(struct 
scsi_device *sdev,
default:
return -EINVAL;
}
+   wake_up_all(&sdev->state_wq);
scsi_start_queue(sdev);
 
return 0;
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 0880d975eed3..32439ca61c18 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -232,6 +232,7 @@ static struct scsi_device *scsi_alloc_sdev(struct 
scsi_target *starget,
sdev->id = starget->id;
sdev->lun = lun;
sdev->channel = starget->channel;
+   init_waitqueue_head(&sdev->state_wq);
mutex_init(&sdev->state_mutex);
sdev->sdev_state = SDEV_CREATED;
INIT_LIST_HEAD(&sdev->siblings);
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 7ae177c8e399..eb9063202036 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -222,6 +222,7 @@ struct scsi_device {
void*handler_data;
 
unsigned char   access_state;
+   struct wait_queue_head  state_wq;
struct mutexstate_mutex;
enum scsi_device_state sdev_state;
struct task_struct  *quiesced_by;
-- 
2.16.2



[PATCH] ibmvfc: Avoid unnecessary port relogin

2018-03-14 Thread Brian King
Following an RSCN, ibmvfc will issue an ADISC to determine
if the underlying target has changed, comparing the
SCSI ID, WWPN, and WWNN to determine how to handle the
rport in discovery. However, the comparison of the WWPN
and WWNN was performing a memcmp between a big endian
field against a CPU endian field, which resulted in
the wrong answer on LE systems. This was observed as unexpected
errors getting logged at boot time as targets were getting
relogins when not needed.

Signed-off-by: Brian King 
---

Index: linux.git/drivers/scsi/ibmvscsi/ibmvfc.c
===
--- linux.git.orig/drivers/scsi/ibmvscsi/ibmvfc.c
+++ linux.git/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -3579,11 +3579,9 @@ static void ibmvfc_tgt_implicit_logout(s
 static int ibmvfc_adisc_needs_plogi(struct ibmvfc_passthru_mad *mad,
struct ibmvfc_target *tgt)
 {
-   if (memcmp(&mad->fc_iu.response[2], &tgt->ids.port_name,
-  sizeof(tgt->ids.port_name)))
+   if (wwn_to_u64((u8 *)&mad->fc_iu.response[2]) != tgt->ids.port_name)
return 1;
-   if (memcmp(&mad->fc_iu.response[4], &tgt->ids.node_name,
-  sizeof(tgt->ids.node_name)))
+   if (wwn_to_u64((u8 *)&mad->fc_iu.response[4]) != tgt->ids.node_name)
return 1;
if (be32_to_cpu(mad->fc_iu.response[6]) != tgt->scsi_id)
return 1;



Re: [PATCH 10/12] scsi: remove the mvme147 driver

2018-03-14 Thread Geert Uytterhoeven
Hi Martin,

On Wed, Mar 14, 2018 at 4:58 PM, Martin K. Petersen
 wrote:
 IIRC, the Australian Navy may keep their MVME boxes running until
 close to Y2038.

>>> But surely not updating them to 4.17 or later?
>>
>> I don't know. Perhaps to prolong life until after Y2038 ;-)
>
> I'm happy to keep things in the tree if they are:
>
>   1) maintained and tested
>   2) actively used
>   3) not blocking removal of legacy interfaces

I'm aware and I do understand.

Lets wait for Adrian...

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH] scsi: scsi_dh_alua: Correct comment for alua_alloc_pg()

2018-03-14 Thread Laurence Oberman
On Wed, 2018-03-14 at 09:52 -0400, John Pittman wrote:
> In the comment for function alua_alloc_pg() the argument '@h' is
> mistakenly referred to.  Fix this by replacing it with the correct
> argument reference, '@tpgs', and provide a short description.
> 
> Signed-off-by: John Pittman 
> ---
>  drivers/scsi/device_handler/scsi_dh_alua.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c
> b/drivers/scsi/device_handler/scsi_dh_alua.c
> index 4b44325..ab89e42 100644
> --- a/drivers/scsi/device_handler/scsi_dh_alua.c
> +++ b/drivers/scsi/device_handler/scsi_dh_alua.c
> @@ -214,8 +214,8 @@ static struct alua_port_group
> *alua_find_get_pg(char *id_str, size_t id_size,
>  /*
>   * alua_alloc_pg - Allocate a new port_group structure
>   * @sdev: scsi device
> - * @h: alua device_handler data
>   * @group_id: port group id
> + * @tpgs: target port group settings
>   *
>   * Allocate a new port_group structure for a given
>   * device.

Looks good to me, Thanks

Reviewed-by Laurence Oberman 



Re: [PATCH] scsi: sd: Remember that READ CAPACITY(16) succeeded

2018-03-14 Thread Laurence Oberman
On Wed, 2018-03-14 at 12:15 -0400, Martin K. Petersen wrote:
> The USB storage glue sets the try_rc_10_first flag in an attempt to
> avoid wedging poorly implemented legacy USB devices.
> 
> If the device capacity is too large to be expressed in the provided
> response buffer field of READ CAPACITY(10), a well-behaved device
> will
> set the reported capacity to 0x. We will then attempt to
> issue a
> READ CAPACITY(16) to obtain the real capacity.
> 
> Since this part of the discovery logic is not covered by the
> first_scan
> flag, a warning will be printed a couple of times times per
> revalidate
> attempt if we upgrade from READ CAPACITY(10) to READ CAPACITY(16).
> 
> Remember that we have successfully issued READ CAPACITY(16) so we can
> take the fast path on subsequent revalidate attempts.
> 
> Reported-by: Menion 
> Signed-off-by: Martin K. Petersen 
> ---
>  drivers/scsi/sd.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index bff21e636ddd..6e971b94af7d 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -2484,6 +2484,8 @@ sd_read_capacity(struct scsi_disk *sdkp,
> unsigned char *buffer)
>   sector_size = old_sector_size;
>   goto got_data;
>   }
> + /* Remember that READ CAPACITY(16) succeeded
> */
> + sdp->try_rc_10_first = 0;
>   }
>   }
>  

Looks fine to me.
Reviewed-by: Laurence Oberman 


[PATCH] scsi: sd: Remember that READ CAPACITY(16) succeeded

2018-03-14 Thread Martin K. Petersen
The USB storage glue sets the try_rc_10_first flag in an attempt to
avoid wedging poorly implemented legacy USB devices.

If the device capacity is too large to be expressed in the provided
response buffer field of READ CAPACITY(10), a well-behaved device will
set the reported capacity to 0x. We will then attempt to issue a
READ CAPACITY(16) to obtain the real capacity.

Since this part of the discovery logic is not covered by the first_scan
flag, a warning will be printed a couple of times times per revalidate
attempt if we upgrade from READ CAPACITY(10) to READ CAPACITY(16).

Remember that we have successfully issued READ CAPACITY(16) so we can
take the fast path on subsequent revalidate attempts.

Reported-by: Menion 
Signed-off-by: Martin K. Petersen 
---
 drivers/scsi/sd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index bff21e636ddd..6e971b94af7d 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2484,6 +2484,8 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char 
*buffer)
sector_size = old_sector_size;
goto got_data;
}
+   /* Remember that READ CAPACITY(16) succeeded */
+   sdp->try_rc_10_first = 0;
}
}
 
-- 
2.14.1



Re: [PATCH 10/12] scsi: remove the mvme147 driver

2018-03-14 Thread Martin K. Petersen

Geert,

>>> IIRC, the Australian Navy may keep their MVME boxes running until
>>> close to Y2038.
>>>
>> But surely not updating them to 4.17 or later?
>
> I don't know. Perhaps to prolong life until after Y2038 ;-)

I'm happy to keep things in the tree if they are:

  1) maintained and tested
  2) actively used
  3) not blocking removal of legacy interfaces

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 10/12] scsi: remove the mvme147 driver

2018-03-14 Thread Geert Uytterhoeven
Hi Hannes,

On Wed, Mar 14, 2018 at 4:26 PM, Hannes Reinecke  wrote:
> On 03/14/2018 02:25 PM, Geert Uytterhoeven wrote:
>> On Wed, Mar 14, 2018 at 2:16 PM, Christoph Hellwig  wrote:
>>> On Wed, Mar 14, 2018 at 12:56:31PM +0100, John Paul Adrian Glaubitz wrote:
 Ah, bummer. I wanted to keep the MVME drivers but I never managed to get 
 them ported to the new SCSI layer.

 Anyone out there who could help me with that?
>>>
>>> Here is how a trivial conversion should look like.  Probably doesn't
>>> even compile as-is but might be a good starting point:
>>
>> Thanks a lot!
>> IIRC, the Australian Navy may keep their MVME boxes running until close to
>> Y2038.
>>
> But surely not updating them to 4.17 or later?

I don't know. Perhaps to prolong life until after Y2038 ;-)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH 10/12] scsi: remove the mvme147 driver

2018-03-14 Thread Hannes Reinecke
On 03/14/2018 02:25 PM, Geert Uytterhoeven wrote:
> Hi Christoph,
> 
> On Wed, Mar 14, 2018 at 2:16 PM, Christoph Hellwig  wrote:
>> On Wed, Mar 14, 2018 at 12:56:31PM +0100, John Paul Adrian Glaubitz wrote:
>>> Ah, bummer. I wanted to keep the MVME drivers but I never managed to get 
>>> them ported to the new SCSI layer.
>>>
>>> Anyone out there who could help me with that?
>>
>> Here is how a trivial conversion should look like.  Probably doesn't
>> even compile as-is but might be a good starting point:
> 
> Thanks a lot!
> IIRC, the Australian Navy may keep their MVME boxes running until close to
> Y2038.
> 
But surely not updating them to 4.17 or later?

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 V5 1/5] scsi: hpsa: fix selection of reply queue

2018-03-14 Thread Bityutskiy, Artem
On Tue, 2018-03-13 at 17:42 +0800, Ming Lei wrote:
> From 84676c1f21 (genirq/affinity: assign vectors to all possible CPUs),
> one msix vector can be created without any online CPU mapped, then one
> command's completion may not be notified.
> 
> This patch setups mapping between cpu and reply queue according to irq
> affinity info retrived by pci_irq_get_affinity(), and uses this mapping
> table to choose reply queue for queuing one command.
> 
> Then the chosen reply queue has to be active, and fixes IO hang caused
> by using inactive reply queue which doesn't have any online CPU mapped.
> 
> Cc: Hannes Reinecke 
> Cc: "Martin K. Petersen" ,
> Cc: James Bottomley ,
> Cc: Christoph Hellwig ,
> Cc: Don Brace 
> Cc: Kashyap Desai 
> Cc: Laurence Oberman 
> Cc: Meelis Roos 
> Cc: Artem Bityutskiy 
> Cc: Mike Snitzer 
> Tested-by: Laurence Oberman 
> Tested-by: Don Brace 
> Tested-by: Artem Bityutskiy 
> Acked-by: Don Brace 
> Fixes: 84676c1f21e8 ("genirq/affinity: assign vectors to all possible CPUs")
> Signed-off-by: Ming Lei 

Checked v5 my Skylake Xeon and with this patch the regression that I
reported is fixed.

Tested-by: Artem Bityutskiy 
Link: https://lkml.kernel.org/r/1519311270.2535.53.ca...@intel.com
-
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


Re: [PATCH V5 2/5] scsi: megaraid_sas: fix selection of reply queue

2018-03-14 Thread Artem Bityutskiy
On Tue, 2018-03-13 at 17:42 +0800, Ming Lei wrote:
> From 84676c1f21 (genirq/affinity: assign vectors to all possible CPUs),
> one msix vector can be created without any online CPU mapped, then
> command may be queued, and won't be notified after its completion.
> 
> This patch setups mapping between cpu and reply queue according to irq
> affinity info retrived by pci_irq_get_affinity(), and uses this info
> to choose reply queue for queuing one command.
> 
> Then the chosen reply queue has to be active, and fixes IO hang caused
> by using inactive reply queue which doesn't have any online CPU mapped.
> 
> Cc: Hannes Reinecke 
> Cc: "Martin K. Petersen" ,
> Cc: James Bottomley ,
> Cc: Christoph Hellwig ,
> Cc: Don Brace 
> Cc: Kashyap Desai 
> Cc: Laurence Oberman 
> Cc: Mike Snitzer 
> Cc: Meelis Roos 
> Cc: Artem Bityutskiy 
> Fixes: 84676c1f21e8 ("genirq/affinity: assign vectors to all possible CPUs")
> Signed-off-by: Ming Lei 

Checked v5 my Skylake Xeon and with this patch the regression that I reported 
is fixed.

Tested-by: Artem Bityutskiy 
Link: https://lkml.kernel.org/r/1519311270.2535.53.ca...@intel.com


Re: [PATCH 4/5] scsi_io_completion: conditional hints on fastpath

2018-03-14 Thread Johannes Thumshirn
On Wed, Mar 14, 2018 at 11:39:47AM +0100, Douglas Gilbert wrote:
> So the difference measured on a Lenovo X270 (i5-7200U) amounts to
> around 7 nanoseconds.
> 
> Doug Gilbert

Wow, thanks a lot.

So it's actually buying us something measurable (not all too much though).

Looks good,
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] scsi: scsi_dh_alua: Correct comment for alua_alloc_pg()

2018-03-14 Thread John Pittman
In the comment for function alua_alloc_pg() the argument '@h' is
mistakenly referred to.  Fix this by replacing it with the correct
argument reference, '@tpgs', and provide a short description.

Signed-off-by: John Pittman 
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index 4b44325..ab89e42 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -214,8 +214,8 @@ static struct alua_port_group *alua_find_get_pg(char 
*id_str, size_t id_size,
 /*
  * alua_alloc_pg - Allocate a new port_group structure
  * @sdev: scsi device
- * @h: alua device_handler data
  * @group_id: port group id
+ * @tpgs: target port group settings
  *
  * Allocate a new port_group structure for a given
  * device.
-- 
2.7.5



Re: [PATCH 10/12] scsi: remove the mvme147 driver

2018-03-14 Thread Geert Uytterhoeven
Hi Christoph,

On Wed, Mar 14, 2018 at 2:16 PM, Christoph Hellwig  wrote:
> On Wed, Mar 14, 2018 at 12:56:31PM +0100, John Paul Adrian Glaubitz wrote:
>> Ah, bummer. I wanted to keep the MVME drivers but I never managed to get 
>> them ported to the new SCSI layer.
>>
>> Anyone out there who could help me with that?
>
> Here is how a trivial conversion should look like.  Probably doesn't
> even compile as-is but might be a good starting point:

Thanks a lot!
IIRC, the Australian Navy may keep their MVME boxes running until close to
Y2038.

Adrian: Do you have hardware to test this?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[PATCH] scsi: eata: drop EATA and EATA-PIO drivers

2018-03-14 Thread Salvatore Mesoraca
Remove support for EATA and EATA-PIO SCSI host adapters.
These devices are ancient and, apparently, nobody is still
using them.

https://lkml.kernel.org/r/20180313090540.GA4810%20()%20infradead%20!%20org

Signed-off-by: Salvatore Mesoraca 
---
 Documentation/scsi/scsi-parameters.txt |2 -
 MAINTAINERS|6 -
 drivers/scsi/Kconfig   |   62 -
 drivers/scsi/Makefile  |2 -
 drivers/scsi/eata.c| 2571 
 drivers/scsi/eata_generic.h|  401 -
 drivers/scsi/eata_pio.c|  966 
 drivers/scsi/eata_pio.h|   54 -
 8 files changed, 4064 deletions(-)
 delete mode 100644 drivers/scsi/eata.c
 delete mode 100644 drivers/scsi/eata_generic.h
 delete mode 100644 drivers/scsi/eata_pio.c
 delete mode 100644 drivers/scsi/eata_pio.h

diff --git a/Documentation/scsi/scsi-parameters.txt 
b/Documentation/scsi/scsi-parameters.txt
index 453d4b7..8f7be8a 100644
--- a/Documentation/scsi/scsi-parameters.txt
+++ b/Documentation/scsi/scsi-parameters.txt
@@ -34,8 +34,6 @@ parameters may be changed at runtime by the command
See drivers/scsi/BusLogic.c, comment before function
BusLogic_ParseDriverOptions().
 
-   eata=   [HW,SCSI]
-
fdomain=[HW,SCSI]
See header of drivers/scsi/fdomain.c.
 
diff --git a/MAINTAINERS b/MAINTAINERS
index 4623caf..f28756b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5005,12 +5005,6 @@ T:   git git://linuxtv.org/anttip/media_tree.git
 S: Maintained
 F: drivers/media/tuners/e4000*
 
-EATA ISA/EISA/PCI SCSI DRIVER
-M: Dario Ballabio 
-L: linux-scsi@vger.kernel.org
-S: Maintained
-F: drivers/scsi/eata.c
-
 EC100 MEDIA DRIVER
 M: Antti Palosaari 
 L: linux-me...@vger.kernel.org
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 8a739b7..f4052dc 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -640,68 +640,6 @@ config SCSI_DMX3191D
  To compile this driver as a module, choose M here: the
  module will be called dmx3191d.
 
-config SCSI_EATA
-   tristate "EATA ISA/EISA/PCI (DPT and generic EATA/DMA-compliant boards) 
support"
-   depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API
-   ---help---
- This driver supports all EATA/DMA-compliant SCSI host adapters.  DPT
- ISA and all EISA I/O addresses are probed looking for the "EATA"
- signature. The addresses of all the PCI SCSI controllers reported
-  by the PCI subsystem are probed as well.
-
- You want to read the start of  and the
- SCSI-HOWTO, available from
- .
-
- To compile this driver as a module, choose M here: the
- module will be called eata.
-
-config SCSI_EATA_TAGGED_QUEUE
-   bool "enable tagged command queueing"
-   depends on SCSI_EATA
-   help
- This is a feature of SCSI-2 which improves performance: the host
- adapter can send several SCSI commands to a device's queue even if
- previous commands haven't finished yet.
- This is equivalent to the "eata=tc:y" boot option.
-
-config SCSI_EATA_LINKED_COMMANDS
-   bool "enable elevator sorting"
-   depends on SCSI_EATA
-   help
- This option enables elevator sorting for all probed SCSI disks and
- CD-ROMs. It definitely reduces the average seek distance when doing
- random seeks, but this does not necessarily result in a noticeable
- performance improvement: your mileage may vary...
- This is equivalent to the "eata=lc:y" boot option.
-
-config SCSI_EATA_MAX_TAGS
-   int "maximum number of queued commands"
-   depends on SCSI_EATA
-   default "16"
-   help
- This specifies how many SCSI commands can be maximally queued for
- each probed SCSI device. You should reduce the default value of 16
- only if you have disks with buggy or limited tagged command support.
- Minimum is 2 and maximum is 62. This value is also the window size
- used by the elevator sorting option above. The effective value used
- by the driver for each probed SCSI device is reported at boot time.
- This is equivalent to the "eata=mq:8" boot option.
-
-config SCSI_EATA_PIO
-   tristate "EATA-PIO (old DPT PM2001, PM2012A) support"
-   depends on (ISA || EISA || PCI) && SCSI && BROKEN
-   ---help---
- This driver supports all EATA-PIO protocol compliant SCSI Host
- Adapters like the DPT PM2001 and the PM2012A.  EATA-DMA compliant
- host adapters could also use this driver but are discouraged from
- doing so, since this driver only supports hard disks and lacks
- numerous features.  You might want to have a look at the SCSI-HOWTO,
- available from 

Re: [PATCH 10/12] scsi: remove the mvme147 driver

2018-03-14 Thread Christoph Hellwig
On Wed, Mar 14, 2018 at 12:56:31PM +0100, John Paul Adrian Glaubitz wrote:
> Ah, bummer. I wanted to keep the MVME drivers but I never managed to get them 
> ported to the new SCSI layer.
> 
> Anyone out there who could help me with that?

Here is how a trivial conversion should look like.  Probably doesn't
even compile as-is but might be a good starting point:

---
>From e1a863426652c4db3254187c14ed718e78f3033d Mon Sep 17 00:00:00 2001
From: Christoph Hellwig 
Date: Wed, 14 Mar 2018 14:13:00 +0100
Subject: mvme147: stop using scsi_module.c

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/mvme147.c | 109 ++---
 1 file changed, 58 insertions(+), 51 deletions(-)

diff --git a/drivers/scsi/mvme147.c b/drivers/scsi/mvme147.c
index e6b2b681fda3..f8d8d9de394d 100644
--- a/drivers/scsi/mvme147.c
+++ b/drivers/scsi/mvme147.c
@@ -3,6 +3,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -14,9 +17,6 @@
 #include "wd33c93.h"
 #include "mvme147.h"
 
-#include 
-
-
 static irqreturn_t mvme147_intr(int irq, void *data)
 {
struct Scsi_Host *instance = data;
@@ -65,40 +65,57 @@ static void dma_stop(struct Scsi_Host *instance, struct 
scsi_cmnd *SCpnt,
m147_pcc->dma_cntrl = 0;
 }
 
-int mvme147_detect(struct scsi_host_template *tpnt)
+static struct scsi_host_template mvme147_host_template = {
+   .module = THIS_MODULE,
+   .proc_name  = "MVME147",
+   .name   = "MVME147 built-in SCSI",
+   .queuecommand   = wd33c93_queuecommand,
+   .eh_abort_handler   = wd33c93_abort,
+   .eh_host_reset_handler  = wd33c93_host_reset,
+   .show_info  = wd33c93_show_info,
+   .write_info = wd33c93_write_info,
+   .can_queue  = CAN_QUEUE,
+   .this_id= 7,
+   .sg_tablesize   = SG_ALL,
+   .cmd_per_lun= CMD_PER_LUN,
+   .use_clustering = ENABLE_CLUSTERING
+};
+
+static struct Scsi_Host *mvme147_shost;
+
+static int __init mvme147_init(void)
 {
-   static unsigned char called = 0;
-   struct Scsi_Host *instance;
wd33c93_regs regs;
struct WD33C93_hostdata *hdata;
+   int error = -ENOMEM;
 
-   if (!MACH_IS_MVME147 || called)
+   if (!MACH_IS_MVME147)
return 0;
-   called++;
 
-   tpnt->proc_name = "MVME147";
-   tpnt->show_info = wd33c93_show_info,
-   tpnt->write_info = wd33c93_write_info,
-
-   instance = scsi_register(tpnt, sizeof(struct WD33C93_hostdata));
-   if (!instance)
+   mvme147_shost = scsi_host_alloc(&mvme147_host_template,
+   sizeof(struct WD33C93_hostdata));
+   if (!mvme147_shost)
goto err_out;
+   mvme147_shost->base = 0xfffe4000;
+   mvme147_shost->irq = MVME147_IRQ_SCSI_PORT;
 
-   instance->base = 0xfffe4000;
-   instance->irq = MVME147_IRQ_SCSI_PORT;
regs.SASR = (volatile unsigned char *)0xfffe4000;
regs.SCMD = (volatile unsigned char *)0xfffe4001;
-   hdata = shost_priv(instance);
+
+   hdata = shost_priv(mvme147_shost);
hdata->no_sync = 0xff;
hdata->fast = 0;
hdata->dma_mode = CTRL_DMA;
-   wd33c93_init(instance, regs, dma_setup, dma_stop, WD33C93_FS_8_10);
 
-   if (request_irq(MVME147_IRQ_SCSI_PORT, mvme147_intr, 0,
-   "MVME147 SCSI PORT", instance))
+   wd33c93_init(mvme147_shost, regs, dma_setup, dma_stop, WD33C93_FS_8_10);
+
+   error = request_irq(MVME147_IRQ_SCSI_PORT, mvme147_intr, 0,
+   "MVME147 SCSI PORT", mvme147_shost);
+   if (error)
goto err_unregister;
-   if (request_irq(MVME147_IRQ_SCSI_DMA, mvme147_intr, 0,
-   "MVME147 SCSI DMA", instance))
+   error = request_irq(MVME147_IRQ_SCSI_DMA, mvme147_intr, 0,
+   "MVME147 SCSI DMA", mvme147_shost);
+   if (error)
goto err_free_irq;
 #if 0  /* Disabled; causes problems booting */
m147_pcc->scsi_interrupt = 0x10;/* Assert SCSI bus reset */
@@ -111,41 +128,31 @@ int mvme147_detect(struct scsi_host_template *tpnt)
 
m147_pcc->dma_cntrl = 0x00; /* ensure DMA is stopped */
m147_pcc->dma_intr = 0x89;  /* Ack and enable ints */
-
-   return 1;
+   
+   error = scsi_add_host(mvme147_shost, NULL);
+   if (error)
+   goto err_free_irq;
+   scsi_scan_host(mvme147_shost);
+   return 0;
 
 err_free_irq:
-   free_irq(MVME147_IRQ_SCSI_PORT, mvme147_intr);
+   free_irq(MVME147_IRQ_SCSI_PORT, mvme147_shost);
 err_unregister:
-   scsi_unregister(instance);
+   scsi_host_put(mvme147_shost);
 err_out:
-   return 0;
+   return error;
 }
 
-static struct scsi_host_template driver_template = {
-   .proc_name  = "MVME147",
-   .name

Re: Debugging SCSI 'UNMAP' ("Logical Block Provisioning") failure on an SSD

2018-03-14 Thread Kashyap Chamarthy
On Wed, Mar 14, 2018 at 12:29:50PM +0100, Oliver Neukum wrote:
> Am Mittwoch, den 14.03.2018, 11:22 +0100 schrieb Kashyap Chamarthy:
> > I see.  So I ran `dmesg -w`, as I attached the disk & see the following:
> 
> UAS and no quirk for your device. It looks like it indeed just does
> not support TRIM.

Sorry, I didn't give you complete information — with the previous
`dmesg` output, I actually attached the SSD (Samsung T5) via regular USB
"A Cable".  

Now, I re-attached the SSD via the "Thunderbolt" port on my other laptop
(Lenovo T470s), it _does_ show "UAS".   Refer the arrow below:

[...]
[131839.680706] usb 4-1: new SuperSpeedPlus USB device number 2 using xhci_hcd
[131839.698814] usb 4-1: New USB device found, idVendor=04e8, idProduct=61f5
[131839.698817] usb 4-1: New USB device strings: Mfr=2, Product=3, 
SerialNumber=1
[131839.698818] usb 4-1: Product: Portable SSD T5
[131839.698819] usb 4-1: Manufacturer: Samsung
[131839.698820] usb 4-1: SerialNumber: 1234567A7AD6
[131839.701232] scsi host2: uas   <---
[131839.701631] scsi 2:0:0:0: Direct-Access Samsung  Portable SSD T5  0
PQ: 0 ANSI: 6
[131839.703470] sd 2:0:0:0: Attached scsi generic sg1 type 0
[131839.705486] sd 2:0:0:0: [sdc] 976773168 512-byte logical blocks: (500 
GB/466 GiB)
[131839.705895] sd 2:0:0:0: [sdc] Write Protect is off
[131839.705900] sd 2:0:0:0: [sdc] Mode Sense: 43 00 00 00
[131839.706146] sd 2:0:0:0: [sdc] Write cache: enabled, read cache: enabled, 
doesn't support DPO or FUA
[131839.709656] sd 2:0:0:0: [sdc] Attached SCSI disk
[131839.927167] EXT4-fs (sdc): recovery complete
[131839.927175] EXT4-fs (sdc): mounted filesystem with ordered data mode. Opts: 
(null)
[...]

-- 
/kashyap


Re: [PATCH 10/12] scsi: remove the mvme147 driver

2018-03-14 Thread John Paul Adrian Glaubitz
Ah, bummer. I wanted to keep the MVME drivers but I never managed to get them 
ported to the new SCSI layer.

Anyone out there who could help me with that?

Adrian

> On Mar 14, 2018, at 12:48 PM, Christoph Hellwig  wrote:
> 
> This driver hasn't seen any recent bug fixing and is one of the last
> drivers using the scsi_module.c infrastruture that has been deprecated
> 15 years ago.
> 
> Signed-off-by: Christoph Hellwig 
> ---
> drivers/scsi/Kconfig   |   8 ---
> drivers/scsi/Makefile  |   1 -
> drivers/scsi/mvme147.c | 151 -
> drivers/scsi/mvme147.h |  25 
> drivers/scsi/wd33c93.c |   5 --
> 5 files changed, 190 deletions(-)
> delete mode 100644 drivers/scsi/mvme147.c
> delete mode 100644 drivers/scsi/mvme147.h
> 
> diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
> index 11e89e56b865..a95084008fe0 100644
> --- a/drivers/scsi/Kconfig
> +++ b/drivers/scsi/Kconfig
> @@ -1390,14 +1390,6 @@ config SCSI_MAC_ESP
>  To compile this driver as a module, choose M here: the module
>  will be called mac_esp.
> 
> -config MVME147_SCSI
> -bool "WD33C93 SCSI driver for MVME147"
> -depends on MVME147 && SCSI=y
> -select SCSI_SPI_ATTRS
> -help
> -  Support for the on-board SCSI controller on the Motorola MVME147
> -  single-board computer.
> -
> config MVME16x_SCSI
>tristate "NCR53C710 SCSI driver for MVME16x"
>depends on MVME16x && SCSI
> diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
> index d5135efbf9cd..9575f291acda 100644
> --- a/drivers/scsi/Makefile
> +++ b/drivers/scsi/Makefile
> @@ -51,7 +51,6 @@ obj-$(CONFIG_SCSI_ZORRO7XX)+= 53c700.ozorro7xx.o
> obj-$(CONFIG_A3000_SCSI)+= a3000.owd33c93.o
> obj-$(CONFIG_A2091_SCSI)+= a2091.owd33c93.o
> obj-$(CONFIG_GVP11_SCSI)+= gvp11.owd33c93.o
> -obj-$(CONFIG_MVME147_SCSI)+= mvme147.owd33c93.o
> obj-$(CONFIG_SGIWD93_SCSI)+= sgiwd93.owd33c93.o
> obj-$(CONFIG_ATARI_SCSI)+= atari_scsi.o
> obj-$(CONFIG_MAC_SCSI)+= mac_scsi.o
> diff --git a/drivers/scsi/mvme147.c b/drivers/scsi/mvme147.c
> deleted file mode 100644
> index e6b2b681fda3..
> --- a/drivers/scsi/mvme147.c
> +++ /dev/null
> @@ -1,151 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -#include 
> -#include 
> -#include 
> -#include 
> -
> -#include 
> -#include 
> -#include 
> -#include 
> -
> -#include "scsi.h"
> -#include 
> -#include "wd33c93.h"
> -#include "mvme147.h"
> -
> -#include 
> -
> -
> -static irqreturn_t mvme147_intr(int irq, void *data)
> -{
> -struct Scsi_Host *instance = data;
> -
> -if (irq == MVME147_IRQ_SCSI_PORT)
> -wd33c93_intr(instance);
> -else
> -m147_pcc->dma_intr = 0x89;/* Ack and enable ints */
> -return IRQ_HANDLED;
> -}
> -
> -static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
> -{
> -struct Scsi_Host *instance = cmd->device->host;
> -struct WD33C93_hostdata *hdata = shost_priv(instance);
> -unsigned char flags = 0x01;
> -unsigned long addr = virt_to_bus(cmd->SCp.ptr);
> -
> -/* setup dma direction */
> -if (!dir_in)
> -flags |= 0x04;
> -
> -/* remember direction */
> -hdata->dma_dir = dir_in;
> -
> -if (dir_in) {
> -/* invalidate any cache */
> -cache_clear(addr, cmd->SCp.this_residual);
> -} else {
> -/* push any dirty cache */
> -cache_push(addr, cmd->SCp.this_residual);
> -}
> -
> -/* start DMA */
> -m147_pcc->dma_bcr = cmd->SCp.this_residual | (1 << 24);
> -m147_pcc->dma_dadr = addr;
> -m147_pcc->dma_cntrl = flags;
> -
> -/* return success */
> -return 0;
> -}
> -
> -static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
> - int status)
> -{
> -m147_pcc->dma_cntrl = 0;
> -}
> -
> -int mvme147_detect(struct scsi_host_template *tpnt)
> -{
> -static unsigned char called = 0;
> -struct Scsi_Host *instance;
> -wd33c93_regs regs;
> -struct WD33C93_hostdata *hdata;
> -
> -if (!MACH_IS_MVME147 || called)
> -return 0;
> -called++;
> -
> -tpnt->proc_name = "MVME147";
> -tpnt->show_info = wd33c93_show_info,
> -tpnt->write_info = wd33c93_write_info,
> -
> -instance = scsi_register(tpnt, sizeof(struct WD33C93_hostdata));
> -if (!instance)
> -goto err_out;
> -
> -instance->base = 0xfffe4000;
> -instance->irq = MVME147_IRQ_SCSI_PORT;
> -regs.SASR = (volatile unsigned char *)0xfffe4000;
> -regs.SCMD = (volatile unsigned char *)0xfffe4001;
> -hdata = shost_priv(instance);
> -hdata->no_sync = 0xff;
> -hdata->fast = 0;
> -hdata->dma_mode = CTRL_DMA;
> -wd33c93_init(instance, regs, dma_setup, dma_stop, WD33C93_FS_8_10);
> -
> -if (request_irq(MVME147_IRQ_SCSI_PORT, mvme147_intr, 0,
> -"MVME147 SCSI PORT", instance))
> -goto err_unregister;
> -if (request_irq(MVME147_IRQ_SCSI_DMA, mvme147_intr, 0,
> -"MVME147 S

[PATCH 12/12] scsi: remove ChangeLog.1992-1997

2018-03-14 Thread Christoph Hellwig
This 20+ year old changelog has no useful information for kernel
development or users, so remove it.

Signed-off-by: Christoph Hellwig 
---
 Documentation/scsi/ChangeLog.1992-1997 | 2023 
 1 file changed, 2023 deletions(-)
 delete mode 100644 Documentation/scsi/ChangeLog.1992-1997

diff --git a/Documentation/scsi/ChangeLog.1992-1997 
b/Documentation/scsi/ChangeLog.1992-1997
deleted file mode 100644
index 6faad7e6417c..
--- a/Documentation/scsi/ChangeLog.1992-1997
+++ /dev/null
@@ -1,2023 +0,0 @@
-Sat Jan 18 15:51:45 1997  Richard Henderson  
-
-   * Don't play with usage_count directly, instead hand around
-   the module header and use the module macros.
-
-Fri May 17 00:00:00 1996  Leonard N. Zubkoff 
-
-   * BusLogic Driver Version 2.0.3 Released.
-
-Tue Apr 16 21:00:00 1996  Leonard N. Zubkoff 
-
-   * BusLogic Driver Version 1.3.2 Released.
-
-Sun Dec 31 23:26:00 1995  Leonard N. Zubkoff 
-
-   * BusLogic Driver Version 1.3.1 Released.
-
-Fri Nov 10 15:29:49 1995  Leonard N. Zubkoff 
-
-   * Released new BusLogic driver.
-
-Wed Aug  9 22:37:04 1995  Andries Brouwer  
-
-   As a preparation for new device code, separated the various
-   functions the request->dev field had into the device proper,
-   request->rq_dev and a status field request->rq_status.
-
-   The 2nd argument of bios_param is now a kdev_t.
-
-Wed Jul 19 10:43:15 1995  Michael Neuffer  
-
-* scsi.c (scsi_proc_info): /proc/scsi/scsi now also lists all
-   attached devices.
-
-   * scsi_proc.c (proc_print_scsidevice): Added. Used by scsi.c and
-   eata_dma_proc.c to produce some device info for /proc/scsi.
-
-   * eata_dma.c (eata_queue)(eata_int_handler)(eata_scsi_done):
-   Changed handling of internal SCSI commands send to the HBA.
-
-
-Wed Jul 19 10:09:17 1995  Michael Neuffer  
-
-   * Linux 1.3.11 released.
-
-   * eata_dma.c (eata_queue)(eata_int_handler): Added code to do
-   command latency measurements if requested by root through
-   /proc/scsi interface.
-   Throughout Use HZ constant for time references.
-
-   * eata_pio.c: Use HZ constant for time references.
-
-   * aic7xxx.c, aic7xxx.h, aic7xxx_asm.c: Changed copyright from BSD
-   to GNU style.
-
-   * scsi.h: Added READ_12 command opcode constant
-
-Wed Jul 19 09:25:30 1995  Michael Neuffer 
-
-   * Linux 1.3.10 released.
-
-   * scsi_proc.c (dispatch_scsi_info): Removed unused variable.
-
-Wed Jul 19 09:25:30 1995  Michael Neuffer  
-
-   * Linux 1.3.9 released.
-
-   * scsi.c Blacklist concept expanded to 'support' more device
-   deficiencies. blacklist[] renamed to device_list[]
-   (scan_scsis): Code cleanup.
-
-   * scsi_debug.c (scsi_debug_proc_info): Added support to control
-   device lockup simulation via /proc/scsi interface.
-
-
-Wed Jul 19 09:22:34 1995  Michael Neuffer  
-
-   * Linux 1.3.7 released.
-
-   * scsi_proc.c: Fixed a number of bugs in directory handling
-
-Wed Jul 19 09:18:28 1995  Michael Neuffer  
-
-   * Linux 1.3.5 released.
-
-   * Native wide, multichannel and /proc/scsi support now in official
-   kernel distribution.
-
-* scsi.c/h, hosts.c/h et al reindented to increase readability
-   (especially on 80 column wide terminals).
-
-   * scsi.c, scsi_proc.c, ../../fs/proc/inode.c: Added
-   /proc/scsi/scsi which allows root to scan for hotplugged devices.
-
-   * scsi.c (scsi_proc_info): Added, to support /proc/scsi/scsi.
-   (scan_scsis): Added some 'spaghetti' code to allow scanning for
-   single devices.
-   
-
-Thu Jun 20 15:20:27 1995  Michael Neuffer  
-
-* proc.c: Renamed to scsi_proc.c
-
-Mon Jun 12 20:32:45 1995  Michael Neuffer  
-
-   * Linux 1.3.0 released.
-
-Mon May 15 19:33:14 1995  Michael Neuffer  
-
-   * scsi.c: Added native multichannel and wide scsi support.
-
-   * proc.c (dispatch_scsi_info) (build_proc_dir_hba_entries):
-   Updated /proc/scsi interface.
-
-Thu May  4 17:58:48 1995  Michael Neuffer  
-
-   * sd.c (requeue_sd_request): Zero out the scatterlist only if
-   scsi_malloc returned memory for it.
-
-   * eata_dma.c (register_HBA) (eata_queue): Add support for
-   large scatter/gather tables and set use_clustering accordingly
-
-   * hosts.c: Make use_clustering changeable in the Scsi_Host structure.
-
-Wed Apr 12 15:25:52 1995  Eric Youngdale  (eric@andante)
-
-   * Linux 1.2.5 released.
-
-   * buslogic.c: Update to version 1.15 (From Leonard N. Zubkoff).
-   Fixed interrupt routine to avoid races when handling multiple
-   complete commands per interrupt.  Seems to come up with faster
-   cards.
-
-   * eata_dma.c: Update to 2.3.5r. Modularize. Improved error handling
-throughout and fixed bug interrupt routine which resulted in shifted
-status bytes. Added blink LED state checks for ISA and

[PATCH 06/12] scsi: remove the eata driver

2018-03-14 Thread Christoph Hellwig
This driver hasn't seen any recent bug fixing and is one of the last
drivers using the scsi_module.c infrastruture that has been deprecated
15 years ago.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/Kconfig  |   48 -
 drivers/scsi/Makefile |1 -
 drivers/scsi/eata.c   | 2571 -
 3 files changed, 2620 deletions(-)
 delete mode 100644 drivers/scsi/eata.c

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 51efb947537d..b18dfa1c14a1 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -640,54 +640,6 @@ config SCSI_DMX3191D
  To compile this driver as a module, choose M here: the
  module will be called dmx3191d.
 
-config SCSI_EATA
-   tristate "EATA ISA/EISA/PCI (DPT and generic EATA/DMA-compliant boards) 
support"
-   depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API
-   ---help---
- This driver supports all EATA/DMA-compliant SCSI host adapters.  DPT
- ISA and all EISA I/O addresses are probed looking for the "EATA"
- signature. The addresses of all the PCI SCSI controllers reported
-  by the PCI subsystem are probed as well.
-
- You want to read the start of  and the
- SCSI-HOWTO, available from
- .
-
- To compile this driver as a module, choose M here: the
- module will be called eata.
-
-config SCSI_EATA_TAGGED_QUEUE
-   bool "enable tagged command queueing"
-   depends on SCSI_EATA
-   help
- This is a feature of SCSI-2 which improves performance: the host
- adapter can send several SCSI commands to a device's queue even if
- previous commands haven't finished yet.
- This is equivalent to the "eata=tc:y" boot option.
-
-config SCSI_EATA_LINKED_COMMANDS
-   bool "enable elevator sorting"
-   depends on SCSI_EATA
-   help
- This option enables elevator sorting for all probed SCSI disks and
- CD-ROMs. It definitely reduces the average seek distance when doing
- random seeks, but this does not necessarily result in a noticeable
- performance improvement: your mileage may vary...
- This is equivalent to the "eata=lc:y" boot option.
-
-config SCSI_EATA_MAX_TAGS
-   int "maximum number of queued commands"
-   depends on SCSI_EATA
-   default "16"
-   help
- This specifies how many SCSI commands can be maximally queued for
- each probed SCSI device. You should reduce the default value of 16
- only if you have disks with buggy or limited tagged command support.
- Minimum is 2 and maximum is 62. This value is also the window size
- used by the elevator sorting option above. The effective value used
- by the driver for each probed SCSI device is reported at boot time.
- This is equivalent to the "eata=mq:8" boot option.
-
 config SCSI_FUTURE_DOMAIN
tristate "Future Domain 16xx SCSI/AHA-2920A support"
depends on (ISA || PCI) && SCSI
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 738d02a2a455..46f1c1033f0e 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -93,7 +93,6 @@ obj-$(CONFIG_SCSI_HPSA)   += hpsa.o
 obj-$(CONFIG_SCSI_SMARTPQI)+= smartpqi/
 obj-$(CONFIG_SCSI_SYM53C8XX_2) += sym53c8xx_2/
 obj-$(CONFIG_SCSI_ZALON)   += zalon7xx.o
-obj-$(CONFIG_SCSI_EATA)+= eata.o
 obj-$(CONFIG_SCSI_DC395x)  += dc395x.o
 obj-$(CONFIG_SCSI_AM53C974)+= esp_scsi.o   am53c974.o
 obj-$(CONFIG_CXLFLASH) += cxlflash/
diff --git a/drivers/scsi/eata.c b/drivers/scsi/eata.c
deleted file mode 100644
index 6501c330d8c8..
--- a/drivers/scsi/eata.c
+++ /dev/null
@@ -1,2571 +0,0 @@
-/*
- *  eata.c - Low-level driver for EATA/DMA SCSI host adapters.
- *
- *  03 Jun 2003 Rev. 8.10 for linux-2.5.70
- *+ Update for new IRQ API.
- *+ Use "goto" when appropriate.
- *+ Drop eata.h.
- *+ Update for new module_param API.
- *+ Module parameters  can now be specified only in the
- *  same format as the kernel boot options.
- *
- * boot optionold module param 
- * -----
- * addr,...   io_port=addr,...
- * lc:[y|n]   linked_comm=[1|0]
- * mq:xx  max_queue_depth=xx
- * tm:[0|1|2] tag_mode=[0|1|2]
- * et:[y|n]   ext_tran=[1|0]
- * rs:[y|n]   rev_scan=[1|0]
- * ip:[y|n]   isa_probe=[1|0]
- * ep:[y|n]   eisa_probe=[1|0]
- * pp:[y|n]   pci_probe=[1|0]
- *
- *  A valid example using the new parameter format is:
- *  modprobe eata "eata=0x7410,0x230,lc:y,tm:0,mq:4,ep:n"
- *
- *  which is equivalent to the old format:
- *  modprobe eata io_port=0x7410,0x230 linked_comm=1 tag_mode=0 

[PATCH 10/12] scsi: remove the mvme147 driver

2018-03-14 Thread Christoph Hellwig
This driver hasn't seen any recent bug fixing and is one of the last
drivers using the scsi_module.c infrastruture that has been deprecated
15 years ago.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/Kconfig   |   8 ---
 drivers/scsi/Makefile  |   1 -
 drivers/scsi/mvme147.c | 151 -
 drivers/scsi/mvme147.h |  25 
 drivers/scsi/wd33c93.c |   5 --
 5 files changed, 190 deletions(-)
 delete mode 100644 drivers/scsi/mvme147.c
 delete mode 100644 drivers/scsi/mvme147.h

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 11e89e56b865..a95084008fe0 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -1390,14 +1390,6 @@ config SCSI_MAC_ESP
  To compile this driver as a module, choose M here: the module
  will be called mac_esp.
 
-config MVME147_SCSI
-   bool "WD33C93 SCSI driver for MVME147"
-   depends on MVME147 && SCSI=y
-   select SCSI_SPI_ATTRS
-   help
- Support for the on-board SCSI controller on the Motorola MVME147
- single-board computer.
-
 config MVME16x_SCSI
tristate "NCR53C710 SCSI driver for MVME16x"
depends on MVME16x && SCSI
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index d5135efbf9cd..9575f291acda 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -51,7 +51,6 @@ obj-$(CONFIG_SCSI_ZORRO7XX)   += 53c700.o zorro7xx.o
 obj-$(CONFIG_A3000_SCSI)   += a3000.o  wd33c93.o
 obj-$(CONFIG_A2091_SCSI)   += a2091.o  wd33c93.o
 obj-$(CONFIG_GVP11_SCSI)   += gvp11.o  wd33c93.o
-obj-$(CONFIG_MVME147_SCSI) += mvme147.owd33c93.o
 obj-$(CONFIG_SGIWD93_SCSI) += sgiwd93.owd33c93.o
 obj-$(CONFIG_ATARI_SCSI)   += atari_scsi.o
 obj-$(CONFIG_MAC_SCSI) += mac_scsi.o
diff --git a/drivers/scsi/mvme147.c b/drivers/scsi/mvme147.c
deleted file mode 100644
index e6b2b681fda3..
--- a/drivers/scsi/mvme147.c
+++ /dev/null
@@ -1,151 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-
-#include "scsi.h"
-#include 
-#include "wd33c93.h"
-#include "mvme147.h"
-
-#include 
-
-
-static irqreturn_t mvme147_intr(int irq, void *data)
-{
-   struct Scsi_Host *instance = data;
-
-   if (irq == MVME147_IRQ_SCSI_PORT)
-   wd33c93_intr(instance);
-   else
-   m147_pcc->dma_intr = 0x89;  /* Ack and enable ints */
-   return IRQ_HANDLED;
-}
-
-static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
-{
-   struct Scsi_Host *instance = cmd->device->host;
-   struct WD33C93_hostdata *hdata = shost_priv(instance);
-   unsigned char flags = 0x01;
-   unsigned long addr = virt_to_bus(cmd->SCp.ptr);
-
-   /* setup dma direction */
-   if (!dir_in)
-   flags |= 0x04;
-
-   /* remember direction */
-   hdata->dma_dir = dir_in;
-
-   if (dir_in) {
-   /* invalidate any cache */
-   cache_clear(addr, cmd->SCp.this_residual);
-   } else {
-   /* push any dirty cache */
-   cache_push(addr, cmd->SCp.this_residual);
-   }
-
-   /* start DMA */
-   m147_pcc->dma_bcr = cmd->SCp.this_residual | (1 << 24);
-   m147_pcc->dma_dadr = addr;
-   m147_pcc->dma_cntrl = flags;
-
-   /* return success */
-   return 0;
-}
-
-static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
-int status)
-{
-   m147_pcc->dma_cntrl = 0;
-}
-
-int mvme147_detect(struct scsi_host_template *tpnt)
-{
-   static unsigned char called = 0;
-   struct Scsi_Host *instance;
-   wd33c93_regs regs;
-   struct WD33C93_hostdata *hdata;
-
-   if (!MACH_IS_MVME147 || called)
-   return 0;
-   called++;
-
-   tpnt->proc_name = "MVME147";
-   tpnt->show_info = wd33c93_show_info,
-   tpnt->write_info = wd33c93_write_info,
-
-   instance = scsi_register(tpnt, sizeof(struct WD33C93_hostdata));
-   if (!instance)
-   goto err_out;
-
-   instance->base = 0xfffe4000;
-   instance->irq = MVME147_IRQ_SCSI_PORT;
-   regs.SASR = (volatile unsigned char *)0xfffe4000;
-   regs.SCMD = (volatile unsigned char *)0xfffe4001;
-   hdata = shost_priv(instance);
-   hdata->no_sync = 0xff;
-   hdata->fast = 0;
-   hdata->dma_mode = CTRL_DMA;
-   wd33c93_init(instance, regs, dma_setup, dma_stop, WD33C93_FS_8_10);
-
-   if (request_irq(MVME147_IRQ_SCSI_PORT, mvme147_intr, 0,
-   "MVME147 SCSI PORT", instance))
-   goto err_unregister;
-   if (request_irq(MVME147_IRQ_SCSI_DMA, mvme147_intr, 0,
-   "MVME147 SCSI DMA", instance))
-   goto err_free_irq;
-#if 0  /* Disabled; causes problems booting */
-   m147_pcc->scsi_interrupt = 0x10;/* Assert SCSI bus reset */
-   udelay(100);
-   m147_pcc->scsi_

[PATCH 11/12] scsi: remove the old scsi_module.c initialization model

2018-03-14 Thread Christoph Hellwig
After more than 15 years all users of this legacy interface are finally
gone.  Rest in peace!

Signed-off-by: Christoph Hellwig 
---
 Documentation/driver-api/scsi.rst   |   6 --
 Documentation/scsi/scsi_mid_low_api.txt | 122 +---
 drivers/scsi/hosts.c|  23 --
 drivers/scsi/scsi_module.c  |  73 ---
 include/scsi/scsi_host.h|  35 -
 5 files changed, 1 insertion(+), 258 deletions(-)
 delete mode 100644 drivers/scsi/scsi_module.c

diff --git a/Documentation/driver-api/scsi.rst 
b/Documentation/driver-api/scsi.rst
index 3ae337929721..31ad0fed6763 100644
--- a/Documentation/driver-api/scsi.rst
+++ b/Documentation/driver-api/scsi.rst
@@ -154,12 +154,6 @@ lists).
 .. kernel-doc:: drivers/scsi/scsi_lib_dma.c
:export:
 
-drivers/scsi/scsi_module.c
-~~~
-
-The file drivers/scsi/scsi_module.c contains legacy support for
-old-style host templates. It should never be used by any new driver.
-
 drivers/scsi/scsi_proc.c
 ~
 
diff --git a/Documentation/scsi/scsi_mid_low_api.txt 
b/Documentation/scsi/scsi_mid_low_api.txt
index 2c31d9ee6776..177c031763c0 100644
--- a/Documentation/scsi/scsi_mid_low_api.txt
+++ b/Documentation/scsi/scsi_mid_low_api.txt
@@ -114,9 +114,7 @@ called "xxx" could be defined as
 "static int xxx_slave_alloc(struct scsi_device * sdev) { /* code */ }"
 
 ** the scsi_host_alloc() function is a replacement for the rather vaguely
-named scsi_register() function in most situations. The scsi_register()
-and scsi_unregister() functions remain to support legacy LLDs that use
-the passive initialization model.
+named scsi_register() function in most situations.
 
 
 Hotplug initialization model
@@ -228,79 +226,6 @@ slave_configure() callbacks). Such instances are "owned" 
by the mid-level.
 struct scsi_device instances are freed after slave_destroy().
 
 
-Passive initialization model
-
-These older LLDs include a file called "scsi_module.c" [yes the ".c" is a
-little surprising] in their source code. For that file to work an
-instance of struct scsi_host_template with the name "driver_template"
-needs to be defined. Here is a typical code sequence used in this model:
-static struct scsi_host_template driver_template = {
-...
-};
-#include "scsi_module.c"
-
-The scsi_module.c file contains two functions:
-  - init_this_scsi_driver() which is executed when the LLD is
-initialized (i.e. boot time or module load time)
-  - exit_this_scsi_driver() which is executed when the LLD is shut
-down (i.e. module unload time)
-Note: since these functions are tagged with __init and __exit qualifiers
-an LLD should not call them explicitly (since the kernel does that).
-
-Here is an example of an initialization sequence when two hosts are
-detected (so detect() returns 2) and the SCSI bus scan on each host
-finds 1 SCSI device (and a second device does not respond).
-
-LLD  mid level LLD
-===--=-===--
-init_this_scsi_driver() +
-|
- detect()  -+
-|   |
-|scsi_register()
-|scsi_register()
-|
-  slave_alloc()
-  slave_configure()  -->  scsi_change_queue_depth()
-  slave_alloc()   ***
-  slave_destroy() ***
-|
-  slave_alloc()
-  slave_configure()
-  slave_alloc()   ***
-  slave_destroy() ***
-
-
-The mid level invokes scsi_change_queue_depth() with "cmd_per_lun" for that
-host as the queue length. These settings can be overridden by a
-slave_configure() supplied by the LLD.
-
-*** For scsi devices that the mid level tries to scan but do not
-respond, a slave_alloc(), slave_destroy() pair is called.
-
-Here is an LLD shutdown sequence:
-
-LLD  mid level LLD
-===--=-===--
-exit_this_scsi_driver() +
-|
- slave_destroy()
-release()   -->   scsi_unregister()
-|
- slave_destroy()
-release()   -->   scsi_unregister()
-
-
-An LLD need not define slave_destroy() (i.e. it is optional). 
-
-The shortcoming of the "passive initialization model" is that host
-registration and de-registration are (typically) tied to LLD initialization
-and shutdown. Once the LLD is initialized the

[PATCH 08/12] scsi: remove the NCR53c406a driver

2018-03-14 Thread Christoph Hellwig
This driver hasn't seen any recent bug fixing and is one of the last
drivers using the scsi_module.c infrastruture that has been deprecated
15 years ago.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/Kconfig  |   12 -
 drivers/scsi/Makefile |1 -
 drivers/scsi/NCR53c406a.c | 1090 -
 3 files changed, 1103 deletions(-)
 delete mode 100644 drivers/scsi/NCR53c406a.c

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 117c2fb41b77..9fa0cfd5a068 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -841,18 +841,6 @@ config SCSI_IZIP_SLOW_CTR
 
  Generally, saying N is fine.
 
-config SCSI_NCR53C406A
-   tristate "NCR53c406a SCSI support"
-   depends on ISA && SCSI
-   help
- This is support for the NCR53c406a SCSI host adapter.  For user
- configurable parameters, check out 
- in the kernel source.  Also read the SCSI-HOWTO, available from
- .
-
- To compile this driver as a module, choose M here: the
- module will be called NCR53c406.
-
 config SCSI_NCR_D700
tristate "NCR Dual 700 MCA SCSI support"
depends on MCA && SCSI
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 77bb0017bb02..192a58d7d9d9 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -75,7 +75,6 @@ obj-$(CONFIG_SCSI_PM8001) += pm8001/
 obj-$(CONFIG_SCSI_ISCI)+= isci/
 obj-$(CONFIG_SCSI_IPS) += ips.o
 obj-$(CONFIG_SCSI_GENERIC_NCR5380) += g_NCR5380.o
-obj-$(CONFIG_SCSI_NCR53C406A)  += NCR53c406a.o
 obj-$(CONFIG_SCSI_NCR_D700)+= 53c700.o NCR_D700.o
 obj-$(CONFIG_SCSI_NCR_Q720)+= NCR_Q720_mod.o
 obj-$(CONFIG_SCSI_SYM53C416)   += sym53c416.o
diff --git a/drivers/scsi/NCR53c406a.c b/drivers/scsi/NCR53c406a.c
deleted file mode 100644
index 44b09870bf51..
--- a/drivers/scsi/NCR53c406a.c
+++ /dev/null
@@ -1,1090 +0,0 @@
-/* 
- *  NCR53c406.c
- *  Low-level SCSI driver for NCR53c406a chip.
- *  Copyright (C) 1994, 1995, 1996 Normunds Saumanis (normu...@fi.ibm.com)
- * 
- *  LILO command line usage: ncr53c406a=[,[,]]
- *  Specify IRQ = 0 for non-interrupt driven mode.
- *  FASTPIO = 1 for fast pio mode, 0 for slow mode.
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License as published by the
- *  Free Software Foundation; either version 2, or (at your option) any
- *  later version.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- */
-
-#define NCR53C406A_DEBUG 0
-#define VERBOSE_NCR53C406A_DEBUG 0
-
-/* Set this to 1 for PIO mode (recommended) or to 0 for DMA mode */
-#define USE_PIO 1
-
-#define USE_BIOS 0
-   /* #define BIOS_ADDR 0xD8000 *//* define this 
if autoprobe fails */
-   /* #define PORT_BASE 0x330 *//* define this if 
autoprobe fails */
-   /* #define IRQ_LEV   0  *//* define this if 
autoprobe fails */
-#define DMA_CHAN  5/* this is ignored if DMA is disabled */
-
-/* Set this to 0 if you encounter kernel lockups while transferring 
- * data in PIO mode */
-#define USE_FAST_PIO 1
-
-/* = End of user configurable parameters = */
-
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include "scsi.h"
-#include 
-
-/* = */
-
-#define WATCHDOG 500
-
-#define SYNC_MODE 0/* Synchronous transfer mode */
-
-#ifdef DEBUG
-#undef NCR53C406A_DEBUG
-#define NCR53C406A_DEBUG 1
-#endif
-
-#if USE_PIO
-#define USE_DMA 0
-#else
-#define USE_DMA 1
-#endif
-
-/* Default configuration */
-#define C1_IMG   0x07  /* ID=7 */
-#define C2_IMG   0x48  /* FE SCSI2 */
-#if USE_DMA
-#define C3_IMG   0x21  /* CDB TE */
-#else
-#define C3_IMG   0x20  /* CDB */
-#endif
-#define C4_IMG   0x04  /* ANE */
-#define C5_IMG   0xb6  /* AA PI SIE POL */
-
-#define REG0 (outb(C4_IMG, CONFIG4))
-#define REG1 (outb(C5_IMG, CONFIG5))
-
-#if NCR53C406A_DEBUG
-#define DEB(x) x
-#else
-#define DEB(x)
-#endif
-
-#if VERBOSE_NCR53C406A_DEBUG
-#define VDEB(x) x
-#else
-#define VDEB(x)
-#endif
-
-#define LOAD_DMA_COUNT(count) \
-  outb(count & 0xff, TC_LSB); \
-  outb((count >> 8) & 0xff, TC_MSB); \
-  outb((count >> 16) & 0xff, TC_HIGH);
-
-/* Chip commands */
-#define DMA_OP   0x80
-
-#define SCSI_NOP 0x00
-#define FLUSH_FIFO   0x01
-#define CHIP_RESET   0x02
-#define SCSI_RESET   0x03
-#define RESELECT 0x40
-#define SELECT_NO_AT

[PATCH 09/12] scsi: remove the sym53c416 driver

2018-03-14 Thread Christoph Hellwig
This driver hasn't seen any recent bug fixing and is one of the last
drivers using the scsi_module.c infrastruture that has been deprecated
15 years ago.

Signed-off-by: Christoph Hellwig 
---
 Documentation/scsi/scsi-parameters.txt |   3 -
 drivers/scsi/Kconfig   |  18 -
 drivers/scsi/Makefile  |   1 -
 drivers/scsi/sym53c416.c   | 844 -
 drivers/scsi/sym53c416.h   |  33 --
 5 files changed, 899 deletions(-)
 delete mode 100644 drivers/scsi/sym53c416.c
 delete mode 100644 drivers/scsi/sym53c416.h

diff --git a/Documentation/scsi/scsi-parameters.txt 
b/Documentation/scsi/scsi-parameters.txt
index 453d4b79c78d..ee142045017d 100644
--- a/Documentation/scsi/scsi-parameters.txt
+++ b/Documentation/scsi/scsi-parameters.txt
@@ -110,9 +110,6 @@ parameters may be changed at runtime by the command
st= [HW,SCSI] SCSI tape parameters (buffers, etc.)
See Documentation/scsi/st.txt.
 
-   sym53c416=  [HW,SCSI]
-   See header of drivers/scsi/sym53c416.c.
-
tmscsim=[HW,SCSI]
See comment before function dc390_setup() in
drivers/scsi/tmscsim.c.
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 9fa0cfd5a068..11e89e56b865 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -1172,24 +1172,6 @@ config SCSI_SIM710
 
  It currently supports Compaq EISA cards and NCR MCA cards
 
-config SCSI_SYM53C416
-   tristate "Symbios 53c416 SCSI support"
-   depends on ISA && SCSI
-   ---help---
- This is support for the sym53c416 SCSI host adapter, the SCSI
- adapter that comes with some HP scanners. This driver requires that
- the sym53c416 is configured first using some sort of PnP
- configuration program (e.g. isapnp) or by a PnP aware BIOS. If you
- are using isapnp then you need to compile this driver as a module
- and then load it using insmod after isapnp has run. The parameters
- of the configured card(s) should be passed to the driver. The format
- is:
-
- insmod sym53c416 sym53c416=, [sym53c416_1=,]
-
- To compile this driver as a module, choose M here: the
- module will be called sym53c416.
-
 config SCSI_DC395x
tristate "Tekram DC395(U/UW/F) and DC315(U) SCSI support"
depends on PCI && SCSI
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 192a58d7d9d9..d5135efbf9cd 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -77,7 +77,6 @@ obj-$(CONFIG_SCSI_IPS)+= ips.o
 obj-$(CONFIG_SCSI_GENERIC_NCR5380) += g_NCR5380.o
 obj-$(CONFIG_SCSI_NCR_D700)+= 53c700.o NCR_D700.o
 obj-$(CONFIG_SCSI_NCR_Q720)+= NCR_Q720_mod.o
-obj-$(CONFIG_SCSI_SYM53C416)   += sym53c416.o
 obj-$(CONFIG_SCSI_QLOGIC_FAS)  += qlogicfas408.o   qlogicfas.o
 obj-$(CONFIG_PCMCIA_QLOGIC)+= qlogicfas408.o
 obj-$(CONFIG_SCSI_QLOGIC_1280) += qla1280.o 
diff --git a/drivers/scsi/sym53c416.c b/drivers/scsi/sym53c416.c
deleted file mode 100644
index e68bcdc75bc3..
--- a/drivers/scsi/sym53c416.c
+++ /dev/null
@@ -1,844 +0,0 @@
-/*
- *  sym53c416.c
- *  Low-level SCSI driver for sym53c416 chip.
- *  Copyright (C) 1998 Lieven Willems (lw_li...@hotmail.com)
- * 
- *  Changes : 
- * 
- *  Marcelo Tosatti  : Added io_request_lock locking
- *  Alan Cox  : Cleaned up code formatting
- *  Fixed an irq locking bug
- *  Added ISAPnP support
- *  Bjoern A. Zeeb  : Initial irq locking updates
- *   Added another card with ISAPnP support
- * 
- *  LILO command line usage: sym53c416=[,]
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License as published by the
- *  Free Software Foundation; either version 2, or (at your option) any
- *  later version.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include "scsi.h"
-#include 
-#include "sym53c416.h"
-
-#define VERSION_STRING"Version 1.0.0-ac"
-
-#define TC_LOW   0x00 /* Transfer counter low*/
-#define TC_MID   0x01 /* Transfer counter mid*/
-#define SCSI_FIFO0x02 /* SCSI FIFO register  */
-#define COMMAND_REG  0x03 /* Command Register*/
-#define STATUS_REG   0x04 /* Status Register (READ)  */
-#define DEST_BUS_ID  0x04 /* Destination Bus ID (WRITE)  */
-#define INT_REG  0x05 

[PATCH 07/12] scsi: remove the fdomain and fdomain_cs drivers

2018-03-14 Thread Christoph Hellwig
These drivers haven't seen any recent bug fixing and are two of the last
drivers using the scsi_module.c infrastruture that has been deprecated
15 years ago.

Signed-off-by: Christoph Hellwig 
---
 MAINTAINERS|6 -
 arch/powerpc/configs/c2k_defconfig |1 -
 drivers/scsi/Kconfig   |   20 -
 drivers/scsi/Makefile  |1 -
 drivers/scsi/fdomain.c | 1783 
 drivers/scsi/fdomain.h |   24 -
 drivers/scsi/pcmcia/Kconfig|9 -
 drivers/scsi/pcmcia/Makefile   |2 -
 drivers/scsi/pcmcia/fdomain_core.c |2 -
 drivers/scsi/pcmcia/fdomain_stub.c |  209 -
 10 files changed, 2057 deletions(-)
 delete mode 100644 drivers/scsi/fdomain.c
 delete mode 100644 drivers/scsi/fdomain.h
 delete mode 100644 drivers/scsi/pcmcia/fdomain_core.c
 delete mode 100644 drivers/scsi/pcmcia/fdomain_stub.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 3bdc260e36b7..24f6ea691f4d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5848,12 +5848,6 @@ F:   tools/testing/selftests/futex/
 F: tools/perf/bench/futex*
 F: Documentation/*futex*
 
-FUTURE DOMAIN TMC-16x0 SCSI DRIVER (16-bit)
-M: Rik Faith 
-L: linux-scsi@vger.kernel.org
-S: Odd Fixes (e.g., new signatures)
-F: drivers/scsi/fdomain.*
-
 GCC PLUGINS
 M: Kees Cook 
 R: Emese Revfy 
diff --git a/arch/powerpc/configs/c2k_defconfig 
b/arch/powerpc/configs/c2k_defconfig
index 4bb832a41d55..6c1196b0f81e 100644
--- a/arch/powerpc/configs/c2k_defconfig
+++ b/arch/powerpc/configs/c2k_defconfig
@@ -184,7 +184,6 @@ CONFIG_MEGARAID_NEWGEN=y
 CONFIG_MEGARAID_MM=m
 CONFIG_MEGARAID_MAILBOX=m
 CONFIG_MEGARAID_SAS=m
-CONFIG_SCSI_FUTURE_DOMAIN=m
 CONFIG_SCSI_GDTH=m
 CONFIG_SCSI_IPS=m
 CONFIG_SCSI_INITIO=m
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index b18dfa1c14a1..117c2fb41b77 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -640,26 +640,6 @@ config SCSI_DMX3191D
  To compile this driver as a module, choose M here: the
  module will be called dmx3191d.
 
-config SCSI_FUTURE_DOMAIN
-   tristate "Future Domain 16xx SCSI/AHA-2920A support"
-   depends on (ISA || PCI) && SCSI
-   select CHECK_SIGNATURE
-   ---help---
- This is support for Future Domain's 16-bit SCSI host adapters
- (TMC-1660/1680, TMC-1650/1670, TMC-3260, TMC-1610M/MER/MEX) and
- other adapters based on the Future Domain chipsets (Quantum
- ISA-200S, ISA-250MG; Adaptec AHA-2920A; and at least one IBM board).
- It is explained in section 3.7 of the SCSI-HOWTO, available from
- .
-
- NOTE: Newer Adaptec AHA-2920C boards use the Adaptec AIC-7850 chip
- and should use the aic7xxx driver ("Adaptec AIC7xxx chipset SCSI
- controller support"). This Future Domain driver works with the older
- Adaptec AHA-2920A boards with a Future Domain chip on them.
-
- To compile this driver as a module, choose M here: the
- module will be called fdomain.
-
 config SCSI_GDTH
tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller 
support"
depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 46f1c1033f0e..77bb0017bb02 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -74,7 +74,6 @@ obj-$(CONFIG_SCSI_AIC94XX)+= aic94xx/
 obj-$(CONFIG_SCSI_PM8001)  += pm8001/
 obj-$(CONFIG_SCSI_ISCI)+= isci/
 obj-$(CONFIG_SCSI_IPS) += ips.o
-obj-$(CONFIG_SCSI_FUTURE_DOMAIN)+= fdomain.o
 obj-$(CONFIG_SCSI_GENERIC_NCR5380) += g_NCR5380.o
 obj-$(CONFIG_SCSI_NCR53C406A)  += NCR53c406a.o
 obj-$(CONFIG_SCSI_NCR_D700)+= 53c700.o NCR_D700.o
diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
deleted file mode 100644
index ebbe5a3e665d..
--- a/drivers/scsi/fdomain.c
+++ /dev/null
@@ -1,1783 +0,0 @@
-/* fdomain.c -- Future Domain TMC-16x0 SCSI driver
- * Created: Sun May  3 18:53:19 1992 by fa...@cs.unc.edu
- * Revised: Mon Dec 28 21:59:02 1998 by fa...@acm.org
- * Author: Rickard E. Faith, fa...@cs.unc.edu
- * Copyright 1992-1996, 1998 Rickard E. Faith (fa...@acm.org)
- * Shared IRQ supported added 7/7/2001  Alan Cox 
-
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
-
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
-
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave

[PATCH 05/12] scsi: remove the eata_pio driver

2018-03-14 Thread Christoph Hellwig
This driver hasn't seen any recent bug fixing and is one of the last
drivers using the scsi_module.c infrastruture that has been deprecated
15 years ago.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/Kconfig|  14 -
 drivers/scsi/Makefile   |   1 -
 drivers/scsi/eata_generic.h | 401 --
 drivers/scsi/eata_pio.c | 966 
 drivers/scsi/eata_pio.h |  54 ---
 5 files changed, 1436 deletions(-)
 delete mode 100644 drivers/scsi/eata_generic.h
 delete mode 100644 drivers/scsi/eata_pio.c
 delete mode 100644 drivers/scsi/eata_pio.h

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 8647ca9199b3..51efb947537d 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -688,20 +688,6 @@ config SCSI_EATA_MAX_TAGS
  by the driver for each probed SCSI device is reported at boot time.
  This is equivalent to the "eata=mq:8" boot option.
 
-config SCSI_EATA_PIO
-   tristate "EATA-PIO (old DPT PM2001, PM2012A) support"
-   depends on (ISA || EISA || PCI) && SCSI && BROKEN
-   ---help---
- This driver supports all EATA-PIO protocol compliant SCSI Host
- Adapters like the DPT PM2001 and the PM2012A.  EATA-DMA compliant
- host adapters could also use this driver but are discouraged from
- doing so, since this driver only supports hard disks and lacks
- numerous features.  You might want to have a look at the SCSI-HOWTO,
- available from .
-
- To compile this driver as a module, choose M here: the
- module will be called eata_pio.
-
 config SCSI_FUTURE_DOMAIN
tristate "Future Domain 16xx SCSI/AHA-2920A support"
depends on (ISA || PCI) && SCSI
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index fcfd28d2884c..738d02a2a455 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -93,7 +93,6 @@ obj-$(CONFIG_SCSI_HPSA)   += hpsa.o
 obj-$(CONFIG_SCSI_SMARTPQI)+= smartpqi/
 obj-$(CONFIG_SCSI_SYM53C8XX_2) += sym53c8xx_2/
 obj-$(CONFIG_SCSI_ZALON)   += zalon7xx.o
-obj-$(CONFIG_SCSI_EATA_PIO)+= eata_pio.o
 obj-$(CONFIG_SCSI_EATA)+= eata.o
 obj-$(CONFIG_SCSI_DC395x)  += dc395x.o
 obj-$(CONFIG_SCSI_AM53C974)+= esp_scsi.o   am53c974.o
diff --git a/drivers/scsi/eata_generic.h b/drivers/scsi/eata_generic.h
deleted file mode 100644
index 1a396c5e7f73..
--- a/drivers/scsi/eata_generic.h
+++ /dev/null
@@ -1,401 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/
-* Header file for eata_dma.c and eata_pio.c*
-* Linux EATA SCSI drivers  *
-* (c) 1993-96 Michael Neuffer   *
-* m...@i-connect.net*
-* neuf...@mail.uni-mainz.de *
-*
-* last change: 96/08/14 *
-/
-
-
-#ifndef _EATA_GENERIC_H
-#define _EATA_GENERIC_H
-
-
-
-/*
- * Misc. definitions*
- */
-
-#define R_LIMIT 0x2
-
-#define MAXISA4
-#define MAXEISA  16  
-#define MAXPCI   16
-#define MAXIRQ   16 
-#define MAXTARGET 16
-#define MAXCHANNEL 3
-
-#define IS_ISA'I'
-#define IS_EISA   'E'
-#define IS_PCI'P'
-
-#define BROKEN_INQUIRY 1
-
-#define BUSMASTER   0xff
-#define PIO 0xfe
-
-#define EATA_SIGNATURE 0x45415441 /* BIG ENDIAN coded "EATA" sig.   */
-
-#define DPT_ID1 0x12
-#define DPT_ID2 0x14
-
-#define ATT_ID1 0x06
-#define ATT_ID2 0x94
-#define ATT_ID3 0x0
-
-#define NEC_ID1 0x38
-#define NEC_ID2 0xa3
-#define NEC_ID3 0x82
-
- 
-#define EATA_CP_SIZE44
-
-#define MAX_PCI_DEVICES  32   /* Maximum # Of Devices Per Bus   */
-#define MAX_METHOD_216/* Max Devices For Method 2   */
-#define MAX_PCI_BUS 16/* Maximum # Of Busses Allowed*/
-
-#define SG_SIZE 64 
-#define SG_SIZE_BIG 252   /* max. 8096 elements, 64k */
-
-#define UPPER_DEVICE_QUEUE_LIMIT 64/* The limit we have to set for the 
-   * device queue to keep the broken 
-   * midlevel SCSI code from producing
-   * bogus timeouts
-   */
-
-#define TYPE_DISK_QUEUE  16
-#define TYPE_TAPE_QUEUE  4
-#define TYPE_ROM_QUEUE   4
-#define TYPE_OTHER_QUEUE 2
-
-#define FREE0
-#define OK  0
-#define NO_TIMEOUT   0
-#define USED1
-#define TIMEOUT 2
-#define RESET   4
-#define LOCKED  8
-#d

[PATCH 04/12] esas2r: remove initialization / cleanup dead wood

2018-03-14 Thread Christoph Hellwig
esas2r has been converted to hotplug style initialization long ago, but
kept various remant of the old-style scsi_module.c initialization around.
Remove those.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/esas2r/esas2r.h  |  2 --
 drivers/scsi/esas2r/esas2r_init.c | 21 
 drivers/scsi/esas2r/esas2r_main.c | 72 +++
 3 files changed, 4 insertions(+), 91 deletions(-)

diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h
index 1da6407ee142..858c3b33db78 100644
--- a/drivers/scsi/esas2r/esas2r.h
+++ b/drivers/scsi/esas2r/esas2r.h
@@ -962,7 +962,6 @@ struct esas2r_adapter {
  * Function Declarations
  * SCSI functions
  */
-int esas2r_release(struct Scsi_Host *);
 const char *esas2r_info(struct Scsi_Host *);
 int esas2r_write_params(struct esas2r_adapter *a, struct esas2r_request *rq,
struct esas2r_sas_nvram *data);
@@ -984,7 +983,6 @@ int esas2r_target_reset(struct scsi_cmnd *cmd);
 /* Internal functions */
 int esas2r_init_adapter(struct Scsi_Host *host, struct pci_dev *pcid,
int index);
-int esas2r_cleanup(struct Scsi_Host *host);
 int esas2r_read_fw(struct esas2r_adapter *a, char *buf, long off, int count);
 int esas2r_write_fw(struct esas2r_adapter *a, const char *buf, long off,
int count);
diff --git a/drivers/scsi/esas2r/esas2r_init.c 
b/drivers/scsi/esas2r/esas2r_init.c
index 5b14dd29b764..9dffcb28c9b7 100644
--- a/drivers/scsi/esas2r/esas2r_init.c
+++ b/drivers/scsi/esas2r/esas2r_init.c
@@ -661,27 +661,6 @@ void esas2r_kill_adapter(int i)
}
 }
 
-int esas2r_cleanup(struct Scsi_Host *host)
-{
-   struct esas2r_adapter *a;
-   int index;
-
-   if (host == NULL) {
-   int i;
-
-   esas2r_debug("esas2r_cleanup everything");
-   for (i = 0; i < MAX_ADAPTERS; i++)
-   esas2r_kill_adapter(i);
-   return -1;
-   }
-
-   esas2r_debug("esas2r_cleanup called for host %p", host);
-   a = (struct esas2r_adapter *)host->hostdata;
-   index = a->index;
-   esas2r_kill_adapter(index);
-   return index;
-}
-
 int esas2r_suspend(struct pci_dev *pdev, pm_message_t state)
 {
struct Scsi_Host *host = pci_get_drvdata(pdev);
diff --git a/drivers/scsi/esas2r/esas2r_main.c 
b/drivers/scsi/esas2r/esas2r_main.c
index 4eb14301a497..e07eac5be087 100644
--- a/drivers/scsi/esas2r/esas2r_main.c
+++ b/drivers/scsi/esas2r/esas2r_main.c
@@ -235,7 +235,6 @@ static struct scsi_host_template driver_template = {
.module = THIS_MODULE,
.show_info  = esas2r_show_info,
.name   = ESAS2R_LONGNAME,
-   .release= esas2r_release,
.info   = esas2r_info,
.ioctl  = esas2r_ioctl,
.queuecommand   = esas2r_queuecommand,
@@ -520,44 +519,16 @@ static int esas2r_probe(struct pci_dev *pcid,
 
 static void esas2r_remove(struct pci_dev *pdev)
 {
-   struct Scsi_Host *host;
-   int index;
-
-   if (pdev == NULL) {
-   esas2r_log(ESAS2R_LOG_WARN, "esas2r_remove pdev==NULL");
-   return;
-   }
-
-   host = pci_get_drvdata(pdev);
-
-   if (host == NULL) {
-   /*
-* this can happen if pci_set_drvdata was already called
-* to clear the host pointer.  if this is the case, we
-* are okay; this channel has already been cleaned up.
-*/
-
-   return;
-   }
+   struct Scsi_Host *host = pci_get_drvdata(pdev);
+   struct esas2r_adapter *a = (struct esas2r_adapter *)host->hostdata;
 
esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev),
   "esas2r_remove(%p) called; "
   "host:%p", pdev,
   host);
 
-   index = esas2r_cleanup(host);
-
-   if (index < 0)
-   esas2r_log_dev(ESAS2R_LOG_WARN, &(pdev->dev),
-  "unknown host in %s",
-  __func__);
-
+   esas2r_kill_adapter(a->index);
found_adapters--;
-
-   /* if this was the last adapter, clean up the rest of the driver */
-
-   if (found_adapters == 0)
-   esas2r_cleanup(NULL);
 }
 
 static int __init esas2r_init(void)
@@ -638,30 +609,7 @@ static int __init esas2r_init(void)
for (i = 0; i < MAX_ADAPTERS; i++)
esas2r_adapters[i] = NULL;
 
-   /* initialize */
-
-   driver_template.module = THIS_MODULE;
-
-   if (pci_register_driver(&esas2r_pci_driver) != 0)
-   esas2r_log(ESAS2R_LOG_CRIT, "pci_register_driver FAILED");
-   else
-   esas2r_log(ESAS2R_LOG_INFO, "pci_register_driver() OK");
-
-   if (!found_adapters) {
-   pci_unregister_driver(&esas2r_pci_driver);
-  

remove obsolete drivers and scsi_module.c

2018-03-14 Thread Christoph Hellwig
Hi all,

this series removes the obsolete scsi_module.c infratructure that
has been obsolete for 15 years, and the remaining drivers that depend
on them.


[PATCH 02/12] ips: don't set .detect and .release in the host template

2018-03-14 Thread Christoph Hellwig
Since moving away from using scsi_module.c these were never called.
The implementations are called directly, though so they remain.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/ips.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index 67621308eb9c..e3c8857741a1 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -224,8 +224,6 @@ module_param(ips, charp, 0);
 /*
  * Function prototypes
  */
-static int ips_detect(struct scsi_host_template *);
-static int ips_release(struct Scsi_Host *);
 static int ips_eh_abort(struct scsi_cmnd *);
 static int ips_eh_reset(struct scsi_cmnd *);
 static int ips_queue(struct Scsi_Host *, struct scsi_cmnd *);
@@ -355,8 +353,6 @@ static dma_addr_t ips_flashbusaddr;
 static long ips_FlashDataInUse;/* CD Boot - Flash Data In Use 
Flag */
 static uint32_t MaxLiteCmds = 32;  /* Max Active Cmds for a Lite Adapter */
 static struct scsi_host_template ips_driver_template = {
-   .detect = ips_detect,
-   .release= ips_release,
.info   = ips_info,
.queuecommand   = ips_queue,
.eh_abort_handler   = ips_eh_abort,
-- 
2.14.2



[PATCH 01/12] dpt_i2o: stop using scsi_unregister

2018-03-14 Thread Christoph Hellwig
dpt_i2o doesn't use scsi_register, so it should not use scsi_unregister
either.  Also refactor the module exit path to make a little more sense.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/dpt_i2o.c | 16 
 drivers/scsi/dpti.h|  1 -
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index fd172b0890d3..3c667b23a801 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -302,16 +302,12 @@ static int adpt_detect(struct scsi_host_template* sht)
 }
 
 
-/*
- * scsi_unregister will be called AFTER we return.
- */
-static int adpt_release(struct Scsi_Host *host)
+static void adpt_release(adpt_hba *pHba)
 {
-   adpt_hba* pHba = (adpt_hba*) host->hostdata[0];
+   scsi_remove_host(pHba->host);
 // adpt_i2o_quiesce_hba(pHba);
adpt_i2o_delete_hba(pHba);
-   scsi_unregister(host);
-   return 0;
+   scsi_host_put(pHba->host);
 }
 
 
@@ -1087,8 +1083,6 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba)
 
 
mutex_lock(&adpt_configuration_lock);
-   // scsi_unregister calls our adpt_release which
-   // does a quiese
if(pHba->host){
free_irq(pHba->host->irq, pHba);
}
@@ -3595,11 +3589,9 @@ static void __exit adpt_exit(void)
 {
adpt_hba*pHba, *next;
 
-   for (pHba = hba_chain; pHba; pHba = pHba->next)
-   scsi_remove_host(pHba->host);
for (pHba = hba_chain; pHba; pHba = next) {
next = pHba->next;
-   adpt_release(pHba->host);
+   adpt_release(pHba);
}
 }
 
diff --git a/drivers/scsi/dpti.h b/drivers/scsi/dpti.h
index 1fa345ab8ecb..dfc8d2eaa09e 100644
--- a/drivers/scsi/dpti.h
+++ b/drivers/scsi/dpti.h
@@ -32,7 +32,6 @@ static int adpt_detect(struct scsi_host_template * sht);
 static int adpt_queue(struct Scsi_Host *h, struct scsi_cmnd * cmd);
 static int adpt_abort(struct scsi_cmnd * cmd);
 static int adpt_reset(struct scsi_cmnd* cmd);
-static int adpt_release(struct Scsi_Host *host);
 static int adpt_slave_configure(struct scsi_device *);
 
 static const char *adpt_info(struct Scsi_Host *pSHost);
-- 
2.14.2



[PATCH 03/12] aha1740: stop using scsi_unregister

2018-03-14 Thread Christoph Hellwig
aha1740 doesn't use scsi_register, so it should not use scsi_unregister
either.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/aha1740.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c
index bad35ffc015d..b48d5436f094 100644
--- a/drivers/scsi/aha1740.c
+++ b/drivers/scsi/aha1740.c
@@ -592,7 +592,7 @@ static int aha1740_probe (struct device *dev)
 DMA_BIDIRECTIONAL);
if (!host->ecb_dma_addr) {
printk (KERN_ERR "aha1740_probe: Couldn't map ECB, giving 
up\n");
-   scsi_unregister (shpnt);
+   scsi_host_put (shpnt);
goto err_host_put;
}

-- 
2.14.2



Re: [PATCH 12/13] qla2xxx: Fix Async GPN_FT for FCP and FC-NVMe scan

2018-03-14 Thread Hannes Reinecke
On 03/12/2018 07:16 PM, Himanshu Madhani wrote:
> From: Quinn Tran 
> 
> This patch combines FCP and FC-NVMe scan into single scan when
> driver detects FC-NVMe capability on same port.
> 
> Signed-off-by: Quinn Tran 
> Signed-off-by: Himanshu Madhani 
> ---
>  drivers/scsi/qla2xxx/qla_def.h  |   7 ++
>  drivers/scsi/qla2xxx/qla_gbl.h  |   2 +-
>  drivers/scsi/qla2xxx/qla_gs.c   | 231 
> 
>  drivers/scsi/qla2xxx/qla_init.c |   8 +-
>  drivers/scsi/qla2xxx/qla_os.c   |   8 +-
>  5 files changed, 204 insertions(+), 52 deletions(-)
> 
Please fixup the kbuild robot warning.

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 11/13] qla2xxx: Cleanup code to improve FC-NVMe error handling

2018-03-14 Thread Hannes Reinecke
On 03/12/2018 07:16 PM, Himanshu Madhani wrote:
> From: Darren Trapp 
> 
> Signed-off-by: Darren Trapp 
> Signed-off-by: Himanshu Madhani 
> ---
>  drivers/scsi/qla2xxx/qla_isr.c  | 78 
> +++--
>  drivers/scsi/qla2xxx/qla_nvme.c |  2 +-
>  2 files changed, 29 insertions(+), 51 deletions(-)
> 
And also here, please add some description what this patch does.

Otherwise:

Reviewed-by: Hannes Reinecke 

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 10/13] qla2xxx: Fix FC-NVMe IO abort during driver reset

2018-03-14 Thread Hannes Reinecke
On 03/12/2018 07:16 PM, Himanshu Madhani wrote:
> From: Darren Trapp 
> 
> Signed-off-by: Darren Trapp 
> Signed-off-by: Himanshu Madhani 
> ---
>  drivers/scsi/qla2xxx/qla_nvme.c | 17 -
>  drivers/scsi/qla2xxx/qla_nvme.h |  2 +-
>  drivers/scsi/qla2xxx/qla_os.c   |  2 +-
>  3 files changed, 14 insertions(+), 7 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

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 09/13] qla2xxx: Fix retry for PRLI RJT with reason of BUSY

2018-03-14 Thread Hannes Reinecke
On 03/12/2018 07:16 PM, Himanshu Madhani wrote:
> From: Darren Trapp 
> 
> Signed-off-by: Darren Trapp 
> Signed-off-by: Himanshu Madhani 
> ---
>  drivers/scsi/qla2xxx/qla_dbg.c  |  2 +-
>  drivers/scsi/qla2xxx/qla_init.c | 13 -
>  drivers/scsi/qla2xxx/qla_mbx.c  |  7 +--
>  3 files changed, 18 insertions(+), 4 deletions(-)
> 
Again, some more descriptive text would be nice.

Otherwise:

Reviewed-by: Hannes Reinecke 

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: Debugging SCSI 'UNMAP' ("Logical Block Provisioning") failure on an SSD

2018-03-14 Thread Oliver Neukum
Am Mittwoch, den 14.03.2018, 11:22 +0100 schrieb Kashyap Chamarthy:
> I see.  So I ran `dmesg -w`, as I attached the disk & see the following:

UAS and no quirk for your device. It looks like it indeed just does
not support TRIM.

Sorry
Oliver



Re: [PATCH 08/13] qla2xxx: Remove nvme_done_list

2018-03-14 Thread Hannes Reinecke
On 03/12/2018 07:16 PM, Himanshu Madhani wrote:
> From: Darren Trapp 
> 
> Signed-off-by: Darren Trapp 
> Signed-off-by: Himanshu Madhani 
> ---
>  drivers/scsi/qla2xxx/qla_def.h  |  1 -
>  drivers/scsi/qla2xxx/qla_gbl.h  |  2 --
>  drivers/scsi/qla2xxx/qla_init.c |  1 -
>  drivers/scsi/qla2xxx/qla_mid.c  |  6 --
>  drivers/scsi/qla2xxx/qla_nvme.c | 13 ++---
>  drivers/scsi/qla2xxx/qla_os.c   |  1 -
>  6 files changed, 2 insertions(+), 22 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

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 07/13] qla2xxx: Return busy if rport going away

2018-03-14 Thread Hannes Reinecke
On 03/12/2018 07:16 PM, Himanshu Madhani wrote:
> From: Darren Trapp 
> 
> This patch adds mechanism to retur EBUSY if rport is going away
> to prevent exhausting FC-NVMe layer's retry counter.
> 
> Signed-off-by: Darren Trapp 
> Signed-off-by: Himanshu Madhani 
> ---
>  drivers/scsi/qla2xxx/qla_def.h  |  1 +
>  drivers/scsi/qla2xxx/qla_isr.c  |  4 +++-
>  drivers/scsi/qla2xxx/qla_nvme.c | 31 ---
>  3 files changed, 24 insertions(+), 12 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

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 06/13] qla2xxx: Fix n2n_ae flag to prevent dev_loss on PDB change

2018-03-14 Thread Hannes Reinecke
On 03/12/2018 07:16 PM, Himanshu Madhani wrote:
> From: Darren Trapp 
> 
Some more text would be nice; not everyone knows what n2n_ae or PDB is ...

> Signed-off-by: Darren Trapp 
> Signed-off-by: Himanshu Madhani 
> ---
>  drivers/scsi/qla2xxx/qla_def.h | 2 --
>  drivers/scsi/qla2xxx/qla_isr.c | 3 ---
>  drivers/scsi/qla2xxx/qla_mbx.c | 3 +++
>  3 files changed, 3 insertions(+), 5 deletions(-)
> 
Otherwise:
Reviewed-by: Hannes Reinecke 

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 05/13] qla2xxx: Add FC-NVMe abort processing

2018-03-14 Thread Hannes Reinecke
On 03/12/2018 07:16 PM, Himanshu Madhani wrote:
> From: Darren Trapp 
> 
> Signed-off-by: Darren Trapp 
> Signed-off-by: Himanshu Madhani 
> ---
>  drivers/scsi/qla2xxx/qla_nvme.c | 36 ++--
>  drivers/scsi/qla2xxx/qla_nvme.h |  1 +
>  2 files changed, 19 insertions(+), 18 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

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 04/13] qla2xxx: Restore ZIO threshold setting

2018-03-14 Thread Hannes Reinecke
On 03/12/2018 07:16 PM, Himanshu Madhani wrote:
> From: Darren Trapp 
> 
> Signed-off-by: Darren Trapp 
> Signed-off-by: Himanshu Madhani 
> ---
>  drivers/scsi/qla2xxx/qla_nvme.c | 5 -
>  1 file changed, 5 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
> index a8e81fc14c44..5ee447680ddd 100644
> --- a/drivers/scsi/qla2xxx/qla_nvme.c
> +++ b/drivers/scsi/qla2xxx/qla_nvme.c
> @@ -464,11 +464,6 @@ static int qla2x00_start_nvme_mq(srb_t *sp)
>   /* Set chip new ring index. */
>   WRT_REG_DWORD(req->req_q_in, req->ring_index);
>  
> - /* Manage unprocessed RIO/ZIO commands in response queue. */
> - if (vha->flags.process_response_queue &&
> - rsp->ring_ptr->signature != RESPONSE_PROCESSED)
> - qla24xx_process_response_queue(vha, rsp);
> -
>  queuing_error:
>   spin_unlock_irqrestore(&qpair->qp_lock, flags);
>   return rval;
> 
Reviewed-by: Hannes Reinecke 

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 03/13] qla2xxx: Add changes for devloss timeout in driver

2018-03-14 Thread Hannes Reinecke
On 03/12/2018 07:16 PM, Himanshu Madhani wrote:
> From: Darren Trapp 
> 
> Add support for error recovery within devloss timeout, now that
> FC-NVMe transport support devloss timeout.
> 
> Signed-off-by: Darren Trapp 
> Signed-off-by: Himanshu Madhani 
> ---
>  drivers/scsi/qla2xxx/qla_def.h|   1 +
>  drivers/scsi/qla2xxx/qla_init.c   |   8 +++
>  drivers/scsi/qla2xxx/qla_isr.c|   5 +-
>  drivers/scsi/qla2xxx/qla_nvme.c   | 142 
> +-
>  drivers/scsi/qla2xxx/qla_nvme.h   |   6 +-
>  drivers/scsi/qla2xxx/qla_target.c |  13 ++--
>  drivers/scsi/qla2xxx/qla_target.h |   2 +-
>  7 files changed, 87 insertions(+), 90 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

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 02/13] qla2xxx: Set IIDMA and fcport state before qla_nvme_register_remote()

2018-03-14 Thread Hannes Reinecke
On 03/12/2018 07:16 PM, Himanshu Madhani wrote:
> From: Darren Trapp 
> 
> Signed-off-by: Darren Trapp 
> Signed-off-by: Himanshu Madhani 
> ---
>  drivers/scsi/qla2xxx/qla_init.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
> index cb182b102bfd..6caccc52376a 100644
> --- a/drivers/scsi/qla2xxx/qla_init.c
> +++ b/drivers/scsi/qla2xxx/qla_init.c
> @@ -5110,13 +5110,14 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t 
> *fcport)
>   fcport->deleted = 0;
>   fcport->logout_on_delete = 1;
>  
> + qla2x00_set_fcport_state(fcport, FCS_ONLINE);
> + qla2x00_iidma_fcport(vha, fcport);
> +
>   if (fcport->fc4f_nvme) {
>   qla_nvme_register_remote(vha, fcport);
>   return;
>   }
>  
> - qla2x00_set_fcport_state(fcport, FCS_ONLINE);
> - qla2x00_iidma_fcport(vha, fcport);
>   qla24xx_update_fcport_fcp_prio(vha, fcport);
>  
>  reg_port:
> 
Reviewed-by: Hannes Reinecke 

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 01/13] qla2xxx: Remove unneeded message and minor cleanup for FC-NVMe

2018-03-14 Thread Hannes Reinecke
On 03/12/2018 07:16 PM, Himanshu Madhani wrote:
> Signed-off-by: Himanshu Madhani 
> ---
>  drivers/scsi/qla2xxx/qla_nvme.c | 11 +++
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

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 4/5] scsi_io_completion: conditional hints on fastpath

2018-03-14 Thread Douglas Gilbert

On 2018-03-09 10:13 AM, Johannes Thumshirn wrote:

On Tue, Mar 06, 2018 at 10:21:33PM -0500, Douglas Gilbert wrote:

ChangeLog:
   - add likely() and unlikely() hints to conditionals on or near the
 fastpath
   - fix a comment in scsi_io_completion_action()


Do you have any numbers what this patch buys us performance wise?


How does 7 nanoseconds sound?

Measuring the time taken by scsi_io_completion() gives figures that
jump around seemingly randomly between 1.2 and 2.0 microseconds
(when the system is under heavy load). Turns out that almost all of
that is caused by the call to scsi_end_request() (and the functions
it calls). So the timing I was after was from the call into
scsi_io_completion() to the point on the fastpath just before
scsi_end_request() is called. ftrace function-graph doesn't even show
this time (perhaps it has a lower threshold value).

So I wrote my own timer, starting and stopping at those points, reading
the hr timer with ktime and only timing on one CPU (to avoid atomics
an mutexes). The input was a fio script used previously for testing
scsi_mq.

The "before" timing was on a kernel build with MKP's tree which now has
my "[PATCH v4] Make SCSI Status CONDITION MET equivalent to GOOD"
patch applied, but not this patchset. Also some of the time being measured
is from the measuring code itself :-)

Here is the "before", averaged over 100 millisecond windows:
  hrtimer: interrupt took 16045 ns
  print_timings: cum_time=10156 ns, count=630299, avg=158 ns
  print_timings: cum_time=10126 ns, count=623939, avg=160 ns
  print_timings: cum_time=10020 ns, count=625046, avg=159 ns
  print_timings: cum_time=10098 ns, count=624375, avg=160 ns
  print_timings: cum_time=10060 ns, count=619438, avg=161 ns
  print_timings: cum_time=10132 ns, count=616604, avg=162 ns
  print_timings: cum_time=10050 ns, count=617839, avg=161 ns
  print_timings: cum_time=10079 ns, count=623943, avg=160 ns
  print_timings: cum_time=10128 ns, count=617545, avg=161 ns
  print_timings: cum_time=10083 ns, count=617902, avg=161 ns

Here is the "after":
  print_timings: cum_time=10022 ns, count=628977, avg=158 ns
  print_timings: cum_time=10021 ns, count=642545, avg=155 ns
  print_timings: cum_time=10042 ns, count=647620, avg=154 ns
  print_timings: cum_time=10115 ns, count=649420, avg=153 ns
  print_timings: cum_time=10001 ns, count=646527, avg=154 ns
  print_timings: cum_time=10103 ns, count=648608, avg=154 ns
  print_timings: cum_time=10074 ns, count=650341, avg=153 ns
  print_timings: cum_time=10115 ns, count=652359, avg=153 ns
  print_timings: cum_time=10031 ns, count=636437, avg=157 ns
  print_timings: cum_time=10096 ns, count=632879, avg=158 ns


Attached is some ftrace function-graph output of scsi_io_completion()
which is gzipped for brevity.

Looked at in lines of C code, in the window I'm interested in the
"before" code does:
   - 4 local variable initializations
   - zeros two locals, sets false in another
   - wait_for = (cmd->allowed + 1) * req->timeout;  (local initialization)
   - 5 failed "if"s (one is "else if") with no hints
   - fails to trigger on BUG_ON
   - doesn't print a SCSI_LOG_HLCOMPLETE
   - before it gets to the fastpath exit:
if (!(blk_rq_bytes(req) == 0 && error) &&
!scsi_end_request(req, error, good_bytes, 0))
return;

The "after" code does:
   - 4 local variable initializations
   - 2 failed "if"s with hints
   - one failed "if" with hint in place of BUG_ON
   - doesn't print a SCSI_LOG_HLCOMPLETE
   - before it gets to the fastpath exit which has hints:
if (likely(blk_rq_bytes(req) > 0 || blk_stat == BLK_STS_OK)) {
if (likely(!scsi_end_request(req, blk_stat, good_bytes, 0)))
return; /* no bytes remaining */
}

So the difference measured on a Lenovo X270 (i5-7200U) amounts to
around 7 nanoseconds.

Doug Gilbert


scsi_io_completion_ftrace.txt.gz
Description: application/gzip


Re: Debugging SCSI 'UNMAP' ("Logical Block Provisioning") failure on an SSD

2018-03-14 Thread Kashyap Chamarthy
On Wed, Mar 14, 2018 at 10:52:36AM +0100, Oliver Neukum wrote:
> Am Dienstag, den 13.03.2018, 12:50 +0100 schrieb Kashyap Chamarthy:
> > Earlier, I didn't know which list to email, so I wrote to Martin K.
> > Petersen (who pointed me to the lists when I asked where I can post
> > publicly), and he made this observation on the above quoted text:
> > 
> >     "Linux can run USB block devices in either legacy or UAS mode.
> >     Chances are this device is being driven in usb-storage mode. We
> >     usually have quirks based on the model strings that decide whether
> >     to use one or the other."
> 
> Neither driver would edit commands or result to that degree.
> Whether UAS or storage are used dmesg will tell you.

I see.  So I ran `dmesg -w`, as I attached the disk & see the following:

---
[...]
[474027.606253] sd 3:0:0:0: Attached scsi generic sg1 type 0
[474027.607751] sd 3:0:0:0: [sdb] 976773168 512-byte logical blocks: (500 
GB/466 GiB)
[474027.607857] sd 3:0:0:0: [sdb] Write Protect is off
[474027.607858] sd 3:0:0:0: [sdb] Mode Sense: 43 00 00 00
[474027.608019] sd 3:0:0:0: [sdb] Write cache: enabled, read cache: enabled, 
doesn't support DPO or FUA
[474027.612347] sd 3:0:0:0: [sdb] Attached SCSI disk
[474027.863216] EXT4-fs (sdb): recovery complete
[474027.866955] EXT4-fs (sdb): mounted filesystem with ordered data mode. Opts: 
(null)
[474038.146095] usb 3-1: USB disconnect, device number 4
[474038.147543] print_req_error: I/O error, dev sdb, sector 0
[474038.155354] sd 3:0:0:0: [sdb] Synchronizing SCSI cache
[474038.175128] print_req_error: I/O error, dev sdb, sector 0
[474038.179130] print_req_error: I/O error, dev sdb, sector 0
[474038.183135] print_req_error: I/O error, dev sdb, sector 0
[474038.183156] print_req_error: I/O error, dev sdb, sector 0
[474038.267134] sd 3:0:0:0: [sdb] Synchronize Cache(10) failed: Result: 
hostbyte=DID_ERROR driverbyte=DRIVER_OK
[474076.230377] usb 3-1: new SuperSpeed USB device number 5 using xhci_hcd
[474076.248589] usb 3-1: New USB device found, idVendor=04e8, idProduct=61f5
[474076.248593] usb 3-1: New USB device strings: Mfr=2, Product=3, 
SerialNumber=1
[474076.248596] usb 3-1: Product: Portable SSD T5
[474076.248598] usb 3-1: Manufacturer: Samsung
[474076.248600] usb 3-1: SerialNumber: 1234567A7AD6
[474076.254990] scsi host3: uas
[474076.255605] scsi 3:0:0:0: Direct-Access Samsung  Portable SSD T5  0
PQ: 0 ANSI: 6
[474076.263707] sd 3:0:0:0: Attached scsi generic sg1 type 0
[474076.264140] sd 3:0:0:0: [sdb] 976773168 512-byte logical blocks: (500 
GB/466 GiB)
[474076.264220] sd 3:0:0:0: [sdb] Write Protect is off
[474076.264222] sd 3:0:0:0: [sdb] Mode Sense: 43 00 00 00
[474076.264546] sd 3:0:0:0: [sdb] Write cache: enabled, read cache: enabled, 
doesn't support DPO or FUA
[474076.267595] sd 3:0:0:0: [sdb] Attached SCSI disk
[474076.463067] EXT4-fs (sdb): recovery complete
[474076.463070] EXT4-fs (sdb): mounted filesystem with ordered data mode. Opts: 
(null)
---

-- 
/kashyap


Re: Debugging SCSI 'UNMAP' ("Logical Block Provisioning") failure on an SSD

2018-03-14 Thread Oliver Neukum
Am Dienstag, den 13.03.2018, 12:50 +0100 schrieb Kashyap Chamarthy:
> Earlier, I didn't know which list to email, so I wrote to Martin K.
> Petersen (who pointed me to the lists when I asked where I can post
> publicly), and he made this observation on the above quoted text:
> 
>     "Linux can run USB block devices in either legacy or UAS mode.
>     Chances are this device is being driven in usb-storage mode. We
>     usually have quirks based on the model strings that decide whether
>     to use one or the other."

Neither driver would edit commands or result to that degree.
Whether UAS or storage are used dmesg will tell you.

Regards
Oliver



Re: [PATCH V5 5/5] scsi: virtio_scsi: unify scsi_host_template

2018-03-14 Thread Christoph Hellwig
Looks good,

Reviewed-by: Christoph Hellwig 


Re: [PATCH V5 1/5] scsi: hpsa: fix selection of reply queue

2018-03-14 Thread Christoph Hellwig
I still don't like the code duplication, but I guess I can fix this
up in one of the next merge windows myself..

Reviewed-by: Christoph Hellwig 


Re: [PATCH V5 4/5] scsi: virtio_scsi: fix IO hang caused by irq vector automatic affinity

2018-03-14 Thread Christoph Hellwig
Looks good,

Reviewed-by: Christoph Hellwig 


Re: [PATCH V5 2/5] scsi: megaraid_sas: fix selection of reply queue

2018-03-14 Thread Christoph Hellwig
Same as for hpsa..

Reviewed-by: Christoph Hellwig 


Re: [PATCH v3] m68k/amiga - Amiga Zorro NCR53C9x boards: new zorro_esp.c

2018-03-14 Thread Michael Schmitz
Hi Geert,

Am 14.03.2018 um 21:30 schrieb Geert Uytterhoeven:
> Hi Michael,
> 
> On Wed, Mar 14, 2018 at 9:23 AM, Michael Schmitz  wrote:
>> thanks for the review - largely uncontroversial except for the volatile...
> 
> The presence of volatile in drivers is always considered controversial ;-)

Yes indeed. I just hadn't looked at raw_io.h in ages (too many unhappy
memories), and didn't remember the __force volatile trick there.

>> Meaning writeb(val, reg) instead of reg = val?
>>
>> #define out_8(addr,b) (void)((*(__force volatile u8 *) (addr)) = (b))
>>
>> nicely hides the 'volatile' but suggests I also need to pass it a
>> pointer, so
>>
>> writeb((addr >> 24) & 0xff, &dregs->dma_addr)
> 
> Yes, you have to pass it an (__iomem) pointer.

Thanks.

>> I'll have to compare the assembly generated by the two versions before I
>> dare test that, but I'll give that a try. Liberal use of wmb() did fix
>> the miscompile but that just looked too ugly.
> 
> Using the macros should have the same effect due to the embedded volatile.

I tend to agree, but crashing elgar or trashing the SCSI filesystem
there isn't something I would like to risk (Adrian has been very
accommodating allowing me to test the driver there, but a reset tends to
be taking a few hours thanks to the time zone difference). So I'd rather
make sure nothing can go wrong.

Cheers,

Michael


> 
> Gr{oetje,eeting}s,
> 
> Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds
> 


Re: [PATCH v3] m68k/amiga - Amiga Zorro NCR53C9x boards: new zorro_esp.c

2018-03-14 Thread Michael Schmitz
Hi Tuomas,

oddly enough, it does. How embarrassing...

Hope I got the names of the boards right this time.

Thanks for spotting this!

Cheers,

Michael

Am 14.03.2018 um 20:13 schrieb Vainikka Tuomas:
> The config description lists 53c700 devices, not ESP devices?
> 
> -Tuomas
> 
> From: linux-m68k-ow...@vger.kernel.org  on 
> behalf of Michael Schmitz 
> Sent: 12 March 2018 09:26:40
> To: linux-scsi@vger.kernel.org
> Cc: linux-m...@vger.kernel.org; da...@davemloft.net; ge...@linux-m68k.org; 
> fth...@telegraphics.com.au; Michael Schmitz; Michael Schmitz
> Subject: [PATCH v3] m68k/amiga - Amiga Zorro NCR53C9x boards: new zorro_esp.c
> 
> From: Michael Schmitz 
> 
> New combined SCSI driver for all ESP based Zorro SCSI boards for
> m68k Amiga.
> 
> Code largely based on board specific parts of the old drivers (blz1230.c,
> blz2060.c, cyberstorm.c, cyberstormII.c, fastlane.c which were removed
> after the 2.6 kernel series for lack of maintenance) with contributions
> by Tuomas Vainikka (TCQ bug tests and workaround) and Finn Thain (TCQ
> bugfix by use of PIO in extended message in transfer).
> 
> New Kconfig option and Makefile entries for new Amiga Zorro ESP SCSI
> driver included in this patch.
> 
> Use DMA transfers wherever possible, with board-specific DMA set-up
> functions copied from the old driver code. Three byte reselection messages
>  do appear to cause DMA timeouts. So wire up a PIO transfer routine for
> these instead.
> 
> PIO code taken from mac_esp.c where the reselection timeout issue was
> debugged and fixed first, with the following modifications:
> 
> esp_reselect_with_tag explicitly sets esp->cmd_block_dma as target address
> for the message bytes. Fixup to use kernel virtual address esp->cmd_block
> in PIO transfer if DMA address is esp->cmd_block_dma.
> 
> Signed-off-by: Michael Schmitz 
> 
> ---
> 
> Changes since v1:
> 
> Fixed issues raised by Finn Thain in initial code review:
> 
> - use KBUILD_MODNAME for driver name string.
> - use pr_fmt() for pr_* format prefix.
> - clean up DMA error reporting: clear error flag before each DMA
>   operation, set error flag on PIO error. Don't test phase in dma_err hook.
> - change confusing comment about semantics of read flag, add comments
>   indicating DMA direction to DMA setup hooks.
> - drop spurious braces around switch clauses.
> - lift cfreq setting out of ID switch clauses.
> - fix indentation.
> - fix error codes on probe fail.
> - drop check for board ID when unmapping DMA regs in error handling:
>   the ioaddr > 0xff test already catches all cases where the DMA
>   registers were ioremapped.
> - dynamically alloc zorro_private_data.
> - fix use of driver_data field (don't mix host and zorro_esp_priv
>   pointers). Note: require esp pointer in zorro_esp_priv to find host
>   pointer!
> - back out phase bits changes to pio_cmd !write branch introduced
>   to cope with ESP SELAS command. We don't use that code so keep
>   it in sync with Finn's version.
> - use esp_ops.dma_length_limit() to limit transfer size. After review
>   of old driver code, use 0xff max transfer size throughout.
> 
> Fixed issues raised by Geert Uytterhoven:
> 
> - dynamically alloc zorro_private_data, store as device drvdata.
> - store ctrl_data for CyberStormI in driver private data.
> - use dma_sync_single_for_device() instead of cache_push/clear.
> - handle case of duplicate board identity - check whether board is
>   Zorro III or Zorro II (use ROM resource data for this). Also fix
>   up DMA mask for Zorro II boards to 32 bits (these are really CPU
>   expansion slot boards).
> - remove zorro3 field from driver_data struct (now in private data).
> - add braces around ambiguous if - else construct.
> - use named structs instead of array for board config data.
> - use scsi_option driver data flag for boards with optional ESP.
> 
> Other improvements and bugfixes
> 
> - fix Zorro device table error (duplicate ID used, also raised
>   by Kars de Jong).
> - error code fixup in error handling path.
> - add separate DMA setup for Blizzard 1230 II board.
> - add support for Cyberstorm II board.
> - add register structs and DMA setup for Zorro III Fastlane board,
>   following logic from old fastlane.c driver. Wire up Fastlane DMA
>   and interrupt status routines, map the necessary low 24 bit board
>   address space used for DMA target address setting. Clean up DMA
>   register space ioremap() branch for Zorro III boards (currently
>   Fastlane only) to end confusion about what to do in error recovery.
> - use esp_ops.fastlane_esp_dma_invalidate() on Fastlane (and skip
>   fastlane_esp_reset_dma() in DMA setup).
> - credit Tuomas Vainikka for contributing Blizzard 1230 code (and
>   testing).
> - clarify comment about unsupported Oktagon SCSI board.
> - remove unused const definitions carried over from old driver.
> 
> Changes since v2:
> 
> Issues raised by Finn Thain:
> 
> - add SPDX-License-Identifier.

Re: [PATCH v3] m68k/amiga - Amiga Zorro NCR53C9x boards: new zorro_esp.c

2018-03-14 Thread Geert Uytterhoeven
Hi Michael,

On Wed, Mar 14, 2018 at 9:23 AM, Michael Schmitz  wrote:
> thanks for the review - largely uncontroversial except for the volatile...

The presence of volatile in drivers is always considered controversial ;-)

> Am 14.03.2018 um 20:49 schrieb Geert Uytterhoeven:
>>> +/* Blizzard 1230 DMA interface */
>>> +
>>> +struct blz1230_dma_registers {
>>> +   volatile unsigned char dma_addr;/* DMA address  
>>> [0x] */
>>
>> volatile considered harmful.
>
> Yes, I saw that. I also saw gcc miscompile the DMA set-up (in
> particular, the case where three bytes of the transfer address are
> stuffed consecutively into the same DMA address register).
>
>> If you would use proper *{read,write}*() accessors instead of direct
>> assignments,
>> you can drop the volatile's here.
>
> Meaning writeb(val, reg) instead of reg = val?
>
> #define out_8(addr,b) (void)((*(__force volatile u8 *) (addr)) = (b))
>
> nicely hides the 'volatile' but suggests I also need to pass it a
> pointer, so
>
> writeb((addr >> 24) & 0xff, &dregs->dma_addr)

Yes, you have to pass it an (__iomem) pointer.

> would do the same as
>
> dregs->dma_addr  = (addr >> 24) & 0xff; ??

Right.

> I'll have to compare the assembly generated by the two versions before I
> dare test that, but I'll give that a try. Liberal use of wmb() did fix
> the miscompile but that just looked too ugly.

Using the macros should have the same effect due to the embedded volatile.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH v3] m68k/amiga - Amiga Zorro NCR53C9x boards: new zorro_esp.c

2018-03-14 Thread Michael Schmitz
Hi Geert,

thanks for the review - largely uncontroversial except for the volatile...

Am 14.03.2018 um 20:49 schrieb Geert Uytterhoeven:
>> +/* Blizzard 1230 DMA interface */
>> +
>> +struct blz1230_dma_registers {
>> +   volatile unsigned char dma_addr;/* DMA address  [0x] 
>> */
> 
> volatile considered harmful.

Yes, I saw that. I also saw gcc miscompile the DMA set-up (in
particular, the case where three bytes of the transfer address are
stuffed consecutively into the same DMA address register).

> If you would use proper *{read,write}*() accessors instead of direct
> assignments,
> you can drop the volatile's here.

Meaning writeb(val, reg) instead of reg = val?

#define out_8(addr,b) (void)((*(__force volatile u8 *) (addr)) = (b))

nicely hides the 'volatile' but suggests I also need to pass it a
pointer, so

writeb((addr >> 24) & 0xff, &dregs->dma_addr)

would do the same as

dregs->dma_addr  = (addr >> 24) & 0xff; ??

I'll have to compare the assembly generated by the two versions before I
dare test that, but I'll give that a try. Liberal use of wmb() did fix
the miscompile but that just looked too ugly.

>> +#define ZORRO_ESP_PIO_LOOP(operands, reg1) \
>> +   { \
>> +   asm volatile ( \
>> +"1: moveb " operands "\n" \
>> +"   subqw #1,%1   \n" \
>> +"   jbne 1b   \n" \
>> +: "+a" (addr), "+r" (reg1) \
>> +: "a" (fifo)); \
>> +   }
> 
> Please pass "addr" and "fifo" as macro parameters, too, so it's easier for
> the reviewer to notice they are used.

Yes, I can do that (meaning Finn would need to make the same change to
keep our versions in sync).

>> +   /* Switch to the correct the DMA routine and clock frequency. */
>> +   switch (ent->id) {
>> +   case ZORRO_PROD_PHASE5_BLIZZARD_2060:
>> +   zorro_esp_ops.send_dma_cmd = zorro_esp_send_blz2060_dma_cmd;
> 
> Please use function pointers in struct zorro_driver_data, so you don't need
> a switch() here (except for Fastlane vs. B1230II).

At that point, the Blizzard 1230 II zorro_driver_data has been replaced
by the Fastlane one so the correct function pointer would be used. I
didn't realize that also nicely solves my problem here.

Thanks!

Cheers,

Michael


Re: [PATCH v3] m68k/amiga - Amiga Zorro NCR53C9x boards: new zorro_esp.c

2018-03-14 Thread Geert Uytterhoeven
Hi Michael,

On Mon, Mar 12, 2018 at 8:26 AM, Michael Schmitz  wrote:
> From: Michael Schmitz 
>
> New combined SCSI driver for all ESP based Zorro SCSI boards for
> m68k Amiga.
>
> Code largely based on board specific parts of the old drivers (blz1230.c,
> blz2060.c, cyberstorm.c, cyberstormII.c, fastlane.c which were removed
> after the 2.6 kernel series for lack of maintenance) with contributions
> by Tuomas Vainikka (TCQ bug tests and workaround) and Finn Thain (TCQ
> bugfix by use of PIO in extended message in transfer).
>
> New Kconfig option and Makefile entries for new Amiga Zorro ESP SCSI
> driver included in this patch.
>
> Use DMA transfers wherever possible, with board-specific DMA set-up
> functions copied from the old driver code. Three byte reselection messages
>  do appear to cause DMA timeouts. So wire up a PIO transfer routine for
> these instead.
>
> PIO code taken from mac_esp.c where the reselection timeout issue was
> debugged and fixed first, with the following modifications:
>
> esp_reselect_with_tag explicitly sets esp->cmd_block_dma as target address
> for the message bytes. Fixup to use kernel virtual address esp->cmd_block
> in PIO transfer if DMA address is esp->cmd_block_dma.
>
> Signed-off-by: Michael Schmitz 
>
> ---
>
> Changes since v1:

[...]

Thanks for the update!

A few more comments below, mostly stylistic / practice.

> --- /dev/null
> +++ b/drivers/scsi/zorro_esp.c

> +struct zorro_driver_data {
> +   const char *name;
> +   unsigned long offset;
> +   unsigned long dma_offset;
> +   int absolute;   /* offset is absolute address */
> +   int scsi_option;
> +};
> +
> +static struct zorro_driver_data cyberstormI_data = {

const

> +static struct zorro_device_id zorro_esp_zorro_tbl[] = {

const

> +   {
> +   .id = ZORRO_PROD_PHASE5_BLIZZARD_1220_CYBERSTORM,
> +   .driver_data = (unsigned long)&cyberstormI_data,
> +   },
> +   {
> +   .id = ZORRO_PROD_PHASE5_CYBERSTORM_MK_II,
> +   .driver_data = (unsigned long)&cyberstormII_data,
> +   },
> +   {
> +   .id = ZORRO_PROD_PHASE5_BLIZZARD_2060,
> +   .driver_data = (unsigned long)&blizzard2060_data,
> +   },
> +   {
> +   .id = ZORRO_PROD_PHASE5_BLIZZARD_1230_IV_1260,
> +   .driver_data = (unsigned long)&blizzard1230_data,
> +   },
> +   {
> +   .id = 
> ZORRO_PROD_PHASE5_BLIZZARD_1230_II_FASTLANE_Z3_CYBERSCSI_CYBERSTORM060,
> +   .driver_data = (unsigned long)&blizzard1230II_data,
> +   },
> +   { 0 }
> +};
> +MODULE_DEVICE_TABLE(zorro, zorro_esp_zorro_tbl);
> +
> +/* Blizzard 1230 DMA interface */
> +
> +struct blz1230_dma_registers {
> +   volatile unsigned char dma_addr;/* DMA address  [0x] 
> */

volatile considered harmful.
If you would use proper *{read,write}*() accessors instead of direct
assignments,
you can drop the volatile's here.

> +#define ZORRO_ESP_GET_PRIV(esp) ((struct zorro_esp_priv *) \
> +   dev_get_drvdata(esp->dev))

This macro can be dropped, just use "dev_get_drvdata(esp->dev)" directly.
No cast is needed.

> +static int fastlane_esp_irq_pending(struct esp *esp)
> +{
> +   struct fastlane_dma_registers *dregs =
> +   (struct fastlane_dma_registers *) (esp->dma_regs);

struct fastlane_dma_registers __iomem *dregs = esp->dma_regs;

(and make C=1 will become (more) happy)

> +   unsigned char dma_status;
> +
> +   dma_status = dregs->cond_reg;

readb().

> +#define ZORRO_ESP_PIO_LOOP(operands, reg1) \
> +   { \
> +   asm volatile ( \
> +"1: moveb " operands "\n" \
> +"   subqw #1,%1   \n" \
> +"   jbne 1b   \n" \
> +: "+a" (addr), "+r" (reg1) \
> +: "a" (fifo)); \
> +   }

Please pass "addr" and "fifo" as macro parameters, too, so it's easier for
the reviewer to notice they are used.

> +#define ZORRO_ESP_PIO_FILL(operands, reg1) \
> +   { \
> +   asm volatile ( \
> +"   moveb " operands "\n" \
> +"   moveb " operands "\n" \
> +"   moveb " operands "\n" \
> +"   moveb " operands "\n" \
> +"   moveb " operands "\n" \
> +"   moveb " operands "\n" \
> +"   moveb " operands "\n" \
> +"   moveb " operands "\n" \
> +"   moveb " operands "\n" \
> +"   moveb " operands "\n" \
> +"   moveb " operands "\n" \
> +"   moveb " operands "\n" \
> +"   moveb " operands "\n" \
> +"   moveb " operands "\n" \
> +"   moveb " operands "\n" \
> +"   moveb " operands "\n" \
> +"   subqw #8,%1   \n" \
> +"   subqw #8,%1   \n" \
> +: "+a" (addr), "+r" (reg1) \
> +  

Re: [PATCH v3] m68k/amiga - Amiga Zorro NCR53C9x boards: new zorro_esp.c

2018-03-14 Thread Vainikka Tuomas
The config description lists 53c700 devices, not ESP devices?

-Tuomas

From: linux-m68k-ow...@vger.kernel.org  on 
behalf of Michael Schmitz 
Sent: 12 March 2018 09:26:40
To: linux-scsi@vger.kernel.org
Cc: linux-m...@vger.kernel.org; da...@davemloft.net; ge...@linux-m68k.org; 
fth...@telegraphics.com.au; Michael Schmitz; Michael Schmitz
Subject: [PATCH v3] m68k/amiga - Amiga Zorro NCR53C9x boards: new zorro_esp.c

From: Michael Schmitz 

New combined SCSI driver for all ESP based Zorro SCSI boards for
m68k Amiga.

Code largely based on board specific parts of the old drivers (blz1230.c,
blz2060.c, cyberstorm.c, cyberstormII.c, fastlane.c which were removed
after the 2.6 kernel series for lack of maintenance) with contributions
by Tuomas Vainikka (TCQ bug tests and workaround) and Finn Thain (TCQ
bugfix by use of PIO in extended message in transfer).

New Kconfig option and Makefile entries for new Amiga Zorro ESP SCSI
driver included in this patch.

Use DMA transfers wherever possible, with board-specific DMA set-up
functions copied from the old driver code. Three byte reselection messages
 do appear to cause DMA timeouts. So wire up a PIO transfer routine for
these instead.

PIO code taken from mac_esp.c where the reselection timeout issue was
debugged and fixed first, with the following modifications:

esp_reselect_with_tag explicitly sets esp->cmd_block_dma as target address
for the message bytes. Fixup to use kernel virtual address esp->cmd_block
in PIO transfer if DMA address is esp->cmd_block_dma.

Signed-off-by: Michael Schmitz 

---

Changes since v1:

Fixed issues raised by Finn Thain in initial code review:

- use KBUILD_MODNAME for driver name string.
- use pr_fmt() for pr_* format prefix.
- clean up DMA error reporting: clear error flag before each DMA
  operation, set error flag on PIO error. Don't test phase in dma_err hook.
- change confusing comment about semantics of read flag, add comments
  indicating DMA direction to DMA setup hooks.
- drop spurious braces around switch clauses.
- lift cfreq setting out of ID switch clauses.
- fix indentation.
- fix error codes on probe fail.
- drop check for board ID when unmapping DMA regs in error handling:
  the ioaddr > 0xff test already catches all cases where the DMA
  registers were ioremapped.
- dynamically alloc zorro_private_data.
- fix use of driver_data field (don't mix host and zorro_esp_priv
  pointers). Note: require esp pointer in zorro_esp_priv to find host
  pointer!
- back out phase bits changes to pio_cmd !write branch introduced
  to cope with ESP SELAS command. We don't use that code so keep
  it in sync with Finn's version.
- use esp_ops.dma_length_limit() to limit transfer size. After review
  of old driver code, use 0xff max transfer size throughout.

Fixed issues raised by Geert Uytterhoven:

- dynamically alloc zorro_private_data, store as device drvdata.
- store ctrl_data for CyberStormI in driver private data.
- use dma_sync_single_for_device() instead of cache_push/clear.
- handle case of duplicate board identity - check whether board is
  Zorro III or Zorro II (use ROM resource data for this). Also fix
  up DMA mask for Zorro II boards to 32 bits (these are really CPU
  expansion slot boards).
- remove zorro3 field from driver_data struct (now in private data).
- add braces around ambiguous if - else construct.
- use named structs instead of array for board config data.
- use scsi_option driver data flag for boards with optional ESP.

Other improvements and bugfixes

- fix Zorro device table error (duplicate ID used, also raised
  by Kars de Jong).
- error code fixup in error handling path.
- add separate DMA setup for Blizzard 1230 II board.
- add support for Cyberstorm II board.
- add register structs and DMA setup for Zorro III Fastlane board,
  following logic from old fastlane.c driver. Wire up Fastlane DMA
  and interrupt status routines, map the necessary low 24 bit board
  address space used for DMA target address setting. Clean up DMA
  register space ioremap() branch for Zorro III boards (currently
  Fastlane only) to end confusion about what to do in error recovery.
- use esp_ops.fastlane_esp_dma_invalidate() on Fastlane (and skip
  fastlane_esp_reset_dma() in DMA setup).
- credit Tuomas Vainikka for contributing Blizzard 1230 code (and
  testing).
- clarify comment about unsupported Oktagon SCSI board.
- remove unused const definitions carried over from old driver.

Changes since v2:

Issues raised by Finn Thain:

- add SPDX-License-Identifier.
- remove unused ratelimit.h.
- drop phys_to_virt() in PIO transfer routine, after ensuring PIO is only
  used for message in transfers to esp->command_block. This obviates any
  need for finding the virtual address corresponding to a DMA handle.
- drop BUG_ON(!(cmd & ESP_CMD_DMA)) assertion in DMA setup. Short of changes
  to the core ESP driver, this can never trigger.
- make ioremap() of DMA address range conditional on

Re: [PATCH] scsi: iscsi_tcp: set BDI_CAP_STABLE_WRITES when data digest enabled

2018-03-14 Thread jianchao.wang
Would anyone please take a review at this patch ?

Thanks in advace
Jianchao

On 03/07/2018 08:29 PM, Jianchao Wang wrote:
> iscsi tcp will first send out data, then calculate and send data
> digest. If we don't have BDI_CAP_STABLE_WRITES, the page cache will
> be written in spite of the on going writeback. Consequently, wrong
> digest will be got and sent to target.
> 
> To fix this, set BDI_CAP_STABLE_WRITES when data digest is enabled
> in iscsi_tcp .slave_configure callback.
> 
> Signed-off-by: Jianchao Wang 
> ---
>  drivers/scsi/iscsi_tcp.c | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
> index 6198559..261c686 100644
> --- a/drivers/scsi/iscsi_tcp.c
> +++ b/drivers/scsi/iscsi_tcp.c
> @@ -37,6 +37,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -954,6 +955,12 @@ static int iscsi_sw_tcp_slave_alloc(struct scsi_device 
> *sdev)
>  
>  static int iscsi_sw_tcp_slave_configure(struct scsi_device *sdev)
>  {
> + struct iscsi_sw_tcp_host *tcp_sw_host = iscsi_host_priv(sdev->host);
> + struct iscsi_session *session = tcp_sw_host->session;
> + struct iscsi_conn *conn = session->leadconn;
> +
> + if (conn->datadgst_en)
> + sdev->request_queue->backing_dev_info->capabilities |= 
> BDI_CAP_STABLE_WRITES;
>   blk_queue_bounce_limit(sdev->request_queue, BLK_BOUNCE_ANY);
>   blk_queue_dma_alignment(sdev->request_queue, 0);
>   return 0;
>