[PATCH 4/4] mpt3sas: Update driver version to 27.101.00.00.

2018-12-06 Thread Suganath Prabu
Update driver version from 27.100.00.00 to 27.101.00.00.

Signed-off-by: Suganath Prabu 
---
 drivers/scsi/mpt3sas/mpt3sas_base.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
b/drivers/scsi/mpt3sas/mpt3sas_base.h
index 3a294b9..8003519 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -75,9 +75,9 @@
 #define MPT3SAS_DRIVER_NAME"mpt3sas"
 #define MPT3SAS_AUTHOR "Avago Technologies "
 #define MPT3SAS_DESCRIPTION"LSI MPT Fusion SAS 3.0 Device Driver"
-#define MPT3SAS_DRIVER_VERSION "27.100.00.00"
+#define MPT3SAS_DRIVER_VERSION "27.101.00.00"
 #define MPT3SAS_MAJOR_VERSION  27
-#define MPT3SAS_MINOR_VERSION  100
+#define MPT3SAS_MINOR_VERSION  101
 #define MPT3SAS_BUILD_VERSION  0
 #define MPT3SAS_RELEASE_VERSION00
 
-- 
1.8.3.1



[PATCH 3/4] mpt3sas: Replace readl with ioc->base_readl.

2018-12-06 Thread Suganath Prabu
Use ioc->base_readl to restrict the readl retries to only
Aero controllers.

Signed-off-by: Suganath Prabu 
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 39 +++--
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index d371c8e..8a0851e 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -742,7 +742,7 @@ mpt3sas_halt_firmware(struct MPT3SAS_ADAPTER *ioc)
 
dump_stack();
 
-   doorbell = readl(>chip->Doorbell);
+   doorbell = ioc->base_readl(>chip->Doorbell);
if ((doorbell & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT)
mpt3sas_base_fault_info(ioc , doorbell);
else {
@@ -1351,10 +1351,10 @@ _base_mask_interrupts(struct MPT3SAS_ADAPTER *ioc)
u32 him_register;
 
ioc->mask_interrupts = 1;
-   him_register = readl(>chip->HostInterruptMask);
+   him_register = ioc->base_readl(>chip->HostInterruptMask);
him_register |= MPI2_HIM_DIM + MPI2_HIM_RIM + MPI2_HIM_RESET_IRQ_MASK;
writel(him_register, >chip->HostInterruptMask);
-   readl(>chip->HostInterruptMask);
+   ioc->base_readl(>chip->HostInterruptMask);
 }
 
 /**
@@ -1368,7 +1368,7 @@ _base_unmask_interrupts(struct MPT3SAS_ADAPTER *ioc)
 {
u32 him_register;
 
-   him_register = readl(>chip->HostInterruptMask);
+   him_register = ioc->base_readl(>chip->HostInterruptMask);
him_register &= ~MPI2_HIM_RIM;
writel(him_register, >chip->HostInterruptMask);
ioc->mask_interrupts = 0;
@@ -4880,7 +4880,7 @@ mpt3sas_base_get_iocstate(struct MPT3SAS_ADAPTER *ioc, 
int cooked)
 {
u32 s, sc;
 
-   s = readl(>chip->Doorbell);
+   s = ioc->base_readl(>chip->Doorbell);
sc = s & MPI2_IOC_STATE_MASK;
return cooked ? sc : s;
 }
@@ -4936,7 +4936,7 @@ _base_wait_for_doorbell_int(struct MPT3SAS_ADAPTER *ioc, 
int timeout)
count = 0;
cntdn = 1000 * timeout;
do {
-   int_status = readl(>chip->HostInterruptStatus);
+   int_status = ioc->base_readl(>chip->HostInterruptStatus);
if (int_status & MPI2_HIS_IOC2SYS_DB_STATUS) {
dhsprintk(ioc,
  ioc_info(ioc, "%s: successful count(%d), 
timeout(%d)\n",
@@ -4962,7 +4962,7 @@ _base_spin_on_doorbell_int(struct MPT3SAS_ADAPTER *ioc, 
int timeout)
count = 0;
cntdn = 2000 * timeout;
do {
-   int_status = readl(>chip->HostInterruptStatus);
+   int_status = ioc->base_readl(>chip->HostInterruptStatus);
if (int_status & MPI2_HIS_IOC2SYS_DB_STATUS) {
dhsprintk(ioc,
  ioc_info(ioc, "%s: successful count(%d), 
timeout(%d)\n",
@@ -5000,14 +5000,14 @@ _base_wait_for_doorbell_ack(struct MPT3SAS_ADAPTER 
*ioc, int timeout)
count = 0;
cntdn = 1000 * timeout;
do {
-   int_status = readl(>chip->HostInterruptStatus);
+   int_status = ioc->base_readl(>chip->HostInterruptStatus);
if (!(int_status & MPI2_HIS_SYS2IOC_DB_STATUS)) {
dhsprintk(ioc,
  ioc_info(ioc, "%s: successful count(%d), 
timeout(%d)\n",
   __func__, count, timeout));
return 0;
} else if (int_status & MPI2_HIS_IOC2SYS_DB_STATUS) {
-   doorbell = readl(>chip->Doorbell);
+   doorbell = ioc->base_readl(>chip->Doorbell);
if ((doorbell & MPI2_IOC_STATE_MASK) ==
MPI2_IOC_STATE_FAULT) {
mpt3sas_base_fault_info(ioc , doorbell);
@@ -5042,7 +5042,7 @@ _base_wait_for_doorbell_not_used(struct MPT3SAS_ADAPTER 
*ioc, int timeout)
count = 0;
cntdn = 1000 * timeout;
do {
-   doorbell_reg = readl(>chip->Doorbell);
+   doorbell_reg = ioc->base_readl(>chip->Doorbell);
if (!(doorbell_reg & MPI2_DOORBELL_USED)) {
dhsprintk(ioc,
  ioc_info(ioc, "%s: successful count(%d), 
timeout(%d)\n",
@@ -5157,13 +5157,13 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER 
*ioc, int request_bytes,
__le32 *mfp;
 
/* make sure doorbell is not in use */
-   if ((readl(>chip->Doorbell) & MPI2_DOORBELL_USED)) {
+   if ((ioc->base_readl(>chip->Doorbell) & MPI2_DOORBELL_USED)) {
ioc_err(ioc, "doorbell is in use (line=%d)\n", __LINE__);
return -EFAULT;
}
 
/* clear pending doorbell interrupts from previous state changes */
-   if (readl(>chip->HostInterruptStatus) &
+   if (ioc->base_readl(>chip->HostInterruptStatus) &
MPI2_HIS_IOC2SYS_DB_STATUS)
  

[PATCH 1/4] mpt3sas: Introduce flag for aero based controllers.

2018-12-06 Thread Suganath Prabu
Adding flag "is_aero_ioc" to differentiate aero based controllers
from other gen35 controllers.

Signed-off-by: Suganath Prabu 
---
 drivers/scsi/mpt3sas/mpt3sas_base.h  |  1 +
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 14 --
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
b/drivers/scsi/mpt3sas/mpt3sas_base.h
index 4b8b602..f200929 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -1399,6 +1399,7 @@ struct MPT3SAS_ADAPTER {
void*device_remove_in_progress;
u16 device_remove_in_progress_sz;
u8  is_gen35_ioc;
+   u8  is_aero_ioc;
PUT_SMID_IO_FP_HIP put_smid_scsi_io;
 
 };
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 5b9806d..039dee4 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -10366,10 +10366,6 @@ _scsih_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
ioc->id = mpt3_ids++;
sprintf(ioc->driver_name, "%s", MPT3SAS_DRIVER_NAME);
switch (pdev->device) {
-   case MPI26_MFGPAGE_DEVID_CFG_SEC_3816:
-   case MPI26_MFGPAGE_DEVID_CFG_SEC_3916:
-   dev_info(>dev,
-   "HBA is in Configurable Secure mode\n");
case MPI26_MFGPAGE_DEVID_SAS3508:
case MPI26_MFGPAGE_DEVID_SAS3508_1:
case MPI26_MFGPAGE_DEVID_SAS3408:
@@ -10377,12 +10373,18 @@ _scsih_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
case MPI26_MFGPAGE_DEVID_SAS3516_1:
case MPI26_MFGPAGE_DEVID_SAS3416:
case MPI26_MFGPAGE_DEVID_SAS3616:
+   ioc->is_gen35_ioc = 1;
+   break;
+   case MPI26_MFGPAGE_DEVID_CFG_SEC_3816:
+   case MPI26_MFGPAGE_DEVID_CFG_SEC_3916:
+   dev_info(>dev,
+   "HBA is in Configurable Secure mode\n");
case MPI26_MFGPAGE_DEVID_HARD_SEC_3816:
case MPI26_MFGPAGE_DEVID_HARD_SEC_3916:
-   ioc->is_gen35_ioc = 1;
+   ioc->is_aero_ioc = ioc->is_gen35_ioc = 1;
break;
default:
-   ioc->is_gen35_ioc = 0;
+   ioc->is_gen35_ioc = ioc->is_aero_ioc = 0;
}
if ((ioc->hba_mpi_version_belonged == MPI25_VERSION &&
pdev->revision >= SAS3_PCI_DEVICE_C0_REVISION) ||
-- 
1.8.3.1



[PATCH 2/4] mpt3sas: Add separate function for aero doorbell reads.

2018-12-06 Thread Suganath Prabu
Sometimes Aero controllers appears to be returning bad data (0)
for doorbell register read and if retries are performed immediately
after the bad read, they return good data.

Workaround is added to retry read from doorbell registers
for maximum three times if driver get the zero.
Added functions base_readl_aero for Aero IOC and base_readl for
gen35 and other controllers.

Signed-off-by: Suganath Prabu 
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 30 ++
 drivers/scsi/mpt3sas/mpt3sas_base.h |  2 ++
 2 files changed, 32 insertions(+)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 9254b52..d371c8e 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -157,6 +157,32 @@ module_param_call(mpt3sas_fwfault_debug, 
_scsih_set_fwfault_debug,
param_get_int, _fwfault_debug, 0644);
 
 /**
+ * _base_readl_aero - retry readl for max three times.
+ * @addr - MPT Fusion system interface register address
+ *
+ * Retry the readl() for max three times if it gets zero value
+ * while reading the system interface register.
+ */
+static inline u32
+_base_readl_aero(const volatile void __iomem *addr)
+{
+   u32 i = 0, ret_val;
+
+   do {
+   ret_val = readl(addr);
+   i++;
+   } while (ret_val == 0 && i < 3);
+
+   return ret_val;
+}
+
+static inline u32
+_base_readl(const volatile void __iomem *addr)
+{
+   return readl(addr);
+}
+
+/**
  * _base_clone_reply_to_sys_mem - copies reply to reply free iomem
  *   in BAR0 space.
  *
@@ -6398,6 +6424,10 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
 
ioc->rdpq_array_enable_assigned = 0;
ioc->dma_mask = 0;
+   if (ioc->is_aero_ioc)
+   ioc->base_readl = &_base_readl_aero;
+   else
+   ioc->base_readl = &_base_readl;
r = mpt3sas_base_map_resources(ioc);
if (r)
goto out_free_resources;
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
b/drivers/scsi/mpt3sas/mpt3sas_base.h
index f200929..3a294b9 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -912,6 +912,7 @@ typedef void (*NVME_BUILD_PRP)(struct MPT3SAS_ADAPTER *ioc, 
u16 smid,
 typedef void (*PUT_SMID_IO_FP_HIP) (struct MPT3SAS_ADAPTER *ioc, u16 smid,
u16 funcdep);
 typedef void (*PUT_SMID_DEFAULT) (struct MPT3SAS_ADAPTER *ioc, u16 smid);
+typedef u32 (*BASE_READ_REG) (const volatile void __iomem *addr);
 
 /* IOC Facts and Port Facts converted from little endian to cpu */
 union mpi3_version_union {
@@ -1392,6 +1393,7 @@ struct MPT3SAS_ADAPTER {
u8  hide_drives;
spinlock_t  diag_trigger_lock;
u8  diag_trigger_active;
+   BASE_READ_REG   base_readl;
struct SL_WH_MASTER_TRIGGER_T diag_trigger_master;
struct SL_WH_EVENT_TRIGGERS_T diag_trigger_event;
struct SL_WH_SCSI_TRIGGERS_T diag_trigger_scsi;
-- 
1.8.3.1



[PATCH 0/4] mpt3sas: Fix hardware bug in aero controllers.

2018-12-06 Thread Suganath Prabu
Problem statement:
Sometimes aero controllers appears to be returning bad data (0)
for doorbell register read and if retries are performed immediately
after the bad read, they return good data.

Fix:
In below four patches added workaround to retry read operation from
controller doorbell registers for maximum three times, if read
returns zero.

Suganath Prabu (4):
  mpt3sas: Introduce flag for aero based controllers.
  mpt3sas: Add separate function for aero doorbell reads.
  mpt3sas: Replace readl with ioc->base_readl.
  mpt3sas: Update driver version to 27.101.00.00.

 drivers/scsi/mpt3sas/mpt3sas_base.c  | 69 ++--
 drivers/scsi/mpt3sas/mpt3sas_base.h  |  7 ++--
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 14 
 3 files changed, 63 insertions(+), 27 deletions(-)

-- 
1.8.3.1



[PATCH] Revert "scsi: qla2xxx: Fix NVMe Target discovery"

2018-12-06 Thread Himanshu Madhani
This reverts commit db186382af21e926e90df19499475f2552192b77.

This commit introduced regression with FCP discovery so revert
it back to fix discovery for FCP luns

Cc: 
Signed-off-by: Himanshu Madhani 
---
Hi Martin, 

This patch has introduced regression for LUN discovery with FC. 

Please apply this revert to 4.20/scsi-fixes branch at your earliest convenience.

Thanks,
Himanshu
---
 drivers/scsi/qla2xxx/qla_os.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index b658b9a5eb1e..d0ecc729a90a 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -4886,10 +4886,10 @@ void qla24xx_create_new_sess(struct scsi_qla_host *vha, 
struct qla_work_evt *e)
fcport->d_id = e->u.new_sess.id;
fcport->flags |= FCF_FABRIC_DEVICE;
fcport->fw_login_state = DSC_LS_PLOGI_PEND;
-   if (e->u.new_sess.fc4_type & FS_FC4TYPE_FCP)
+   if (e->u.new_sess.fc4_type == FS_FC4TYPE_FCP)
fcport->fc4_type = FC4_TYPE_FCP_SCSI;
 
-   if (e->u.new_sess.fc4_type & FS_FC4TYPE_NVME) {
+   if (e->u.new_sess.fc4_type == FS_FC4TYPE_NVME) {
fcport->fc4_type = FC4_TYPE_OTHER;
fcport->fc4f_nvme = FC4_TYPE_NVME;
}
-- 
2.12.0



Re: [PATCH 01/10] gdth: refactor ioc_general

2018-12-06 Thread Finn Thain


On Thu, 6 Dec 2018, Christoph Hellwig wrote:

> This function is a huge mess with duplicated error handling.  Split out
> a few useful helpers and use goto labels to untangle the error handling
> and no-data ioctl handling.
> 
> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/scsi/gdth.c | 244 +++-
>  1 file changed, 126 insertions(+), 118 deletions(-)
> 
> diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
> index 16709735b546..45e67d4cb3af 100644
> --- a/drivers/scsi/gdth.c
> +++ b/drivers/scsi/gdth.c
> @@ -4155,131 +4155,139 @@ static int ioc_resetdrv(void __user *arg, char 
> *cmnd)
>  return 0;
>  }
>  
> -static int ioc_general(void __user *arg, char *cmnd)
> +static void gdth_ioc_addr32(gdth_ha_str *ha, gdth_ioctl_general *gen,
> + u64 paddr)
>  {
> -gdth_ioctl_general gen;
> -char *buf = NULL;
> -u64 paddr; 
> -gdth_ha_str *ha;
> -int rval;
> + if (ha->cache_feat & SCATTER_GATHER) {
> + gen->command.u.cache.DestAddr = 0x;
> + gen->command.u.cache.sg_canz = 1;
> + gen->command.u.cache.sg_lst[0].sg_ptr = (u32)paddr;
> + gen->command.u.cache.sg_lst[0].sg_len = gen->data_len;
> + gen->command.u.cache.sg_lst[1].sg_len = 0;
> + } else {
> + gen->command.u.cache.DestAddr = paddr;
> + gen->command.u.cache.sg_canz = 0;
> + }
> +}
>  
> -if (copy_from_user(, arg, sizeof(gdth_ioctl_general)))
> -return -EFAULT;
> -ha = gdth_find_ha(gen.ionode);
> -if (!ha)
> -return -EFAULT;
> +static void gdth_ioc_addr64(gdth_ha_str *ha, gdth_ioctl_general *gen,
> + u64 paddr)
> +{
> + if (ha->cache_feat & SCATTER_GATHER) {
> + gen->command.u.cache64.DestAddr = (u64)-1;
> + gen->command.u.cache64.sg_canz = 1;
> + gen->command.u.cache64.sg_lst[0].sg_ptr = paddr;
> + gen->command.u.cache64.sg_lst[0].sg_len = gen->data_len;
> + gen->command.u.cache64.sg_lst[1].sg_len = 0;
> + } else {
> + gen->command.u.cache64.DestAddr = paddr;
> + gen->command.u.cache64.sg_canz = 0;
> + }
> +}
>  
> -if (gen.data_len > INT_MAX)
> -return -EINVAL;
> -if (gen.sense_len > INT_MAX)
> -return -EINVAL;
> -if (gen.data_len + gen.sense_len > INT_MAX)
> -return -EINVAL;
> +static void gdth_ioc_cacheservice(gdth_ha_str *ha, gdth_ioctl_general *gen,
> + u64 paddr)
> +{
> + if (ha->cache_feat & GDT_64BIT) {
> + /* copy elements from 32-bit IOCTL structure */
> + gen->command.u.cache64.BlockCnt = gen->command.u.cache.BlockCnt;
> + gen->command.u.cache64.BlockNo = gen->command.u.cache.BlockNo;
> + gen->command.u.cache64.DeviceNo = gen->command.u.cache.DeviceNo;
>  
> -if (gen.data_len + gen.sense_len != 0) {
> -if (!(buf = gdth_ioctl_alloc(ha, gen.data_len + gen.sense_len,
> - FALSE, )))
> -return -EFAULT;
> -if (copy_from_user(buf, arg + sizeof(gdth_ioctl_general),  
> -   gen.data_len + gen.sense_len)) {
> -gdth_ioctl_free(ha, gen.data_len+gen.sense_len, buf, paddr);
> -return -EFAULT;
> -}
> + gdth_ioc_addr64(ha, gen, paddr);
> + } else {
> + gdth_ioc_addr32(ha, gen, paddr);
> + }
> +}
>  
> -if (gen.command.OpCode == GDT_IOCTL) {
> -gen.command.u.ioctl.p_param = paddr;
> -} else if (gen.command.Service == CACHESERVICE) {
> -if (ha->cache_feat & GDT_64BIT) {
> -/* copy elements from 32-bit IOCTL structure */
> -gen.command.u.cache64.BlockCnt = 
> gen.command.u.cache.BlockCnt;
> -gen.command.u.cache64.BlockNo = gen.command.u.cache.BlockNo;
> -gen.command.u.cache64.DeviceNo = 
> gen.command.u.cache.DeviceNo;
> -/* addresses */
> -if (ha->cache_feat & SCATTER_GATHER) {
> -gen.command.u.cache64.DestAddr = (u64)-1;
> -gen.command.u.cache64.sg_canz = 1;
> -gen.command.u.cache64.sg_lst[0].sg_ptr = paddr;
> -gen.command.u.cache64.sg_lst[0].sg_len = gen.data_len;
> -gen.command.u.cache64.sg_lst[1].sg_len = 0;
> -} else {
> -gen.command.u.cache64.DestAddr = paddr;
> -gen.command.u.cache64.sg_canz = 0;
> -}
> -} else {
> -if (ha->cache_feat & SCATTER_GATHER) {
> -gen.command.u.cache.DestAddr = 0x;
> -gen.command.u.cache.sg_canz = 1;
> -gen.command.u.cache.sg_lst[0].sg_ptr = (u32)paddr;
> -gen.command.u.cache.sg_lst[0].sg_len = gen.data_len;
> -

Re: 9305-16i fault 0x5853 (regression from 4.17.2 to 4.19.2) and EEH fence errors

2018-12-06 Thread Matt Corallo
Would be nice to be pointed to the correct place to report major 
regressions, if not here.


Note that the same error occurs:
 * on 4.18.19
 * on 4.19.8-rc1
 * with the latest firmware (16.00.01)
 * on a number of other peoples' powerpc64/power9 hardware.

Note that both 4.18.X and 4.19.Y will, in addition to the above error, 
also occasionally hit EEH fences (on 4.18 this appears to be the 
predominant error, on 4.19 this is less common).


[ 1711.273181] EEH: Frozen PHB#31-PE#fd detected
[ 1711.273235] EEH: PE location: N/A, PHB location: N/A
[ 1711.273297] CPU: 13 PID: 10993 Comm: kworker/u128:4 Tainted: G 
W 4.18.0-3-powerpc64le #1 Debian 4.18.20-2
[ 1711.273307] Workqueue: poll_mpt3sas0_statu _base_fault_reset_work 
[mpt3sas]

[ 1711.273310] Call Trace:
[ 1711.273314] [c00fb5623a80] [c097690c] 
dump_stack+0xb0/0xf4 (unreliable)
[ 1711.273318] [c00fb5623ac0] [c003cad0] 
eeh_dev_check_failure+0x5e0/0x600
[ 1711.273321] [c00fb5623b70] [c003cb7c] 
eeh_check_failure+0x8c/0xd0
[ 1711.273326] [c00fb5623bb0] [c00808b6935c] 
mpt3sas_base_get_iocstate+0x94/0xb0 [mpt3sas]
[ 1711.273330] [c00fb5623bf0] [c00808b6da10] 
_base_fault_reset_work+0xd8/0x310 [mpt3sas]
[ 1711.273334] [c00fb5623c80] [c0129040] 
process_one_work+0x260/0x530
[ 1711.273336] [c00fb5623d20] [c0129398] 
worker_thread+0x88/0x5d0

[ 1711.273340] [c00fb5623dc0] [c0132238] kthread+0x1a8/0x1b0
[ 1711.273344] [c00fb5623e30] [c000bdd4] 
ret_from_kernel_thread+0x5c/0x88

[ 1711.273347] mpt3sas_cm0: SAS host is non-operational 
[ 1711.273690] EEH: Detected PCI bus error on PHB#31-PE#fd
[ 1711.273693] EEH: This PCI device has failed 1 times in the last hour 
and will be permanently disabled after 5 failures.

[ 1711.273694] EEH: Notify device drivers to shutdown
[ 1711.273697] EEH: Beginning: 'error_detected(IO frozen)'
[ 1711.273699] EEH: PE#fd (PCI 0031:01:00.0): Invoking 
mpt3sas->error_detected(IO frozen)

[ 1711.273701] mpt3sas_cm0: PCI error: detected callback, state(2)!!
[ 1711.274838] EEH: PE#fd (PCI 0031:01:00.0): mpt3sas driver reports: 
'need reset'
[ 1711.274839] EEH: Finished:'error_detected(IO frozen)' with aggregate 
recovery state:'need reset'

[ 1711.274842] EEH: Collect temporary log
[ 1711.274861] EEH: of node=0031:01:00.0
[ 1711.274863] EEH: PCI device/vendor: 00c41000
[ 1711.274864] EEH: PCI cmd/status register: 00100142
[ 1711.274865] EEH: PCI-E capabilities and status follow:
[ 1711.274872] EEH: PCI-E 00: 0002d010 10008025 2950 00415083
[ 1711.274878] EEH: PCI-E 10: 1083   
[ 1711.274879] EEH: PCI-E 20: 
[ 1711.274879] EEH: PCI-E AER capability register set follows:
[ 1711.274886] EEH: PCI-E AER 00: 1e020001   00462031
[ 1711.274892] EEH: PCI-E AER 10:  2000 01e0 
[ 1711.274897] EEH: PCI-E AER 20:    
[ 1711.274899] EEH: PCI-E AER 30:  00010015
[ 1711.274900] PHB4 PHB#49 Diag-data (Version: 1)
[ 1711.274901] brdgCtl:0002
[ 1711.274902] RootSts:00060040 00402000 a0830008 00100107 0800
[ 1711.274902] PhbSts: 001c 001c
[ 1711.274903] Lem:00011000  
1000
[ 1711.274904] PhbErr: 0880 0800 
214898000240 a0084000
[ 1711.274905] RxeArbErr:  0008 0008 
07170176 8a82018a
[ 1711.274906] PblErr: 0002 0002 
 
[ 1711.274907] RegbErr:00400040 0040 
8804 

[ 1711.274908] PE[0fd] A/B: 820080230100 8a82018a
[ 1711.274909] PE[100] A/B: 80003bfe 300d2593
[ 1711.274910] PE[1fd] A/B: 8000 8000
[ 1711.274910] EEH: Reset without hotplug activity
[ 1716.201556] EEH: Notify device drivers the completion of reset
[ 1716.201559] EEH: Beginning: 'slot_reset'
[ 1716.201568] EEH: PE#fd (PCI 0031:01:00.0): Invoking mpt3sas->slot_reset()
[ 1716.201569] mpt3sas_cm0: PCI error: slot reset callback!!
[ 1716.201649] mpt3sas 0031:01:00.0: Using 64-bit DMA iommu bypass
[ 1716.201656] mpt3sas_cm0: 64 BIT PCI BUS DMA ADDRESSING SUPPORTED, 
total mem (131847972 kB)
[ 1716.256003] mpt3sas_cm0: CurrentHostPageSize is 0: Setting default 
host page size to 4k
[ 1716.256024] mpt3sas_cm0: MSI-X vectors supported: 96, no of cores: 
64, max_msix_vectors: -1

[ 1716.258361] mpt3sas0-msix0: PCI-MSI-X enabled: IRQ 75
[ 1716.258363] mpt3sas0-msix1: PCI-MSI-X enabled: IRQ 76
[ 1716.258364] mpt3sas0-msix2: PCI-MSI-X enabled: IRQ 77
[ 1716.258365] mpt3sas0-msix3: PCI-MSI-X enabled: IRQ 78
[ 1716.258366] mpt3sas0-msix4: PCI-MSI-X enabled: IRQ 79
[ 1716.258367] mpt3sas0-msix5: PCI-MSI-X enabled: IRQ 89
[ 1716.258368] mpt3sas0-msix6: PCI-MSI-X enabled: IRQ 90
[ 1716.258368] mpt3sas0-msix7: PCI-MSI-X enabled: IRQ 91
[ 1716.258369] 

SCSI reset loop with sym 53c895

2018-12-06 Thread Tobias Klausmann
Hey everybody,

I'm the arch lead for Gentoo Linux on alpha (yes, the arch still
exists). Starting with 4.20-rc*, I get SCSI reset loops shortly
after boot:


aboot: starting kernel boot/vmlinuz-4.20.0-rc3 with arguments ro root=/dev/sda2 
console=ttyS0 loglevel=6
[0.00] Linux version 4.20.0-rc3+ (klausman@monolith) (gcc version 8.2.0 
(Gentoo 8.2.0-r4 p1.5)) #49 SMP
Sun Nov 25 20:23:08 CET 2018
[0.00] Booting on Tsunami variation Clipper using machine vector 
Clipper from SRM
[0.00] Major Options: SMP EV67 LEGACY_START VERBOSE_MCHECK DISCONTIGMEM 
MAGIC_SYSRQ
[0.00] Command line: ro root=/dev/sda2 console=ttyS0 loglevel=6
[0.00] Raw memory layout:
[0.00]  memcluster  0, usage 1, start0, end  256
[0.00]  memcluster  1, usage 0, start  256, end   130985
[0.00]  memcluster  2, usage 1, start   130985, end   131072
[0.00]  memcluster  3, usage 0, start   131072, end  1048562
[0.00]  memcluster  4, usage 1, start  1048562, end  1048576
[0.00] Initializing bootmem allocator on Node ID 0
[0.00]  memcluster  1, usage 0, start  256, end   130985
[0.00]  memcluster  3, usage 0, start   131072, end  1048562
[0.00]  Detected node memory:   start  256, end  1048562
[0.00] 8192K Bcache detected; load hit latency 21 cycles, load miss 
latency 175 cycles
[0.00] Kernel command line: ro root=/dev/sda2 console=ttyS0 loglevel=6
[0.00] Sorting __ex_table...
[0.00] random: get_random_u64 called from 
cache_random_seq_create+0x98/0x1b0 with crng_init=0
[0.00] random: get_random_u32 called from new_slab+0x210/0x700 with 
crng_init=0
[0.00] Turning on RTC interrupts.
[0.069335] random: get_random_u32 called from bucket_table_alloc+0xbc/0x230 
with crng_init=0
[0.069335] random: fast init done
[0.218749] SCSI subsystem initialized
[0.244140] pci 0001:01:03.0: Firmware left e100 interrupts enabled; 
disabling
[0.247070] Initialise system trusted keyrings
[0.272460] Key type asymmetric registered
[0.273437] Asymmetric key parser 'x509' registered
[0.441406] sym0: Symbios NVRAM, ID 7, Fast-40, LVD, parity checking
[0.442382] sym0: open drain IRQ line driver, using on-chip SRAM
[0.443359] sym0: using LOAD/STORE-based firmware.
[0.444335] sym0: SCSI BUS has been reset.
[0.445312] sym0:0: ERROR (81:0) (0-0-0) (0/7/0) @ (scripta 38:f31c0004).
[0.445312] sym0: script cmd = e21c0004
[0.445312] sym0: regdump:
[0.445312]  ca
[0.445312]  00
[0.445312]  00
[0.445312]  07
[0.445312]  47
[0.445312]  00
[0.445312]  00
[0.445312]  0f
[0.445312]  00
[0.445312]  08
[0.445312]  00
[0.445312]  00
[0.445312]  80
[0.445312]  00
[0.445312]  08
[0.445312]  0a
[0.445312]  07
[0.445312]  ff
[0.445312]  ff
[0.445312]  ff
[0.445312]  00
[0.445312]  ff
[0.445312]  ff
[0.445312]  ff
[0.445312] .

(repeats here, forever)

The machine is a Compaq ES40 (4-cpu, 8G of RAM) with two 53c895s,
which have six SCA disks each. Some of these disks are quite old,
over a decade in some cases, but have never had problems (and
booting 4.19.5 works just fine). I haven't tested 4.20-rc5 yet,
but I doubt the behaviour will be different.

As for the rest, it's a pretty normal setup aside from the exotic
arch, no fancy extra buses, no AGP or memory holes.

I'll try to bisect this when the machine can be taken out of
testing and image building, but that might not happen before
Christmas or even the new year.

Any ideas for something to try?

Best,
Tobias

PS: Not subscribed to the list, so please CC me on replies,
thanks!



[Bug 199435] HPSA + P420i resetting logical Direct-Access never complete

2018-12-06 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=199435

--- Comment #27 from Gaetan Trellu (gaetan.tre...@incloudus.com) ---
By compiling the hpsa kernel module from SourceForge on Ubuntu 16.04 with
kernel 4.4 solved the issue for us.

Steps:
# apt-get install dkms build-essential
# tar xjvf hpsa-3.4.20-141.tar.bz2
# cd hpsa-3.4.20/drivers/
# sudo cp -a scsi /usr/src/hpsa-3.4.20.141
# dkms add -m hpsa -v 3.4.20.141
# dkms build -m hpsa -v 3.4.20.141
# dkms install -m hpsa -v 3.4.20.141

Link: https://sourceforge.net/projects/cciss/

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


Re: [PATCH 03/10] gdth: remove gdth_{alloc,free}_ioctl

2018-12-06 Thread Johannes Thumshirn
On 06/12/2018 17:50, Johannes Thumshirn wrote:
> Why not calling dma_alloc_coherent() directly instead of using the
> pci_alloc_consistent() wrapper?

Ah should've read the whole series


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


Re: [PATCH 03/10] gdth: remove gdth_{alloc,free}_ioctl

2018-12-06 Thread Johannes Thumshirn
On 06/12/2018 16:57, Christoph Hellwig wrote:
> Out of the three callers once insists on the scratch buffer, and the
> others are fine with a new allocation.  Switch those two to juse use
> pci_alloc_consistent directly, and open code the scratch buffer
> allocation in the remaining one.  This avoids a case where we might
> be doing a memory allocation under a spinlock with irqs disabled.

Why not calling dma_alloc_coherent() directly instead of using the
pci_alloc_consistent() wrapper?

Johannes
-- 
Johannes ThumshirnSUSE Labs Filesystems
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 2/2] zfcp: improve kdoc for return of zfcp_status_read_refill()

2018-12-06 Thread Steffen Maier
Complements

v2.6.35 commit 64deb6efdc55
("[SCSI] zfcp: Use status_read_buf_num provided by FCP channel")
which replaced the hardcoded 16 with a variable value

Also complements already existing fixups for above commit

v2.6.35 commit 8d88cf3f3b9a
("[SCSI] zfcp: Update status read mempool")
v3.10   commit 9edf7d75ee5f
("[SCSI] zfcp: status read buffers on first adapter open with link down")

Signed-off-by: Steffen Maier 
Reviewed-by: Jens Remus 
---
 drivers/s390/scsi/zfcp_aux.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 882789fff574..9cf30d124b9e 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -264,10 +264,10 @@ static void zfcp_free_low_mem_buffers(struct zfcp_adapter 
*adapter)
  * zfcp_status_read_refill - refill the long running status_read_requests
  * @adapter: ptr to struct zfcp_adapter for which the buffers should be 
refilled
  *
- * Returns: 0 on success, 1 otherwise
- *
- * if there are 16 or more status_read requests missing an adapter_reopen
- * is triggered
+ * Return:
+ * * 0 on success meaning at least one status read is pending
+ * * 1 if posting failed and not a single status read buffer is pending,
+ * also triggers adapter reopen recovery
  */
 int zfcp_status_read_refill(struct zfcp_adapter *adapter)
 {
-- 
2.16.4



[PATCH 1/2] zfcp: fix posting too many status read buffers leading to adapter shutdown

2018-12-06 Thread Steffen Maier
Suppose adapter (open) recovery is between opened QDIO queues and before
(the end of) initial posting of status read buffers (SRBs). This time
window can be seconds long due to FSF_PROT_HOST_CONNECTION_INITIALIZING
causing by design looping with exponential increase sleeps in the function
performing exchange config data during recovery
[zfcp_erp_adapter_strat_fsf_xconf()]. Recovery triggered by local link up.

Suppose an event occurs for which the FCP channel would send an
unsolicited notification to zfcp by means of a previously posted SRB.
We saw it with local cable pull (link down) in multi-initiator zoning
with multiple NPIV-enabled subchannels of the same shared FCP channel.

As soon as zfcp_erp_adapter_strategy_open_fsf() starts posting the
initial status read buffers from within the adapter's ERP thread,
the channel does send an unsolicited notification.

Since v2.6.27 commit d26ab06ede83 ("[SCSI] zfcp: receiving an unsolicted
status can lead to I/O stall"), zfcp_fsf_status_read_handler() schedules
adapter->stat_work to re-fill the just consumed SRB from a work item.

Now the ERP thread and the work item post SRBs in parallel.
Both contexts call the helper function zfcp_status_read_refill().
The tracking of missing (to be posted / re-filled) SRBs is not thread-safe
due to separate atomic_read() and atomic_dec(), in order to depend on
posting success. Hence, both contexts can see
atomic_read(>stat_miss) == 1. One of the two contexts posts
one too many SRB. Zfcp gets QDIO_ERROR_SLSB_STATE on the output queue
(trace tag "qdireq1") leading to zfcp_erp_adapter_shutdown() in
zfcp_qdio_handler_error().

An obvious and seemingly clean fix would be to schedule stat_work
from the ERP thread and wait for it to finish. This would serialize
all SRB re-fills. However, we already have another work item wait on the
ERP thread: adapter->scan_work runs zfcp_fc_scan_ports() which calls
zfcp_fc_eval_gpn_ft(). The latter calls zfcp_erp_wait() to wait for all
the open port recoveries during zfcp auto port scan, but in fact it waits
for any pending recovery including an adapter recovery. This approach
leads to a deadlock.
[see also v3.19 commit 18f87a67e6d6 ("zfcp: auto port scan resiliency");
v2.6.37 commit d3e1088d6873
("[SCSI] zfcp: No ERP escalation on gpn_ft eval");
v2.6.28 commit fca55b6fb587
("[SCSI] zfcp: fix deadlock between wq triggered port scan and ERP")
fixing v2.6.27 commit c57a39a45a76
("[SCSI] zfcp: wait until adapter is finished with ERP during auto-port");
v2.6.27 commit cc8c282963bd
("[SCSI] zfcp: Automatically attach remote ports")]

Instead make the accounting of missing SRBs atomic for parallel
execution in both the ERP thread and adapter->stat_work.

Signed-off-by: Steffen Maier 
Fixes: d26ab06ede83 ("[SCSI] zfcp: receiving an unsolicted status can lead to 
I/O stall")
Cc:  #2.6.27+
Reviewed-by: Jens Remus 
---
 drivers/s390/scsi/zfcp_aux.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index df10f4e07a4a..882789fff574 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -271,16 +271,16 @@ static void zfcp_free_low_mem_buffers(struct zfcp_adapter 
*adapter)
  */
 int zfcp_status_read_refill(struct zfcp_adapter *adapter)
 {
-   while (atomic_read(>stat_miss) > 0)
+   while (atomic_add_unless(>stat_miss, -1, 0))
if (zfcp_fsf_status_read(adapter->qdio)) {
+   atomic_inc(>stat_miss); /* undo add -1 */
if (atomic_read(>stat_miss) >=
adapter->stat_read_buf_num) {
zfcp_erp_adapter_reopen(adapter, 0, "axsref1");
return 1;
}
break;
-   } else
-   atomic_dec(>stat_miss);
+   }
return 0;
 }
 
-- 
2.16.4



[PATCH 0/2] zfcp: small bugfix on top of previous v4.21 patches

2018-12-06 Thread Steffen Maier
James, Martin,

One new recovery fix, which is not urgent, for an old bug.
It's sufficient to apply it on top of the previously sent
23 zfcp updates for the v4.21 merge window
[https://www.spinics.net/lists/linux-scsi/msg125211.html].
The 2 new patches apply to Martin's 4.21/scsi-queue
and to James' misc branch.

Steffen Maier (2):
  zfcp: fix posting too many status read buffers leading to adapter
shutdown
  zfcp: improve kdoc for return of zfcp_status_read_refill()

 drivers/s390/scsi/zfcp_aux.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

-- 
2.16.4



[PATCH 09/10] gdth: remove interrupt coalescing support

2018-12-06 Thread Christoph Hellwig
This code has been under a never defined ifdef since the beginning
of time (or at least history), and has just bitrotted.  Nuke it.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/gdth.c | 151 
 1 file changed, 12 insertions(+), 139 deletions(-)

diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index b8a033f18d7d..14f1d15cb6eb 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -89,10 +89,6 @@
  * phase:   unused
  */
 
-
-/* interrupt coalescing */
-/* #define INT_COAL */
-
 /* statistics */
 #define GDTH_STATISTICS
 
@@ -192,9 +188,6 @@ static u8   DebugState = DEBUG_GDTH;
 
 #ifdef GDTH_STATISTICS
 static u32 max_rq=0, max_index=0, max_sg=0;
-#ifdef INT_COAL
-static u32 max_int_coal=0;
-#endif
 static u32 act_ints=0, act_ios=0, act_stats=0, act_rq=0;
 static struct timer_list gdth_timer;
 #endif
@@ -1189,9 +1182,6 @@ static int gdth_search_drives(gdth_ha_str *ha)
 gdth_arcdl_str *alst;
 gdth_alist_str *alst2;
 gdth_oem_str_ioctl *oemstr;
-#ifdef INT_COAL
-gdth_perf_modes *pmod;
-#endif
 
 TRACE(("gdth_search_drives() hanum %d\n", ha->hanum));
 ok = 0;
@@ -1234,35 +1224,6 @@ static int gdth_search_drives(gdth_ha_str *ha)
 cdev_cnt = (u16)ha->info;
 ha->fw_vers = ha->service;
 
-#ifdef INT_COAL
-if (ha->type == GDT_PCIMPR) {
-/* set perf. modes */
-pmod = (gdth_perf_modes *)ha->pscratch;
-pmod->version  = 1;
-pmod->st_mode  = 1;/* enable one status buffer */
-*((u64 *)>st_buff_addr1) = ha->coal_stat_phys;
-pmod->st_buff_indx1= COALINDEX;
-pmod->st_buff_addr2= 0;
-pmod->st_buff_u_addr2  = 0;
-pmod->st_buff_indx2= 0;
-pmod->st_buff_size = sizeof(gdth_coal_status) * MAXOFFSETS;
-pmod->cmd_mode = 0;// disable all cmd buffers
-pmod->cmd_buff_addr1   = 0;
-pmod->cmd_buff_u_addr1 = 0;
-pmod->cmd_buff_indx1   = 0;
-pmod->cmd_buff_addr2   = 0;
-pmod->cmd_buff_u_addr2 = 0;
-pmod->cmd_buff_indx2   = 0;
-pmod->cmd_buff_size= 0;
-pmod->reserved1= 0;
-pmod->reserved2= 0;
-if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, SET_PERF_MODES,
-  INVALID_CHANNEL,sizeof(gdth_perf_modes))) {
-printk("GDT-HA %d: Interrupt coalescing activated\n", ha->hanum);
-}
-}
-#endif
-
 /* detect number of buses - try new IOCTL */
 iocr = (gdth_raw_iochan_str *)ha->pscratch;
 iocr->hdr.version= 0x;
@@ -2538,12 +2499,6 @@ static irqreturn_t __gdth_interrupt(gdth_ha_str *ha,
 u8 IStatus;
 u16 Service;
 unsigned long flags = 0;
-#ifdef INT_COAL
-int coalesced = FALSE;
-int next = FALSE;
-gdth_coal_status *pcs = NULL;
-int act_int_coal = 0;   
-#endif
 
 TRACE(("gdth_interrupt() IRQ %d\n", ha->irq));
 
@@ -2570,24 +2525,6 @@ static irqreturn_t __gdth_interrupt(gdth_ha_str *ha,
 ++act_ints;
 #endif
 
-#ifdef INT_COAL
-/* See if the fw is returning coalesced status */
-if (IStatus == COALINDEX) {
-/* Coalesced status.  Setup the initial status 
-   buffer pointer and flags */
-pcs = ha->coal_stat;
-coalesced = TRUE;
-next = TRUE;
-}
-
-do {
-if (coalesced) {
-/* For coalesced requests all status
-   information is found in the status buffer */
-IStatus = (u8)(pcs->status & 0xff);
-}
-#endif
-
 if (ha->type == GDT_PCI) {
 dp6_ptr = ha->brd;
 if (IStatus & 0x80) {   /* error flag */
@@ -2620,28 +2557,15 @@ static irqreturn_t __gdth_interrupt(gdth_ha_str *ha,
 dp6m_ptr = ha->brd;
 if (IStatus & 0x80) {   /* error flag */
 IStatus &= ~0x80;
-#ifdef INT_COAL
-if (coalesced)
-ha->status = pcs->ext_status & 0x;
-else 
-#endif
-ha->status = readw(_ptr->i960r.status);
+ha->status = readw(_ptr->i960r.status);
 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,ha->status));
 } else  /* no error */
 ha->status = S_OK;
-#ifdef INT_COAL
-/* get information */
-if (coalesced) {
-ha->info = pcs->info0;
-ha->info2 = pcs->info1;
-ha->service = (pcs->ext_status >> 16) & 0x;
-} else
-#endif
-{
-ha->info = readl(_ptr->i960r.info[0]);
-ha->service = readw(_ptr->i960r.service);
-ha->info2 = readl(_ptr->i960r.info[1]);
-}
+
+ha->info = readl(_ptr->i960r.info[0]);
+ha->service = 

[PATCH 04/10] gdth: remove ISA and EISA support

2018-12-06 Thread Christoph Hellwig
The non-PCI code has bitrotted for quite a while and will just oops
on load because it passes a NULL pointer to the PCI DMA routines.

Lets kill it for good - if someone really wants to use one of these
cards I'll help mentoring them to write a proper driver glue.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/Kconfig |   2 +-
 drivers/scsi/gdth.c  | 709 ++-
 drivers/scsi/gdth.h  |  30 --
 3 files changed, 24 insertions(+), 717 deletions(-)

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index f07444d30b21..0cfa385625d8 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -676,7 +676,7 @@ config SCSI_DMX3191D
 
 config SCSI_GDTH
tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller 
support"
-   depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API
+   depends on PCI && SCSI
---help---
  Formerly called GDT SCSI Disk Array Controller Support.
 
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 7174e7a88da2..45ddecd0284c 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -1,6 +1,6 @@
 /
  * Linux driver for *  
- * ICP vortex GmbH:GDT ISA/EISA/PCI Disk Array Controllers  *
+ * ICP vortex GmbH:GDT PCI Disk Array Controllers   *
  * Intel Corporation:  Storage RAID Controllers *
  *  *
  * gdth.c   *
@@ -32,15 +32,10 @@
  /
 
 /* All GDT Disk Array Controllers are fully supported by this driver.
- * This includes the PCI/EISA/ISA SCSI Disk Array Controllers and the
+ * This includes the PCI SCSI Disk Array Controllers and the
  * PCI Fibre Channel Disk Array Controllers. See gdth.h for a complete
  * list of all controller types.
  * 
- * If you have one or more GDT3000/3020 EISA controllers with 
- * controller BIOS disabled, you have to set the IRQ values with the 
- * command line option "gdth=irq1,irq2,...", where the irq1,irq2,... are
- * the IRQ values for the EISA controllers.
- * 
  * After the optional list of IRQ values, other possible 
  * command line options are:
  * disable:Ydisable driver
@@ -61,14 +56,12 @@
  *  access a shared resource from several nodes, 
  *  appropriate controller firmware required
  * shared_access:N  enable driver reserve/release protocol
- * probe_eisa_isa:Y scan for EISA/ISA controllers
- * probe_eisa_isa:N do not scan for EISA/ISA controllers
  * force_dma32:Yuse only 32 bit DMA mode
  * force_dma32:Nuse 64 bit DMA mode, if supported
  *
  * The default values are: "gdth=disable:N,reserve_mode:1,reverse_scan:N,
  *  max_ids:127,rescan:N,hdr_channel:0,
- *  shared_access:Y,probe_eisa_isa:N,force_dma32:N".
+ *  shared_access:Y,force_dma32:N".
  * Here is another example: "gdth=reserve_list:0,1,2,0,0,1,3,0,rescan:Y".
  * 
  * When loading the gdth driver as a module, the same options are available. 
@@ -79,7 +72,7 @@
  * 
  * Default: "modprobe gdth disable=0 reserve_mode=1 reverse_scan=0
  *   max_ids=127 rescan=0 hdr_channel=0 shared_access=0
- *   probe_eisa_isa=0 force_dma32=0"
+ *   force_dma32=0"
  * The other example: "modprobe gdth reserve_list=0,1,2,0,0,1,3,0 rescan=1".
  */
 
@@ -286,12 +279,6 @@ static struct timer_list gdth_timer;
 
 #define BUS_L2P(a,b)((b)>(a)->virt_bus ? (b-1):(b))
 
-#ifdef CONFIG_ISA
-static u8   gdth_drq_tab[4] = {5,6,7,7};/* DRQ table */
-#endif
-#if defined(CONFIG_EISA) || defined(CONFIG_ISA)
-static u8   gdth_irq_tab[6] = {0,10,11,12,14,0};/* IRQ table */
-#endif
 static u8   gdth_polling;   /* polling if TRUE */
 static int  gdth_ctr_count  = 0;/* controller count */
 static LIST_HEAD(gdth_instances);   /* controller list */
@@ -325,10 +312,6 @@ static u8 gdth_direction_tab[0x100] = {
 };
 
 /* LILO and modprobe/insmod parameters */
-/* IRQ list for GDT3000/3020 EISA controllers */
-static int irq[MAXHA] __initdata = 
-{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
 /* disable driver flag */
 static int disable __initdata = 0;
 /* reserve flag */
@@ -348,13 +331,10 @@ static int max_ids = MAXID;
 static int rescan = 0;
 /* shared access */
 static int shared_access = 1;
-/* enable support for EISA and ISA controllers */
-static int probe_eisa_isa = 0;
 /* 64 bit DMA mode, support for drives > 2 TB, if force_dma32 = 0 */
 static int force_dma32 = 0;
 
 /* parameters for 

[PATCH 03/10] gdth: remove gdth_{alloc,free}_ioctl

2018-12-06 Thread Christoph Hellwig
Out of the three callers once insists on the scratch buffer, and the
others are fine with a new allocation.  Switch those two to juse use
pci_alloc_consistent directly, and open code the scratch buffer
allocation in the remaining one.  This avoids a case where we might
be doing a memory allocation under a spinlock with irqs disabled.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/gdth.c  |  7 ++--
 drivers/scsi/gdth_proc.c | 71 
 drivers/scsi/gdth_proc.h |  3 --
 3 files changed, 25 insertions(+), 56 deletions(-)

diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 45e67d4cb3af..7174e7a88da2 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -4232,7 +4232,7 @@ static int ioc_general(void __user *arg, char *cmnd)
gdth_ioctl_general gen;
gdth_ha_str *ha;
char *buf = NULL;
-   u64 paddr;
+   dma_addr_t paddr;
int rval;
 
if (copy_from_user(, arg, sizeof(gdth_ioctl_general)))
@@ -4251,7 +4251,8 @@ static int ioc_general(void __user *arg, char *cmnd)
if (gen.data_len + gen.sense_len == 0)
goto execute;
 
-   buf = gdth_ioctl_alloc(ha, gen.data_len + gen.sense_len, FALSE, );
+buf = pci_alloc_consistent(ha->pdev, gen.data_len + gen.sense_len,
+   );
if (!buf)
return -EFAULT;
 
@@ -4286,7 +4287,7 @@ static int ioc_general(void __user *arg, char *cmnd)
 
rval = 0;
 out_free_buf:
-   gdth_ioctl_free(ha, gen.data_len+gen.sense_len, buf, paddr);
+   pci_free_consistent(ha->pdev, gen.data_len + gen.sense_len, buf, paddr);
return rval;
 }
  
diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
index bd5532a80b0e..8e77f8fd8641 100644
--- a/drivers/scsi/gdth_proc.c
+++ b/drivers/scsi/gdth_proc.c
@@ -31,7 +31,6 @@ static int gdth_set_asc_info(struct Scsi_Host *host, char 
*buffer,
 int i, found;
 gdth_cmd_strgdtcmd;
 gdth_cpar_str   *pcpar;
-u64 paddr;
 
 charcmnd[MAX_COMMAND_SIZE];
 memset(cmnd, 0xff, 12);
@@ -113,13 +112,23 @@ static int gdth_set_asc_info(struct Scsi_Host *host, char 
*buffer,
 }
 
 if (wb_mode) {
-if (!gdth_ioctl_alloc(ha, sizeof(gdth_cpar_str), TRUE, ))
-return(-EBUSY);
+   unsigned long flags;
+
+   BUILD_BUG_ON(sizeof(gdth_cpar_str) > GDTH_SCRATCH);
+
+   spin_lock_irqsave(>smp_lock, flags);
+   if (ha->scratch_busy) {
+   spin_unlock_irqrestore(>smp_lock, flags);
+return -EBUSY;
+   }
+   ha->scratch_busy = TRUE;
+   spin_unlock_irqrestore(>smp_lock, flags);
+
 pcpar = (gdth_cpar_str *)ha->pscratch;
 memcpy( pcpar, >cpar, sizeof(gdth_cpar_str) );
 gdtcmd.Service = CACHESERVICE;
 gdtcmd.OpCode = GDT_IOCTL;
-gdtcmd.u.ioctl.p_param = paddr;
+gdtcmd.u.ioctl.p_param = ha->scratch_phys;
 gdtcmd.u.ioctl.param_size = sizeof(gdth_cpar_str);
 gdtcmd.u.ioctl.subfunc = CACHE_CONFIG;
 gdtcmd.u.ioctl.channel = INVALID_CHANNEL;
@@ -127,7 +136,10 @@ static int gdth_set_asc_info(struct Scsi_Host *host, char 
*buffer,
 
 gdth_execute(host, , cmnd, 30, NULL);
 
-gdth_ioctl_free(ha, GDTH_SCRATCH, ha->pscratch, paddr);
+   spin_lock_irqsave(>smp_lock, flags);
+   ha->scratch_busy = FALSE;
+   spin_unlock_irqrestore(>smp_lock, flags);
+
 printk("Done.\n");
 return(orig_length);
 }
@@ -143,7 +155,7 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host 
*host)
 int id, i, j, k, sec, flag;
 int no_mdrv = 0, drv_no, is_mirr;
 u32 cnt;
-u64 paddr;
+dma_addr_t paddr;
 int rc = -ENOMEM;
 
 gdth_cmd_str *gdtcmd;
@@ -232,7 +244,7 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host 
*host)
 seq_puts(m, "\nPhysical Devices:");
 flag = FALSE;
 
-buf = gdth_ioctl_alloc(ha, size, FALSE, );
+buf = pci_alloc_consistent(ha->pdev, size, );
 if (!buf) 
 goto stop_output;
 for (i = 0; i < ha->bus_cnt; ++i) {
@@ -406,7 +418,7 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host 
*host)
 seq_printf(m,
" To Array Drv.:\t%s\n", hrec);
 }   
-
+
 if (!flag)
 seq_puts(m, "\n --\n");
 
@@ -500,7 +512,7 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host 
*host)
 }
 }
 }
-gdth_ioctl_free(ha, size, buf, paddr);
+   pci_free_consistent(ha->pdev, size, buf, paddr);
 
 for (i = 0; i < MAX_HDRIVES; ++i) {
 if (!(ha->hdr[i].present))
@@ -553,47 +565,6 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host 
*host)
 return rc;
 }
 
-static char *gdth_ioctl_alloc(gdth_ha_str *ha, int size, int scratch,
-  u64 *paddr)
-{
-unsigned long flags;
-char *ret_val;
-
-if (size == 

[PATCH 02/10] gdth: reuse dma coherent allocation in gdth_show_info

2018-12-06 Thread Christoph Hellwig
gdth_show_info currently allocs and frees a dma buffer four times,
which isn't very efficient. Reuse a single allocation instead.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/gdth_proc.c | 20 +---
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
index 3a9751a80225..bd5532a80b0e 100644
--- a/drivers/scsi/gdth_proc.c
+++ b/drivers/scsi/gdth_proc.c
@@ -226,11 +226,13 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host 
*host)
 #endif
 
 if (ha->more_proc) {
+size_t size = max_t(size_t, GDTH_SCRATCH, sizeof(gdth_hget_str));
+
 /* more information: 2. about physical devices */
 seq_puts(m, "\nPhysical Devices:");
 flag = FALSE;
 
-buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, );
+buf = gdth_ioctl_alloc(ha, size, FALSE, );
 if (!buf) 
 goto stop_output;
 for (i = 0; i < ha->bus_cnt; ++i) {
@@ -323,7 +325,6 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host 
*host)
 }
 }
 }
-gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
 
 if (!flag)
 seq_puts(m, "\n --\n");
@@ -332,9 +333,6 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host 
*host)
 seq_puts(m, "\nLogical Drives:");
 flag = FALSE;
 
-buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, );
-if (!buf) 
-goto stop_output;
 for (i = 0; i < MAX_LDRIVES; ++i) {
 if (!ha->hdr[i].is_logdrv)
 continue;
@@ -408,7 +406,6 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host 
*host)
 seq_printf(m,
" To Array Drv.:\t%s\n", hrec);
 }   
-gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
 
 if (!flag)
 seq_puts(m, "\n --\n");
@@ -417,9 +414,6 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host 
*host)
 seq_puts(m, "\nArray Drives:");
 flag = FALSE;
 
-buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, );
-if (!buf) 
-goto stop_output;
 for (i = 0; i < MAX_LDRIVES; ++i) {
 if (!(ha->hdr[i].is_arraydrv && ha->hdr[i].is_master))
 continue;
@@ -468,8 +462,7 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host 
*host)
hrec);
 }
 }
-gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
-
+
 if (!flag)
 seq_puts(m, "\n --\n");
 
@@ -477,9 +470,6 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host 
*host)
 seq_puts(m, "\nHost Drives:");
 flag = FALSE;
 
-buf = gdth_ioctl_alloc(ha, sizeof(gdth_hget_str), FALSE, );
-if (!buf) 
-goto stop_output;
 for (i = 0; i < MAX_LDRIVES; ++i) {
 if (!ha->hdr[i].is_logdrv || 
 (ha->hdr[i].is_arraydrv && !ha->hdr[i].is_master))
@@ -510,7 +500,7 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host 
*host)
 }
 }
 }
-gdth_ioctl_free(ha, sizeof(gdth_hget_str), buf, paddr);
+gdth_ioctl_free(ha, size, buf, paddr);
 
 for (i = 0; i < MAX_HDRIVES; ++i) {
 if (!(ha->hdr[i].present))
-- 
2.19.1



[PATCH 01/10] gdth: refactor ioc_general

2018-12-06 Thread Christoph Hellwig
This function is a huge mess with duplicated error handling.  Split out
a few useful helpers and use goto labels to untangle the error handling
and no-data ioctl handling.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/gdth.c | 244 +++-
 1 file changed, 126 insertions(+), 118 deletions(-)

diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 16709735b546..45e67d4cb3af 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -4155,131 +4155,139 @@ static int ioc_resetdrv(void __user *arg, char *cmnd)
 return 0;
 }
 
-static int ioc_general(void __user *arg, char *cmnd)
+static void gdth_ioc_addr32(gdth_ha_str *ha, gdth_ioctl_general *gen,
+   u64 paddr)
 {
-gdth_ioctl_general gen;
-char *buf = NULL;
-u64 paddr; 
-gdth_ha_str *ha;
-int rval;
+   if (ha->cache_feat & SCATTER_GATHER) {
+   gen->command.u.cache.DestAddr = 0x;
+   gen->command.u.cache.sg_canz = 1;
+   gen->command.u.cache.sg_lst[0].sg_ptr = (u32)paddr;
+   gen->command.u.cache.sg_lst[0].sg_len = gen->data_len;
+   gen->command.u.cache.sg_lst[1].sg_len = 0;
+   } else {
+   gen->command.u.cache.DestAddr = paddr;
+   gen->command.u.cache.sg_canz = 0;
+   }
+}
 
-if (copy_from_user(, arg, sizeof(gdth_ioctl_general)))
-return -EFAULT;
-ha = gdth_find_ha(gen.ionode);
-if (!ha)
-return -EFAULT;
+static void gdth_ioc_addr64(gdth_ha_str *ha, gdth_ioctl_general *gen,
+   u64 paddr)
+{
+   if (ha->cache_feat & SCATTER_GATHER) {
+   gen->command.u.cache64.DestAddr = (u64)-1;
+   gen->command.u.cache64.sg_canz = 1;
+   gen->command.u.cache64.sg_lst[0].sg_ptr = paddr;
+   gen->command.u.cache64.sg_lst[0].sg_len = gen->data_len;
+   gen->command.u.cache64.sg_lst[1].sg_len = 0;
+   } else {
+   gen->command.u.cache64.DestAddr = paddr;
+   gen->command.u.cache64.sg_canz = 0;
+   }
+}
 
-if (gen.data_len > INT_MAX)
-return -EINVAL;
-if (gen.sense_len > INT_MAX)
-return -EINVAL;
-if (gen.data_len + gen.sense_len > INT_MAX)
-return -EINVAL;
+static void gdth_ioc_cacheservice(gdth_ha_str *ha, gdth_ioctl_general *gen,
+   u64 paddr)
+{
+   if (ha->cache_feat & GDT_64BIT) {
+   /* copy elements from 32-bit IOCTL structure */
+   gen->command.u.cache64.BlockCnt = gen->command.u.cache.BlockCnt;
+   gen->command.u.cache64.BlockNo = gen->command.u.cache.BlockNo;
+   gen->command.u.cache64.DeviceNo = gen->command.u.cache.DeviceNo;
 
-if (gen.data_len + gen.sense_len != 0) {
-if (!(buf = gdth_ioctl_alloc(ha, gen.data_len + gen.sense_len,
- FALSE, )))
-return -EFAULT;
-if (copy_from_user(buf, arg + sizeof(gdth_ioctl_general),  
-   gen.data_len + gen.sense_len)) {
-gdth_ioctl_free(ha, gen.data_len+gen.sense_len, buf, paddr);
-return -EFAULT;
-}
+   gdth_ioc_addr64(ha, gen, paddr);
+   } else {
+   gdth_ioc_addr32(ha, gen, paddr);
+   }
+}
 
-if (gen.command.OpCode == GDT_IOCTL) {
-gen.command.u.ioctl.p_param = paddr;
-} else if (gen.command.Service == CACHESERVICE) {
-if (ha->cache_feat & GDT_64BIT) {
-/* copy elements from 32-bit IOCTL structure */
-gen.command.u.cache64.BlockCnt = gen.command.u.cache.BlockCnt;
-gen.command.u.cache64.BlockNo = gen.command.u.cache.BlockNo;
-gen.command.u.cache64.DeviceNo = gen.command.u.cache.DeviceNo;
-/* addresses */
-if (ha->cache_feat & SCATTER_GATHER) {
-gen.command.u.cache64.DestAddr = (u64)-1;
-gen.command.u.cache64.sg_canz = 1;
-gen.command.u.cache64.sg_lst[0].sg_ptr = paddr;
-gen.command.u.cache64.sg_lst[0].sg_len = gen.data_len;
-gen.command.u.cache64.sg_lst[1].sg_len = 0;
-} else {
-gen.command.u.cache64.DestAddr = paddr;
-gen.command.u.cache64.sg_canz = 0;
-}
-} else {
-if (ha->cache_feat & SCATTER_GATHER) {
-gen.command.u.cache.DestAddr = 0x;
-gen.command.u.cache.sg_canz = 1;
-gen.command.u.cache.sg_lst[0].sg_ptr = (u32)paddr;
-gen.command.u.cache.sg_lst[0].sg_len = gen.data_len;
-gen.command.u.cache.sg_lst[1].sg_len = 0;
-} else {
-gen.command.u.cache.DestAddr = paddr;
-gen.command.u.cache.sg_canz = 0;
-}
-}
-} else if 

[PATCH 10/10] gdth: use generic DMA API

2018-12-06 Thread Christoph Hellwig
Switch from the legacy PCI DMA API to the generic DMA API.  Also switch
to dma_map_single from pci_map_page in one case where this makes the code
simpler.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/gdth.c  | 59 +++-
 drivers/scsi/gdth_proc.c |  4 +--
 2 files changed, 30 insertions(+), 33 deletions(-)

diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 14f1d15cb6eb..e1071fc2249b 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -2077,9 +2077,9 @@ static int gdth_fill_cache_cmd(gdth_ha_str *ha, struct 
scsi_cmnd *scp,
 
 if (scsi_bufflen(scp)) {
 cmndinfo->dma_dir = (read_write == 1 ?
-PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);   
-sgcnt = pci_map_sg(ha->pdev, scsi_sglist(scp), scsi_sg_count(scp),
-   cmndinfo->dma_dir);
+DMA_TO_DEVICE : DMA_FROM_DEVICE);   
+sgcnt = dma_map_sg(>pdev->dev, scsi_sglist(scp),
+  scsi_sg_count(scp), cmndinfo->dma_dir);
 if (mode64) {
 struct scatterlist *sl;
 
@@ -2153,8 +2153,6 @@ static int gdth_fill_raw_cmd(gdth_ha_str *ha, struct 
scsi_cmnd *scp, u8 b)
 dma_addr_t sense_paddr;
 int cmd_index, sgcnt, mode64;
 u8 t,l;
-struct page *page;
-unsigned long offset;
 struct gdth_cmndinfo *cmndinfo;
 
 t = scp->device->id;
@@ -2196,10 +2194,8 @@ static int gdth_fill_raw_cmd(gdth_ha_str *ha, struct 
scsi_cmnd *scp, u8 b)
 }
 
 } else {
-page = virt_to_page(scp->sense_buffer);
-offset = (unsigned long)scp->sense_buffer & ~PAGE_MASK;
-sense_paddr = pci_map_page(ha->pdev,page,offset,
-   16,PCI_DMA_FROMDEVICE);
+sense_paddr = dma_map_single(>pdev->dev, scp->sense_buffer, 16,
+DMA_FROM_DEVICE);
 
cmndinfo->sense_paddr  = sense_paddr;
 cmdp->OpCode   = GDT_WRITE; /* always */
@@ -2240,9 +2236,9 @@ static int gdth_fill_raw_cmd(gdth_ha_str *ha, struct 
scsi_cmnd *scp, u8 b)
 }
 
 if (scsi_bufflen(scp)) {
-cmndinfo->dma_dir = PCI_DMA_BIDIRECTIONAL;
-sgcnt = pci_map_sg(ha->pdev, scsi_sglist(scp), scsi_sg_count(scp),
-   cmndinfo->dma_dir);
+cmndinfo->dma_dir = DMA_BIDIRECTIONAL;
+sgcnt = dma_map_sg(>pdev->dev, scsi_sglist(scp),
+  scsi_sg_count(scp), cmndinfo->dma_dir);
 if (mode64) {
 struct scatterlist *sl;
 
@@ -2750,12 +2746,12 @@ static int gdth_sync_event(gdth_ha_str *ha, int 
service, u8 index,
 return 2;
 }
 if (scsi_bufflen(scp))
-pci_unmap_sg(ha->pdev, scsi_sglist(scp), scsi_sg_count(scp),
+dma_unmap_sg(>pdev->dev, scsi_sglist(scp), scsi_sg_count(scp),
  cmndinfo->dma_dir);
 
 if (cmndinfo->sense_paddr)
-pci_unmap_page(ha->pdev, cmndinfo->sense_paddr, 16,
-   PCI_DMA_FROMDEVICE);
+dma_unmap_page(>pdev->dev, cmndinfo->sense_paddr, 16,
+  DMA_FROM_DEVICE);
 
 if (ha->status == S_OK) {
 cmndinfo->status = S_OK;
@@ -3659,8 +3655,8 @@ static int ioc_general(void __user *arg, char *cmnd)
if (gen.data_len + gen.sense_len == 0)
goto execute;
 
-buf = pci_alloc_consistent(ha->pdev, gen.data_len + gen.sense_len,
-   );
+buf = dma_alloc_coherent(>pdev->dev, gen.data_len + gen.sense_len,
+   , GFP_KERNEL);
if (!buf)
return -EFAULT;
 
@@ -3695,7 +3691,8 @@ static int ioc_general(void __user *arg, char *cmnd)
 
rval = 0;
 out_free_buf:
-   pci_free_consistent(ha->pdev, gen.data_len + gen.sense_len, buf, paddr);
+   dma_free_coherent(>pdev->dev, gen.data_len + gen.sense_len, buf,
+   paddr);
return rval;
 }
  
@@ -4140,14 +4137,14 @@ static int gdth_pci_probe_one(gdth_pci_str *pcistr, 
gdth_ha_str **ha_out)
 
error = -ENOMEM;
 
-   ha->pscratch = pci_alloc_consistent(ha->pdev, GDTH_SCRATCH,
-   _dma_handle);
+   ha->pscratch = dma_alloc_coherent(>pdev->dev, GDTH_SCRATCH,
+   _dma_handle, GFP_KERNEL);
if (!ha->pscratch)
goto out_free_irq;
ha->scratch_phys = scratch_dma_handle;
 
-   ha->pmsg = pci_alloc_consistent(ha->pdev, sizeof(gdth_msg_str),
-   _dma_handle);
+   ha->pmsg = dma_alloc_coherent(>pdev->dev, sizeof(gdth_msg_str),
+   _dma_handle, GFP_KERNEL);
if (!ha->pmsg)
goto out_free_pscratch;
ha->msg_phys = scratch_dma_handle;
@@ -4174,16 +4171,16 @@ static int 

[PATCH 07/10] gdth: remove dead dma statistics code

2018-12-06 Thread Christoph Hellwig
This code can't be built into the kernel without editing the source
file and is not generall useful.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/gdth.c  | 18 --
 drivers/scsi/gdth_proc.c |  8 
 2 files changed, 26 deletions(-)

diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 63d704301875..b8a033f18d7d 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -2126,12 +2126,6 @@ static int gdth_fill_cache_cmd(gdth_ha_str *ha, struct 
scsi_cmnd *scp,
 cmdp->u.cache64.sg_canz = sgcnt;
 scsi_for_each_sg(scp, sl, sgcnt, i) {
 cmdp->u.cache64.sg_lst[i].sg_ptr = sg_dma_address(sl);
-#ifdef GDTH_DMA_STATISTICS
-if (cmdp->u.cache64.sg_lst[i].sg_ptr > (u64)0x)
-ha->dma64_cnt++;
-else
-ha->dma32_cnt++;
-#endif
 cmdp->u.cache64.sg_lst[i].sg_len = sg_dma_len(sl);
 }
 } else {
@@ -2141,9 +2135,6 @@ static int gdth_fill_cache_cmd(gdth_ha_str *ha, struct 
scsi_cmnd *scp,
 cmdp->u.cache.sg_canz = sgcnt;
 scsi_for_each_sg(scp, sl, sgcnt, i) {
 cmdp->u.cache.sg_lst[i].sg_ptr = sg_dma_address(sl);
-#ifdef GDTH_DMA_STATISTICS
-ha->dma32_cnt++;
-#endif
 cmdp->u.cache.sg_lst[i].sg_len = sg_dma_len(sl);
 }
 }
@@ -2298,12 +2289,6 @@ static int gdth_fill_raw_cmd(gdth_ha_str *ha, struct 
scsi_cmnd *scp, u8 b)
 cmdp->u.raw64.sg_ranz = sgcnt;
 scsi_for_each_sg(scp, sl, sgcnt, i) {
 cmdp->u.raw64.sg_lst[i].sg_ptr = sg_dma_address(sl);
-#ifdef GDTH_DMA_STATISTICS
-if (cmdp->u.raw64.sg_lst[i].sg_ptr > (u64)0x)
-ha->dma64_cnt++;
-else
-ha->dma32_cnt++;
-#endif
 cmdp->u.raw64.sg_lst[i].sg_len = sg_dma_len(sl);
 }
 } else {
@@ -2313,9 +2298,6 @@ static int gdth_fill_raw_cmd(gdth_ha_str *ha, struct 
scsi_cmnd *scp, u8 b)
 cmdp->u.raw.sg_ranz = sgcnt;
 scsi_for_each_sg(scp, sl, sgcnt, i) {
 cmdp->u.raw.sg_lst[i].sg_ptr = sg_dma_address(sl);
-#ifdef GDTH_DMA_STATISTICS
-ha->dma32_cnt++;
-#endif
 cmdp->u.raw.sg_lst[i].sg_len = sg_dma_len(sl);
 }
 }
diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
index 8e77f8fd8641..fc36c49a5334 100644
--- a/drivers/scsi/gdth_proc.c
+++ b/drivers/scsi/gdth_proc.c
@@ -229,14 +229,6 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host 
*host)
" Serial No.:   \t0x%8X\tCache RAM size:\t%d KB\n",
ha->binfo.ser_no, ha->binfo.memsize / 1024);
 
-#ifdef GDTH_DMA_STATISTICS
-/* controller statistics */
-seq_puts(m, "\nController Statistics:\n");
-seq_printf(m,
-   " 32-bit DMA buffer:\t%lu\t64-bit DMA buffer:\t%lu\n",
-   ha->dma32_cnt, ha->dma64_cnt);
-#endif
-
 if (ha->more_proc) {
 size_t size = max_t(size_t, GDTH_SCRATCH, sizeof(gdth_hget_str));
 
-- 
2.19.1



[PATCH 08/10] gdth: remove dead code under #ifdef GDTH_IOCTL_PROC

2018-12-06 Thread Christoph Hellwig
This can't ever be compiled into the kernel, so remove it.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/gdth_ioctl.h | 89 ---
 drivers/scsi/gdth_proc.c  | 18 
 2 files changed, 107 deletions(-)

diff --git a/drivers/scsi/gdth_ioctl.h b/drivers/scsi/gdth_ioctl.h
index 4c91894ac244..ee4c9bf1022a 100644
--- a/drivers/scsi/gdth_ioctl.h
+++ b/drivers/scsi/gdth_ioctl.h
@@ -27,11 +27,7 @@
 #define GDTH_MAXSG  32  /* max. s/g elements */
 
 #define MAX_LDRIVES 255 /* max. log. drive count */
-#ifdef GDTH_IOCTL_PROC
-#define MAX_HDRIVES 100 /* max. host drive count */
-#else
 #define MAX_HDRIVES MAX_LDRIVES /* max. host drive count */
-#endif
 
 /* scatter/gather element */
 typedef struct {
@@ -178,91 +174,6 @@ typedef struct {
 gdth_evt_data   event_data;
 } __attribute__((packed)) gdth_evt_str;
 
-
-#ifdef GDTH_IOCTL_PROC
-/* IOCTL structure (write) */
-typedef struct {
-u32 magic;  /* IOCTL magic */
-u16  ioctl;  /* IOCTL */
-u16  ionode; /* controller number */
-u16  service;/* controller service */
-u16  timeout;/* timeout */
-union {
-struct {
-u8  command[512];   /* controller command */
-u8  data[1];/* add. data */
-} general;
-struct {
-u8  lock;   /* lock/unlock */
-u8  drive_cnt;  /* drive count */
-u16  drives[MAX_HDRIVES];/* drives */
-} lockdrv;
-struct {
-u8  lock;   /* lock/unlock */
-u8  channel;/* channel */
-} lockchn;
-struct {
-int erase;  /* erase event ? */
-int handle;
-u8  evt[EVENT_SIZE];/* event structure */
-} event;
-struct {
-u8  bus;/* SCSI bus */
-u8  target; /* target ID */
-u8  lun;/* LUN */
-u8  cmd_len;/* command length */
-u8  cmd[12];/* SCSI command */
-} scsi;
-struct {
-u16  hdr_no; /* host drive number */
-u8  flag;   /* old meth./add/remove */
-} rescan;
-} iu;
-} gdth_iowr_str;
-
-/* IOCTL structure (read) */
-typedef struct {
-u32 size;   /* buffer size */
-u32 status; /* IOCTL error code */
-union {
-struct {
-u8  data[1];/* data */
-} general;
-struct {
-u16  version;/* driver version */
-} drvers;
-struct {
-u8  type;   /* controller type */
-u16  info;   /* slot etc. */
-u16  oem_id; /* OEM ID */
-u16  bios_ver;   /* not used */
-u16  access; /* not used */
-u16  ext_type;   /* extended type */
-u16  device_id;  /* device ID */
-u16  sub_device_id;  /* sub device ID */
-} ctrtype;
-struct {
-u8  version;/* OS version */
-u8  subversion; /* OS subversion */
-u16  revision;   /* revision */
-} osvers;
-struct {
-u16  count;  /* controller count */
-} ctrcnt;
-struct {
-int handle;
-u8  evt[EVENT_SIZE];/* event structure */
-} event;
-struct {
-u8  bus;/* SCSI bus, 0xff: invalid */
-u8  target; /* target ID */
-u8  lun;/* LUN */
-u8  cluster_type;   /* cluster properties */
-} hdr_list[MAX_HDRIVES];/* index is host drive number 
*/
-} iu;
-} gdth_iord_str;
-#endif
-
 /* GDTIOCTL_GENERAL */
 typedef struct {
 u16 ionode;  /* controller number */
diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
index fc36c49a5334..5a13ccac8dee 100644
--- a/drivers/scsi/gdth_proc.c
+++ b/drivers/scsi/gdth_proc.c
@@ -557,24 +557,6 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host 
*host)
 return rc;
 }
 
-#ifdef GDTH_IOCTL_PROC
-static int gdth_ioctl_check_bin(gdth_ha_str *ha, u16 size)
-{
-unsigned long flags;
-int ret_val;
-
-

[PATCH 05/10] gdth: remove direct serial port access

2018-12-06 Thread Christoph Hellwig
Remove never compile in support for sending debug traces straight to
the serial port using direct port access.

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

diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 45ddecd0284c..e8121b80233c 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -185,79 +185,9 @@ static void gdth_scsi_done(struct scsi_cmnd *scp);
 
 #ifdef DEBUG_GDTH
 static u8   DebugState = DEBUG_GDTH;
-
-#ifdef __SERIAL__
-#define MAX_SERBUF 160
-static void ser_init(void);
-static void ser_puts(char *str);
-static void ser_putc(char c);
-static int  ser_printk(const char *fmt, ...);
-static char strbuf[MAX_SERBUF+1];
-#ifdef __COM2__
-#define COM_BASE 0x2f8
-#else
-#define COM_BASE 0x3f8
-#endif
-static void ser_init()
-{
-unsigned port=COM_BASE;
-
-outb(0x80,port+3);
-outb(0,port+1);
-/* 19200 Baud, if 9600: outb(12,port) */
-outb(6, port);
-outb(3,port+3);
-outb(0,port+1);
-/*
-ser_putc('I');
-ser_putc(' ');
-*/
-}
-
-static void ser_puts(char *str)
-{
-char *ptr;
-
-ser_init();
-for (ptr=str;*ptr;++ptr)
-ser_putc(*ptr);
-}
-
-static void ser_putc(char c)
-{
-unsigned port=COM_BASE;
-
-while ((inb(port+5) & 0x20)==0);
-outb(c,port);
-if (c==0x0a)
-{
-while ((inb(port+5) & 0x20)==0);
-outb(0x0d,port);
-}
-}
-
-static int ser_printk(const char *fmt, ...)
-{
-va_list args;
-int i;
-
-va_start(args,fmt);
-i = vsprintf(strbuf,fmt,args);
-ser_puts(strbuf);
-va_end(args);
-return i;
-}
-
-#define TRACE(a){if (DebugState==1) {ser_printk a;}}
-#define TRACE2(a)   {if (DebugState==1 || DebugState==2) {ser_printk a;}}
-#define TRACE3(a)   {if (DebugState!=0) {ser_printk a;}}
-
-#else /* !__SERIAL__ */
 #define TRACE(a){if (DebugState==1) {printk a;}}
 #define TRACE2(a)   {if (DebugState==1 || DebugState==2) {printk a;}}
 #define TRACE3(a)   {if (DebugState!=0) {printk a;}}
-#endif
-
 #else /* !DEBUG */
 #define TRACE(a)
 #define TRACE2(a)
-- 
2.19.1



[PATCH 06/10] gdth: remove dead rtc code

2018-12-06 Thread Christoph Hellwig
This code has been under the never defined GDTH_RTC ifdef forever,
nuke it.

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

diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index e8121b80233c..63d704301875 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -115,10 +115,6 @@
 #include 
 #include 
 #include 
-
-#ifdef GDTH_RTC
-#include 
-#endif
 #include 
 
 #include 
@@ -1197,11 +1193,6 @@ static int gdth_search_drives(gdth_ha_str *ha)
 gdth_perf_modes *pmod;
 #endif
 
-#ifdef GDTH_RTC
-u8 rtc[12];
-unsigned long flags;
-#endif 
-   
 TRACE(("gdth_search_drives() hanum %d\n", ha->hanum));
 ok = 0;
 
@@ -1221,29 +1212,6 @@ static int gdth_search_drives(gdth_ha_str *ha)
 }
 TRACE2(("gdth_search_drives(): SCREENSERVICE initialized\n"));
 
-#ifdef GDTH_RTC
-/* read realtime clock info, send to controller */
-/* 1. wait for the falling edge of update flag */
-spin_lock_irqsave(_lock, flags);
-for (j = 0; j < 100; ++j)
-if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP)
-break;
-for (j = 0; j < 100; ++j)
-if (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP))
-break;
-/* 2. read info */
-do {
-for (j = 0; j < 12; ++j) 
-rtc[j] = CMOS_READ(j);
-} while (rtc[0] != CMOS_READ(0));
-spin_unlock_irqrestore(_lock, flags);
-TRACE2(("gdth_search_drives(): RTC: %x/%x/%x\n",*(u32 *)[0],
-*(u32 *)[4], *(u32 *)[8]));
-/* 3. send to controller firmware */
-gdth_internal_cmd(ha, SCREENSERVICE, GDT_REALTIME, *(u32 *)[0],
-  *(u32 *)[4], *(u32 *)[8]);
-#endif  
- 
 /* unfreeze all IOs */
 gdth_internal_cmd(ha, CACHESERVICE, GDT_UNFREEZE_IO, 0, 0, 0);
  
-- 
2.19.1



various fixups for gdth

2018-12-06 Thread Christoph Hellwig
Cleans up various oddities found during a code audit, and drops the
legacy ISA support which hasn't had a chance to actually work for a
long time.


Re: [PATCH v10 4/6] scsi: ufs: Add core reset support

2018-12-06 Thread Marc Gonzalez
On 23/10/2018 06:35, Can Guo wrote:

> From: Dov Levenglick 
> 
> Enables core reset support. Add full initialization of the PHY and the
> controller before initializing UFS PHY and during link recovery.
> 
> Signed-off-by: Dov Levenglick 
> Signed-off-by: Amit Nischal 
> Signed-off-by: Subhash Jadavani 
> Signed-off-by: Can Guo 

FWIW, this patch does not apply cleanly on top of v4.20-rc4 because
it clashes with df032bf27a414acf61c957ec2fad22a57d903b39
("scsi: ufs: Add a bsg endpoint that supports UPIUs").

Seems git's 3-way merge is smart enough to handle the conflict.

Regards.


Re: [PATCH v7 3/5] target: add device vendor_id configfs attribute

2018-12-06 Thread Martin K. Petersen


David,

> Indeed, the comment should refer to page 0x83.
> @Martin: all patches in this series have now been reviewed+acked. Can
>  you fix the above comment (s/0x80/0x83) if/when you merge, or
>should I resend the series with this fixed?

I'll fix it up.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH v7 3/5] target: add device vendor_id configfs attribute

2018-12-06 Thread David Disseldorp
On Thu, 6 Dec 2018 15:25:42 +0300, Roman Bolshakov wrote:

> >  /*
> > + * STANDARD and VPD page 0x80 T10 Vendor Identification  
> 
> Perhaps you meant 0x83 (Device Identification VPD page, T10 vendor ID
> based designator). INQUIRY page 0x80 is Unit Serial Number.

Indeed, the comment should refer to page 0x83.
@Martin: all patches in this series have now been reviewed+acked. Can
 you fix the above comment (s/0x80/0x83) if/when you merge, or
 should I resend the series with this fixed?

Cheers, David


Re: [PATCH v7 2/5] target: consistently null-terminate t10_wwn strings

2018-12-06 Thread Roman Bolshakov
On Wed, Dec 05, 2018 at 01:18:35PM +0100, David Disseldorp wrote:
> In preparation for supporting user provided vendor strings, add an extra
> byte to the vendor, model and revision arrays in struct t10_wwn. This
> ensures that the full INQUIRY data can be carried in the arrays along
> with a null-terminator.
> 
> Change a number of array readers and writers so that they account for
> explicit null-termination:
> - The pscsi_set_inquiry_info() and emulate_model_alias_store() codepaths
>   don't currently explicitly null-terminate; fix this.
> - Existing t10_wwn field dumps use for-loops which step over
>   null-terminators for right-padding.
>   + Use printf with width specifiers instead.
> 
> Signed-off-by: David Disseldorp 
> ---
>  drivers/target/target_core_configfs.c | 16 +++
>  drivers/target/target_core_device.c   | 46 ++--
>  drivers/target/target_core_pscsi.c| 50 
> +++
>  drivers/target/target_core_spc.c  |  7 ++---
>  drivers/target/target_core_stat.c | 32 +-
>  include/target/target_core_base.h | 14 +++---
>  6 files changed, 63 insertions(+), 102 deletions(-)
> 

Reviewed-by: Roman Bolshakov 

Thank you,
Roman Bolshakov


Re: [PATCH v7 3/5] target: add device vendor_id configfs attribute

2018-12-06 Thread Roman Bolshakov
On Wed, Dec 05, 2018 at 01:18:36PM +0100, David Disseldorp wrote:
> The vendor_id attribute will allow for the modification of the T10
> Vendor Identification string returned in inquiry responses. Its value
> can be viewed and modified via the ConfigFS path at:
> target/core/$backstore/$name/wwn/vendor_id
> 
> "LIO-ORG" remains the default value, which is set when the backstore
> device is enabled.
> 
> Signed-off-by: David Disseldorp 
> ---
>  drivers/target/target_core_configfs.c | 70 
> +++
>  1 file changed, 70 insertions(+)
> 
> diff --git a/drivers/target/target_core_configfs.c 
> b/drivers/target/target_core_configfs.c
> index 8277bcf81d6e..f099c2ae451f 100644
> --- a/drivers/target/target_core_configfs.c
> +++ b/drivers/target/target_core_configfs.c
> @@ -1217,6 +1217,74 @@ static struct t10_wwn *to_t10_wwn(struct config_item 
> *item)
>  }
>  
>  /*
> + * STANDARD and VPD page 0x80 T10 Vendor Identification

Perhaps you meant 0x83 (Device Identification VPD page, T10 vendor ID
based designator). INQUIRY page 0x80 is Unit Serial Number.

Besides that,
Reviewed-by: Roman Bolshakov 

Thank you,
Roman


Re: [PATCH] scsi: t10-pi: Return correct ref tag when queue has no integrity profile

2018-12-06 Thread chenxiang (M)



Hi,
在 2018/12/6 20:04, John Garry 写道:

On 06/12/2018 04:17, Martin K. Petersen wrote:

+



Bart,


Had you considered to use lower_32_bits() instead of "0x"?
That would to avoid that reviewers have to count the 'f'-s to verify
correctness of t10_pi_ref_tag().


I hadn't. I guess I tend to think of lower_32_bits() as something you do
to pointers, not to block numbers.



Xiang Chen tested the patch successfully. I'll let him provide 
tested-by tag.


I have tested the patch with running fio on 3008 (on our ARM64 board 
with 4 DIF disks and 8 non-DIF disks), and now it works well.

Tested-by: Xiang Chen 



Thanks,
John


.






Re: [PATCH v10 0/6] Support for Qualcomm UFS QMP PHY on SDM845

2018-12-06 Thread Marc Gonzalez
On 05/12/2018 08:01, Vivek Gautam wrote:

> On Tue, Oct 23, 2018 at 10:07 AM Can Guo  wrote:
>>
>> This patch series adds support for UFS QMP PHY on SDM845 and the
>> compatible string for it. This patch series depends on the current
>> proposed QMP V3 USB3 UNI PHY support for sdm845 driver [1], on
>> the DT bindings for the QMP V3 USB3 PHYs based dirver [2], and also
>> rebased on updated pipe_clk initialization sequence [3]. This series
>> can only be merged once the dependent patches do.
>> [1] 
>> http://lists-archives.com/linux-kernel/29071659-dt-bindings-phy-qcom-qmp-update-bindings-for-sdm845.html
>> [2] 
>> http://lists-archives.com/linux-kernel/29071660-phy-qcom-qmp-add-qmp-v3-usb3-uni-phy-support-for-sdm845.html
>> [3] https://patchwork.kernel.org/patch/10376551/
> 
> Besides my comment for PATCH 4/6, I have already reviewed the entire series,
> and it looks good.
> If adding new bindings for sdm845 needs a further review, can you separate out
> just the phy patches from this series (patch 1, 2, 3 & 6), and re-send them.
> We can ask Kishon if he can pull them in for this merge window.
> Thanks.

I'm confused. I was trying to 'git am' this series on top of v4.20 but it
has been partly merged AFAICT.

commit 0d58280cf1e61b06cb4d4aab672efccdc28794f6
Author: Can Guo 
AuthorDate: Thu Sep 20 21:27:54 2018 -0700
Commit: Kishon Vijay Abraham I 
CommitDate: Tue Sep 25 16:10:13 2018 +0530

commit 6b04526812ac41ba82317caa8df3549dda2cab97
Author: Can Guo 
AuthorDate: Thu Sep 20 21:27:55 2018 -0700
Commit: Kishon Vijay Abraham I 
CommitDate: Tue Sep 25 16:10:14 2018 +0530

commit cc31cdbef9b7166fe42e08267349cfbaa32696b6
Author: Can Guo 
AuthorDate: Thu Sep 20 21:27:56 2018 -0700
Commit: Kishon Vijay Abraham I 
CommitDate: Tue Sep 25 16:10:14 2018 +0530

Can't find
[PATCH v10 4/6] scsi: ufs: Add core reset support
[PATCH v10 5/6] scsi: ufs: Power on phy after it is initialized

commit 99c7c7364b714e1de54a25c3642d991de1675e27
Author: Can Guo 
AuthorDate: Tue Sep 25 12:10:12 2018 +0530
Commit: Kishon Vijay Abraham I 
CommitDate: Tue Sep 25 16:10:14 2018 +0530


So basically, only patches 4 and 5 have not landed yet?
(Are they perhaps in someone's -next tree?)

Regards.


Re: [PATCH] scsi: t10-pi: Return correct ref tag when queue has no integrity profile

2018-12-06 Thread John Garry

On 06/12/2018 04:17, Martin K. Petersen wrote:

+



Bart,


Had you considered to use lower_32_bits() instead of "0x"?
That would to avoid that reviewers have to count the 'f'-s to verify
correctness of t10_pi_ref_tag().


I hadn't. I guess I tend to think of lower_32_bits() as something you do
to pointers, not to block numbers.



Xiang Chen tested the patch successfully. I'll let him provide tested-by 
tag.


Thanks,
John



Re: [PATCH RFC] sr: mark the device as changed when burning a CD

2018-12-06 Thread Maurizio Lombardi



Dne 6.12.2018 v 11:34 Maurizio Lombardi napsal(a):
> This is what I see when a cd burn operation completes:
> 


This is the complete blktrace log:

 11,034 0.81759 11653  D   W 63488 (2a 00 00 03 3c 29 00 00 
1f 00 ..) [wodim]
 11,034 0.81759 11653  D   W 63488 (2a 00 00 03 3c 29 00 00 
1f 00 ..) [wodim]
 11,034 0.81759 11653  D   W 63488 (2a 00 00 03 3c 29 00 00 
1f 00 ..) [wodim]
 11,034 0.81759 11653  D   W 63488 (2a 00 00 03 3c 29 00 00 
1f 00 ..) [wodim]
 11,038 0.049744147 11653  D   W 63488 (2a 00 00 03 3c 48 00 00 
1f 00 ..) [wodim]
 11,038 0.049744147 11653  D   W 63488 (2a 00 00 03 3c 48 00 00 
1f 00 ..) [wodim]
 11,038 0.049744147 11653  D   W 63488 (2a 00 00 03 3c 48 00 00 
1f 00 ..) [wodim]
 11,038 0.049744147 11653  D   W 63488 (2a 00 00 03 3c 48 00 00 
1f 00 ..) [wodim]
 11,03   12 0.102512363 11653  D   W 63488 (2a 00 00 03 3c 67 00 00 
1f 00 ..) [wodim]
 11,03   12 0.102512363 11653  D   W 63488 (2a 00 00 03 3c 67 00 00 
1f 00 ..) [wodim]
 11,03   12 0.102512363 11653  D   W 63488 (2a 00 00 03 3c 67 00 00 
1f 00 ..) [wodim]
 11,03   12 0.102512363 11653  D   W 63488 (2a 00 00 03 3c 67 00 00 
1f 00 ..) [wodim]
 11,03   16 0.152219178 11653  D   W 63488 (2a 00 00 03 3c 86 00 00 
1f 00 ..) [wodim]
 11,03   16 0.152219178 11653  D   W 63488 (2a 00 00 03 3c 86 00 00 
1f 00 ..) [wodim]
 11,03   16 0.152219178 11653  D   W 63488 (2a 00 00 03 3c 86 00 00 
1f 00 ..) [wodim]
 11,03   16 0.152219178 11653  D   W 63488 (2a 00 00 03 3c 86 00 00 
1f 00 ..) [wodim]
 11,03   20 0.205093330 11653  D   W 63488 (2a 00 00 03 3c a5 00 00 
1f 00 ..) [wodim]
 11,03   20 0.205093330 11653  D   W 63488 (2a 00 00 03 3c a5 00 00 
1f 00 ..) [wodim]
 11,03   20 0.205093330 11653  D   W 63488 (2a 00 00 03 3c a5 00 00 
1f 00 ..) [wodim]
 11,03   20 0.205093330 11653  D   W 63488 (2a 00 00 03 3c a5 00 00 
1f 00 ..) [wodim]
 11,03   24 0.254684616 11653  D   W 63488 (2a 00 00 03 3c c4 00 00 
1f 00 ..) [wodim]
 11,03   24 0.254684616 11653  D   W 63488 (2a 00 00 03 3c c4 00 00 
1f 00 ..) [wodim]
 11,03   24 0.254684616 11653  D   W 63488 (2a 00 00 03 3c c4 00 00 
1f 00 ..) [wodim]
 11,03   24 0.254684616 11653  D   W 63488 (2a 00 00 03 3c c4 00 00 
1f 00 ..) [wodim]
 11,03   28 0.307478799 11653  D   W 63488 (2a 00 00 03 3c e3 00 00 
1f 00 ..) [wodim]
 11,03   28 0.307478799 11653  D   W 63488 (2a 00 00 03 3c e3 00 00 
1f 00 ..) [wodim]
 11,03   28 0.307478799 11653  D   W 63488 (2a 00 00 03 3c e3 00 00 
1f 00 ..) [wodim]
 11,03   28 0.307478799 11653  D   W 63488 (2a 00 00 03 3c e3 00 00 
1f 00 ..) [wodim]
 11,03   32 0.357166787 11653  D   W 63488 (2a 00 00 03 3d 02 00 00 
1f 00 ..) [wodim]
 11,03   32 0.357166787 11653  D   W 63488 (2a 00 00 03 3d 02 00 00 
1f 00 ..) [wodim]
 11,03   32 0.357166787 11653  D   W 63488 (2a 00 00 03 3d 02 00 00 
1f 00 ..) [wodim]
 11,03   32 0.357166787 11653  D   W 63488 (2a 00 00 03 3d 02 00 00 
1f 00 ..) [wodim]
 11,03   36 0.409940696 11653  D   W 63488 (2a 00 00 03 3d 21 00 00 
1f 00 ..) [wodim]
 11,03   36 0.409940696 11653  D   W 63488 (2a 00 00 03 3d 21 00 00 
1f 00 ..) [wodim]
 11,03   36 0.409940696 11653  D   W 63488 (2a 00 00 03 3d 21 00 00 
1f 00 ..) [wodim]
 11,03   36 0.409940696 11653  D   W 63488 (2a 00 00 03 3d 21 00 00 
1f 00 ..) [wodim]
 11,03   40 0.459603865 11653  D   W 63488 (2a 00 00 03 3d 40 00 00 
1f 00 ..) [wodim]
 11,03   40 0.459603865 11653  D   W 63488 (2a 00 00 03 3d 40 00 00 
1f 00 ..) [wodim]
 11,03   40 0.459603865 11653  D   W 63488 (2a 00 00 03 3d 40 00 00 
1f 00 ..) [wodim]
 11,03   40 0.459603865 11653  D   W 63488 (2a 00 00 03 3d 40 00 00 
1f 00 ..) [wodim]
 11,03   44 0.512511601 11653  D   W 63488 (2a 00 00 03 3d 5f 00 00 
1f 00 ..) [wodim]
 11,03   44 0.512511601 11653  D   W 63488 (2a 00 00 03 3d 5f 00 00 
1f 00 ..) [wodim]
 11,03   44 0.512511601 11653  D   W 63488 (2a 00 00 03 3d 5f 00 00 
1f 00 ..) [wodim]
 11,03   44 0.512511601 11653  D   W 63488 (2a 00 00 03 3d 5f 00 00 
1f 00 ..) [wodim]
 11,03   48 0.562033003 11653  D   W 63488 (2a 00 00 03 3d 7e 00 00 
1f 00 ..) [wodim]
 11,03   48 0.562033003 11653  D   W 63488 (2a 00 00 03 3d 7e 00 00 
1f 00 ..) [wodim]
 11,03   48 0.562033003 11653  D   W 63488 (2a 00 00 03 3d 7e 00 00 
1f 00 ..) [wodim]
 11,03   48 0.562033003 11653  D   W 63488 (2a 00 00 03 3d 7e 00 00 
1f 00 ..) [wodim]
 11,03   52 0.614956620 11653  D   W 63488 (2a 00 00 03 3d 9d 00 00 
1f 00 ..) 

Re: [PATCH RFC] sr: mark the device as changed when burning a CD

2018-12-06 Thread Maurizio Lombardi
Hi Jens,

Dne 20.6.2018 v 16:09 Jens Axboe napsal(a):
> On 6/20/18 5:52 AM, Maurizio Lombardi wrote:
>> Hi Jens,
>>
>> Dne 23.5.2018 v 16:42 Jens Axboe napsal(a):
>>> On 5/23/18 3:19 AM, Maurizio Lombardi wrote:


 Dne 22.5.2018 v 16:47 Jens Axboe napsal(a):
> It's been many years, but back in the day the program writing the cd
> would eject the disc once done. This of course forces a reload of
> the toc and clearing of the flag. What program is this? Seems like
> it should probably eject when it's done.

 They are using wodim to burn the CDs on their servers.
 The problem is that they do not want the CD to be ejected because their 
 drives
 lack a motorized tray, thus requiring manual intervention which they would 
 like to avoid.
>>>
>>> I took a quick look at it, man that sr driver needs a bit of love :-)
>>>
>>> Anyway, I wonder if something like the below would work. Check for
>>> a close track command in the sr completion handler, and flag the media
>>> as changed if we see one. Totally untested...
>>>
>>>
>>> diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
>>> index 3f3cb72e0c0c..48f0d7a096db 100644
>>> --- a/drivers/scsi/sr.c
>>> +++ b/drivers/scsi/sr.c
>>> @@ -328,6 +328,9 @@ static int sr_done(struct scsi_cmnd *SCpnt)
>>> scmd_printk(KERN_INFO, SCpnt, "done: %x\n", result);
>>>  #endif
>>>  
>>> +   if (SCpnt->cmnd[0] == GPCMD_CLOSE_TRACK)
>>> +   cd->device->changed = 1;
>>> +
>>> /*
>>>  * Handle MEDIUM ERRORs or VOLUME OVERFLOWs that indicate partial
>>>  * success.  Since this is a relatively rare error condition, no
>>>
>>
>> I just want to let you know that I tested the patch but unfortunately it 
>> doesn't work.
>> I will try to find out what GPCMD_* commands are passed to sr_done() when 
>> burning a disc
>> to see if there is another one which we could use.
> 
> It's been a decade since I last messed with this or burned a cd-r, so that
> would be appreciated. blktrace should be enough to tell you what commands
> are being sent.
> 

You remember this patch? The problem was that after a cd burn operation 
completes,
you can't mount the cd unless you eject it first.

I finally carried out the test you suggested by using blktrace.

This is what I see when a cd burn operation completes:

11,03   32 0.357166787 11653  D   W 63488 (2a 00 00 03 3d 02 00 00 
1f 00 ..) [wodim]
 11,03   32 0.357166787 11653  D   W 63488 (2a 00 00 03 3d 02 00 00 
1f 00 ..) [wodim]
 11,03   32 0.357166787 11653  D   W 63488 (2a 00 00 03 3d 02 00 00 
1f 00 ..) [wodim]
 11,03   32 0.357166787 11653  D   W 63488 (2a 00 00 03 3d 02 00 00 
1f 00 ..) [wodim]
 11,03   80 0.922358386 11653  D   W 63488 (2a 00 00 03 3e 57 00 00 
1f 00 ..) [wodim]
 11,03   80 0.922358386 11653  D   W 63488 (2a 00 00 03 3e 57 00 00 
1f 00 ..) [wodim]
 11,03   80 0.922358386 11653  D   W 63488 (2a 00 00 03 3e 57 00 00 
1f 00 ..) [wodim]
 11,03   80 0.922358386 11653  D   W 63488 (2a 00 00 03 3e 57 00 00 
1f 00 ..) [wodim]
 11,03  112 1.332351325 11653  D   W 63488 (2a 00 00 03 3f 4f 00 00 
1f 00 ..) [wodim]
 11,03  112 1.332351325 11653  D   W 63488 (2a 00 00 03 3f 4f 00 00 
1f 00 ..) [wodim]
 11,03  112 1.332351325 11653  D   W 63488 (2a 00 00 03 3f 4f 00 00 
1f 00 ..) [wodim]
 11,03  112 1.332351325 11653  D   W 63488 (2a 00 00 03 3f 4f 00 00 
1f 00 ..) [wodim]
 11,03  152 1.791786352 11653  D   W 63488 (2a 00 00 03 40 66 00 00 
1f 00 ..) [wodim]
 11,03  152 1.791786352 11653  D   W 63488 (2a 00 00 03 40 66 00 00 
1f 00 ..) [wodim]
 11,03  152 1.791786352 11653  D   W 63488 (2a 00 00 03 40 66 00 00 
1f 00 ..) [wodim]
 11,03  152 1.791786352 11653  D   W 63488 (2a 00 00 03 40 66 00 00 
1f 00 ..) [wodim]
 11,03  196 2.357046291 11653  D   W 63488 (2a 00 00 03 41 bb 00 00 
1f 00 ..) [wodim]
 11,03  196 2.357046291 11653  D   W 63488 (2a 00 00 03 41 bb 00 00 
1f 00 ..) [wodim]
 11,03  196 2.357046291 11653  D   W 63488 (2a 00 00 03 41 bb 00 00 
1f 00 ..) [wodim]
 11,03  196 2.357046291 11653  D   W 63488 (2a 00 00 03 41 bb 00 00 
1f 00 ..) [wodim]
 11,03  304 3.600032959 11653  D   N 0 (35 00 ..) [wodim]
 11,03  304 3.600032959 11653  D   N 0 (35 00 ..) [wodim]
 11,03  304 3.600032959 11653  D   N 0 (35 00 ..) [wodim]
 11,03  304 3.600032959 11653  D   N 0 (35 00 ..) [wodim]
 11,03  33218.496219927 11653  D   N 0 (35 00 ..) [wodim]
 11,03  33218.496219927 11653  D   N 0 (35 00 ..) [wodim]
 11,03  33218.496219927 11653  D   N 0 (35 00 ..) [wodim]
 11,03  33218.496219927 11653  D   N 0 (35 00 ..) [wodim]
 11,03  35218.499114653  7433  D   N 0 (00 ..) [kworker/3:2]
 11,03  35218.499114653  7433  D   N 0 (00 ..)