Re: [V2 PATCH 04/11] aacraid: MSI-x support

2015-03-27 Thread Johannes Thumshirn
Mahesh Rajashekhara mahesh.rajashekh...@pmcs.com writes:

 Add MSI-x interrupt mode support.

 Signed-off-by: Mahesh Rajashekhara mahesh.rajashekh...@pmcs.com
 ---
  drivers/scsi/aacraid/aacraid.h  |   80 -
  drivers/scsi/aacraid/comminit.c |   95 +-
  drivers/scsi/aacraid/commsup.c  |   20 ++-
  drivers/scsi/aacraid/dpcsup.c   |9 +-
  drivers/scsi/aacraid/linit.c|   20 ++-
  drivers/scsi/aacraid/src.c  |  388 
 ++-
  6 files changed, 505 insertions(+), 107 deletions(-)

 diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
 index 9e38b20..015c341 100644
 --- a/drivers/scsi/aacraid/aacraid.h
 +++ b/drivers/scsi/aacraid/aacraid.h
 @@ -6,11 +6,61 @@
  #define nblank(x) _nblank(x)[0]
  
  #include linux/interrupt.h
 +#include linux/pci.h
  
  
 /*--
   *  D E F I N E S
   
 **/
  
 +#define AAC_MAX_MSIX 32  /* vectors */
 +#define AAC_PCI_MSI_ENABLE   0x8000
 +
 +enum {
 + AAC_ENABLE_INTERRUPT= 0x0,
 + AAC_DISABLE_INTERRUPT,
 + AAC_ENABLE_MSIX,
 + AAC_DISABLE_MSIX,
 + AAC_CLEAR_AIF_BIT,
 + AAC_CLEAR_SYNC_BIT,
 + AAC_ENABLE_INTX
 +};
 +
 +#define AAC_INT_MODE_INTX(10)
 +#define AAC_INT_MODE_MSI (11)
 +#define AAC_INT_MODE_AIF (12)
 +#define AAC_INT_MODE_SYNC(13)
 +
 +#define AAC_INT_ENABLE_TYPE1_INTX0xfffb
 +#define AAC_INT_ENABLE_TYPE1_MSIX0xfffa
 +#define AAC_INT_DISABLE_ALL  0x
 +
 +/* Bit definitions in IOA-Host Interrupt Register */
 +#define PMC_TRANSITION_TO_OPERATIONAL(131)
 +#define PMC_IOARCB_TRANSFER_FAILED   (128)
 +#define PMC_IOA_UNIT_CHECK   (127)
 +#define PMC_NO_HOST_RRQ_FOR_CMD_RESPONSE (126)
 +#define PMC_CRITICAL_IOA_OP_IN_PROGRESS  (125)
 +#define PMC_IOARRIN_LOST (14)
 +#define PMC_SYSTEM_BUS_MMIO_ERROR(13)
 +#define PMC_IOA_PROCESSOR_IN_ERROR_STATE (12)
 +#define PMC_HOST_RRQ_VALID   (11)
 +#define PMC_OPERATIONAL_STATUS   (131)
 +#define PMC_ALLOW_MSIX_VECTOR0   (10)
 +
 +#define PMC_IOA_ERROR_INTERRUPTS (PMC_IOARCB_TRANSFER_FAILED | \
 +  PMC_IOA_UNIT_CHECK | \
 +  PMC_NO_HOST_RRQ_FOR_CMD_RESPONSE | \
 +  PMC_IOARRIN_LOST | \
 +  PMC_SYSTEM_BUS_MMIO_ERROR | \
 +  PMC_IOA_PROCESSOR_IN_ERROR_STATE)
 +
 +#define PMC_ALL_INTERRUPT_BITS   (PMC_IOA_ERROR_INTERRUPTS | \
 +  PMC_HOST_RRQ_VALID | \
 +  PMC_TRANSITION_TO_OPERATIONAL | \
 +  PMC_ALLOW_MSIX_VECTOR0)
 +#define  PMC_GLOBAL_INT_BIT2 0x0004
 +#define  PMC_GLOBAL_INT_BIT0 0x0001
 +
  #ifndef AAC_DRIVER_BUILD
  # define AAC_DRIVER_BUILD 30300
  # define AAC_DRIVER_BRANCH -ms
 @@ -36,6 +86,7 @@
  #define CONTAINER_TO_ID(cont)(cont)
  #define CONTAINER_TO_LUN(cont)   (0)
  
 +#define PMC_DEVICE_S60x28b
  #define PMC_DEVICE_S70x28c
  #define PMC_DEVICE_S80x28d
  #define PMC_DEVICE_S90x28f
 @@ -434,7 +485,7 @@ enum fib_xfer_state {
  struct aac_init
  {
   __le32  InitStructRevision;
 - __le32  MiniPortRevision;
 + __le32  Sa_MSIXVectors;
   __le32  fsrev;
   __le32  CommHeaderAddress;
   __le32  FastIoCommAreaAddress;
 @@ -755,7 +806,8 @@ struct rkt_registers {
  
  struct src_mu_registers {
   /*  PCI*| Name */
 - __le32  reserved0[8];   /*  00h | Reserved */
 + __le32  reserved0[6];   /*  00h | Reserved */
 + __le32  IOAR[2];/*  18h | IOA-host interrupt register */
   __le32  IDR;/*  20h | Inbound Doorbell Register */
   __le32  IISR;   /*  24h | Inbound Int. Status Register */
   __le32  reserved1[3];   /*  28h | Reserved */
 @@ -767,17 +819,18 @@ struct src_mu_registers {
   __le32  OMR;/*  bch | Outbound Message Register */
   __le32  IQ_L;   /*  c0h | Inbound Queue (Low address) */
   __le32  IQ_H;   /*  c4h | Inbound Queue (High address) */
 + __le32  ODR_MSI;/*  c8h | MSI register for sync./AIF */
  };
  
  struct src_registers {
 - struct src_mu_registers MUnit;  /* 00h - c7h */
 + struct src_mu_registers MUnit;  /* 00h - cbh */
   union {
   struct {
 - __le32 reserved1[130790];   /* c8h - 7fc5fh */
 + __le32 reserved1[130789];   /* cch - 7fc5fh */
   struct src_inbound IndexRegs;   /* 7fc60h */
   } tupelo;
   

[PATCH] advansys: fix compilation errors and warnings when CONFIG_PCI is not set

2015-06-03 Thread Johannes Thumshirn
Fix compilation errors on forgotten #include linux/dmapool.h and warnings when
CONFIG_PCI is not set.

Reported-by: Jim Davis jim.ep...@gmail.com
Signed-off-by: Johannes Thumshirn jthumsh...@suse.de
---
 drivers/scsi/advansys.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 14d3aa5..4305178 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -37,6 +37,7 @@
 #include linux/spinlock.h
 #include linux/dma-mapping.h
 #include linux/firmware.h
+#include linux/dmapool.h
 
 #include asm/io.h
 #include asm/dma.h
@@ -9435,6 +9436,7 @@ static int AscInitSetConfig(struct pci_dev *pdev, struct 
Scsi_Host *shost)
  * on big-endian platforms so char fields read as words are actually being
  * unswapped on big-endian platforms.
  */
+#ifdef CONFIG_PCI
 static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config = {
ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
0x, /* cfg_msw */
@@ -9771,7 +9773,6 @@ static ADVEEP_38C1600_CONFIG 
ADVEEP_38C1600_Config_Field_IsChar = {
0   /* 63 reserved */
 };
 
-#ifdef CONFIG_PCI
 /*
  * Wait for EEPROM command to complete
  */
@@ -11385,7 +11386,9 @@ static int advansys_board_found(struct Scsi_Host 
*shost, unsigned int iop,
  err_unmap:
if (boardp-ioremap_addr)
iounmap(boardp-ioremap_addr);
+#ifdef CONFIG_PCI
  err_shost:
+#endif
return ret;
 }
 
-- 
1.8.5.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] megaraid_sas: insert missing space in kernel message

2015-06-10 Thread Johannes Thumshirn
On Tue, Jun 09, 2015 at 04:53:43PM +0100, Colin King wrote:
 From: Colin Ian King colin.k...@canonical.com
 
 The printk format specifier string is missing a space between
 the %p format specifier and the on the defer text. Minor fix,
 add the missing space.
 
 Signed-off-by: Colin Ian King colin.k...@canonical.com
 ---
  drivers/scsi/megaraid/megaraid_sas_base.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
 b/drivers/scsi/megaraid/megaraid_sas_base.c
 index 890637f..4889ef6 100644
 --- a/drivers/scsi/megaraid/megaraid_sas_base.c
 +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
 @@ -3148,7 +3148,7 @@ megasas_internal_reset_defer_cmds(struct 
 megasas_instance *instance)
   cmd = instance-cmd_list[i];
   if (cmd-sync_cmd == 1 || cmd-scmd) {
   printk(KERN_NOTICE megasas: moving cmd[%d]:%p:%d:%p
 - on the defer queue as internal\n,
 +  on the defer queue as internal\n,
   defer_index, cmd, cmd-sync_cmd, cmd-scmd);
  
   if (!list_empty(cmd-list)) {
 -- 
 2.1.4
 

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mvsas: always iounmap resources

2015-06-22 Thread Johannes Thumshirn
On Fri, Jun 12, 2015 at 08:31:38AM +0200, Hannes Reinecke wrote:
 On 05/22/2015 11:15 AM, Johannes Thumshirn wrote:
  In case pci_resource_start() or pci_resource_len() reutrn 0, mvsas_ioremap
  returns without doing an iounmap() of mvi-regs_ex.
  
  Found by the cocinelle tool.
  
  Signed-off-by: Johannes Thumshirn jthumsh...@suse.de
  ---
   drivers/scsi/mvsas/mv_init.c | 5 -
   1 file changed, 4 insertions(+), 1 deletion(-)
  
  diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
  index 53030b0..04a3205 100644
  --- a/drivers/scsi/mvsas/mv_init.c
  +++ b/drivers/scsi/mvsas/mv_init.c
  @@ -339,8 +339,11 @@ int mvs_ioremap(struct mvs_info *mvi, int bar, int 
  bar_ex)
   
  res_start = pci_resource_start(pdev, bar);
  res_len = pci_resource_len(pdev, bar);
  -   if (!res_start || !res_len)
  +   if (!res_start || !res_len) {
  +   iounmap(mvi-regs_ex);
  +   mvi-regs_ex = NULL;
  goto err_out;
  +   }
   
  res_flag = pci_resource_flags(pdev, bar);
  if (res_flag  IORESOURCE_CACHEABLE)
  
 Reviewed-by: Hannes Reinecke h...@suse.de
 

James, any update on this?
Do you intent to take it for 4.2?

Thank,
Johannes
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in


Re: [PATCH] SCSI-OSD: Delete an unnecessary check before the function call put_disk

2015-06-24 Thread Johannes Thumshirn
On Wed, Jun 24, 2015 at 04:16:34PM +0200, SF Markus Elfring wrote:
 From: Markus Elfring elfr...@users.sourceforge.net
 Date: Wed, 24 Jun 2015 16:06:21 +0200
 
 The put_disk() function tests whether its argument is NULL and then
 returns immediately. Thus the test around the call is not needed.
 
 This issue was detected by using the Coccinelle software.
 
 Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
 ---
  drivers/scsi/osd/osd_uld.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
 
 diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
 index 243eab3..e2075522 100644
 --- a/drivers/scsi/osd/osd_uld.c
 +++ b/drivers/scsi/osd/osd_uld.c
 @@ -407,9 +407,7 @@ static void __remove(struct device *dev)
  
   OSD_INFO(osd_remove %s\n,
oud-disk ? oud-disk-disk_name : NULL);
 -
 - if (oud-disk)
 - put_disk(oud-disk);
 + put_disk(oud-disk);
   ida_remove(osd_minor_ida, oud-minor);
  
   kfree(oud);
 -- 
 2.4.4
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH resend] mpt2sas: setpci reset kernel panic fix

2015-06-19 Thread Johannes Thumshirn
(mpt2sas_ioc_list);
 -
 +/* global ioc lock for list operations */
 +spinlock_t gioc_lock;
  /* local parameters */
  static u8 scsi_io_cb_idx = -1;
  static u8 tm_cb_idx = -1;
 @@ -279,6 +280,20 @@ static struct pci_device_id scsih_pci_table[] = {
  MODULE_DEVICE_TABLE(pci, scsih_pci_table);
  
  /**
 + * mpt2sas_initialize_gioc_lock - initialize the gobal ioc lock
 + */
 +void
 +mpt2sas_initialize_gioc_lock(void)
 +{
 + static int gioc_lock_initialize;
 +
 + if (!gioc_lock_initialize) {
 + spin_lock_init(gioc_lock);
 + gioc_lock_initialize = 1;
 + }
 +}
 +
 +/**
   * _scsih_set_debug_level - global setting of ioc-logging_level.
   *
   * Note: The logging levels are defined in mpt2sas_debug.h.
 @@ -288,13 +303,17 @@ _scsih_set_debug_level(const char *val, struct 
 kernel_param *kp)
  {
   int ret = param_set_int(val, kp);
   struct MPT2SAS_ADAPTER *ioc;
 + unsigned long flags;
  
   if (ret)
   return ret;
  
 + mpt2sas_initialize_gioc_lock();
   printk(KERN_INFO setting logging_level(0x%08x)\n, logging_level);
 + spin_lock_irqsave(gioc_lock, flags);
   list_for_each_entry(ioc, mpt2sas_ioc_list, list)
   ioc-logging_level = logging_level;
 + spin_unlock_irqrestore(gioc_lock, flags);
   return 0;
  }
  module_param_call(logging_level, _scsih_set_debug_level, param_get_int,
 @@ -7867,7 +7886,9 @@ _scsih_remove(struct pci_dev *pdev)
   sas_remove_host(shost);
   scsi_remove_host(shost);
   mpt2sas_base_detach(ioc);
 + spin_lock_irqsave(gioc_lock, flags);
   list_del(ioc-list);
 + spin_unlock_irqrestore(gioc_lock, flags);
   scsi_host_put(shost);
  }
  
 @@ -8132,6 +8153,7 @@ _scsih_probe(struct pci_dev *pdev, const struct 
 pci_device_id *id)
   struct MPT2SAS_ADAPTER *ioc;
   struct Scsi_Host *shost;
   int rv;
 + unsigned long flags;
  
   shost = scsi_host_alloc(scsih_driver_template,
   sizeof(struct MPT2SAS_ADAPTER));
 @@ -8142,7 +8164,9 @@ _scsih_probe(struct pci_dev *pdev, const struct 
 pci_device_id *id)
   ioc = shost_priv(shost);
   memset(ioc, 0, sizeof(struct MPT2SAS_ADAPTER));
   INIT_LIST_HEAD(ioc-list);
 + spin_lock_irqsave(gioc_lock, flags);
   list_add_tail(ioc-list, mpt2sas_ioc_list);
 + spin_unlock_irqrestore(gioc_lock, flags);
   ioc-shost = shost;
   ioc-id = mpt_ids++;
   sprintf(ioc-name, %s%d, MPT2SAS_DRIVER_NAME, ioc-id);
 @@ -8167,6 +8191,9 @@ _scsih_probe(struct pci_dev *pdev, const struct 
 pci_device_id *id)
   ioc-schedule_dead_ioc_flush_running_cmds = _scsih_flush_running_cmds;
   /* misc semaphores and spin locks */
   mutex_init(ioc-reset_in_progress_mutex);
 + /* initializing pci_access_mutex lock */
 + if (ioc-is_warpdrive)
 + mutex_init(ioc-pci_access_mutex);
   spin_lock_init(ioc-ioc_reset_in_progress_lock);
   spin_lock_init(ioc-scsi_lookup_lock);
   spin_lock_init(ioc-sas_device_lock);
 @@ -8269,7 +8296,9 @@ _scsih_probe(struct pci_dev *pdev, const struct 
 pci_device_id *id)
   out_attach_fail:
   destroy_workqueue(ioc-firmware_event_thread);
   out_thread_fail:
 + spin_lock_irqsave(gioc_lock, flags);
   list_del(ioc-list);
 + spin_unlock_irqrestore(gioc_lock, flags);
   scsi_host_put(shost);
   return rv;
  }
 @@ -8506,6 +8535,7 @@ _scsih_init(void)
   return -ENODEV;
   }
  
 + mpt2sas_initialize_gioc_lock();
   mpt2sas_base_initialize_callback_handler();
  
/* queuecommand callback hander */
 -- 
 1.7.1
 
 
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in

Generally, would it be sufficiant to have _one_ call to
mpt2sas_initialize_gioc_lock() (per instance)? This way a) everbody (read
people debugging it) knew it will be already initialized and b) you don't need
is already initialized check any more.


Thanks,
Johannes

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in


Re: [PATCH resend] mpt2sas: setpci reset kernel panic fix

2015-06-19 Thread Johannes Thumshirn
On Fri, Jun 19, 2015 at 04:15:12AM -0700, Christoph Hellwig wrote:
  @@ -79,7 +79,8 @@ static int _scsih_scan_finished(struct Scsi_Host *shost, 
  unsigned long time);
   
   /* global parameters */
   LIST_HEAD(mpt2sas_ioc_list);
  -
  +/* global ioc lock for list operations */
  +spinlock_t gioc_lock;
   /* local parameters */
   static u8 scsi_io_cb_idx = -1;
   static u8 tm_cb_idx = -1;
  @@ -279,6 +280,20 @@ static struct pci_device_id scsih_pci_table[] = {
   MODULE_DEVICE_TABLE(pci, scsih_pci_table);
   
   /**
  + * mpt2sas_initialize_gioc_lock - initialize the gobal ioc lock
  + */
  +void
  +mpt2sas_initialize_gioc_lock(void)
  +{
  +   static int gioc_lock_initialize;
  +
  +   if (!gioc_lock_initialize) {
  +   spin_lock_init(gioc_lock);
  +   gioc_lock_initialize = 1;
  +   }
  +}
 
 Just use DEFINE_SPINLOCK() to initialize the lock at compile time.

Or yes, even better.

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in


Re: [PATCH v1 01/20] [SCSI] mpt3sas: Added Combined Reply Queue feature to extend up-to 96 MSIX vector support

2015-06-19 Thread Johannes Thumshirn
 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER 
 *ioc, int sleep_flag)
  
   /* initialize reply post host index */
   list_for_each_entry(reply_q, ioc-reply_queue_list, list) {
 - writel(reply_q-msix_index  MPI2_RPHI_MSIX_INDEX_SHIFT,
 - ioc-chip-ReplyPostHostIndex);
 + if (ioc-msix96_vector) {
 + writel((reply_q-msix_index  7)
 +MPI2_RPHI_MSIX_INDEX_SHIFT,
 +ioc-replyPostRegisterIndex[reply_q-msix_index/8]);
 + } else {
 + writel(reply_q-msix_index 
 + MPI2_RPHI_MSIX_INDEX_SHIFT,
 + ioc-chip-ReplyPostHostIndex);
 + }
 +
   if (!_base_is_controller_msix_enabled(ioc))
   goto skip_init_reply_post_host_index;
   }
 @@ -4577,6 +4617,9 @@ mpt3sas_base_free_resources(struct MPT3SAS_ADAPTER *ioc)
   _base_free_irq(ioc);
   _base_disable_msix(ioc);
  
 + if (ioc-msix96_vector)
 + kfree(ioc-replyPostRegisterIndex);
 +
   if (ioc-chip_phys  ioc-chip)
   iounmap(ioc-chip);
   ioc-chip_phys = 0;
 @@ -4600,6 +4643,7 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
  {
   int r, i;
   int cpu_id, last_cpu_id = 0;
 + u8 revision;
  
   dinitprintk(ioc, pr_info(MPT3SAS_FMT %s\n, ioc-name,
   __func__));
 @@ -4618,6 +4662,18 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
   r = -ENOMEM;
   goto out_free_resources;
   }
 + /* Check whether the controller revision is C0 or above.
 + C0 and above revision controllers support 96 vectors */
 + revision = ioc-pdev-revision;
 +
 + if ((ioc-pdev-device == MPI25_MFGPAGE_DEVID_SAS3004 ||
 +  ioc-pdev-device == MPI25_MFGPAGE_DEVID_SAS3008 ||
 +  ioc-pdev-device == MPI25_MFGPAGE_DEVID_SAS3108_1 ||
 +  ioc-pdev-device == MPI25_MFGPAGE_DEVID_SAS3108_2 ||
 +  ioc-pdev-device == MPI25_MFGPAGE_DEVID_SAS3108_5 ||
 +  ioc-pdev-device == MPI25_MFGPAGE_DEVID_SAS3108_6) 
 +  (revision = 0x02))
 + ioc-msix96_vector = 1;
  
   ioc-rdpq_array_enable_assigned = 0;
   ioc-dma_mask = 0;
 diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
 b/drivers/scsi/mpt3sas/mpt3sas_base.h
 index afa8816..6b8d8f1 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h
 +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
 @@ -728,7 +728,8 @@ typedef void (*MPT3SAS_FLUSH_RUNNING_CMDS)(struct 
 MPT3SAS_ADAPTER *ioc);
   *   is assigned only ones
   * @reply_queue_count: number of reply queue's
   * @reply_queue_list: link list contaning the reply queue info
 - * @reply_post_host_index: head index in the pool where FW completes IO
 + * @msix96_vector: 96 MSI-X vector support
 + * @replyPostRegisterIndex: index of next position in Reply Desc Post Queue
   * @delayed_tr_list: target reset link list
   * @delayed_tr_volume_list: volume target reset link list
   * @@temp_sensors_count: flag to carry the number of temperature sensors
 @@ -937,6 +938,10 @@ struct MPT3SAS_ADAPTER {
   u8  reply_queue_count;
   struct list_head reply_queue_list;
  
 + u8  msix96_vector;
 + /* reply post register index */
 + resource_size_t **replyPostRegisterIndex;
 +
   struct list_head delayed_tr_list;
   struct list_head delayed_tr_volume_list;
   u8  temp_sensors_count;
 -- 
 2.0.2


Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in


Re: [PATCH v1 06/20] [SCSI] mpt3sas: Provides the physical location of sas drives

2015-06-19 Thread Johannes Thumshirn
-handle = handle;
 + sas_device-handle = sas_device_pg0-DevHandle;
   if (sas_target_priv_data)
 - sas_target_priv_data-handle = handle;
 + sas_target_priv_data-handle =
 + sas_device_pg0-DevHandle;
   goto out;
   }
   }
 @@ -6448,13 +6606,15 @@ _scsih_search_responding_sas_devices(struct 
 MPT3SAS_ADAPTER *ioc)
   MPI2_IOCSTATUS_MASK;
   if (ioc_status != MPI2_IOCSTATUS_SUCCESS)
   break;
 - handle = le16_to_cpu(sas_device_pg0.DevHandle);
 + handle = sas_device_pg0.DevHandle =
 + le16_to_cpu(sas_device_pg0.DevHandle);
   device_info = le32_to_cpu(sas_device_pg0.DeviceInfo);
   if (!(_scsih_is_end_device(device_info)))
   continue;
 - _scsih_mark_responding_sas_device(ioc,
 - le64_to_cpu(sas_device_pg0.SASAddress),
 - le16_to_cpu(sas_device_pg0.Slot), handle);
 + sas_device_pg0.SASAddress =
 + le64_to_cpu(sas_device_pg0.SASAddress);
 + sas_device_pg0.Slot = le16_to_cpu(sas_device_pg0.Slot);
 + _scsih_mark_responding_sas_device(ioc, sas_device_pg0);
   }
  
   out:
 -- 
 2.0.2
 

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in


Re: [PATCH 01/20] [SCSI] mpt3sas: Added Combined Reply Queue feature to extend up-to 96 MSIX vector support

2015-06-19 Thread Johannes Thumshirn
On Thu, Jun 18, 2015 at 03:27:26PM +0530, Sreekanth Reddy wrote:
 Hi,
 
 Any other review comments on this patch. please let us known if any
 changes are required.
 
 Thanks,
 Sreekanth
 

Have you sent a follow up on this I may have missed?

 On Fri, Jun 12, 2015 at 4:46 PM, Sreekanth Reddy
 sreekanth.re...@avagotech.com wrote:
  Thanks Johannes, we will take care of this point in our current
  on-development mpt2sas/mpt3sas merging activity.
  diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
  b/drivers/scsi/mpt3sas/mpt3sas_base.c

[...]

  index 14a781b..c13a365 100644
  --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
  +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
  @@ -83,7 +83,7 @@ static int msix_disable = -1;
   module_param(msix_disable, int, 0);
   MODULE_PARM_DESC(msix_disable,  disable msix routed interrupts 
  (default=0));
 
  -static int max_msix_vectors = 8;
  +static int max_msix_vectors = -1;
   module_param(max_msix_vectors, int, 0);
   MODULE_PARM_DESC(max_msix_vectors,
 max msix vectors - (default=8));
 ^^^
 
  When changing the default value, please also update the description 
  reflecting
  this change.
 

Thanks

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 06/20] [SCSI] mpt3sas: Provides the physical location of sas drives

2015-06-19 Thread Johannes Thumshirn
On Fri, Jun 12, 2015 at 03:12:18PM +0530, Sreekanth Reddy wrote:
 This Patch will provide more details of the devices such as slot number, 
 enclosure logical id, enclosure level  connector name in the following 
 scenarios,
 
 - When end device is added in the topology,
 - When the end device is removed from the setup,
 - When the SCSI mid layer issues TASK ABORT/ DEVICE RESET/ TARGET RESET 
 during error handling,
 - When any command to the device fails with Sense key Hardware error or 
 Medium error or Unit Attention,
 - When firmware returns device error or device not ready status for the end 
 device,
 - When a Predicted fault is detected on an end device.
 
 This information can be used by the user to identify the location of the 
 desired drive in the topology.
 
 Driver will get these information by reading the sas device page0.
 
 Signed-off-by: Sreekanth Reddy sreekanth.re...@avagotech.com
 ---
  drivers/scsi/mpt3sas/mpt3sas_base.h  |   2 +
  drivers/scsi/mpt3sas/mpt3sas_scsih.c | 238 
 +--
  2 files changed, 201 insertions(+), 39 deletions(-)
 
 diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
 b/drivers/scsi/mpt3sas/mpt3sas_base.h
 index b79ad4f..293ad23 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h
 +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
 @@ -317,6 +317,8 @@ struct _sas_device {
   u8  fast_path;
   u8  pfa_led_on;
   u8  pend_sas_rphy_add;
 + u8   enclosure_level;
 + u8   connector_name[4];

Minor nit of different indent here, don't know if it is worth re-sending?

Other than that:

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/20] [SCSI] mpt3sas: Added Combined Reply Queue feature to extend up-to 96 MSIX vector support

2015-06-19 Thread Johannes Thumshirn
On Fri, Jun 19, 2015 at 02:51:00PM +0530, Sreekanth Reddy wrote:
 On Fri, Jun 19, 2015 at 2:44 PM, Johannes Thumshirn jthumsh...@suse.de 
 wrote:
  On Thu, Jun 18, 2015 at 03:27:26PM +0530, Sreekanth Reddy wrote:
  Hi,
 
  Any other review comments on this patch. please let us known if any
  changes are required.
 
  Thanks,
  Sreekanth
 
 
  Have you sent a follow up on this I may have missed?
 
  On Fri, Jun 12, 2015 at 4:46 PM, Sreekanth Reddy
  sreekanth.re...@avagotech.com wrote:
   Thanks Johannes, we will take care of this point in our current
   on-development mpt2sas/mpt3sas merging activity.
   diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
   b/drivers/scsi/mpt3sas/mpt3sas_base.c
 
  [...]
 
   index 14a781b..c13a365 100644
   --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
   +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
   @@ -83,7 +83,7 @@ static int msix_disable = -1;
module_param(msix_disable, int, 0);
MODULE_PARM_DESC(msix_disable,  disable msix routed interrupts 
   (default=0));
  
   -static int max_msix_vectors = 8;
   +static int max_msix_vectors = -1;
module_param(max_msix_vectors, int, 0);
MODULE_PARM_DESC(max_msix_vectors,
  max msix vectors - (default=8));
   ^^^
  
   When changing the default value, please also update the description 
   reflecting
   this change.
 
 Johannes, I didn't notice this previously, I will post next version of
 this patch by updating the module parameter description

No problem :-)

 
 Thanks,
 Sreekanth
  
 
  Thanks
 
  --
  Johannes Thumshirn   Storage
  jthumsh...@suse.de +49 911 74053 689
  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)
 
 
 
 -- 
 
 Regards,
 Sreekanth

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Patch V2 4/9] [SCSI] aacraid: Enable 64-bit write to controller register

2015-06-11 Thread Johannes Thumshirn
On Wed, Jun 10, 2015 at 06:42:26PM -0700, rajinikanth.panduran...@pmcs.com 
wrote:
 From: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 
 Description:
 If writeq() not supported, then do atomic two 32bit write
 
 Signed-off-by: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 ---
  drivers/scsi/aacraid/aacraid.h  |  9 +
  drivers/scsi/aacraid/comminit.c |  1 +
  drivers/scsi/aacraid/src.c  | 12 ++--
  3 files changed, 20 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
 index 62b0999..e54f597 100644
 --- a/drivers/scsi/aacraid/aacraid.h
 +++ b/drivers/scsi/aacraid/aacraid.h
 @@ -844,6 +844,10 @@ struct src_registers {
   ((AEP)-regs.src.bar0-CSR))
  #define src_writel(AEP, CSR, value)  writel(value, \
   ((AEP)-regs.src.bar0-CSR))
 +#if defined(writeq)
 +#define  src_writeq(AEP, CSR, value) writeq(value, \
 + ((AEP)-regs.src.bar0-CSR))
 +#endif
  
  #define SRC_ODR_SHIFT12
  #define SRC_IDR_SHIFT9
 @@ -1163,6 +1167,11 @@ struct aac_dev
   struct fsa_dev_info *fsa_dev;
   struct task_struct  *thread;
   int cardtype;
 + /*
 +  *This lock will protect the two 32-bit
 +  *writes to the Inbound Queue
 +  */
 + spinlock_t  iq_lock;
  
   /*
*  The following is the device specific extension.
 diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c
 index e0a76d5..e4ff47e 100644
 --- a/drivers/scsi/aacraid/comminit.c
 +++ b/drivers/scsi/aacraid/comminit.c
 @@ -424,6 +424,7 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev)
   dev-management_fib_count = 0;
   spin_lock_init(dev-manage_lock);
   spin_lock_init(dev-sync_lock);
 + spin_lock_init(dev-iq_lock);
   dev-max_fib_size = sizeof(struct hw_fib);
   dev-sg_tablesize = host-sg_tablesize = (dev-max_fib_size
   - sizeof(struct aac_fibhdr)
 diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c
 index eb07b3d..1409a0b 100644
 --- a/drivers/scsi/aacraid/src.c
 +++ b/drivers/scsi/aacraid/src.c
 @@ -447,6 +447,10 @@ static int aac_src_deliver_message(struct fib *fib)
   u32 fibsize;
   dma_addr_t address;
   struct aac_fib_xporthdr *pFibX;
 +#if !defined(writeq)
 + unsigned long flags;
 +#endif
 +
   u16 hdr_size = le16_to_cpu(fib-hw_fib_va-header.Size);
  
   atomic_inc(q-numpending);
 @@ -511,10 +515,14 @@ static int aac_src_deliver_message(struct fib *fib)
   return -EINVAL;
   address |= fibsize;
   }
 -
 +#if defined(writeq)
 + src_writeq(dev, MUnit.IQ_L, (u64)address);
 +#else
 + spin_lock_irqsave(fib-dev-iq_lock, flags);
   src_writel(dev, MUnit.IQ_H, upper_32_bits(address)  0x);
   src_writel(dev, MUnit.IQ_L, address  0x);
 -
 + spin_unlock_irqrestore(fib-dev-iq_lock, flags);
 +#endif
   return 0;
  }

Why not make src_writeq() a wrapper over either writeq() or
spin_lock_irqsave(); src_writel() x2; spin_unlock_irqrestore(), depending on
the presence of writeq?


  
 -- 
 1.9.3
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 13/20] [SCSI] mpt3sas: MPI 2.5 Rev K (2.5.6) specifications

2015-06-15 Thread Johannes Thumshirn
On Fri, Jun 12, 2015 at 03:12:25PM +0530, Sreekanth Reddy wrote:
 Below are the new changes to MPI 2.5 Rev K(2.5.6) specification and 2.00.35 
 header files
 1) Added a minimum size requirement for target mode command buffers.
 2) Added MinMSIxIndex and MaxMSIxIndex fields to CommandBufferPostBase 
 Request.
 3) For BIOS Page 1, added SSUTimeout field, and added Product Name String 
 Format bits to the BiosOptions field
 
 Signed-off-by: Sreekanth Reddy sreekanth.re...@avagotech.com
 ---
  drivers/scsi/mpt3sas/mpi/mpi2.h  |  5 +++--
  drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h | 17 ++---
  2 files changed, 17 insertions(+), 5 deletions(-)
 
 diff --git a/drivers/scsi/mpt3sas/mpi/mpi2.h b/drivers/scsi/mpt3sas/mpi/mpi2.h
 index c2d127c..ec27ad2 100644
 --- a/drivers/scsi/mpt3sas/mpi/mpi2.h
 +++ b/drivers/scsi/mpt3sas/mpi/mpi2.h
 @@ -8,7 +8,7 @@
   * scatter/gather formats.
   * Creation Date:  June 21, 2006
   *
 - * mpi2.h Version:  02.00.34
 + * mpi2.h Version:  02.00.35
   *
   * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25
   *   prefix are for use only on MPI v2.5 products, and must not be used
 @@ -91,6 +91,7 @@
   * 08-19-13  02.00.32  Bumped MPI2_HEADER_VERSION_UNIT.
   * 12-05-13  02.00.33  Bumped MPI2_HEADER_VERSION_UNIT.
   * 01-08-14  02.00.34  Bumped MPI2_HEADER_VERSION_UNIT
 + * 06-13-14  02.00.35  Bumped MPI2_HEADER_VERSION_UNIT.
   * --
   */
  
 @@ -124,7 +125,7 @@
  #define MPI2_VERSION_02_05  (0x0205)
  
  /*Unit and Dev versioning for this MPI header set */
 -#define MPI2_HEADER_VERSION_UNIT(0x22)
 +#define MPI2_HEADER_VERSION_UNIT(0x23)
  #define MPI2_HEADER_VERSION_DEV (0x00)
  #define MPI2_HEADER_VERSION_UNIT_MASK   (0xFF00)
  #define MPI2_HEADER_VERSION_UNIT_SHIFT  (8)
 diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h 
 b/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h
 index 66f2cc1..c337a85 100644
 --- a/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h
 +++ b/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h
 @@ -6,7 +6,7 @@
   * Title:  MPI Configuration messages and pages
   * Creation Date:  November 10, 2006
   *
 - *   mpi2_cnfg.h Version:  02.00.28
 + *   mpi2_cnfg.h Version:  02.00.29
   *
   * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25
   *   prefix are for use only on MPI v2.5 products, and must not be used
 @@ -177,6 +177,8 @@
   *  MPI2_CONFIG_PAGE_SAS_ENCLOSURE_0.
   * 01-08-14  02.00.28  Added more defines for the BiosOptions field of
   *  MPI2_CONFIG_PAGE_BIOS_1.
 + * 06-13-14  02.00.29  Added SSUTimeout field to MPI2_CONFIG_PAGE_BIOS_1, and
 + *  more defines for the BiosOptions field..
   * --
   */
  
 @@ -1324,7 +1326,9 @@ typedef struct _MPI2_CONFIG_PAGE_BIOS_1 {
   MPI2_CONFIG_PAGE_HEADER Header; /*0x00 */
   U32 BiosOptions;/*0x04 */
   U32 IOCSettings;/*0x08 */
 - U32 Reserved1;  /*0x0C */
 + U8  SSUTimeout; /*0x0C */
 + U8  Reserved1;  /*0x0D */
 + U16 Reserved2;  /*0x0E */
   U32 DeviceSettings; /*0x10 */
   U16 NumberOfDevices;/*0x14 */
   U16 UEFIVersion;/*0x16 */
 @@ -1336,9 +1340,16 @@ typedef struct _MPI2_CONFIG_PAGE_BIOS_1 {
   *PTR_MPI2_CONFIG_PAGE_BIOS_1,
   Mpi2BiosPage1_t, *pMpi2BiosPage1_t;
  
 -#define MPI2_BIOSPAGE1_PAGEVERSION  (0x06)
 +#define MPI2_BIOSPAGE1_PAGEVERSION  (0x07)
  
  /*values for BIOS Page 1 BiosOptions field */
 +#define MPI2_BIOSPAGE1_OPTIONS_PNS_MASK (0x3800)
 +#define MPI2_BIOSPAGE1_OPTIONS_PNS_PBDHL(0x)
 +#define MPI2_BIOSPAGE1_OPTIONS_PNS_ENCSLOSURE   (0x0800)
 +#define MPI2_BIOSPAGE1_OPTIONS_PNS_LWWID(0x1000)
 +#define MPI2_BIOSPAGE1_OPTIONS_PNS_PSENS(0x1800)
 +#define MPI2_BIOSPAGE1_OPTIONS_PNS_ESPHY(0x2000)
 +
  #define MPI2_BIOSPAGE1_OPTIONS_X86_DISABLE_BIOS  (0x0400)
  
  #define MPI2_BIOSPAGE1_OPTIONS_MASK_REGISTRATION_UEFI_BSD(0x0300)
 -- 
 2.0.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de

Re: [PATCH 08/20] [SCSI] mpt3sas: Update MPI2 strings to MPI2.5

2015-06-15 Thread Johannes Thumshirn
On Fri, Jun 12, 2015 at 03:12:20PM +0530, Sreekanth Reddy wrote:
 Update MPI2 strings to MPI2.5.
 
 Signed-off-by: Sreekanth Reddy sreekanth.re...@avagotech.com
 ---
  drivers/scsi/mpt3sas/mpt3sas_base.c | 3 +--
  drivers/scsi/mpt3sas/mpt3sas_base.h | 1 -
  2 files changed, 1 insertion(+), 3 deletions(-)
 
 diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
 b/drivers/scsi/mpt3sas/mpt3sas_base.c
 index 32b86bf..6739c0a 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
 +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
 @@ -3901,7 +3901,7 @@ _base_send_ioc_init(struct MPT3SAS_ADAPTER *ioc, int 
 sleep_flag)
   mpi_request.WhoInit = MPI2_WHOINIT_HOST_DRIVER;
   mpi_request.VF_ID = 0; /* TODO */
   mpi_request.VP_ID = 0;
 - mpi_request.MsgVersion = cpu_to_le16(MPI2_VERSION);
 + mpi_request.MsgVersion = cpu_to_le16(MPI25_VERSION);
   mpi_request.HeaderVersion = cpu_to_le16(MPI2_HEADER_VERSION);
  
   if (_base_is_controller_msix_enabled(ioc))
 @@ -4769,7 +4769,6 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
   ioc-build_sg_scmd = _base_build_sg_scmd_ieee;
   ioc-build_sg = _base_build_sg_ieee;
   ioc-build_zero_len_sge = _base_build_zero_len_sge_ieee;
 - ioc-mpi25 = 1;
   ioc-sge_size_ieee = sizeof(Mpi2IeeeSgeSimple64_t);
  
   /*
 diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
 b/drivers/scsi/mpt3sas/mpt3sas_base.h
 index 9396a76..2318ef8 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h
 +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
 @@ -819,7 +819,6 @@ struct MPT3SAS_ADAPTER {
   MPT_BUILD_SG_SCMD build_sg_scmd;
   MPT_BUILD_SGbuild_sg;
   MPT_BUILD_ZERO_LEN_SGE build_zero_len_sge;
 - u8  mpi25;
   u16 sge_size_ieee;
  
   /* function ptr for MPI sg elements only */
 -- 
 2.0.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 05/20] [SCSI] mpt3sas: MPI 2.5 Rev I (2.5.4) specifications.

2015-06-15 Thread Johannes Thumshirn
 _MPI2_CONFIG_PAGE_SAS_DEV_0 {
  #define MPI2_SAS_DEVICE0_FLAGS_SATA_NCQ_SUPPORTED   (0x0020)
  #define MPI2_SAS_DEVICE0_FLAGS_SATA_FUA_SUPPORTED   (0x0010)
  #define MPI2_SAS_DEVICE0_FLAGS_PORT_SELECTOR_ATTACH (0x0008)
 +#define MPI2_SAS_DEVICE0_FLAGS_ENCL_LEVEL_VALID (0x0002)
  #define MPI2_SAS_DEVICE0_FLAGS_DEVICE_PRESENT   (0x0001)
  
  
 @@ -3019,8 +3031,10 @@ typedef struct _MPI2_CONFIG_PAGE_SAS_ENCLOSURE_0 {
   NumSlots;   /*0x18 */
   U16
   StartSlot;  /*0x1A */
 - U16
 + U8
   Reserved2;  /*0x1C */
 + U8
 + EnclosureLevel; /*0x1D */
   U16
   SEPDevHandle;   /*0x1E */
   U32
 @@ -3031,9 +3045,10 @@ typedef struct _MPI2_CONFIG_PAGE_SAS_ENCLOSURE_0 {
   *PTR_MPI2_CONFIG_PAGE_SAS_ENCLOSURE_0,
   Mpi2SasEnclosurePage0_t, *pMpi2SasEnclosurePage0_t;
  
 -#define MPI2_SASENCLOSURE0_PAGEVERSION  (0x03)
 +#define MPI2_SASENCLOSURE0_PAGEVERSION  (0x04)
  
  /*values for SAS Enclosure Page 0 Flags field */
 +#define MPI2_SAS_ENCLS0_FLAGS_ENCL_LEVEL_VALID  (0x0010)
  #define MPI2_SAS_ENCLS0_FLAGS_MNG_MASK  (0x000F)
  #define MPI2_SAS_ENCLS0_FLAGS_MNG_UNKNOWN   (0x)
  #define MPI2_SAS_ENCLS0_FLAGS_MNG_IOC_SES   (0x0001)
 diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_ioc.h 
 b/drivers/scsi/mpt3sas/mpi/mpi2_ioc.h
 index 4908309..d7598cc 100644
 --- a/drivers/scsi/mpt3sas/mpi/mpi2_ioc.h
 +++ b/drivers/scsi/mpt3sas/mpi/mpi2_ioc.h
 @@ -6,7 +6,7 @@
   * Title:  MPI IOC, Port, Event, FW Download, and FW Upload messages
   * Creation Date:  October 11, 2006
   *
 - * mpi2_ioc.h Version:  02.00.23
 + * mpi2_ioc.h Version:  02.00.24
   *
   * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25
   *   prefix are for use only on MPI v2.5 products, and must not be used
 @@ -132,6 +132,7 @@
   *   Added MPI2_IOCFACTS_CAPABILITY_RDPQ_ARRAY_CAPABLE.
   *   Added MPI2_FW_DOWNLOAD_ITYPE_PUBLIC_KEY.
   *   Added Encrypted Hash Extended Image.
 + * 12-05-13  02.00.24  Added MPI25_HASH_IMAGE_TYPE_BIOS.
   * --
   */
  
 @@ -1598,6 +1599,7 @@ Mpi25EncryptedHashEntry_t, *pMpi25EncryptedHashEntry_t;
  /* values for HashImageType */
  #define MPI25_HASH_IMAGE_TYPE_UNUSED (0x00)
  #define MPI25_HASH_IMAGE_TYPE_FIRMWARE   (0x01)
 +#define MPI25_HASH_IMAGE_TYPE_BIOS  (0x02)
  
  /* values for HashAlgorithm */
  #define MPI25_HASH_ALGORITHM_UNUSED  (0x00)
 -- 
 2.0.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/20] [SCSI] mpt3sas: MPI 2.5 Rev J (2.5.5) specification and 2.00.34 header files

2015-06-15 Thread Johannes Thumshirn
 MPI2_TOOLBOX_CLEAN_INITIALIZATION   (0x0100)
  #define MPI2_TOOLBOX_CLEAN_FLASH(0x0004)
 -- 
 2.0.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 07/20] [SCSI] mpt3sas: Bump mpt3sas Driver version to v5.100.00.00

2015-06-15 Thread Johannes Thumshirn
On Fri, Jun 12, 2015 at 03:12:19PM +0530, Sreekanth Reddy wrote:
 Bump mpt3sas Driver version to v5.100.00.00
 
 Signed-off-by: Sreekanth Reddy sreekanth.re...@avagotech.com
 ---
  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 293ad23..9396a76 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h
 +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
 @@ -71,8 +71,8 @@
  #define MPT3SAS_DRIVER_NAME  mpt3sas
  #define MPT3SAS_AUTHOR Avago Technologies 
 mpt-fusionlinux@avagotech.com
  #define MPT3SAS_DESCRIPTION  LSI MPT Fusion SAS 3.0 Device Driver
 -#define MPT3SAS_DRIVER_VERSION   04.100.00.00
 -#define MPT3SAS_MAJOR_VERSION4
 +#define MPT3SAS_DRIVER_VERSION   05.100.00.00
 +#define MPT3SAS_MAJOR_VERSION5
  #define MPT3SAS_MINOR_VERSION100
  #define MPT3SAS_BUILD_VERSION0
  #define MPT3SAS_RELEASE_VERSION  00
 -- 
 2.0.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 10/20] [SCSI] mpt3sas: Add branding string support for OEM's HBA

2015-06-15 Thread Johannes Thumshirn
On Mon, Jun 15, 2015 at 04:41:56PM +0530, Sreekanth Reddy wrote:
 On Mon, Jun 15, 2015 at 3:16 PM, Johannes Thumshirn jthumsh...@suse.de 
 wrote:
  On Fri, Jun 12, 2015 at 03:12:22PM +0530, Sreekanth Reddy wrote:
  Added the following Dell branding to the mpt3sas driver.
 
  VendorID   DeviceID  SubsystemVendor ID  SubsystemDevice ID  Dell 
  Branding String
  0x10000x0097  0x1028 0x1F46
  DELL 12Gbps HBA
 
  Signed-off-by: Sreekanth Reddy sreekanth.re...@avagotech.com
  ---
   drivers/scsi/mpt3sas/mpt3sas_base.c | 36 
  
   drivers/scsi/mpt3sas/mpt3sas_base.h | 11 +++
   2 files changed, 47 insertions(+)
 
  diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
  b/drivers/scsi/mpt3sas/mpt3sas_base.c
  index 6739c0a..db362cb 100644
  --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
  +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
  @@ -2345,6 +2345,41 @@ _base_display_intel_branding(struct MPT3SAS_ADAPTER 
  *ioc)
 
 
   /**
  + * _base_display_dell_branding - Display branding string
  + * @ioc: per adapter object
  + *
  + * Return nothing.
  + */
  +static void
  +_base_display_dell_branding(struct MPT3SAS_ADAPTER *ioc)
  +{
  + if (ioc-pdev-subsystem_vendor != PCI_VENDOR_ID_DELL)
  + return;
  +
  + switch (ioc-pdev-device) {
  + case MPI25_MFGPAGE_DEVID_SAS3008:
  + switch (ioc-pdev-subsystem_device) {
  + case MPT3SAS_DELL_12G_HBA_SSDID:
  + pr_info(MPT3SAS_FMT %s\n, ioc-name,
  + MPT3SAS_DELL_12G_HBA_BRANDING);
  + break;
  + default:
  + pr_info(MPT3SAS_FMT
  +Dell 12Gbps HBA: Subsystem ID: 0x%X\n, 
  ioc-name,
  +ioc-pdev-subsystem_device);
  + break;
  + }
  + break;
  + default:
  + pr_info(MPT3SAS_FMT
  + Dell 12Gbps HBA: Subsystem ID: 0x%X\n, ioc-name,
  + ioc-pdev-subsystem_device);
  + break;
  + }
  +}
  +
  +
  +/**
* _base_display_ioc_capabilities - Disply IOC's capabilities.
* @ioc: per adapter object
*
  @@ -2374,6 +2409,7 @@ _base_display_ioc_capabilities(struct 
  MPT3SAS_ADAPTER *ioc)
bios_version  0x00FF);
 
_base_display_intel_branding(ioc);
  + _base_display_dell_branding(ioc);
 
pr_info(MPT3SAS_FMT Protocol=(, ioc-name);
 
  diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
  b/drivers/scsi/mpt3sas/mpt3sas_base.h
  index 2318ef8..c4780c7 100644
  --- a/drivers/scsi/mpt3sas/mpt3sas_base.h
  +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
  @@ -152,6 +152,17 @@
   #define MPT3SAS_INTEL_RS3UC080_SSDID0x3524
 
   /*
  + * Dell HBA branding
  + */
  +#define MPT3SAS_DELL_12G_HBA_BRANDING   \
  + Dell 12Gbps HBA
  +
  +/*
  + * Dell HBA SSDIDs
  + */
  +#define MPT3SAS_DELL_12G_HBA_SSDID   0x1F46
  +
  +/*
* status bits for ioc-diag_buffer_status
*/
   #define MPT3_DIAG_BUFFER_IS_REGISTERED   (0x01)
  --
  2.0.2
 
  --
  To unsubscribe from this list: send the line unsubscribe linux-scsi in
  the body of a message to majord...@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html
 
  This might be something you might consider re-organizing for your code-base
  merge as well, as it leads to a lot of code duplication the more OEMs you 
  have.
 
 May I know which hunk of this patch may leads to code duplication for
 more OEMs we add? Whether declaring individual function for each OEMs
 leads to this code duplication.

Hi Sreekanth,

In
[PATCH 11/20] [SCSI] mpt3sas: Add branding string support for OEM custom HBA
you add _base_display_cisco_branding(). In
[PATCH 10/20] [SCSI] mpt3sas: Add branding string support for OEM's HBA
you add _base_display_dell_branding(). You already have
_base_display_intel_branding().

Each of them follows the pattern:
1) Check if it is a OEM device for XXX
2) Check witch OEM device for XXX it is
3) Display a string based on that specific OEM device
4) Return

Johannes
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 15/20] [SCSI] mpt3sas: Return host busy error status to SML when DMA mapping of scatter gather list fails for a SCSI command

2015-06-15 Thread Johannes Thumshirn
On Fri, Jun 12, 2015 at 03:12:27PM +0530, Sreekanth Reddy wrote:
 scsi_dma_map API will return a negative value (i.e. -ENOMEM)
 if DMA mapping of sg lists fails and zero if the sg list in the
 SCSI cmd is NULL. But drivers doesn't handled sg list DMA mapping
 failure case properly.
 
 So, Updated the code to return host busy error status to SCSI MID Layer(SML),
 when DMA mapping of scatter gather list fails for a SCSI command.
 So that SML will retry this SCSI cmd after some time.
 
 Signed-off-by: Sreekanth Reddy sreekanth.re...@avagotech.com
 ---
  drivers/scsi/mpt3sas/mpt3sas_base.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
 b/drivers/scsi/mpt3sas/mpt3sas_base.c
 index 267e489..0b26c8d 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
 +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
 @@ -1345,7 +1345,7 @@ _base_build_sg_scmd_ieee(struct MPT3SAS_ADAPTER *ioc,
  
   sg_scmd = scsi_sglist(scmd);
   sges_left = scsi_dma_map(scmd);
 - if (!sges_left) {
 + if (!sges_left  0) {
   sdev_printk(KERN_ERR, scmd-device,
   pci_map_sg failed: request for %d bytes!\n,
   scsi_bufflen(scmd));
 @@ -1414,7 +1414,7 @@ _base_build_sg_scmd_ieee(struct MPT3SAS_ADAPTER *ioc,
   fill_in_last_segment:
  
   /* fill the last segment */
 - while (sges_left) {
 + while (sges_left  0) {
   if (sges_left == 1)
   _base_add_sg_single_ieee(sg_local,
   simple_sgl_flags_last, 0, sg_dma_len(sg_scmd),
 -- 
 2.0.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 20/20] [SCSI] mpt3sas : Bump mpt3sas driver version to 9.100.00.00

2015-06-15 Thread Johannes Thumshirn
On Fri, Jun 12, 2015 at 03:12:32PM +0530, Sreekanth Reddy wrote:
 Bump mpt3sas driver version to 9.100.00.00
 
 Signed-off-by: Sreekanth Reddy sreekanth.re...@avagotech.com
 ---
  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 b97039b..0ffe763 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h
 +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
 @@ -71,8 +71,8 @@
  #define MPT3SAS_DRIVER_NAME  mpt3sas
  #define MPT3SAS_AUTHOR Avago Technologies 
 mpt-fusionlinux@avagotech.com
  #define MPT3SAS_DESCRIPTION  LSI MPT Fusion SAS 3.0 Device Driver
 -#define MPT3SAS_DRIVER_VERSION   06.100.00.00
 -#define MPT3SAS_MAJOR_VERSION6
 +#define MPT3SAS_DRIVER_VERSION   09.100.00.00
 +#define MPT3SAS_MAJOR_VERSION9
  #define MPT3SAS_MINOR_VERSION100
  #define MPT3SAS_BUILD_VERSION0
  #define MPT3SAS_RELEASE_VERSION  00
 -- 
 2.0.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 12/20] [SCSI] mpt3sas: Bump mpt3sas driver version to v6.100.00.00

2015-06-15 Thread Johannes Thumshirn
On Fri, Jun 12, 2015 at 03:12:24PM +0530, Sreekanth Reddy wrote:
 Bump mpt3sas driver version to v6.100.00.00.
 
 Signed-off-by: Sreekanth Reddy sreekanth.re...@avagotech.com
 ---
  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 7cdbc65..a89c752 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h
 +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
 @@ -71,8 +71,8 @@
  #define MPT3SAS_DRIVER_NAME  mpt3sas
  #define MPT3SAS_AUTHOR Avago Technologies 
 mpt-fusionlinux@avagotech.com
  #define MPT3SAS_DESCRIPTION  LSI MPT Fusion SAS 3.0 Device Driver
 -#define MPT3SAS_DRIVER_VERSION   05.100.00.00
 -#define MPT3SAS_MAJOR_VERSION5
 +#define MPT3SAS_DRIVER_VERSION   06.100.00.00
 +#define MPT3SAS_MAJOR_VERSION6
  #define MPT3SAS_MINOR_VERSION100
  #define MPT3SAS_BUILD_VERSION0
  #define MPT3SAS_RELEASE_VERSION  00
 -- 
 2.0.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/20] [SCSI] mpt3sas: Remove redundancy code while freeing the controller resources.

2015-06-15 Thread Johannes Thumshirn
On Mon, Jun 15, 2015 at 03:56:56PM +0530, Sreekanth Reddy wrote:
 On Fri, Jun 12, 2015 at 6:10 PM, Johannes Thumshirn jthumsh...@suse.de 
 wrote:
  On Fri, Jun 12, 2015 at 05:48:56PM +0530, Sreekanth Reddy wrote:
  On Fri, Jun 12, 2015 at 4:58 PM, Johannes Thumshirn jthumsh...@suse.de 
  wrote:
   On Fri, Jun 12, 2015 at 03:12:16PM +0530, Sreekanth Reddy wrote:
   Removed the redundancy code while freeing the controller resources.
  
   Signed-off-by: Sreekanth Reddy sreekanth.re...@avagotech.com
   ---
drivers/scsi/mpt3sas/mpt3sas_base.c | 57 
   +
  [...]
   + _base_free_irq(ioc);
   + _base_disable_msix(ioc);
   +
   + if (ioc-msix96_vector)
   + kfree(ioc-replyPostRegisterIndex);
  
   kfree() already checks for zero or a NULL pointer.
 
  Sorry Johannes, I didn't get you. If I understand this correctly, you
  are suggesting to check for NULL pointer before calling kree() API as
  shown below,
 
  if (ioc-msix96_vector  (ioc-replyPostRegisterIndex != NULL))
  kfree(ioc-replyPostRegisterIndex);
 
  Correct me if I'm wrong, but I thought you don't need the if
  (ioc-msix96_vector) before the kfree(). ioc-replyPostRegisterIndex should 
  be
  NULL if ioc-msix96_vector is 0, as far as I can see.
 
  In _scsih_probe() you have:
  shost = scsi_host_alloc(scsih_driver_template,
  sizeof(struct MPT3SAS_ADAPTER));
  if (!shost)
 return -ENODEV;
 
  /* init local params */
  ioc = shost_priv(shost);
 
  and scsi_host_alloc() does a kzalloc() for shost.
 
  so ioc-replyPortRegisterIndex is NULL.
 
  Or am I thinking wrong here?
 
 Yes, ioc-replyPostRegisterIndex will be NULL if ioc-msix96_vector is 0,
 We have added this checks as a precautionary. since calling this
 function (i.e kfree()) on memory not previously allocated with
 kmalloc(), or on memory which has already been freed, may results in
 very bad things, such as freeing memory belonging to another part of
 the kernel.


OK, then please leave it in.

 
 
  Regards,
  Sreekanth
 
  --
  Johannes Thumshirn   Storage
  jthumsh...@suse.de +49 911 74053 689
  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)
 
 
 
 -- 
 
 Regards,
 Sreekanth

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 18/20] [SCSI] mpt3sas: Call dma_mapping_error() API after mapping an address with dma_map_single() API

2015-06-15 Thread Johannes Thumshirn
On Fri, Jun 12, 2015 at 03:12:30PM +0530, Sreekanth Reddy wrote:
 Added dma_mapping_error() API after mapping an address with dma_map_single() 
 API.
 Otherwise when CONFIG_DMA_API_DEBUG is enabled in the kernel, then it 
 complains
 about mpt3sas driver not calling dma_mapping_error after mapping an address 
 with
 dma_map_single
 
 Signed-off-by: Sreekanth Reddy sreekanth.re...@avagotech.com
 ---
  drivers/scsi/mpt3sas/mpt3sas_transport.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/scsi/mpt3sas/mpt3sas_transport.c 
 b/drivers/scsi/mpt3sas/mpt3sas_transport.c
 index 7a7aa68..70fd019 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_transport.c
 +++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c
 @@ -1964,7 +1964,7 @@ _transport_smp_handler(struct Scsi_Host *shost, struct 
 sas_rphy *rphy,
   } else {
   dma_addr_out = pci_map_single(ioc-pdev, bio_data(req-bio),
   blk_rq_bytes(req), PCI_DMA_BIDIRECTIONAL);
 - if (!dma_addr_out) {
 + if (pci_dma_mapping_error(ioc-pdev, dma_addr_out)) {
   pr_info(MPT3SAS_FMT %s(): DMA Addr out = NULL\n,
   ioc-name, __func__);
   rc = -ENOMEM;
 @@ -1986,7 +1986,7 @@ _transport_smp_handler(struct Scsi_Host *shost, struct 
 sas_rphy *rphy,
   } else {
   dma_addr_in =  pci_map_single(ioc-pdev, bio_data(rsp-bio),
   blk_rq_bytes(rsp), PCI_DMA_BIDIRECTIONAL);
 - if (!dma_addr_in) {
 + if (pci_dma_mapping_error(ioc-pdev, dma_addr_in)) {
   pr_info(MPT3SAS_FMT %s(): DMA Addr in = NULL\n,
   ioc-name, __func__);
   rc = -ENOMEM;
 -- 
 2.0.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 10/20] [SCSI] mpt3sas: Add branding string support for OEM's HBA

2015-06-15 Thread Johannes Thumshirn
On Fri, Jun 12, 2015 at 03:12:22PM +0530, Sreekanth Reddy wrote:
 Added the following Dell branding to the mpt3sas driver.
 
 VendorID   DeviceID  SubsystemVendor ID  SubsystemDevice ID  Dell 
 Branding String
 0x10000x0097  0x1028 0x1F46DELL 
 12Gbps HBA
 
 Signed-off-by: Sreekanth Reddy sreekanth.re...@avagotech.com
 ---
  drivers/scsi/mpt3sas/mpt3sas_base.c | 36 
  drivers/scsi/mpt3sas/mpt3sas_base.h | 11 +++
  2 files changed, 47 insertions(+)
 
 diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
 b/drivers/scsi/mpt3sas/mpt3sas_base.c
 index 6739c0a..db362cb 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
 +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
 @@ -2345,6 +2345,41 @@ _base_display_intel_branding(struct MPT3SAS_ADAPTER 
 *ioc)
  
  
  /**
 + * _base_display_dell_branding - Display branding string
 + * @ioc: per adapter object
 + *
 + * Return nothing.
 + */
 +static void
 +_base_display_dell_branding(struct MPT3SAS_ADAPTER *ioc)
 +{
 + if (ioc-pdev-subsystem_vendor != PCI_VENDOR_ID_DELL)
 + return;
 +
 + switch (ioc-pdev-device) {
 + case MPI25_MFGPAGE_DEVID_SAS3008:
 + switch (ioc-pdev-subsystem_device) {
 + case MPT3SAS_DELL_12G_HBA_SSDID:
 + pr_info(MPT3SAS_FMT %s\n, ioc-name,
 + MPT3SAS_DELL_12G_HBA_BRANDING);
 + break;
 + default:
 + pr_info(MPT3SAS_FMT
 +Dell 12Gbps HBA: Subsystem ID: 0x%X\n, ioc-name,
 +ioc-pdev-subsystem_device);
 + break;
 + }
 + break;
 + default:
 + pr_info(MPT3SAS_FMT
 + Dell 12Gbps HBA: Subsystem ID: 0x%X\n, ioc-name,
 + ioc-pdev-subsystem_device);
 + break;
 + }
 +}
 +
 +
 +/**
   * _base_display_ioc_capabilities - Disply IOC's capabilities.
   * @ioc: per adapter object
   *
 @@ -2374,6 +2409,7 @@ _base_display_ioc_capabilities(struct MPT3SAS_ADAPTER 
 *ioc)
   bios_version  0x00FF);
  
   _base_display_intel_branding(ioc);
 + _base_display_dell_branding(ioc);
  
   pr_info(MPT3SAS_FMT Protocol=(, ioc-name);
  
 diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
 b/drivers/scsi/mpt3sas/mpt3sas_base.h
 index 2318ef8..c4780c7 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h
 +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
 @@ -152,6 +152,17 @@
  #define MPT3SAS_INTEL_RS3UC080_SSDID0x3524
  
  /*
 + * Dell HBA branding
 + */
 +#define MPT3SAS_DELL_12G_HBA_BRANDING   \
 + Dell 12Gbps HBA
 +
 +/*
 + * Dell HBA SSDIDs
 + */
 +#define MPT3SAS_DELL_12G_HBA_SSDID   0x1F46
 +
 +/*
   * status bits for ioc-diag_buffer_status
   */
  #define MPT3_DIAG_BUFFER_IS_REGISTERED   (0x01)
 -- 
 2.0.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

This might be something you might consider re-organizing for your code-base
merge as well, as it leads to a lot of code duplication the more OEMs you have.

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 19/20] [SCSI] mpt3sas: When device is blocked followed by unblock fails, unfreeze the I/Os

2015-06-15 Thread Johannes Thumshirn
;
 - scsi_internal_device_unblock(sdev, SDEV_RUNNING);
 - }
 + if (sas_device_priv_data-block)
 + _scsih_internal_device_unblock(sdev,
 + sas_device_priv_data);
   }
  }
  
 @@ -2678,10 +2745,7 @@ _scsih_block_io_all_device(struct MPT3SAS_ADAPTER *ioc)
   continue;
   if (sas_device_priv_data-block)
   continue;
 - sas_device_priv_data-block = 1;
 - scsi_internal_device_block(sdev);
 - sdev_printk(KERN_INFO, sdev, device_blocked, handle(0x%04x)\n,
 - sas_device_priv_data-sas_target-handle);
 + _scsih_internal_device_block(sdev, sas_device_priv_data);
   }
  }
  
 @@ -2713,10 +2777,7 @@ _scsih_block_io_device(struct MPT3SAS_ADAPTER *ioc, 
 u16 handle)
   continue;
   if (sas_device-pend_sas_rphy_add)
   continue;
 - sas_device_priv_data-block = 1;
 - scsi_internal_device_block(sdev);
 - sdev_printk(KERN_INFO, sdev,
 - device_blocked, handle(0x%04x)\n, handle);
 + _scsih_internal_device_block(sdev, sas_device_priv_data);
   }
  }
  
 -- 
 2.0.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 14/20] [SCSI] mpt3sas: Complete the SCSI command with DID_RESET status for log_info value 0x0x32010081

2015-06-15 Thread Johannes Thumshirn
On Fri, Jun 12, 2015 at 03:12:26PM +0530, Sreekanth Reddy wrote:
 For any SCSI command, if the driver receives
 IOC status = SCSI_IOC_TERMINATED and log info = 0x32010081 then
 that command will be completed with DID_RESET host status.
 
 The definition of this log info value is
 Virtual IO has failed and has to be retried.
 
 Firmware will provide this log info value with IOC Status
 SCSI_IOC_TERMINATED, whenever a drive (with is a part of a volume)
 is pulled and pushed back within some minimal delay.
 With this log info value, firmware informs the driver to retry the
 failed IO command infinite times, so to provide some time for the
 firmware to discover the reinserted drive successfully instated of
 just retrying failed command for five times(doesn't giving enough
 time for firmware to complete the drive discovery) and failing the
 IO permanently even though drive came back successfully.
 
 Signed-off-by: Sreekanth Reddy sreekanth.re...@avagotech.com
 ---
  drivers/scsi/mpt3sas/mpt3sas_scsih.c | 3 +++
  1 file changed, 3 insertions(+)
 
 diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
 b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
 index 64dd90b..837c22a 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
 +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
 @@ -4241,6 +4241,9 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, 
 u8 msix_index, u32 reply)
   scmd-device-expecting_cc_ua = 1;
   }
   break;
 + } else if (log_info == 0x32010081) {
 + scmd-result = DID_RESET  16;
 + break;

Could you make that a #define instead of some magic vlaue, so everyone can see
what is happening when reading the source?

   }
   scmd-result = DID_SOFT_ERROR  16;
   break;
 -- 
 2.0.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/20] [SCSI] mpt3sas: Added Combined Reply Queue feature to extend up-to 96 MSIX vector support

2015-06-12 Thread Johannes Thumshirn
 reply post host index */
   list_for_each_entry(reply_q, ioc-reply_queue_list, list) {
 - writel(reply_q-msix_index  MPI2_RPHI_MSIX_INDEX_SHIFT,
 - ioc-chip-ReplyPostHostIndex);
 + if (ioc-msix96_vector) {
 + writel((reply_q-msix_index  7)
 +MPI2_RPHI_MSIX_INDEX_SHIFT,
 +ioc-replyPostRegisterIndex[reply_q-msix_index/8]);
 + } else {
 + writel(reply_q-msix_index 
 + MPI2_RPHI_MSIX_INDEX_SHIFT,
 + ioc-chip-ReplyPostHostIndex);
 + }
 +
   if (!_base_is_controller_msix_enabled(ioc))
   goto skip_init_reply_post_host_index;
   }
 @@ -4577,6 +4617,9 @@ mpt3sas_base_free_resources(struct MPT3SAS_ADAPTER *ioc)
   _base_free_irq(ioc);
   _base_disable_msix(ioc);
  
 + if (ioc-msix96_vector)
 + kfree(ioc-replyPostRegisterIndex);
 +
   if (ioc-chip_phys  ioc-chip)
   iounmap(ioc-chip);
   ioc-chip_phys = 0;
 @@ -4600,6 +4643,7 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
  {
   int r, i;
   int cpu_id, last_cpu_id = 0;
 + u8 revision;
  
   dinitprintk(ioc, pr_info(MPT3SAS_FMT %s\n, ioc-name,
   __func__));
 @@ -4618,6 +4662,18 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
   r = -ENOMEM;
   goto out_free_resources;
   }
 + /* Check whether the controller revision is C0 or above.
 + C0 and above revision controllers support 96 vectors */
 + revision = ioc-pdev-revision;
 +
 + if ((ioc-pdev-device == MPI25_MFGPAGE_DEVID_SAS3004 ||
 +  ioc-pdev-device == MPI25_MFGPAGE_DEVID_SAS3008 ||
 +  ioc-pdev-device == MPI25_MFGPAGE_DEVID_SAS3108_1 ||
 +  ioc-pdev-device == MPI25_MFGPAGE_DEVID_SAS3108_2 ||
 +  ioc-pdev-device == MPI25_MFGPAGE_DEVID_SAS3108_5 ||
 +  ioc-pdev-device == MPI25_MFGPAGE_DEVID_SAS3108_6) 
 +  (revision = 0x02))
 + ioc-msix96_vector = 1;
  
   ioc-rdpq_array_enable_assigned = 0;
   ioc-dma_mask = 0;
 diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
 b/drivers/scsi/mpt3sas/mpt3sas_base.h
 index afa8816..6b8d8f1 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h
 +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
 @@ -728,7 +728,8 @@ typedef void (*MPT3SAS_FLUSH_RUNNING_CMDS)(struct 
 MPT3SAS_ADAPTER *ioc);
   *   is assigned only ones
   * @reply_queue_count: number of reply queue's
   * @reply_queue_list: link list contaning the reply queue info
 - * @reply_post_host_index: head index in the pool where FW completes IO
 + * @msix96_vector: 96 MSI-X vector support
 + * @replyPostRegisterIndex: index of next position in Reply Desc Post Queue
   * @delayed_tr_list: target reset link list
   * @delayed_tr_volume_list: volume target reset link list
   * @@temp_sensors_count: flag to carry the number of temperature sensors
 @@ -937,6 +938,10 @@ struct MPT3SAS_ADAPTER {
   u8  reply_queue_count;
   struct list_head reply_queue_list;
  
 + u8  msix96_vector;
 + /* reply post register index */
 + resource_size_t **replyPostRegisterIndex;
 +

I know there are many uses of mixed-case varibles in this driver and changing
them when they're already in makes no sense, but maybe you could consider
getting rid of them in your mpt2sas/mpt3sas merge, as it is not really a
commonly seen pattern in the linux kernel.

   struct list_head delayed_tr_list;
   struct list_head delayed_tr_volume_list;
   u8  temp_sensors_count;
 -- 
 2.0.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/20] [SCSI] mpt3sas: Remove redundancy code while freeing the controller resources.

2015-06-12 Thread Johannes Thumshirn
On Fri, Jun 12, 2015 at 03:12:16PM +0530, Sreekanth Reddy wrote:
 Removed the redundancy code while freeing the controller resources.
 
 Signed-off-by: Sreekanth Reddy sreekanth.re...@avagotech.com
 ---
  drivers/scsi/mpt3sas/mpt3sas_base.c | 57 
 +
  1 file changed, 32 insertions(+), 25 deletions(-)
 
 diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
 b/drivers/scsi/mpt3sas/mpt3sas_base.c
 index ce57320..32b86bf 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
 +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
 @@ -1798,6 +1798,36 @@ _base_enable_msix(struct MPT3SAS_ADAPTER *ioc)
  }
  
  /**
 + * mpt3sas_base_unmap_resources - free controller resources
 + * @ioc: per adapter object
 + */
 +void
 +mpt3sas_base_unmap_resources(struct MPT3SAS_ADAPTER *ioc)
 +{
 + struct pci_dev *pdev = ioc-pdev;
 +
 + dexitprintk(ioc, printk(MPT3SAS_FMT %s\n,
 + ioc-name, __func__));
 +
 + _base_free_irq(ioc);
 + _base_disable_msix(ioc);
 +
 + if (ioc-msix96_vector)
 + kfree(ioc-replyPostRegisterIndex);

kfree() already checks for zero or a NULL pointer.

 +
 + if (ioc-chip_phys) {
 + iounmap(ioc-chip);
 + ioc-chip_phys = 0;
 + }
 +
 + if (pci_is_enabled(pdev)) {
 + pci_release_selected_regions(ioc-pdev, ioc-bars);
 + pci_disable_pcie_error_reporting(pdev);
 + pci_disable_device(pdev);
 + }
 +}
 +
 +/**
   * mpt3sas_base_map_resources - map in controller resources (io/irq/memap)
   * @ioc: per adapter object
   *
 @@ -1925,14 +1955,7 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc)
   return 0;
  
   out_fail:
 - if (ioc-chip_phys)
 - iounmap(ioc-chip);
 - ioc-chip_phys = 0;
 - pci_release_selected_regions(ioc-pdev, ioc-bars);
 - pci_disable_pcie_error_reporting(pdev);
 - pci_disable_device(pdev);
 - if (ioc-msix96_vector)
 - kfree(ioc-replyPostRegisterIndex);
 + mpt3sas_base_unmap_resources(ioc);
   return r;
  }
  
 @@ -4667,8 +4690,6 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, 
 int sleep_flag)
  void
  mpt3sas_base_free_resources(struct MPT3SAS_ADAPTER *ioc)
  {
 - struct pci_dev *pdev = ioc-pdev;
 -
   dexitprintk(ioc, pr_info(MPT3SAS_FMT %s\n, ioc-name,
   __func__));
  
 @@ -4679,21 +4700,7 @@ mpt3sas_base_free_resources(struct MPT3SAS_ADAPTER 
 *ioc)
   ioc-shost_recovery = 0;
   }
  
 - _base_free_irq(ioc);
 - _base_disable_msix(ioc);
 -
 - if (ioc-msix96_vector)
 - kfree(ioc-replyPostRegisterIndex);
 -
 - if (ioc-chip_phys  ioc-chip)
 - iounmap(ioc-chip);
 - ioc-chip_phys = 0;
 -
 - if (pci_is_enabled(pdev)) {
 - pci_release_selected_regions(ioc-pdev, ioc-bars);
 - pci_disable_pcie_error_reporting(pdev);
 - pci_disable_device(pdev);
 - }
 + mpt3sas_base_unmap_resources(ioc);
   return;
  }
  
 -- 
 2.0.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/20] [SCSI] mpt3sas: Remove redundancy code while freeing the controller resources.

2015-06-12 Thread Johannes Thumshirn
On Fri, Jun 12, 2015 at 05:48:56PM +0530, Sreekanth Reddy wrote:
 On Fri, Jun 12, 2015 at 4:58 PM, Johannes Thumshirn jthumsh...@suse.de 
 wrote:
  On Fri, Jun 12, 2015 at 03:12:16PM +0530, Sreekanth Reddy wrote:
  Removed the redundancy code while freeing the controller resources.
 
  Signed-off-by: Sreekanth Reddy sreekanth.re...@avagotech.com
  ---
   drivers/scsi/mpt3sas/mpt3sas_base.c | 57 
  +
[...]
  + _base_free_irq(ioc);
  + _base_disable_msix(ioc);
  +
  + if (ioc-msix96_vector)
  + kfree(ioc-replyPostRegisterIndex);
 
  kfree() already checks for zero or a NULL pointer.
 
 Sorry Johannes, I didn't get you. If I understand this correctly, you
 are suggesting to check for NULL pointer before calling kree() API as
 shown below,
 
 if (ioc-msix96_vector  (ioc-replyPostRegisterIndex != NULL))
 kfree(ioc-replyPostRegisterIndex);

Correct me if I'm wrong, but I thought you don't need the if
(ioc-msix96_vector) before the kfree(). ioc-replyPostRegisterIndex should be
NULL if ioc-msix96_vector is 0, as far as I can see.

In _scsih_probe() you have:
shost = scsi_host_alloc(scsih_driver_template,
sizeof(struct MPT3SAS_ADAPTER));
if (!shost)
   return -ENODEV;

/* init local params */
ioc = shost_priv(shost);

and scsi_host_alloc() does a kzalloc() for shost.

so ioc-replyPortRegisterIndex is NULL.

Or am I thinking wrong here?

 
 Regards,
 Sreekanth

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/20] [SCSI] mpt3sas: Remove redundancy code while freeing the controller resources.

2015-06-18 Thread Johannes Thumshirn
On Fri, Jun 12, 2015 at 03:12:16PM +0530, Sreekanth Reddy wrote:
 Removed the redundancy code while freeing the controller resources.
 
 Signed-off-by: Sreekanth Reddy sreekanth.re...@avagotech.com
 ---
  drivers/scsi/mpt3sas/mpt3sas_base.c | 57 
 +
  1 file changed, 32 insertions(+), 25 deletions(-)
 
 diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
 b/drivers/scsi/mpt3sas/mpt3sas_base.c
 index ce57320..32b86bf 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
 +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
 @@ -1798,6 +1798,36 @@ _base_enable_msix(struct MPT3SAS_ADAPTER *ioc)
  }
  
  /**
 + * mpt3sas_base_unmap_resources - free controller resources
 + * @ioc: per adapter object
 + */
 +void
 +mpt3sas_base_unmap_resources(struct MPT3SAS_ADAPTER *ioc)
 +{
 + struct pci_dev *pdev = ioc-pdev;
 +
 + dexitprintk(ioc, printk(MPT3SAS_FMT %s\n,
 + ioc-name, __func__));
 +
 + _base_free_irq(ioc);
 + _base_disable_msix(ioc);
 +
 + if (ioc-msix96_vector)
 + kfree(ioc-replyPostRegisterIndex);
 +
 + if (ioc-chip_phys) {
 + iounmap(ioc-chip);
 + ioc-chip_phys = 0;
 + }
 +
 + if (pci_is_enabled(pdev)) {
 + pci_release_selected_regions(ioc-pdev, ioc-bars);
 + pci_disable_pcie_error_reporting(pdev);
 + pci_disable_device(pdev);
 + }
 +}
 +
 +/**
   * mpt3sas_base_map_resources - map in controller resources (io/irq/memap)
   * @ioc: per adapter object
   *
 @@ -1925,14 +1955,7 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc)
   return 0;
  
   out_fail:
 - if (ioc-chip_phys)
 - iounmap(ioc-chip);
 - ioc-chip_phys = 0;
 - pci_release_selected_regions(ioc-pdev, ioc-bars);
 - pci_disable_pcie_error_reporting(pdev);
 - pci_disable_device(pdev);
 - if (ioc-msix96_vector)
 - kfree(ioc-replyPostRegisterIndex);
 + mpt3sas_base_unmap_resources(ioc);
   return r;
  }
  
 @@ -4667,8 +4690,6 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, 
 int sleep_flag)
  void
  mpt3sas_base_free_resources(struct MPT3SAS_ADAPTER *ioc)
  {
 - struct pci_dev *pdev = ioc-pdev;
 -
   dexitprintk(ioc, pr_info(MPT3SAS_FMT %s\n, ioc-name,
   __func__));
  
 @@ -4679,21 +4700,7 @@ mpt3sas_base_free_resources(struct MPT3SAS_ADAPTER 
 *ioc)
   ioc-shost_recovery = 0;
   }
  
 - _base_free_irq(ioc);
 - _base_disable_msix(ioc);
 -
 - if (ioc-msix96_vector)
 - kfree(ioc-replyPostRegisterIndex);
 -
 - if (ioc-chip_phys  ioc-chip)
 - iounmap(ioc-chip);
 - ioc-chip_phys = 0;
 -
 - if (pci_is_enabled(pdev)) {
 - pci_release_selected_regions(ioc-pdev, ioc-bars);
 - pci_disable_pcie_error_reporting(pdev);
 - pci_disable_device(pdev);
 - }
 + mpt3sas_base_unmap_resources(ioc);
   return;
  }
  
 -- 
 2.0.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 10/20] [SCSI] mpt3sas: Add branding string support for OEM's HBA

2015-06-18 Thread Johannes Thumshirn
On Fri, Jun 12, 2015 at 03:12:22PM +0530, Sreekanth Reddy wrote:
 Added the following Dell branding to the mpt3sas driver.
 
 VendorID   DeviceID  SubsystemVendor ID  SubsystemDevice ID  Dell 
 Branding String
 0x10000x0097  0x1028 0x1F46DELL 
 12Gbps HBA
 
 Signed-off-by: Sreekanth Reddy sreekanth.re...@avagotech.com
 ---
  drivers/scsi/mpt3sas/mpt3sas_base.c | 36 
  drivers/scsi/mpt3sas/mpt3sas_base.h | 11 +++
  2 files changed, 47 insertions(+)
 
 diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
 b/drivers/scsi/mpt3sas/mpt3sas_base.c
 index 6739c0a..db362cb 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
 +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
 @@ -2345,6 +2345,41 @@ _base_display_intel_branding(struct MPT3SAS_ADAPTER 
 *ioc)
  
  
  /**
 + * _base_display_dell_branding - Display branding string
 + * @ioc: per adapter object
 + *
 + * Return nothing.
 + */
 +static void
 +_base_display_dell_branding(struct MPT3SAS_ADAPTER *ioc)
 +{
 + if (ioc-pdev-subsystem_vendor != PCI_VENDOR_ID_DELL)
 + return;
 +
 + switch (ioc-pdev-device) {
 + case MPI25_MFGPAGE_DEVID_SAS3008:
 + switch (ioc-pdev-subsystem_device) {
 + case MPT3SAS_DELL_12G_HBA_SSDID:
 + pr_info(MPT3SAS_FMT %s\n, ioc-name,
 + MPT3SAS_DELL_12G_HBA_BRANDING);
 + break;
 + default:
 + pr_info(MPT3SAS_FMT
 +Dell 12Gbps HBA: Subsystem ID: 0x%X\n, ioc-name,
 +ioc-pdev-subsystem_device);
 + break;
 + }
 + break;
 + default:
 + pr_info(MPT3SAS_FMT
 + Dell 12Gbps HBA: Subsystem ID: 0x%X\n, ioc-name,
 + ioc-pdev-subsystem_device);
 + break;
 + }
 +}
 +
 +
 +/**
   * _base_display_ioc_capabilities - Disply IOC's capabilities.
   * @ioc: per adapter object
   *
 @@ -2374,6 +2409,7 @@ _base_display_ioc_capabilities(struct MPT3SAS_ADAPTER 
 *ioc)
   bios_version  0x00FF);
  
   _base_display_intel_branding(ioc);
 + _base_display_dell_branding(ioc);
  
   pr_info(MPT3SAS_FMT Protocol=(, ioc-name);
  
 diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
 b/drivers/scsi/mpt3sas/mpt3sas_base.h
 index 2318ef8..c4780c7 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h
 +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
 @@ -152,6 +152,17 @@
  #define MPT3SAS_INTEL_RS3UC080_SSDID0x3524
  
  /*
 + * Dell HBA branding
 + */
 +#define MPT3SAS_DELL_12G_HBA_BRANDING   \
 + Dell 12Gbps HBA
 +
 +/*
 + * Dell HBA SSDIDs
 + */
 +#define MPT3SAS_DELL_12G_HBA_SSDID   0x1F46
 +
 +/*
   * status bits for ioc-diag_buffer_status
   */
  #define MPT3_DIAG_BUFFER_IS_REGISTERED   (0x01)
 -- 
 2.0.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 14/20 v1] [SCSI] mpt3sas: Complete the SCSI command with DID_RESET status for log_info value 0x0x32010081

2015-06-18 Thread Johannes Thumshirn
On Tue, Jun 16, 2015 at 11:05:24AM +0530, Sreekanth Reddy wrote:
 For any SCSI command, if the driver receives
 IOC status = SCSI_IOC_TERMINATED and log info = 0x32010081 then
 that command will be completed with DID_RESET host status.
 
 The definition of this log info value is
 Virtual IO has failed and has to be retried.
 
 Firmware will provide this log info value with IOC Status
 SCSI_IOC_TERMINATED, whenever a drive (with is a part of a volume)
 is pulled and pushed back within some minimal delay.
 With this log info value, firmware informs the driver to retry the
 failed IO command infinite times, so to provide some time for the
 firmware to discover the reinserted drive successfully instated of
 just retrying failed command for five times(doesn't giving enough
 time for firmware to complete the drive discovery) and failing the
 IO permanently even though drive came back successfully.
 
 Changes in v1:
Defined macro VIRTUAL_IO_FAILED_RETRY for magic a value 0x32010081
 
 Signed-off-by: Sreekanth Reddy sreekanth.re...@avagotech.com
 ---
  drivers/scsi/mpt3sas/mpt3sas_base.h  | 2 ++
  drivers/scsi/mpt3sas/mpt3sas_scsih.c | 3 +++
  2 files changed, 5 insertions(+)
 
 diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
 b/drivers/scsi/mpt3sas/mpt3sas_base.h
 index 0ffe763..f3f79be 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h
 +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
 @@ -203,6 +203,8 @@
  #define MFG10_GF0_SSD_DATA_SCRUB_DISABLE   (0x0008)
  #define MFG10_GF0_SINGLE_DRIVE_R0  (0x0010)
  
 +#define VIRTUAL_IO_FAILED_RETRY  (0x32010081)
 +
  /* OEM Specific Flags will come from OEM specific header files */
  struct Mpi2ManufacturingPage10_t {
   MPI2_CONFIG_PAGE_HEADER Header; /* 00h */
 diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
 b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
 index 7060c8b..7587f77 100644
 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
 +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
 @@ -4302,6 +4302,9 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, 
 u8 msix_index, u32 reply)
   scmd-device-expecting_cc_ua = 1;
   }
   break;
 + } else if (log_info == VIRTUAL_IO_FAILED_RETRY) {
 + scmd-result = DID_RESET  16;
 + break;
   }
   scmd-result = DID_SOFT_ERROR  16;
   break;
 -- 
 2.0.2


Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1] scsi: Initialize sdp after NULL check of cmnd

2015-06-17 Thread Johannes Thumshirn
On Wed, Jun 17, 2015 at 04:51:07PM +0530, Maninder Singh wrote:
 Currently cmnd pointer is already dereferenced before NULL check
 and thus getting below warning in static analysis:
 warn: variable dereferenced before check 'cmnd'
 
 So initialize struct scsi_device *sdp after NULL check
 of cmnd
 
 
 Signed-off-by: Maninder Singh maninder...@samsung.com
 Reviewed-by: Akhilesh Kumar akhiles...@samsung.com
 ---
  drivers/scsi/scsi_debug.c |4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
 index 1f8e2dc..bb97a5a 100644
 --- a/drivers/scsi/scsi_debug.c
 +++ b/drivers/scsi/scsi_debug.c
 @@ -3942,7 +3942,7 @@ schedule_resp(struct scsi_cmnd *cmnd, struct 
 sdebug_dev_info *devip,
   unsigned long iflags;
   int k, num_in_q, qdepth, inject;
   struct sdebug_queued_cmd *sqcp = NULL;
 - struct scsi_device *sdp = cmnd-device;
 + struct scsi_device *sdp;
  
   if (NULL == cmnd || NULL == devip) {
   pr_warn(%s: called with NULL cmnd or devip pointer\n,
 @@ -3950,6 +3950,8 @@ schedule_resp(struct scsi_cmnd *cmnd, struct 
 sdebug_dev_info *devip,
   /* no particularly good error to report back */
   return SCSI_MLQUEUE_HOST_BUSY;
   }
 +
 + sdp = cmnd-device;
   if ((scsi_result)  (SCSI_DEBUG_OPT_NOISE  scsi_debug_opts))
   sdev_printk(KERN_INFO, sdp, %s: non-zero result=0x%x\n,
   __func__, scsi_result);
 -- 
 1.7.1
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mpt2sas: setpci reset kernel panic fix

2015-06-17 Thread Johannes Thumshirn
;
  /* local parameters */
  static u8 scsi_io_cb_idx = -1;
  static u8 tm_cb_idx = -1;
 @@ -279,6 +280,20 @@ static struct pci_device_id scsih_pci_table[] = {
  MODULE_DEVICE_TABLE(pci, scsih_pci_table);
 
  /**
 + * mpt2sas_initialize_gioc_lock - initialize the gobal ioc lock
 + */
 +void
 +mpt2sas_initialize_gioc_lock(void)
 +{
 + static int gioc_lock_initialize;
 +
 + if (!gioc_lock_initialize) {
 + spin_lock_init(gioc_lock);
 + gioc_lock_initialize = 1;
 + }
 +}
 +
 +/**
   * _scsih_set_debug_level - global setting of ioc-logging_level.
   *
   * Note: The logging levels are defined in mpt2sas_debug.h.
 @@ -288,13 +303,17 @@ _scsih_set_debug_level(const char *val, struct
 kernel_param *kp)
  {
   int ret = param_set_int(val, kp);
   struct MPT2SAS_ADAPTER *ioc;
 + unsigned long flags;
 
   if (ret)
   return ret;
 
 + mpt2sas_initialize_gioc_lock();
   printk(KERN_INFO setting logging_level(0x%08x)\n, logging_level);
 + spin_lock_irqsave(gioc_lock, flags);
   list_for_each_entry(ioc, mpt2sas_ioc_list, list)
   ioc-logging_level = logging_level;
 + spin_unlock_irqrestore(gioc_lock, flags);
   return 0;
  }
  module_param_call(logging_level, _scsih_set_debug_level, param_get_int,
 @@ -7867,7 +7886,9 @@ _scsih_remove(struct pci_dev *pdev)
   sas_remove_host(shost);
   scsi_remove_host(shost);
   mpt2sas_base_detach(ioc);
 + spin_lock_irqsave(gioc_lock, flags);
   list_del(ioc-list);
 + spin_unlock_irqrestore(gioc_lock, flags);
   scsi_host_put(shost);
  }
 
 @@ -8132,6 +8153,7 @@ _scsih_probe(struct pci_dev *pdev, const struct
 pci_device_id *id)
   struct MPT2SAS_ADAPTER *ioc;
   struct Scsi_Host *shost;
   int rv;
 + unsigned long flags;
 
   shost = scsi_host_alloc(scsih_driver_template,
  sizeof(struct MPT2SAS_ADAPTER));
 @@ -8142,7 +8164,9 @@ _scsih_probe(struct pci_dev *pdev, const struct
 pci_device_id *id)
   ioc = shost_priv(shost);
   memset(ioc, 0, sizeof(struct MPT2SAS_ADAPTER));
   INIT_LIST_HEAD(ioc-list);
 + spin_lock_irqsave(gioc_lock, flags);
   list_add_tail(ioc-list, mpt2sas_ioc_list);
 + spin_unlock_irqrestore(gioc_lock, flags);
   ioc-shost = shost;
   ioc-id = mpt_ids++;
   sprintf(ioc-name, %s%d, MPT2SAS_DRIVER_NAME, ioc-id);
 @@ -8167,6 +8191,9 @@ _scsih_probe(struct pci_dev *pdev, const struct
 pci_device_id *id)
   ioc-schedule_dead_ioc_flush_running_cmds = _scsih_flush_running_cmds;
   /* misc semaphores and spin locks */
   mutex_init(ioc-reset_in_progress_mutex);
 + /* initializing pci_access_mutex lock */
 + if (ioc-is_warpdrive)
 + mutex_init(ioc-pci_access_mutex);
   spin_lock_init(ioc-ioc_reset_in_progress_lock);
   spin_lock_init(ioc-scsi_lookup_lock);
   spin_lock_init(ioc-sas_device_lock);
 @@ -8269,7 +8296,9 @@ _scsih_probe(struct pci_dev *pdev, const struct
 pci_device_id *id)
   out_attach_fail:
   destroy_workqueue(ioc-firmware_event_thread);
   out_thread_fail:
 + spin_lock_irqsave(gioc_lock, flags);
   list_del(ioc-list);
 + spin_unlock_irqrestore(gioc_lock, flags);
   scsi_host_put(shost);
   return rv;
  }
 @@ -8506,6 +8535,7 @@ _scsih_init(void)
   return -ENODEV;
   }
 
 + mpt2sas_initialize_gioc_lock();
   mpt2sas_base_initialize_callback_handler();
 
   /* queuecommand callback hander */
 -- 
 1.7.1
 
 
 Regards,
 Nagarajkumar Narayanan
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html


Hi Nagarajkumar,

Thanks for the patch, but can you please format the patch according to
Documentation/SubmittingPatches and re-send.

Thanks,
Johannes

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Patch V2 1/9] [SCSI] aacraid: Fix for logical device name and UID not exposed to the OS

2015-06-16 Thread Johannes Thumshirn
On Wed, Jun 10, 2015 at 06:42:23PM -0700, rajinikanth.panduran...@pmcs.com 
wrote:
 From: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 
 Description:
   Driver sends the right size of the response buffer.
 
 Signed-off-by: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 ---
  drivers/scsi/aacraid/aachba.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
 index 9b3dd6e..fe59b00 100644
 --- a/drivers/scsi/aacraid/aachba.c
 +++ b/drivers/scsi/aacraid/aachba.c
 @@ -570,7 +570,7 @@ static int aac_get_container_name(struct scsi_cmnd * 
 scsicmd)
  
   status = aac_fib_send(ContainerCommand,
 cmd_fibcontext,
 -   sizeof (struct aac_get_name),
 +   sizeof(struct aac_get_name_resp),
 FsaNormal,
 0, 1,
 (fib_callback)get_container_name_callback,
 @@ -1052,7 +1052,7 @@ static int aac_get_container_serial(struct scsi_cmnd * 
 scsicmd)
  
   status = aac_fib_send(ContainerCommand,
 cmd_fibcontext,
 -   sizeof (struct aac_get_serial),
 +   sizeof(struct aac_get_serial_resp),
 FsaNormal,
 0, 1,
 (fib_callback) get_container_serial_callback,
 -- 
 1.9.3
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Patch V2 3/9] [SCSI] aacraid: Enable MSI interrupt for series-6 controller

2015-06-16 Thread Johannes Thumshirn
On Wed, Jun 10, 2015 at 06:42:25PM -0700, rajinikanth.panduran...@pmcs.com 
wrote:
 From: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 
 Description:
   Enable MSI interrupt mode for series-6 controller.
 
 Signed-off-by: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 ---
  drivers/scsi/aacraid/src.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c
 index b147341..eb07b3d 100644
 --- a/drivers/scsi/aacraid/src.c
 +++ b/drivers/scsi/aacraid/src.c
 @@ -742,7 +742,7 @@ int aac_src_init(struct aac_dev *dev)
   if (dev-comm_interface != AAC_COMM_MESSAGE_TYPE1)
   goto error_iounmap;
  
 - dev-msi = aac_msi  !pci_enable_msi(dev-pdev);
 + dev-msi = !pci_enable_msi(dev-pdev);
  
   dev-aac_msix[0].vector_no = 0;
   dev-aac_msix[0].dev = dev;
 -- 
 1.9.3
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Patch V2 6/9] [SCSI] aacraid: Reset irq affinity hints before releasing irq

2015-06-16 Thread Johannes Thumshirn
://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Patch V2 7/9] [SCSI] aacraid: Unblock IOCTLs to controller once system resumed from suspend

2015-06-16 Thread Johannes Thumshirn
On Wed, Jun 10, 2015 at 06:42:29PM -0700, rajinikanth.panduran...@pmcs.com 
wrote:
 From: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 
 Description:
   Driver blocks ioctls once it received shutdown/suspend request during
   suspend/hybernation. This patch unblocks ioctls on resume path.
 
 Signed-off-by: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 ---
  drivers/scsi/aacraid/linit.c | 5 +
  1 file changed, 5 insertions(+)
 
 diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
 index 8020348..1142c28 100644
 --- a/drivers/scsi/aacraid/linit.c
 +++ b/drivers/scsi/aacraid/linit.c
 @@ -1448,6 +1448,11 @@ static int aac_resume(struct pci_dev *pdev)
   pci_set_master(pdev);
   if (aac_acquire_resources(aac))
   goto fail_device;
 + /*
 + * reset this flag to unblock ioctl() as it was set at
 + * aac_send_shutdown() to block ioctls from upperlayer
 + */
 + aac-adapter_shutdown = 0;
   scsi_unblock_requests(shost);
  
   return 0;
 -- 
 1.9.3
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Patch V2 9/9] [SCSI] aacraid: Update driver version

2015-06-16 Thread Johannes Thumshirn
On Wed, Jun 10, 2015 at 06:42:31PM -0700, rajinikanth.panduran...@pmcs.com 
wrote:
 From: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 
 Signed-off-by: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 ---
  drivers/scsi/aacraid/aacraid.h | 2 +-
  drivers/scsi/aacraid/linit.c   | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
 index 7b95227..73c3384 100644
 --- a/drivers/scsi/aacraid/aacraid.h
 +++ b/drivers/scsi/aacraid/aacraid.h
 @@ -62,7 +62,7 @@ enum {
  #define  PMC_GLOBAL_INT_BIT0 0x0001
  
  #ifndef AAC_DRIVER_BUILD
 -# define AAC_DRIVER_BUILD 40709
 +# define AAC_DRIVER_BUILD 41010
  # define AAC_DRIVER_BRANCH -ms
  #endif
  #define MAXIMUM_NUM_CONTAINERS   32
 diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
 index 3df0dfb..1627928 100644
 --- a/drivers/scsi/aacraid/linit.c
 +++ b/drivers/scsi/aacraid/linit.c
 @@ -56,7 +56,7 @@
  
  #include aacraid.h
  
 -#define AAC_DRIVER_VERSION   1.2-1
 +#define AAC_DRIVER_VERSION   1.2-2
  #ifndef AAC_DRIVER_BRANCH
  #define AAC_DRIVER_BRANCH
  #endif
 -- 
 1.9.3
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] bfa: fix leak of bfad_im_port_index on module unload

2015-06-12 Thread Johannes Thumshirn
On Fri, Jun 12, 2015 at 01:50:45AM +0300, Alexey Khoroshilov wrote:
 Resources allocated within bfad_im_port_index idr are not deallocated
 on module unload. The patch adds idr_destroy() in exit function.
 
 Found by Linux Driver Verification project (linuxtesting.org).
 
 Signed-off-by: Alexey Khoroshilov khoroshi...@ispras.ru
 ---
  drivers/scsi/bfa/bfad_im.c | 2 ++
  1 file changed, 2 insertions(+)
 
 diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c
 index 7223b0006740..8367c11d554b 100644
 --- a/drivers/scsi/bfa/bfad_im.c
 +++ b/drivers/scsi/bfa/bfad_im.c
 @@ -851,6 +851,8 @@ bfad_im_module_exit(void)
  
   if (bfad_im_scsi_vport_transport_template)
   fc_release_transport(bfad_im_scsi_vport_transport_template);
 +
 + idr_destroy(bfad_im_port_index);
  }
  
  void
 -- 
 1.9.1
 

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 9/9] snic:Add Makefile, patch Kconfig, MAINTAINERS

2015-05-28 Thread Johannes Thumshirn
On Thu, May 28, 2015 at 09:49:08AM +, Narsimhulu Musini (nmusini) wrote:
 Hi Boaz, 
 
 Sure, I will incorporate the comments and suggestions in next patch
 submittal.
 
 Thanks
 Narsimhulu

As you're going to re-submit anyway, I have found several occurences of:
[Insert appropriate license here when releasing outside of Cisco]
in the patches.

Doesn't really look intentional.

Johannes
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] st: null pointer dereference panic caused by use after kref_put by st_open

2015-07-02 Thread Johannes Thumshirn
Seymour, Shane M shane.seym...@hp.com writes:

 Two SLES11 SP3 servers encountered similar crashes simultaneously
 following some kind of SAN/tape target issue:


Thanks,

Reviewed-by: Johannes Thumshirn jthumsh...@suse.com

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1] we added changes in fnic driver patch 1.6.0.16 to acquire io_req_lock in fnic_queuecommand() before issuing I/O so that io completion is serialized. But when releasing the lock we chec

2015-07-03 Thread Johannes Thumshirn
Hiral Shah his...@cisco.com writes:

 Signed-off-by: Hiral Shah his...@cisco.com
 Signed-off-by: Sesidhar Baddela sebad...@cisco.com
 Signed-off-by: Anil Chintalapati achin...@cisco.com
 ---
  drivers/scsi/fnic/fnic.h  | 2 +-
  drivers/scsi/fnic/fnic_scsi.c | 4 +++-
  2 files changed, 4 insertions(+), 2 deletions(-)

 diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
 index 26270c3..ce129e5 100644
 --- a/drivers/scsi/fnic/fnic.h
 +++ b/drivers/scsi/fnic/fnic.h
 @@ -39,7 +39,7 @@
  
  #define DRV_NAME fnic
  #define DRV_DESCRIPTION  Cisco FCoE HBA Driver
 -#define DRV_VERSION  1.6.0.17
 +#define DRV_VERSION  1.6.0.17a
  #define PFX  DRV_NAME : 
  #define DFX DRV_NAME %d: 
  
 diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
 index 155b286..25436cd 100644
 --- a/drivers/scsi/fnic/fnic_scsi.c
 +++ b/drivers/scsi/fnic/fnic_scsi.c
 @@ -425,6 +425,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, 
 void (*done)(struct scsi_
   unsigned long ptr;
   struct fc_rport_priv *rdata;
   spinlock_t *io_lock = NULL;
 + int io_lock_acquired = 0;
  
   if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED)))
   return SCSI_MLQUEUE_HOST_BUSY;
 @@ -518,6 +519,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, 
 void (*done)(struct scsi_
   spin_lock_irqsave(io_lock, flags);
  
   /* initialize rest of io_req */
 + io_lock_acquired = 1;
   io_req-port_id = rport-port_id;
   io_req-start_time = jiffies;
   CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING;
 @@ -571,7 +573,7 @@ out:
 (((u64)CMD_FLAGS(sc)  32) | CMD_STATE(sc)));
  
   /* if only we issued IO, will we have the io lock */
 - if (CMD_FLAGS(sc)  FNIC_IO_INITIALIZED)
 + if (io_lock_acquired)
   spin_unlock_irqrestore(io_lock, flags);

Can't you just use
if (spin_is_locked(io_lock))
   spin_unlock_irqrestore(io_lock, flags);


  
   atomic_dec(fnic-in_flight);

Johannes

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch] mptfusion: prevent some memory corruption

2015-07-03 Thread Johannes Thumshirn
Dan Carpenter dan.carpen...@oracle.com writes:

 These are signed values the come from the user, we put a cap on the
 upper bounds but not on the lower bounds.

 We use karg.dataSgeOffset to calculate sz.  We verify sz and
 proceed as if that means that karg.dataSgeOffset is correct but this
 fails to consider that the sz calculations can have integer overflows.

 Signed-off-by: Dan Carpenter dan.carpen...@oracle.com
 ---
 During my QC process, I realized that I sent a similar patch last year,
 but never received a response.

 http://permalink.gmane.org/gmane.linux.kernel.janitors/32590

 Looking at both of them, I guess I prefer today's patch because it is
 simpler.

 diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
 index 70bb753..fc73937 100644
 --- a/drivers/message/fusion/mptctl.c
 +++ b/drivers/message/fusion/mptctl.c
 @@ -1859,6 +1859,15 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, 
 void __user *mfPtr)
   }
   spin_unlock_irqrestore(ioc-taskmgmt_lock, flags);
  
 + /* Basic sanity checks to prevent underflows or integer overflows */
 + if (karg.maxReplyBytes  0 ||
 + karg.dataInSize  0 ||
 + karg.dataOutSize  0 ||
 + karg.dataSgeOffset  0 ||
 + karg.maxSenseBytes  0 ||
 + karg.dataSgeOffset  ioc-req_sz / 4)
 + return -EINVAL;
 +
   /* Verify that the final request frame will not be too large.
*/
   sz = karg.dataSgeOffset * 4;
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Acked-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mvsas: always iounmap resources

2015-05-22 Thread Johannes Thumshirn
In case pci_resource_start() or pci_resource_len() reutrn 0, mvsas_ioremap
returns without doing an iounmap() of mvi-regs_ex.

Found by the cocinelle tool.

Signed-off-by: Johannes Thumshirn jthumsh...@suse.de
---
 drivers/scsi/mvsas/mv_init.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index 53030b0..04a3205 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -339,8 +339,11 @@ int mvs_ioremap(struct mvs_info *mvi, int bar, int bar_ex)
 
res_start = pci_resource_start(pdev, bar);
res_len = pci_resource_len(pdev, bar);
-   if (!res_start || !res_len)
+   if (!res_start || !res_len) {
+   iounmap(mvi-regs_ex);
+   mvi-regs_ex = NULL;
goto err_out;
+   }
 
res_flag = pci_resource_flags(pdev, bar);
if (res_flag  IORESOURCE_CACHEABLE)
-- 
2.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND] mvsas: always iounmap resources

2015-07-07 Thread Johannes Thumshirn
In case pci_resource_start() or pci_resource_len() reutrn 0, mvsas_ioremap
returns without doing an iounmap() of mvi-regs_ex.

Found by the cocinelle tool.

Signed-off-by: Johannes Thumshirn jthumsh...@suse.de
Reviewed-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/mvsas/mv_init.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index 53030b0..04a3205 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -339,8 +339,11 @@ int mvs_ioremap(struct mvs_info *mvi, int bar, int bar_ex)
 
res_start = pci_resource_start(pdev, bar);
res_len = pci_resource_len(pdev, bar);
-   if (!res_start || !res_len)
+   if (!res_start || !res_len) {
+   iounmap(mvi-regs_ex);
+   mvi-regs_ex = NULL;
goto err_out;
+   }
 
res_flag = pci_resource_flags(pdev, bar);
if (res_flag  IORESOURCE_CACHEABLE)
-- 
2.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V3] fnic: check pci_map_single() return value

2015-08-13 Thread Johannes Thumshirn
,
io_req-sgl_list,
sizeof(io_req-sgl_list[0]) * sg_count,
PCI_DMA_TODEVICE);
 +
 + r = pci_dma_mapping_error(fnic-pdev, io_req-sgl_list_pa);
 + if (r) {
 + printk(KERN_ERR PCI mapping failed with error %d\n, 
 r);
 + return SCSI_MLQUEUE_HOST_BUSY;
 + }
   }
  
   io_req-sense_buf_pa = pci_map_single(fnic-pdev,
 @@ -353,6 +360,15 @@ static inline int fnic_queue_wq_copy_desc(struct fnic 
 *fnic,
 SCSI_SENSE_BUFFERSIZE,
 PCI_DMA_FROMDEVICE);
  
 + r = pci_dma_mapping_error(fnic-pdev, io_req-sense_buf_pa);
 + if (r) {
 + pci_unmap_single(fnic-pdev, io_req-sgl_list_pa,
 + sizeof(io_req-sgl_list[0]) * sg_count,
 + PCI_DMA_TODEVICE);
 + printk(KERN_ERR PCI mapping failed with error %d\n, r);
 + return SCSI_MLQUEUE_HOST_BUSY;
 + }
 +
   int_to_scsilun(sc-device-lun, fc_lun);
  
   /* Enqueue the descriptor in the Copy WQ */


Looks good from my side.

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de
-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi: Export SCSI Inquiry data to sysfs

2015-08-13 Thread Johannes Thumshirn
Export the RAW SCSI Inquiry to sysfs as binfile. This way the data can be
used by userlang without the need to have and ioctl or use the sg_inq tool.

Here is an example of the provided data

linux:~ # hexdump /sys/class/scsi_device/1\:0\:0\:0/device/inquiry
000 8005 3205 001f  4551 554d 2020 2020
010 4551 554d 4420 4456 522d 4d4f 2020 2020
020 2e32 2e33
024

Signed-off-by: Johannes Thumshirn jthumsh...@suse.de
---
 drivers/scsi/scsi_sysfs.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 9ad4116..5ecb65d 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -773,6 +773,29 @@ static struct bin_attribute dev_attr_vpd_##_page = {   
\
 sdev_vpd_pg_attr(pg83);
 sdev_vpd_pg_attr(pg80);
 
+static ssize_t show_inquiry(struct file *filep, struct kobject *kobj,
+   struct bin_attribute *bin_attr,
+   char *buf, loff_t off, size_t count)
+{
+   struct device *dev = container_of(kobj, struct device, kobj);
+   struct scsi_device *sdev = to_scsi_device(dev);
+
+   if (!sdev-inquiry)
+   return -EINVAL;
+
+   return memory_read_from_buffer(buf, count, off, sdev-inquiry,
+  sdev-inquiry_len);
+}
+
+static struct bin_attribute dev_attr_inquiry = {
+   .attr = {
+   .name = inquiry,
+   .mode = S_IRUGO,
+   },
+   .size = 0,
+   .read = show_inquiry,
+};
+
 static ssize_t
 show_iostat_counterbits(struct device *dev, struct device_attribute *attr,
char *buf)
@@ -957,6 +980,7 @@ static struct attribute *scsi_sdev_attrs[] = {
 static struct bin_attribute *scsi_sdev_bin_attrs[] = {
dev_attr_vpd_pg83,
dev_attr_vpd_pg80,
+   dev_attr_inquiry,
NULL
 };
 static struct attribute_group scsi_sdev_attr_group = {
-- 
2.5.0

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RESEND V2 3/7] scsi: storvsc: Untangle the storage protocol negotiation from the vmbus protocol negotiation.

2015-08-13 Thread Johannes Thumshirn
K. Y. Srinivasan k...@microsoft.com writes:

 From: Keith Mange keith.ma...@microsoft.com

 Currently we are making decisions based on vmbus protocol versions
 that have been negotiated; use storage potocol versions instead.

 Tested-by: Alex Ng ale...@microsoft.com
 Signed-off-by: Keith Mange keith.ma...@microsoft.com
 Signed-off-by: K. Y. Srinivasan k...@microsoft.com
 ---
  drivers/scsi/storvsc_drv.c |  109 
 +++-
  1 files changed, 87 insertions(+), 22 deletions(-)

 diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
 index 5f9d133..f29871e 100644
 --- a/drivers/scsi/storvsc_drv.c
 +++ b/drivers/scsi/storvsc_drv.c
 @@ -56,14 +56,18 @@
   * V1 RC  2008/1/31:  2.0
   * Win7: 4.2
   * Win8: 5.1
 + * Win8.1: 6.0
 + * Win10: 6.2
   */
  
  #define VMSTOR_PROTO_VERSION(MAJOR_, MINOR_) MAJOR_)  0xff)  8) | \
   (((MINOR_)  0xff)))
  
 +#define VMSTOR_PROTO_VERSION_WIN6VMSTOR_PROTO_VERSION(2, 0)
  #define VMSTOR_PROTO_VERSION_WIN7VMSTOR_PROTO_VERSION(4, 2)
  #define VMSTOR_PROTO_VERSION_WIN8VMSTOR_PROTO_VERSION(5, 1)
 -
 +#define VMSTOR_PROTO_VERSION_WIN8_1  VMSTOR_PROTO_VERSION(6, 0)
 +#define VMSTOR_PROTO_VERSION_WIN10   VMSTOR_PROTO_VERSION(6, 2)
  
  /*  Packet structure describing virtual storage requests. */
  enum vstor_packet_operation {
 @@ -205,6 +209,46 @@ struct vmscsi_request {
  
  
  /*
 + * The list of storage protocols in order of preference.
 + */
 +struct vmstor_protocol {
 + int protocol_version;
 + int sense_buffer_size;
 + int vmscsi_size_delta;
 +};
 +
 +#define VMSTOR_NUM_PROTOCOLS5

can't you just use ARRAY_SIZE() here, so you don't have to touch the
constant every time a new protocol is appended to the list?

 +
 +const struct vmstor_protocol vmstor_protocols[VMSTOR_NUM_PROTOCOLS] = {
 + {
 + VMSTOR_PROTO_VERSION_WIN10,
 + POST_WIN7_STORVSC_SENSE_BUFFER_SIZE,
 + 0
 + },
 + {
 + VMSTOR_PROTO_VERSION_WIN8_1,
 + POST_WIN7_STORVSC_SENSE_BUFFER_SIZE,
 + 0
 + },
 + {
 + VMSTOR_PROTO_VERSION_WIN8,
 + POST_WIN7_STORVSC_SENSE_BUFFER_SIZE,
 + 0
 + },
 + {
 + VMSTOR_PROTO_VERSION_WIN7,
 + PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE,
 + sizeof(struct vmscsi_win8_extension),
 + },
 + {
 + VMSTOR_PROTO_VERSION_WIN6,
 + PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE,
 + sizeof(struct vmscsi_win8_extension),
 + }
 +};
 +

Thanks,
Johannes
-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch] scsi: aic94xx: set an error code on failure

2015-08-18 Thread Johannes Thumshirn
Dan Carpenter dan.carpen...@oracle.com writes:

 We recently did some cleanup here and now the static checkers notice
 that there is a missing error code when ioremap() fails.  Let's set it
 to -ENOMEM.

 Signed-off-by: Dan Carpenter dan.carpen...@oracle.com

 diff --git a/drivers/scsi/aic94xx/aic94xx_init.c 
 b/drivers/scsi/aic94xx/aic94xx_init.c
 index 140cb8e..f6c336b 100644
 --- a/drivers/scsi/aic94xx/aic94xx_init.c
 +++ b/drivers/scsi/aic94xx/aic94xx_init.c
 @@ -104,6 +104,7 @@ static int asd_map_memio(struct asd_ha_struct *asd_ha)
   if (!io_handle-addr) {
   asd_printk(couldn't map MBAR%d of %s\n, i==0?0:1,
  pci_name(asd_ha-pcidev));
 + err = -ENOMEM;
   goto Err_unreq;
   }
   }
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
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
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch] cxlflash: shift wrapping bug in afu_link_reset()

2015-08-18 Thread Johannes Thumshirn
Dan Carpenter dan.carpen...@oracle.com writes:

 port_sel is a u64 so the shifting should also be a 64 bit shift.

 Fixes: c21e0bbfc485 ('cxlflash: Base support for IBM CXL Flash Adapter')
 Signed-off-by: Dan Carpenter dan.carpen...@oracle.com

 diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
 index 0720d2f..f97421d 100644
 --- a/drivers/scsi/cxlflash/main.c
 +++ b/drivers/scsi/cxlflash/main.c
 @@ -1179,7 +1179,7 @@ static void afu_link_reset(struct afu *afu, int port, 
 u64 *fc_regs)
  
   /* first switch the AFU to the other links, if any */
   port_sel = readq_be(afu-afu_map-global.regs.afu_port_sel);
 - port_sel = ~(1  port);
 + port_sel = ~(1ULL  port);
   writeq_be(port_sel, afu-afu_map-global.regs.afu_port_sel);
   cxlflash_afu_sync(afu, 0, 0, AFU_GSYNC);
  
 @@ -1196,7 +1196,7 @@ static void afu_link_reset(struct afu *afu, int port, 
 u64 *fc_regs)
  __func__, port);
  
   /* switch back to include this port */
 - port_sel |= (1  port);
 + port_sel |= (1ULL  port);
   writeq_be(port_sel, afu-afu_map-global.regs.afu_port_sel);
   cxlflash_afu_sync(afu, 0, 0, AFU_GSYNC);
  
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
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
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [SCSI] bfa: check if port is non NULL before dereferencing

2015-08-17 Thread Johannes Thumshirn
In bfa_fcs_lport_get_rport_max_speed() check if port is non NULL before
dereferencing it's child port-fcs-bfa to trl_enabled.

NB: I'm not entirely sure if port can even be NULL, so the check for NULL might
be useless as well.

Signed-off-by: Johannes Thumshirn jthumsh...@suse.de
---
 drivers/scsi/bfa/bfa_fcs_lport.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
index ff75ef8..096c2a2 100644
--- a/drivers/scsi/bfa/bfa_fcs_lport.c
+++ b/drivers/scsi/bfa/bfa_fcs_lport.c
@@ -5826,12 +5826,14 @@ bfa_fcs_lport_get_rport_max_speed(bfa_fcs_lport_t *port)
bfa_port_speed_t max_speed = 0;
struct bfa_port_attr_s port_attr;
bfa_port_speed_t port_speed, rport_speed;
-   bfa_boolean_t trl_enabled = bfa_fcport_is_ratelim(port-fcs-bfa);
+   bfa_boolean_t trl_enabled;
 
 
if (port == NULL)
return 0;
 
+   trl_enabled = bfa_fcport_is_ratelim(port-fcs-bfa);
+
fcs = port-fcs;
 
/* Get Physical port's current speed */
-- 
2.5.0

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] lpfc: Fix possible use-after-free and double free in lpfc_mbx_cmpl_rdp_page_a2()

2015-08-17 Thread Johannes Thumshirn
If the bf_get() call in lpfc_mbx_cmpl_rdp_page_a2() does succeeds, execution
continues normally and mp gets kfree()d.

If the subsequent call to lpfc_sli_issue_mbox() fails execution jumps to the
error label where lpfc_mbuf_free() is called with mp-virt and mp-phys as
function arguments. This is the use after free. Following the use after free mp
gets kfree()d again which is a double free.

Signed-off-by: Johannes Thumshirn jthumsh...@suse.de
---
 drivers/scsi/lpfc/lpfc_mbox.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c
index eb62772..4abb93a 100644
--- a/drivers/scsi/lpfc/lpfc_mbox.c
+++ b/drivers/scsi/lpfc/lpfc_mbox.c
@@ -2284,7 +2284,7 @@ lpfc_mbx_cmpl_rdp_page_a2(struct lpfc_hba *phba, 
LPFC_MBOXQ_t *mbox)
(struct lpfc_rdp_context *)(mbox-context2);
 
if (bf_get(lpfc_mqe_status, mbox-u.mqe))
-   goto error;
+   goto error_mbuf_free;
 
lpfc_sli_bemem_bcopy(mp-virt, rdp_context-page_a2,
DMP_SFF_PAGE_A2_SIZE);
@@ -2299,13 +2299,14 @@ lpfc_mbx_cmpl_rdp_page_a2(struct lpfc_hba *phba, 
LPFC_MBOXQ_t *mbox)
mbox-mbox_cmpl = lpfc_mbx_cmpl_rdp_link_stat;
mbox-context2 = (struct lpfc_rdp_context *) rdp_context;
if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) == MBX_NOT_FINISHED)
-   goto error;
+   goto error_cmd_free;
 
return;
 
-error:
+error_mbuf_free:
lpfc_mbuf_free(phba, mp-virt, mp-phys);
kfree(mp);
+error_cmd_free:
lpfc_sli4_mbox_cmd_free(phba, mbox);
rdp_context-cmpl(phba, rdp_context, FAILURE);
 }
-- 
2.5.0

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] pm80xx: Don't override ts-stat on IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY

2015-08-17 Thread Johannes Thumshirn
Jack Wang xjtu...@gmail.com writes:

 2015-08-17 15:04 GMT+02:00 Johannes Thumshirn jthumsh...@suse.de:
 In case XXX returns with a status of IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY

Apparently I've hit enter to fast. This shouldn't be XXX but
psataPayload-status. I'll be sending a v2 :-(.

 ts-stat gets set to SAS_OPEN_REJECT but a missing 'break' statement causes a
 fallthrough to the default handler of the switch statement overriding 
 ts-stat
 to SAS_DEV_NO_RESPONSE.

 Signed-off-by: Johannes Thumshirn jthumsh...@suse.de

 Thanks, please feel free to add:
 Acked-by: Jack Wang jinpu.w...@profitbricks.com

 ---
  drivers/scsi/pm8001/pm8001_hwi.c | 1 +
  drivers/scsi/pm8001/pm80xx_hwi.c | 1 +
  2 files changed, 2 insertions(+)

 diff --git a/drivers/scsi/pm8001/pm8001_hwi.c 
 b/drivers/scsi/pm8001/pm8001_hwi.c
 index 96dcc09..d0feec5 100644
 --- a/drivers/scsi/pm8001/pm8001_hwi.c
 +++ b/drivers/scsi/pm8001/pm8001_hwi.c
 @@ -2642,6 +2642,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, 
 void *piomb)
 ts-resp = SAS_TASK_COMPLETE;
 ts-stat = SAS_OPEN_REJECT;
 ts-open_rej_reason = SAS_OREJ_RSVD_RETRY;
 +   break;
 default:
 PM8001_IO_DBG(pm8001_ha,
 pm8001_printk(Unknown status 0x%x\n, status));
 diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c 
 b/drivers/scsi/pm8001/pm80xx_hwi.c
 index 05cce46..18d4ac4 100644
 --- a/drivers/scsi/pm8001/pm80xx_hwi.c
 +++ b/drivers/scsi/pm8001/pm80xx_hwi.c
 @@ -2314,6 +2314,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, 
 void *piomb)
 ts-resp = SAS_TASK_COMPLETE;
 ts-stat = SAS_OPEN_REJECT;
 ts-open_rej_reason = SAS_OREJ_RSVD_RETRY;
 +   break;
 default:
 PM8001_IO_DBG(pm8001_ha,
 pm8001_printk(Unknown status 0x%x\n, status));
 --
 2.5.0

 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
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
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] pm80xx: Don't override ts-stat on IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY

2015-08-17 Thread Johannes Thumshirn
In case XXX returns with a status of IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY
ts-stat gets set to SAS_OPEN_REJECT but a missing 'break' statement causes a
fallthrough to the default handler of the switch statement overriding ts-stat
to SAS_DEV_NO_RESPONSE.

Signed-off-by: Johannes Thumshirn jthumsh...@suse.de
---
 drivers/scsi/pm8001/pm8001_hwi.c | 1 +
 drivers/scsi/pm8001/pm80xx_hwi.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index 96dcc09..d0feec5 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -2642,6 +2642,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, 
void *piomb)
ts-resp = SAS_TASK_COMPLETE;
ts-stat = SAS_OPEN_REJECT;
ts-open_rej_reason = SAS_OREJ_RSVD_RETRY;
+   break;
default:
PM8001_IO_DBG(pm8001_ha,
pm8001_printk(Unknown status 0x%x\n, status));
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index 05cce46..18d4ac4 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -2314,6 +2314,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, 
void *piomb)
ts-resp = SAS_TASK_COMPLETE;
ts-stat = SAS_OPEN_REJECT;
ts-open_rej_reason = SAS_OREJ_RSVD_RETRY;
+   break;
default:
PM8001_IO_DBG(pm8001_ha,
pm8001_printk(Unknown status 0x%x\n, status));
-- 
2.5.0

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] pm80xx: Don't override ts-stat on IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY

2015-08-17 Thread Johannes Thumshirn
In case psataPayload-status has a status of IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY
ts-stat gets set to SAS_OPEN_REJECT but a missing 'break' statement causes a
fallthrough to the default handler of the switch statement overriding ts-stat
to SAS_DEV_NO_RESPONSE.

Signed-off-by: Johannes Thumshirn jthumsh...@suse.de
Acked-by: Jack Wang jinpu.w...@profitbricks.com
---
 drivers/scsi/pm8001/pm8001_hwi.c | 1 +
 drivers/scsi/pm8001/pm80xx_hwi.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index 96dcc09..d0feec5 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -2642,6 +2642,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, 
void *piomb)
ts-resp = SAS_TASK_COMPLETE;
ts-stat = SAS_OPEN_REJECT;
ts-open_rej_reason = SAS_OREJ_RSVD_RETRY;
+   break;
default:
PM8001_IO_DBG(pm8001_ha,
pm8001_printk(Unknown status 0x%x\n, status));
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index 05cce46..18d4ac4 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -2314,6 +2314,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, 
void *piomb)
ts-resp = SAS_TASK_COMPLETE;
ts-stat = SAS_OPEN_REJECT;
ts-open_rej_reason = SAS_OREJ_RSVD_RETRY;
+   break;
default:
PM8001_IO_DBG(pm8001_ha,
pm8001_printk(Unknown status 0x%x\n, status));
-- 
2.5.0

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] lpfc: Fix possible use-after-free and double free in lpfc_mbx_cmpl_rdp_page_a2()

2015-08-18 Thread Johannes Thumshirn
Sebastian Herbszt herb...@gmx.de writes:

 Johannes Thumshirn wrote:
 If the bf_get() call in lpfc_mbx_cmpl_rdp_page_a2() does succeeds, execution
 continues normally and mp gets kfree()d.
 
 If the subsequent call to lpfc_sli_issue_mbox() fails execution jumps to the
 error label where lpfc_mbuf_free() is called with mp-virt and mp-phys as
 function arguments. This is the use after free. Following the use after free 
 mp
 gets kfree()d again which is a double free.

 A similar patch was posted by Colin Ian King on 2015-07-31 [1].

 [1] http://marc.info/?l=linux-scsim=143835937206204w=2

OK,

Is it already in James' tree (haven't checked)? The problematic code was
merged for 4.2-rc1 so if the fix (Collin's or mine I don't care) could go
in while we're still in the rc phase, we could avoid all that stable
circus.

Thanks for digging this out.

Byte,
Johannes
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] SCSI: Fix NULL pointer dereference in runtime PM

2015-08-18 Thread Johannes Thumshirn
Alan Stern st...@rowland.harvard.edu writes:

 The routines in scsi_rpm.c assume that if a runtime-PM callback is
 invoked for a SCSI device, it can only mean that the device's driver 
 has asked the block layer to handle the runtime power management (by
 calling blk_pm_runtime_init(), which among other things sets q-dev).

 However, this assumption turns out to be wrong for things like the ses
 driver.  Normally ses devices are not allowed to do runtime PM, but
 userspace can override this setting.  If this happens, the kernel gets
 a NULL pointer dereference when blk_post_runtime_resume() tries to use
 the uninitialized q-dev pointer.

 This patch fixes the problem by calling the block layer's runtime-PM
 routines only if the device's driver really does have a runtime-PM
 callback routine.  Since ses doesn't define any such callbacks, the
 crash won't occur.

 This fixes Bugzilla #101371.

 Signed-off-by: Alan Stern st...@rowland.harvard.edu
 Reported-by: Stanisław Pitucha virap...@gmail.com
 Reported-by: Ilan Cohen ila...@gmail.com
 Tested-by: Ilan Cohen ila...@gmail.com

 ---


 [as1784]


  drivers/scsi/scsi_pm.c |   22 +++---
  1 file changed, 11 insertions(+), 11 deletions(-)

 Index: usb-4.0/drivers/scsi/scsi_pm.c
 ===
 --- usb-4.0.orig/drivers/scsi/scsi_pm.c
 +++ usb-4.0/drivers/scsi/scsi_pm.c
 @@ -217,15 +217,15 @@ static int sdev_runtime_suspend(struct d
  {
   const struct dev_pm_ops *pm = dev-driver ? dev-driver-pm : NULL;
   struct scsi_device *sdev = to_scsi_device(dev);
 - int err;
 + int err = 0;
  
 - err = blk_pre_runtime_suspend(sdev-request_queue);
 - if (err)
 - return err;
 - if (pm  pm-runtime_suspend)
 + if (pm  pm-runtime_suspend) {
 + err = blk_pre_runtime_suspend(sdev-request_queue);
 + if (err)
 + return err;
   err = pm-runtime_suspend(dev);
 - blk_post_runtime_suspend(sdev-request_queue, err);
 -
 + blk_post_runtime_suspend(sdev-request_queue, err);
 + }
   return err;
  }
  
 @@ -248,11 +248,11 @@ static int sdev_runtime_resume(struct de
   const struct dev_pm_ops *pm = dev-driver ? dev-driver-pm : NULL;
   int err = 0;
  
 - blk_pre_runtime_resume(sdev-request_queue);
 - if (pm  pm-runtime_resume)
 + if (pm  pm-runtime_resume) {
 + blk_pre_runtime_resume(sdev-request_queue);
   err = pm-runtime_resume(dev);
 - blk_post_runtime_resume(sdev-request_queue, err);
 -
 + blk_post_runtime_resume(sdev-request_queue, err);
 + }
   return err;
  }
  

 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
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
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi/be2iscsi: Fix logical-not-parentheses compilation warning

2015-08-04 Thread Johannes Thumshirn

Ok, it has cost me quite some time to figure out what !length  0 is
actually doing, but looks ok to me.


Tomer Barletz barl...@gmail.com writes:

 This fixes the following warning seen with GCC v5.1:
 warning: logical not is only applied to the left hand side of
 comparison [-Wlogical-not-parentheses].

 Signed-off-by: Tomer Barletz barl...@gmail.com
 ---
  drivers/scsi/be2iscsi/be_main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
 index 7a6dbfb..ff8d40e 100644
 --- a/drivers/scsi/be2iscsi/be_main.c
 +++ b/drivers/scsi/be2iscsi/be_main.c
 @@ -3184,7 +3184,7 @@ be_sgl_create_contiguous(void *virtual_address,
  {
   WARN_ON(!virtual_address);
   WARN_ON(!physical_address);
 - WARN_ON(!length  0);
 + WARN_ON(0 == length);

Please write WARN_ON(length == 0);

   WARN_ON(!sgl);
  
   sgl-va = virtual_address;


Given the above is swapped:
Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] megaraid_sas: fix missing { } braces

2015-08-04 Thread Johannes Thumshirn

Hi Colin,

Colin King colin.k...@canonical.com writes:

 From: Colin Ian King colin.k...@canonical.com

 Static analysis by smatch indicated that there was a curly
 braces issue:

 drivers/scsi/megaraid/megaraid_sas_base.c:6139
   megasas_mgmt_fw_ioctl() warn: curly braces intended?

 Add braces in the appropriate place so that kbuf_arr[i] gets
 set to NULL only when we need to.  Also, remove whitespace
 between kbuff_arr and [].

I don't quite get where you removed that whitespace. Might it be a left
over from another version of the patch?


 Signed-off-by: Colin Ian King colin.k...@canonical.com
 ---
  drivers/scsi/megaraid/megaraid_sas_base.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

 diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
 b/drivers/scsi/megaraid/megaraid_sas_base.c
 index 71b884d..8face78 100644
 --- a/drivers/scsi/megaraid/megaraid_sas_base.c
 +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
 @@ -6131,12 +6131,13 @@ megasas_mgmt_fw_ioctl(struct megasas_instance 
 *instance,
   }
  
   for (i = 0; i  ioc-sge_count; i++) {
 - if (kbuff_arr[i])
 + if (kbuff_arr[i]) {
   dma_free_coherent(instance-pdev-dev,
 le32_to_cpu(kern_sge32[i].length),
 kbuff_arr[i],
 le32_to_cpu(kern_sge32[i].phys_addr));
   kbuff_arr[i] = NULL;
 + }
   }
  
   megasas_return_cmd(instance, cmd);

For the curly braces part:
Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

While you're up to it, care to check drivers/scsi/bfa as well? There was
a patch somewhen in the past but it seems it wasn't applied. But if
found this bugzilla entry
https://bugzilla.kernel.org/show_bug.cgi?id=98261
for it.

Thanks,
Johannes

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [TRIVIAL PATCH] block: Correct misuses of 0x%decimal

2015-08-03 Thread Johannes Thumshirn
Joe Perches j...@perches.com writes:

 Correct misuse of 0x%d in logging messages.

 Signed-off-by: Joe Perches j...@perches.com
 ---
  drivers/block/DAC960.c | 4 ++--
  drivers/block/cciss.c  | 2 +-
  2 files changed, 3 insertions(+), 3 deletions(-)

 diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
 index 811e11c..d9b32f2 100644
 --- a/drivers/block/DAC960.c
 +++ b/drivers/block/DAC960.c
 @@ -2954,7 +2954,7 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
 case DAC960_PD_Controller:
   if (!request_region(Controller-IO_Address, 0x80,
   Controller-FullModelName)) {
 -   DAC960_Error(IO port 0x%d busy for Controller at\n,
 +   DAC960_Error(IO port 0x%x busy for Controller at\n,
  Controller, Controller-IO_Address);
 goto Failure;
   }
 @@ -2990,7 +2990,7 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
 case DAC960_P_Controller:
   if (!request_region(Controller-IO_Address, 0x80,
   Controller-FullModelName)){
 -   DAC960_Error(IO port 0x%d busy for Controller at\n,
 +   DAC960_Error(IO port 0x%x busy for Controller at\n,
  Controller, Controller-IO_Address);
 goto Failure;
   }
 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
 index 0422c47..2758982 100644
 --- a/drivers/block/cciss.c
 +++ b/drivers/block/cciss.c
 @@ -3854,7 +3854,7 @@ static void print_cfg_table(ctlr_info_t *h)
readl((tb-HostWrite.CoalIntDelay)));
 dev_dbg(h-pdev-dev,Coalesce Interrupt Count = 0x%x\n,
readl((tb-HostWrite.CoalIntCount)));
 -   dev_dbg(h-pdev-dev,Max outstanding commands = 0x%d\n,
 +   dev_dbg(h-pdev-dev,Max outstanding commands = 0x%x\n,
readl((tb-CmdsOutMax)));
 dev_dbg(h-pdev-dev,Bus Types = 0x%x\n,
 readl((tb-BusTypes)));
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] mpt2sas: setpci reset kernel oops fix

2015-08-06 Thread Johannes Thumshirn
-lsL0P1VTbdAQ9zpAXLjCCl4LS3bUhIe=



 --
 Nagarajkumar Narayanan

Thanks,
Johannes

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi/be2iscsi: Fix logical-not-parentheses compilation warning

2015-08-07 Thread Johannes Thumshirn
Tomer Barletz barl...@gmail.com writes:

 This fixes the following warning seen with GCC v5.1:
 warning: logical not is only applied to the left hand side of
 comparison [-Wlogical-not-parentheses].

 Signed-off-by: Tomer Barletz barl...@gmail.com
 ---
  drivers/scsi/be2iscsi/be_main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
 index 7a6dbfb..cf1908e 100644
 --- a/drivers/scsi/be2iscsi/be_main.c
 +++ b/drivers/scsi/be2iscsi/be_main.c
 @@ -3184,7 +3184,7 @@ be_sgl_create_contiguous(void *virtual_address,
  {
   WARN_ON(!virtual_address);
   WARN_ON(!physical_address);
 - WARN_ON(!length  0);
 + WARN_ON(length == 0);
   WARN_ON(!sgl);
  
   sgl-va = virtual_address;

Looks good.

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RESEND V2 3/7] scsi: storvsc: Untangle the storage protocol negotiation from the vmbus protocol negotiation.

2015-08-14 Thread Johannes Thumshirn
KY Srinivasan k...@microsoft.com writes:

 -Original Message-
 From: Johannes Thumshirn [mailto:jthumsh...@suse.de]
 Sent: Thursday, August 13, 2015 7:34 AM
 To: KY Srinivasan k...@microsoft.com; Keith Mange
 keith.ma...@microsoft.com
 Cc: gre...@linuxfoundation.org; linux-ker...@vger.kernel.org;
 de...@linuxdriverproject.org; oher...@suse.com;
 jbottom...@parallels.com; h...@infradead.org; linux-scsi@vger.kernel.org;
 a...@canonical.com; vkuzn...@redhat.com; jasow...@redhat.com
 Subject: Re: [PATCH RESEND V2 3/7] scsi: storvsc: Untangle the storage
 protocol negotiation from the vmbus protocol negotiation.
 
 K. Y. Srinivasan k...@microsoft.com writes:
 
  From: Keith Mange keith.ma...@microsoft.com
 
  Currently we are making decisions based on vmbus protocol versions
  that have been negotiated; use storage potocol versions instead.
 
  Tested-by: Alex Ng ale...@microsoft.com
  Signed-off-by: Keith Mange keith.ma...@microsoft.com
  Signed-off-by: K. Y. Srinivasan k...@microsoft.com
  ---
   drivers/scsi/storvsc_drv.c |  109
 +++-
   1 files changed, 87 insertions(+), 22 deletions(-)
 
  diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
  index 5f9d133..f29871e 100644
  --- a/drivers/scsi/storvsc_drv.c
  +++ b/drivers/scsi/storvsc_drv.c
  @@ -56,14 +56,18 @@
* V1 RC  2008/1/31:  2.0
* Win7: 4.2
* Win8: 5.1
  + * Win8.1: 6.0
  + * Win10: 6.2
*/
 
   #define VMSTOR_PROTO_VERSION(MAJOR_, MINOR_)  MAJOR_)
  0xff)  8) | \
 (((MINOR_)  0xff)))
 
  +#define VMSTOR_PROTO_VERSION_WIN6
  VMSTOR_PROTO_VERSION(2, 0)
   #define VMSTOR_PROTO_VERSION_WIN7
  VMSTOR_PROTO_VERSION(4, 2)
   #define VMSTOR_PROTO_VERSION_WIN8
  VMSTOR_PROTO_VERSION(5, 1)
  -
  +#define VMSTOR_PROTO_VERSION_WIN8_1
  VMSTOR_PROTO_VERSION(6, 0)
  +#define VMSTOR_PROTO_VERSION_WIN10
  VMSTOR_PROTO_VERSION(6, 2)
 
   /*  Packet structure describing virtual storage requests. */
   enum vstor_packet_operation {
  @@ -205,6 +209,46 @@ struct vmscsi_request {
 
 
   /*
  + * The list of storage protocols in order of preference.
  + */
  +struct vmstor_protocol {
  +  int protocol_version;
  +  int sense_buffer_size;
  +  int vmscsi_size_delta;
  +};
  +
  +#define VMSTOR_NUM_PROTOCOLS5
 
 can't you just use ARRAY_SIZE() here, so you don't have to touch the
 constant every time a new protocol is appended to the list?

 Certainly. These patches have been floating around for more than a month now 
 and if it is ok
 with you, I will submit a patch on top of this current series to address the 
 concern you have raised.
 James, please let me know.


No objections from my side, but it's up to James to decide what and when
he picks up patches.

Thanks,
Johannes

-- 
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
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] scsi: Export SCSI Inquiry data to sysfs

2015-08-14 Thread Johannes Thumshirn
Export the RAW SCSI Inquiry to sysfs as binfile. This way the data can be used
by userland without the need to have and ioctl or use the sg_inq tool.

Here is an example of the provided data

linux:~ # hexdump /sys/class/scsi_device/1\:0\:0\:0/device/inquiry
000 8005 3205 001f  4551 554d 2020 2020
010 4551 554d 4420 4456 522d 4d4f 2020 2020
020 2e32 2e33
024

Signed-off-by: Johannes Thumshirn jthumsh...@suse.de
Reviewed-by: Hannes Reinecke h...@suse.de
---

Chanes to v1:
* Correct typo userlang - userland in commit message.

 drivers/scsi/scsi_sysfs.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 9ad4116..5ecb65d 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -773,6 +773,29 @@ static struct bin_attribute dev_attr_vpd_##_page = {   
\
 sdev_vpd_pg_attr(pg83);
 sdev_vpd_pg_attr(pg80);
 
+static ssize_t show_inquiry(struct file *filep, struct kobject *kobj,
+   struct bin_attribute *bin_attr,
+   char *buf, loff_t off, size_t count)
+{
+   struct device *dev = container_of(kobj, struct device, kobj);
+   struct scsi_device *sdev = to_scsi_device(dev);
+
+   if (!sdev-inquiry)
+   return -EINVAL;
+
+   return memory_read_from_buffer(buf, count, off, sdev-inquiry,
+  sdev-inquiry_len);
+}
+
+static struct bin_attribute dev_attr_inquiry = {
+   .attr = {
+   .name = inquiry,
+   .mode = S_IRUGO,
+   },
+   .size = 0,
+   .read = show_inquiry,
+};
+
 static ssize_t
 show_iostat_counterbits(struct device *dev, struct device_attribute *attr,
char *buf)
@@ -957,6 +980,7 @@ static struct attribute *scsi_sdev_attrs[] = {
 static struct bin_attribute *scsi_sdev_bin_attrs[] = {
dev_attr_vpd_pg83,
dev_attr_vpd_pg80,
+   dev_attr_inquiry,
NULL
 };
 static struct attribute_group scsi_sdev_attr_group = {
-- 
2.5.0

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V2] fnic: check pci_map_single() return value

2015-08-12 Thread Johannes Thumshirn
Hi Maurizio,

Sorry but it looks like you've forgotten one change in fnic_eth_send().

Maurizio Lombardi mlomb...@redhat.com writes:

 the kernel prints some warnings when compiled with CONFIG_DMA_API_DEBUG.
 This is because the fnic driver doesn't check the return value of
 pci_map_single().

 [   11.942770] scsi host12: fnic
  }

[..]
  
  void fnic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf)
 @@ -981,6 +993,7 @@ void fnic_eth_send(struct fcoe_ctlr *fip, struct sk_buff 
 *skb)
   struct ethhdr *eth_hdr;
   struct vlan_ethhdr *vlan_hdr;
   unsigned long flags;
 + int r;
  
   if (!fnic-vlan_hw_insert) {
   eth_hdr = (struct ethhdr *)skb_mac_header(skb);
 @@ -1003,6 +1016,13 @@ void fnic_eth_send(struct fcoe_ctlr *fip, struct 
 sk_buff *skb)
  
   pa = pci_map_single(fnic-pdev, skb-data, skb-len, PCI_DMA_TODEVICE);
  
 + r = pci_dma_mapping_error(fnic-pdev, pa);
 + if (r) {
 + printk(KERN_ERR PCI mapping failed with error %d\n, r);
 + kfree_skb(skb);
 + return;
 + }
 +
   spin_lock_irqsave(fnic-wq_lock[0], flags);
   if (!vnic_wq_desc_avail(wq)) {
   pci_unmap_single(fnic-pdev, pa, skb-len, PCI_DMA_TODEVICE);
 @@ -1071,6 +1091,12 @@ static int fnic_send_frame(struct fnic *fnic, struct 
 fc_frame *fp)
  
   pa = pci_map_single(fnic-pdev, eth_hdr, tot_len, PCI_DMA_TODEVICE);
[..]

Otherwise:

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] csiostor: Use list_for_each_safe instead of re-implementing it

2015-07-16 Thread Johannes Thumshirn
Christophe JAILLET christophe.jail...@wanadoo.fr writes:

 Use 'list_for_each_safe' instead of 'list_for_each' + own logic to keep
 safe when a list entry is deleted.
 Delete the now useless 'csio_list_prev' macro.

 Signed-off-by: Christophe JAILLET christophe.jail...@wanadoo.fr
 ---
  drivers/scsi/csiostor/csio_defs.h |  1 -
  drivers/scsi/csiostor/csio_hw.c   | 10 --
  drivers/scsi/csiostor/csio_scsi.c | 10 --
  3 files changed, 8 insertions(+), 13 deletions(-)

 diff --git a/drivers/scsi/csiostor/csio_defs.h 
 b/drivers/scsi/csiostor/csio_defs.h
 index c38017b..4b3557c 100644
 --- a/drivers/scsi/csiostor/csio_defs.h
 +++ b/drivers/scsi/csiostor/csio_defs.h
 @@ -70,7 +70,6 @@ csio_list_deleted(struct list_head *list)
  }
  
  #define csio_list_next(elem) (((struct list_head *)(elem))-next)
 -#define csio_list_prev(elem) (((struct list_head *)(elem))-prev)
  
  /* State machine */
  typedef void (*csio_sm_state_t)(void *, uint32_t);
 diff --git a/drivers/scsi/csiostor/csio_hw.c b/drivers/scsi/csiostor/csio_hw.c
 index 622bdab..61ee6cb 100644
 --- a/drivers/scsi/csiostor/csio_hw.c
 +++ b/drivers/scsi/csiostor/csio_hw.c
 @@ -3643,20 +3643,19 @@ static void
  csio_mgmt_tmo_handler(uintptr_t data)
  {
   struct csio_mgmtm *mgmtm = (struct csio_mgmtm *) data;
 - struct list_head *tmp;
 + struct list_head *tmp, *next;
   struct csio_ioreq *io_req;
  
   csio_dbg(mgmtm-hw, Mgmt timer invoked!\n);
  
   spin_lock_irq(mgmtm-hw-lock);
  
 - list_for_each(tmp, mgmtm-active_q) {
 + list_for_each_safe(tmp, next, mgmtm-active_q) {
   io_req = (struct csio_ioreq *) tmp;
   io_req-tmo -= min_t(uint32_t, io_req-tmo, ECM_MIN_TMO);
  
   if (!io_req-tmo) {
   /* Dequeue the request from retry Q. */
 - tmp = csio_list_prev(tmp);
   list_del_init(io_req-sm.sm_list);
   if (io_req-io_cbfn) {
   /* io_req will be freed by completion handler */
 @@ -3680,7 +3679,7 @@ csio_mgmtm_cleanup(struct csio_mgmtm *mgmtm)
  {
   struct csio_hw *hw = mgmtm-hw;
   struct csio_ioreq *io_req;
 - struct list_head *tmp;
 + struct list_head *tmp, *next;
   uint32_t count;
  
   count = 30;
 @@ -3692,9 +3691,8 @@ csio_mgmtm_cleanup(struct csio_mgmtm *mgmtm)
   }
  
   /* release outstanding req from ACTIVEQ */
 - list_for_each(tmp, mgmtm-active_q) {
 + list_for_each_safe(tmp, next, mgmtm-active_q) {
   io_req = (struct csio_ioreq *) tmp;
 - tmp = csio_list_prev(tmp);
   list_del_init(io_req-sm.sm_list);
   mgmtm-stats.n_active--;
   if (io_req-io_cbfn) {
 diff --git a/drivers/scsi/csiostor/csio_scsi.c 
 b/drivers/scsi/csiostor/csio_scsi.c
 index 2c4562d..2bfb401 100644
 --- a/drivers/scsi/csiostor/csio_scsi.c
 +++ b/drivers/scsi/csiostor/csio_scsi.c
 @@ -2322,7 +2322,7 @@ csio_scsi_alloc_ddp_bufs(struct csio_scsim *scm, struct 
 csio_hw *hw,
int buf_size, int num_buf)
  {
   int n = 0;
 - struct list_head *tmp;
 + struct list_head *tmp, *next;
   struct csio_dma_buf *ddp_desc = NULL;
   uint32_t unit_size = 0;
  
 @@ -2370,9 +2370,8 @@ csio_scsi_alloc_ddp_bufs(struct csio_scsim *scm, struct 
 csio_hw *hw,
   return 0;
  no_mem:
   /* release dma descs back to freelist and free dma memory */
 - list_for_each(tmp, scm-ddp_freelist) {
 + list_for_each_safe(tmp, next, scm-ddp_freelist) {
   ddp_desc = (struct csio_dma_buf *) tmp;
 - tmp = csio_list_prev(tmp);
   pci_free_consistent(hw-pdev, ddp_desc-len, ddp_desc-vaddr,
   ddp_desc-paddr);
   list_del_init(ddp_desc-list);
 @@ -2393,13 +2392,12 @@ no_mem:
  static void
  csio_scsi_free_ddp_bufs(struct csio_scsim *scm, struct csio_hw *hw)
  {
 - struct list_head *tmp;
 + struct list_head *tmp, *next;
   struct csio_dma_buf *ddp_desc;
  
   /* release dma descs back to freelist and free dma memory */
 - list_for_each(tmp, scm-ddp_freelist) {
 + list_for_each_safe(tmp, next, scm-ddp_freelist) {
   ddp_desc = (struct csio_dma_buf *) tmp;
 - tmp = csio_list_prev(tmp);
   pci_free_consistent(hw-pdev, ddp_desc-len, ddp_desc-vaddr,
   ddp_desc-paddr);
   list_del_init(ddp_desc-list);

Reviewed-by: Johannes Thumshirn jthumsh...@suse.de

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
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)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo

Re: [PATCH] SCSI: mvsas: Fix NULL pointer dereference in mvs_slot_task_free

2015-10-21 Thread Johannes Thumshirn
On Wed, 2015-10-21 at 17:26 +0300, Dāvis Mosāns wrote:
> 2015-10-21 16:47 GMT+03:00 Johannes Thumshirn <jthumsh...@suse.de>:
> > On Wed, 2015-10-21 at 16:18 +0300, Dāvis Mosāns wrote:
> > > 2015-10-21 10:33 GMT+03:00 Johannes Thumshirn <jthumsh...@suse.de
> > > >:
> > > > On Tue, 2015-10-20 at 20:41 +0300, Dāvis Mosāns wrote:
> > > > > 2015-08-21 7:29 GMT+03:00 Dāvis Mosāns <davis...@gmail.com>:
> > > > > > When pci_pool_alloc fails in mvs_task_prep then task-
> > > > > > >lldd_task
> > > > > > stays
> > > > > > NULL but it's later used in mvs_abort_task as slot which is
> > > > > > passed
> > > > > > to mvs_slot_task_free causing NULL pointer dereference.
> > > > > > 
> > > > > > Just return from mvs_slot_task_free when passed with NULL
> > > > > > slot.
> > > > > > 
> > > > > > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=10189
> > > > > > 1
> > > > > > Signed-off-by: Dāvis Mosāns <davis...@gmail.com>
> > > > > > ---
> > > > > >  drivers/scsi/mvsas/mv_sas.c | 2 ++
> > > > > >  1 file changed, 2 insertions(+)
> > > > > > 
> > > > > > diff --git a/drivers/scsi/mvsas/mv_sas.c
> > > > > > b/drivers/scsi/mvsas/mv_sas.c
> > > > > > index 454536c..9c78074 100644
> > > > > > --- a/drivers/scsi/mvsas/mv_sas.c
> > > > > > +++ b/drivers/scsi/mvsas/mv_sas.c
> > > > > > @@ -887,6 +887,8 @@ static void mvs_slot_free(struct
> > > > > > mvs_info
> > > > > > *mvi,
> > > > > > u32 rx_desc)
> > > > > >  static void mvs_slot_task_free(struct mvs_info *mvi,
> > > > > > struct
> > > > > > sas_task *task,
> > > > > >   struct mvs_slot_info *slot, u32
> > > > > > slot_idx)
> > > > > >  {
> > > > > > +   if (!slot)
> > > > > > +   return;
> > > > > > if (!slot->task)
> > > > > > return;
> > > > > > if (!sas_protocol_ata(task->task_proto))
> > > > > > --
> > > > > > 2.5.0
> > > > > > 
> > > > > 
> > > > > Can this get merged?
> > > > > So far since august it have saved me from several kernel
> > > > > crashes.
> > > > 
> > > > If it saved you from several crashes, it probably should be
> > > > tagged
> > > > for
> > > > stable, shouldn't it?
> > > > 
> > > > Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>
> > > > 
> > > > 
> > > 
> > > I don't really know how that works... this is my first patch so
> > > I'm
> > > not really concerned about in which version it gets in as long as
> > > it
> > > does.
> > > I've been compiling kernel with this patch for these months so
> > > for me
> > > it
> > > doesn't really make any difference.
> > 
> > You can add
> > Cc: sta...@vger.kernel.org
> > somewhere around your Signed-off-by
> > 
> > Documentation/stable_kernel_rules.txt has all the process
> > documentation.
> 
> Should I add it together with review tags too and resend patch or
> reply to this
> thread with it edited or just leave it like it is now and whoever
> will see it
> will add it himself?

good question, but I think James can help here.

> 
> 
> also for stable requirements this line is a bit confusing
> "It or an equivalent fix must already exist in Linus' tree
> (upstream)."
> 
> but then later seems it's not requirement for Option 1

yes, if you tag it with the Cc, it will get to stable review _after_ it
is applied to Linus' tree
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: wd719x: Use module_pci_driver

2015-10-22 Thread Johannes Thumshirn
On Thu, 2015-10-22 at 04:16 +0530, Muhammad Falak R Wani wrote:
> Remove boilerplate code by using macro module_pci_driver.
> For drivers whose __init and __exit paths only register and
> unregister to the pci API, it is preferred to use this macro.
> 
> Signed-off-by: Muhammad Falak R Wani <falakre...@gmail.com>
> ---
>  drivers/scsi/wd719x.c | 13 +
>  1 file changed, 1 insertion(+), 12 deletions(-)
> 
> diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c
> index 2a9da2e..6d3bce3 100644
> --- a/drivers/scsi/wd719x.c
> +++ b/drivers/scsi/wd719x.c
> @@ -976,18 +976,7 @@ static struct pci_driver wd719x_pci_driver = {
>   .remove =   wd719x_pci_remove,
>  };
>  
> -static int __init wd719x_init(void)
> -{
> - return pci_register_driver(_pci_driver);
> -}
> -
> -static void __exit wd719x_exit(void)
> -{
> - pci_unregister_driver(_pci_driver);
> -}
> -
> -module_init(wd719x_init);
> -module_exit(wd719x_exit);
> +module_pci_driver(wd719x_pci_driver);
>  
>  MODULE_DESCRIPTION("Western Digital WD7193/7197/7296 SCSI driver");
>  MODULE_AUTHOR("Ondrej Zary, Aaron Dewell, Juergen Gaertner");

Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: wd719x: Remove use of macro DEFINE_PCI_DEVICE_TABLE

2015-10-22 Thread Johannes Thumshirn
On Thu, 2015-10-22 at 03:53 +0530, Muhammad Falak R Wani wrote:
> Use struct pci_device_id instead of DEFINE_PCI_DEVICE_TABLE with
> the goal of getting rid of this macro completely, as this macro
> is deprecated.
> 
> Signed-off-by: Muhammad Falak R Wani <falakre...@gmail.com>
> ---
>  drivers/scsi/wd719x.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c
> index e3da1a2..2a9da2e 100644
> --- a/drivers/scsi/wd719x.c
> +++ b/drivers/scsi/wd719x.c
> @@ -962,7 +962,7 @@ static void wd719x_pci_remove(struct pci_dev
> *pdev)
>   scsi_host_put(sh);
>  }
>  
> -static DEFINE_PCI_DEVICE_TABLE(wd719x_pci_table) = {
> +static const struct pci_device_id wd719x_pci_table[] = {
>   { PCI_DEVICE(PCI_VENDOR_ID_WD, 0x3296) },
>   {}
>  };

Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: restart list search after unlock in scsi_remove_target

2015-10-26 Thread Johannes Thumshirn
On Mon, 2015-10-19 at 16:35 +0200, Christoph Hellwig wrote:
> When dropping a lock while iterating a list we must restart the
> search
> as other threads could have manipulated the list under us.  Without
> this
> we can get stuck in an endless loop.
> 
> Reported-by: Johannes Thumshirn <jthumsh...@suse.de>
> Signed-off-by: Christoph Hellwig <h...@lst.de>
> 
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index b89f..d3b34d8 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -1158,31 +1158,23 @@ static void __scsi_remove_target(struct
> scsi_target *starget)
>  void scsi_remove_target(struct device *dev)
>  {
>   struct Scsi_Host *shost = dev_to_shost(dev->parent);
> - struct scsi_target *starget, *last = NULL;
> + struct scsi_target *starget;
>   unsigned long flags;
>  
> - /* remove targets being careful to lookup next entry before
> -  * deleting the last
> -  */
> +restart:
>   spin_lock_irqsave(shost->host_lock, flags);
>   list_for_each_entry(starget, >__targets, siblings) {
>   if (starget->state == STARGET_DEL)
>   continue;
>   if (starget->dev.parent == dev || >dev ==
> dev) {
> - /* assuming new targets arrive at the end */
>   kref_get(>reap_ref);
>   spin_unlock_irqrestore(shost->host_lock,
> flags);
> - if (last)
> - scsi_target_reap(last);
> - last = starget;
>   __scsi_remove_target(starget);
> - spin_lock_irqsave(shost->host_lock, flags);
> + scsi_target_reap(starget);
> + goto restart;
>   }
>   }
>   spin_unlock_irqrestore(shost->host_lock, flags);
> -
> - if (last)
> - scsi_target_reap(last);
>  }
>  EXPORT_SYMBOL(scsi_remove_target);

Hi Christoph,

I haven't heard anything from the original reporter of the lockup but
my test's went all O.K., so 

Tested-by: Johannes Thumshirn <jthumsh...@suse.de>
Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>

>  
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" 
> in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] megaraid_sas: Convert dev_printk to dev_

2015-10-27 Thread Johannes Thumshirn
   dev_printk(KERN_DEBUG, >dev, "Failed
> to allocate "
> + dev_dbg(>dev, "Failed to allocate "
>      "memory for Fusion context info\n");
>   goto fail_alloc_dma_buf;
>   }
> @@ -5243,7 +5243,7 @@ static int megasas_probe_one(struct pci_dev
> *pdev,
>    >consumer_h);
>  
>   if (!instance->producer || !instance->consumer) {
> - dev_printk(KERN_DEBUG, >dev, "Failed
> to allocate"
> + dev_dbg(>dev, "Failed to allocate"
>      "memory for producer, consumer\n");
>   goto fail_alloc_dma_buf;
>   }
> @@ -5290,7 +5290,7 @@ static int megasas_probe_one(struct pci_dev
> *pdev,
>   
> >evt_detail_h);
>  
>   if (!instance->evt_detail) {
> - dev_printk(KERN_DEBUG, >dev, "Failed to
> allocate memory for "
> + dev_dbg(>dev, "Failed to allocate memory for "
>      "event detail structure\n");
>   goto fail_alloc_dma_buf;
>   }
> @@ -5397,7 +5397,7 @@ static int megasas_probe_one(struct pci_dev
> *pdev,
>    * Initiate AEN (Asynchronous Event Notification)
>    */
>   if (megasas_start_aen(instance)) {
> - dev_printk(KERN_DEBUG, >dev, "start aen
> failed\n");
> + dev_dbg(>dev, "start aen failed\n");
>   goto fail_start_aen;
>   }
>  
> @@ -5973,14 +5973,14 @@ megasas_mgmt_fw_ioctl(struct megasas_instance
> *instance,
>   memset(kbuff_arr, 0, sizeof(kbuff_arr));
>  
>   if (ioc->sge_count > MAX_IOCTL_SGE) {
> - dev_printk(KERN_DEBUG, >pdev->dev, "SGE
> count [%d] >  max limit [%d]\n",
> + dev_dbg(>pdev->dev, "SGE count [%d] >  max
> limit [%d]\n",
>      ioc->sge_count, MAX_IOCTL_SGE);
>   return -EINVAL;
>   }
>  
>   cmd = megasas_get_cmd(instance);
>   if (!cmd) {
> - dev_printk(KERN_DEBUG, >pdev->dev, "Failed
> to get a cmd packet\n");
> + dev_dbg(>pdev->dev, "Failed to get a cmd
> packet\n");
>   return -ENOMEM;
>   }
>  
> @@ -6025,7 +6025,7 @@ megasas_mgmt_fw_ioctl(struct megasas_instance
> *instance,
>   ioc-
> >sgl[i].iov_len,
>   _handle,
> GFP_KERNEL);
>   if (!kbuff_arr[i]) {
> - dev_printk(KERN_DEBUG, >pdev->dev, 
> "Failed to alloc "
> + dev_dbg(>pdev->dev, "Failed to
> alloc "
>      "kernel SGL buffer for IOCTL\n");
>   error = -ENOMEM;
>   goto out;
> @@ -6111,7 +6111,7 @@ megasas_mgmt_fw_ioctl(struct megasas_instance
> *instance,
>    */
>   if (copy_to_user(_ioc->frame.hdr.cmd_status,
>    >frame->hdr.cmd_status, sizeof(u8))) {
> - dev_printk(KERN_DEBUG, >pdev->dev, "Error
> copying out cmd_status\n");
> + dev_dbg(>pdev->dev, "Error copying out
> cmd_status\n");
>   error = -EFAULT;
>   }
>  

Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] megaraid_sas: Convert printk to printk_

2015-10-27 Thread Johannes Thumshirn
On Tue, 2015-10-27 at 16:26 +0800, Weidong Wang wrote:
> Reduce object size a little by using pr_
> calls instead of printk(KERN_.
> 
> Signed-off-by: Weidong Wang <wangweido...@huawei.com>
> ---
>  drivers/scsi/megaraid/megaraid_sas_base.c | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c
> b/drivers/scsi/megaraid/megaraid_sas_base.c
> index ed9846d..2287aa1 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_base.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
> @@ -5889,7 +5889,7 @@ static int megasas_mgmt_fasync(int fd, struct
> file *filep, int mode)
>   return 0;
>   }
>  
> - printk(KERN_DEBUG "megasas: fasync_helper failed [%d]\n",
> rc);
> + pr_debug("megasas: fasync_helper failed [%d]\n", rc);
>  
>   return rc;
>  }
> @@ -6233,7 +6233,7 @@ static int megasas_mgmt_ioctl_aen(struct file
> *file, unsigned long arg)
>   u32 wait_time = MEGASAS_RESET_WAIT_TIME;
>  
>   if (file->private_data != file) {
> - printk(KERN_DEBUG "megasas: fasync_helper was not "
> + pr_debug("megasas: fasync_helper was not "
>      "called first\n");
>   return -EINVAL;
>   }
> @@ -6355,7 +6355,7 @@ static int megasas_mgmt_compat_ioctl_fw(struct
> file *file, unsigned long arg)
>  
>   if (copy_in_user(>frame.hdr.cmd_status,
>    >frame.hdr.cmd_status, sizeof(u8))) {
> - printk(KERN_DEBUG "megasas: error copy_in_user
> cmd_status\n");
> + pr_debug("megasas: error copy_in_user
> cmd_status\n");
>   return -EFAULT;
>   }
>   return error;
> @@ -6455,7 +6455,7 @@ megasas_sysfs_set_dbg_lvl(struct device_driver
> *dd, const char *buf, size_t coun
>   int retval = count;
>  
>   if (sscanf(buf, "%u", _dbg_lvl) < 1) {
> - printk(KERN_ERR "megasas: could not set dbg_lvl\n");
> + pr_err("megasas: could not set dbg_lvl\n");
>   retval = -EINVAL;
>   }
>   return retval;
> @@ -6480,7 +6480,7 @@ megasas_aen_polling(struct work_struct *work)
>   int error;
>  
>   if (!instance) {
> - printk(KERN_ERR "invalid instance!\n");
> + pr_err("invalid instance!\n");
>   kfree(ev);
>   return;
>   }
> @@ -6740,7 +6740,7 @@ static int __init megasas_init(void)
>   rval = register_chrdev(0, "megaraid_sas_ioctl",
> _mgmt_fops);
>  
>   if (rval < 0) {
> - printk(KERN_DEBUG "megasas: failed to open device
> node\n");
> + pr_debug("megasas: failed to open device node\n");
>       return rval;
>   }
>  
> @@ -6752,7 +6752,7 @@ static int __init megasas_init(void)
>   rval = pci_register_driver(_pci_driver);
>  
>   if (rval) {
> - printk(KERN_DEBUG "megasas: PCI hotplug registration
> failed \n");
> + pr_debug("megasas: PCI hotplug registration failed
> \n");
>   goto err_pcidrv;
>   }
>  


Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] megaraid_sas: return -ENOMEM when create DMA pool for cmd frames failed

2015-10-27 Thread Johannes Thumshirn
On Tue, 2015-10-27 at 16:26 +0800, Weidong Wang wrote:
> when create DMA pool for cmd frames failed, we should return -ENOMEM,
> instead of 0.
> In some case in:
> 
> megasas_init_adapter_fusion()
> 
> -->megasas_alloc_cmds()
>    -->megasas_create_frame_pool
>   create DMA pool failed,
> --> megasas_free_cmds() [1]
> 
> -->megasas_alloc_cmds_fusion()
>    failed, then goto fail_alloc_cmds.
> -->megasas_free_cmds() [2]
> 
> we will call megasas_free_cmds twice, [1] will kfree cmd_list,
> [2] will use cmd_list.it will cause a problem:
> 
> Unable to handle kernel NULL pointer dereference at virtual address
> 
> pgd = ffc000f7
> [] *pgd=001fbf893003, *pud=001fbf893003,
> *pmd=001fbf894003, *pte=00606d000707
> Internal error: Oops: 9605 [#1] SMP
>  Modules linked in:
>  CPU: 18 PID: 1 Comm: swapper/0 Not tainted
>  task: ffdfb929 ti: ffdfb923c000 task.ti:
> ffdfb923c000
>  PC is at megasas_free_cmds+0x30/0x70
>  LR is at megasas_free_cmds+0x24/0x70
> 
>  ...
> 
>  Call trace:
>  [] megasas_free_cmds+0x30/0x70
>  [] megasas_init_adapter_fusion+0x2f4/0x4d8
>  [] megasas_init_fw+0x2dc/0x760
>  [] megasas_probe_one+0x3c0/0xcd8
>  [] local_pci_probe+0x4c/0xb4
>  [] pci_device_probe+0x11c/0x14c
>  [] driver_probe_device+0x1ec/0x430
>  [] __driver_attach+0xa8/0xb0
>  [] bus_for_each_dev+0x74/0xc8
>   [] driver_attach+0x28/0x34
>  [] bus_add_driver+0x16c/0x248
>  [] driver_register+0x6c/0x138
>  [] __pci_register_driver+0x5c/0x6c
>  [] megasas_init+0xc0/0x1a8
>  [] do_one_initcall+0xe8/0x1ec
>  [] kernel_init_freeable+0x1c8/0x284
>  [] kernel_init+0x1c/0xe4
> 
> Signed-off-by: Weidong Wang <wangweido...@huawei.com>
> ---
>  drivers/scsi/megaraid/megaraid_sas_base.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c
> b/drivers/scsi/megaraid/megaraid_sas_base.c
> index 2287aa1..8215218 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_base.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
> @@ -3746,8 +3746,9 @@ int megasas_alloc_cmds(struct megasas_instance
> *instance)
>    * Create a frame pool and assign one frame to each cmd
>    */
>   if (megasas_create_frame_pool(instance)) {
> - dev_dbg(>pdev->dev, "Error creating frame
> DMA pool\n");
> + dev_err(>pdev->dev, "Error creating frame
> DMA pool\n");
>   megasas_free_cmds(instance);
> + return -ENOMEM;
>   }
>  
>   return 0;

I think this is needed for stable as well.

Other than that,
Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>

Thanks,
Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: restart list search after unlock in scsi_remove_target

2015-10-27 Thread Johannes Thumshirn
On Mon, 2015-10-19 at 16:35 +0200, Christoph Hellwig wrote:
> When dropping a lock while iterating a list we must restart the
> search
> as other threads could have manipulated the list under us.  Without
> this
> we can get stuck in an endless loop.
> 
> Reported-by: Johannes Thumshirn <jthumsh...@suse.de>
> Signed-off-by: Christoph Hellwig <h...@lst.de>

I have an official acknowledge from the original author that a 48h long
term test on their side didn't reproduce the lockup as well.

James can we please get the patch included in 4.4 and stable?

Thanks
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] SCSI: mvsas: Fix NULL pointer dereference in mvs_slot_task_free

2015-10-21 Thread Johannes Thumshirn
On Wed, 2015-10-21 at 16:18 +0300, Dāvis Mosāns wrote:
> 2015-10-21 10:33 GMT+03:00 Johannes Thumshirn <jthumsh...@suse.de>:
> > On Tue, 2015-10-20 at 20:41 +0300, Dāvis Mosāns wrote:
> > > 2015-08-21 7:29 GMT+03:00 Dāvis Mosāns <davis...@gmail.com>:
> > > > When pci_pool_alloc fails in mvs_task_prep then task->lldd_task
> > > > stays
> > > > NULL but it's later used in mvs_abort_task as slot which is
> > > > passed
> > > > to mvs_slot_task_free causing NULL pointer dereference.
> > > > 
> > > > Just return from mvs_slot_task_free when passed with NULL slot.
> > > > 
> > > > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=101891
> > > > Signed-off-by: Dāvis Mosāns <davis...@gmail.com>
> > > > ---
> > > >  drivers/scsi/mvsas/mv_sas.c | 2 ++
> > > >  1 file changed, 2 insertions(+)
> > > > 
> > > > diff --git a/drivers/scsi/mvsas/mv_sas.c
> > > > b/drivers/scsi/mvsas/mv_sas.c
> > > > index 454536c..9c78074 100644
> > > > --- a/drivers/scsi/mvsas/mv_sas.c
> > > > +++ b/drivers/scsi/mvsas/mv_sas.c
> > > > @@ -887,6 +887,8 @@ static void mvs_slot_free(struct mvs_info
> > > > *mvi,
> > > > u32 rx_desc)
> > > >  static void mvs_slot_task_free(struct mvs_info *mvi, struct
> > > > sas_task *task,
> > > >   struct mvs_slot_info *slot, u32
> > > > slot_idx)
> > > >  {
> > > > +   if (!slot)
> > > > +   return;
> > > >     if (!slot->task)
> > > > return;
> > > > if (!sas_protocol_ata(task->task_proto))
> > > > --
> > > > 2.5.0
> > > > 
> > > 
> > > Can this get merged?
> > > So far since august it have saved me from several kernel crashes.
> > 
> > If it saved you from several crashes, it probably should be tagged
> > for
> > stable, shouldn't it?
> > 
> > Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>
> > 
> > 
> 
> I don't really know how that works... this is my first patch so I'm
> not really concerned about in which version it gets in as long as it
> does.
> I've been compiling kernel with this patch for these months so for me
> it
> doesn't really make any difference.

You can add
Cc: sta...@vger.kernel.org
somewhere around your Signed-off-by 

Documentation/stable_kernel_rules.txt has all the process
documentation.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch] hpsa: logical vs bitwise AND typo

2015-11-12 Thread Johannes Thumshirn
On Thu, 2015-11-12 at 12:43 +0300, Dan Carpenter wrote:
> HPSA_DIAG_OPTS_DISABLE_RLD_CACHING is a mask and bitwise AND was
> intended here instead of logical &&.  This bug is essentially
> harmless,
> it means that sometimes we don't print a warning message which we
> wanted
> to print.
> 
> Fixes: c2adae44e916 ('hpsa: disable report lun data caching')
> Signed-off-by: Dan Carpenter <dan.carpen...@oracle.com>
> 
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 6a8f958..a386036 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -8671,7 +8671,7 @@ static void hpsa_disable_rld_caching(struct
> ctlr_info *h)
>   if ((rc != 0)  || (c->err_info->CommandStatus != 0))
>   goto errout;
>  
> - if (*options && HPSA_DIAG_OPTS_DISABLE_RLD_CACHING)
> + if (*options & HPSA_DIAG_OPTS_DISABLE_RLD_CACHING)
>   goto out;
>  
>  errout:

Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>

> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" 
> in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND] scsi: Export SCSI Inquiry data to sysfs

2015-11-09 Thread Johannes Thumshirn
Export the RAW SCSI Inquiry to sysfs as binfile. This way the data can be used
by userland without the need to have and ioctl or use the sg_inq tool.

Here is an example of the provided data

linux:~ # hexdump /sys/class/scsi_device/1\:0\:0\:0/device/inquiry
000 8005 3205 001f  4551 554d 2020 2020
010 4551 554d 4420 4456 522d 4d4f 2020 2020
020 2e32 2e33
024

Signed-off-by: Johannes Thumshirn <jthumsh...@suse.de>
Reviewed-by: Hannes Reinecke <h...@suse.de>
---
1st sent on Aug. 14 2015
1st resend on Oct. 30 2015

 drivers/scsi/scsi_sysfs.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index b89..fdcf0ab 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -773,6 +773,29 @@ static struct bin_attribute dev_attr_vpd_##_page = {   
\
 sdev_vpd_pg_attr(pg83);
 sdev_vpd_pg_attr(pg80);
 
+static ssize_t show_inquiry(struct file *filep, struct kobject *kobj,
+   struct bin_attribute *bin_attr,
+   char *buf, loff_t off, size_t count)
+{
+   struct device *dev = container_of(kobj, struct device, kobj);
+   struct scsi_device *sdev = to_scsi_device(dev);
+
+   if (!sdev->inquiry)
+   return -EINVAL;
+
+   return memory_read_from_buffer(buf, count, , sdev->inquiry,
+  sdev->inquiry_len);
+}
+
+static struct bin_attribute dev_attr_inquiry = {
+   .attr = {
+   .name = "inquiry",
+   .mode = S_IRUGO,
+   },
+   .size = 0,
+   .read = show_inquiry,
+};
+
 static ssize_t
 show_iostat_counterbits(struct device *dev, struct device_attribute *attr,
char *buf)
@@ -957,6 +980,7 @@ static struct attribute *scsi_sdev_attrs[] = {
 static struct bin_attribute *scsi_sdev_bin_attrs[] = {
_attr_vpd_pg83,
_attr_vpd_pg80,
+   _attr_inquiry,
NULL
 };
 static struct attribute_group scsi_sdev_attr_group = {
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH v3] scsi: stex: Remove use of struct timeval

2015-10-30 Thread Johannes Thumshirn
Hi,

On Fri, 2015-10-30 at 01:30 -0700, Tina Ruchandani wrote:
> Function stex_gettime uses 'struct timeval' whose tv_sec value
> will overflow on 32-bit systems in year 2038 and beyond. This patch
> replaces the use of struct timeval and do_gettimeofday with
> ktime_get_real_seconds, which returns a 64-bit seconds value.

Thanks for the conversion. Can you please check if other (scsi) drivers
have the same y2038 issues? A quick "git grep do_gettimeofday
drivers/scsi/  | wc -l" reveals 30 occurrences (of cause not all are
problematic).


Other than that
Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: restart list search after unlock in scsi_remove_target

2015-10-30 Thread Johannes Thumshirn
Hi Bart,
On Tue, 2015-10-27 at 13:14 -0700, Bart Van Assche wrote:
> On 10/26/2015 01:35 AM, Johannes Thumshirn wrote:
> > I haven't heard anything from the original reporter of the lockup
> > but
> > my test's went all O.K., so
> > 
> > Tested-by: Johannes Thumshirn <jthumsh...@suse.de>
> > Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>
> 
> Hello Christoph and Johannes,
> 
> How about the patch below, which is a variant of Christoph's patch ?
> 
> Thanks,
> 
> Bart.


I'm OK with it and I ran tests with it over night, no lockups happened.
I feel a bit reluctant of giving the patch to mt downsream reporter as
it's not their business to validate patches for me.

So from my POV it's OK as well. So please feel free to add

Tested-by: Johannes Thumshirn <jthumsh...@suse.de>
Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>

on the official submission.

Thanks,
Johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND] scsi: Export SCSI Inquiry data to sysfs

2015-10-30 Thread Johannes Thumshirn
Export the RAW SCSI Inquiry to sysfs as binfile. This way the data can be used
by userland without the need to have and ioctl or use the sg_inq tool.

Here is an example of the provided data

linux:~ # hexdump /sys/class/scsi_device/1\:0\:0\:0/device/inquiry
000 8005 3205 001f  4551 554d 2020 2020
010 4551 554d 4420 4456 522d 4d4f 2020 2020
020 2e32 2e33
024

Signed-off-by: Johannes Thumshirn <jthumsh...@suse.de>
Reviewed-by: Hannes Reinecke <h...@suse.de>
---
 drivers/scsi/scsi_sysfs.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index b89..fdcf0ab 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -773,6 +773,29 @@ static struct bin_attribute dev_attr_vpd_##_page = {   
\
 sdev_vpd_pg_attr(pg83);
 sdev_vpd_pg_attr(pg80);
 
+static ssize_t show_inquiry(struct file *filep, struct kobject *kobj,
+   struct bin_attribute *bin_attr,
+   char *buf, loff_t off, size_t count)
+{
+   struct device *dev = container_of(kobj, struct device, kobj);
+   struct scsi_device *sdev = to_scsi_device(dev);
+
+   if (!sdev->inquiry)
+   return -EINVAL;
+
+   return memory_read_from_buffer(buf, count, , sdev->inquiry,
+  sdev->inquiry_len);
+}
+
+static struct bin_attribute dev_attr_inquiry = {
+   .attr = {
+   .name = "inquiry",
+   .mode = S_IRUGO,
+   },
+   .size = 0,
+   .read = show_inquiry,
+};
+
 static ssize_t
 show_iostat_counterbits(struct device *dev, struct device_attribute *attr,
char *buf)
@@ -957,6 +980,7 @@ static struct attribute *scsi_sdev_attrs[] = {
 static struct bin_attribute *scsi_sdev_bin_attrs[] = {
_attr_vpd_pg83,
_attr_vpd_pg80,
+   _attr_inquiry,
NULL
 };
 static struct attribute_group scsi_sdev_attr_group = {
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4.3-rc7] be2iscsi : Fix bogus WARN_ON length check

2015-10-30 Thread Johannes Thumshirn
Hi Tim,
tim.gard...@canonical.com writes:

> From: Tim Gardner 
>
> drivers/scsi/be2iscsi/be_main.c: In function 'be_sgl_create_contiguous':
> drivers/scsi/be2iscsi/be_main.c:3187:18: warning: logical not is only applied 
> to the left hand side of comparison [-Wlogical-not-parentheses]
>   WARN_ON(!length > 0);
>
> gcc version 5.2.1

This patch (or similar) was already posted on Oct 1 by Joel Stanley.
See http://comments.gmane.org/gmane.linux.scsi/105462

Thanks,
Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH] [SCSI] mvumi: 64bit value for seconds_since1970

2015-10-30 Thread Johannes Thumshirn
On Fri, 2015-10-30 at 02:11 -0700, Tina Ruchandani wrote:
> struct mvumi_hs_page2 stores a "seconds_since1970" field which is of
> type u64. It is however, written to, using 'struct timeval' which has
> a 32-bit seconds field and whose value will overflow in year 2038.
> This patch uses ktime_get_real_seconds() instead since it provides a
> 64-bit seconds value, which is 2038 safe.
> 
> Signed-off-by: Tina Ruchandani <ruchandani.t...@gmail.com>

Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>

> ---
>  drivers/scsi/mvumi.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
> index 3e6b866..02360de 100644
> --- a/drivers/scsi/mvumi.c
> +++ b/drivers/scsi/mvumi.c
> @@ -31,6 +31,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -858,8 +859,8 @@ static void mvumi_hs_build_page(struct mvumi_hba
> *mhba,
>   struct mvumi_hs_page2 *hs_page2;
>   struct mvumi_hs_page4 *hs_page4;
>   struct mvumi_hs_page3 *hs_page3;
> - struct timeval time;
> - unsigned int local_time;
> + u64 time;
> + u64 local_time;
>  
>   switch (hs_header->page_code) {
>   case HS_PAGE_HOST_INFO:
> @@ -877,9 +878,8 @@ static void mvumi_hs_build_page(struct mvumi_hba
> *mhba,
>   hs_page2->slot_number = 0;
>   hs_page2->intr_level = 0;
>   hs_page2->intr_vector = 0;
> - do_gettimeofday();
> - local_time = (unsigned int) (time.tv_sec -
> - (sys_tz.tz_minuteswe
> st * 60));
> + time = ktime_get_real_seconds();
> + local_time = (time - (sys_tz.tz_minuteswest * 60));
>   hs_page2->seconds_since1970 = local_time;
>   hs_header->checksum =
> mvumi_calculate_checksum(hs_header,
>   hs_header-
> >frame_length);

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH] qla2xxx: Remove use of 'struct timeval'

2015-10-30 Thread Johannes Thumshirn
On Fri, 2015-10-30 at 02:15 -0700, Tina Ruchandani wrote:
> struct register_host_info stores a 64-bit UTC system time timestamp.
> This patch removes the use of 'struct timeval' to obtain that
> timestamp
> as its tv_sec value will overflow on 32-bit systems in year 2038
> beyond.
> The patch uses ktime_get_real_seconds() which returns a 64-bit
> seconds value.
> 
> Signed-off-by: Tina Ruchandani <ruchandani.t...@gmail.com>

Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>

> ---
>  drivers/scsi/qla2xxx/qla_mr.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_mr.c
> b/drivers/scsi/qla2xxx/qla_mr.c
> index 6d190b4..d64a64a 100644
> --- a/drivers/scsi/qla2xxx/qla_mr.c
> +++ b/drivers/scsi/qla2xxx/qla_mr.c
> @@ -6,6 +6,7 @@
>   */
>  #include "qla_def.h"
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -1812,7 +1813,6 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t
> *fcport, uint16_t fx_type)
>   struct host_system_info *phost_info;
>   struct register_host_info *preg_hsi;
>   struct new_utsname *p_sysid = NULL;
> - struct timeval tv;
>  
>   sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
>   if (!sp)
> @@ -1886,8 +1886,7 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t
> *fcport, uint16_t fx_type)
>   p_sysid->domainname, DOMNAME_LENGTH);
>   strncpy(phost_info->hostdriver,
>   QLA2XXX_VERSION, VERSION_LENGTH);
> - do_gettimeofday();
> - preg_hsi->utc = (uint64_t)tv.tv_sec;
> + preg_hsi->utc =
> (uint64_t)ktime_get_real_seconds();
>   ql_dbg(ql_dbg_init, vha, 0x0149,
>   "ISP%04X: Host registration with
> firmware\n",
>   ha->pdev->device);

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] SCSI: Fix hard lockup in scsi_remove_target()

2015-10-14 Thread Johannes Thumshirn
On Wed, 2015-10-14 at 07:30 -0700, James Bottomley wrote:
> On Wed, 2015-10-14 at 15:50 +0200, Johannes Thumshirn wrote:
> > Removing a SCSI target via scsi_remove_target() suspected to be
> > racy. When a
> > sibling get's removed from the list it can occassionly happen that
> > one CPU is
> > stuck endlessly looping around this code block
> > 
> > list_for_each_entry(starget, >__targets, siblings) {
> > if (starget->state == STARGET_DEL)
> > continue;
> 
> How long is the __targets list?  It seems a bit unlikely that this is
> the exact cause, because for a short list all in STARGET_DEL that
> loop
> should exit very quickly.  Where in the code does scsi_remove_target
> +0x68/0x240 actually point to?
> 
> Is it not a bit more likely that we're following a removed list
> element?
> Since that points back to itself, the list_for_each_entry() would
> then
> circulate forever.  If that's the case the simple fix would be to use
> the safe version of the list traversal macro.

Yes it is traversing a removed element and yes the patches 2/3 and 3/3
are introducing the safe version of list_for_each_entry(), but they
also decouple the search for elements to be removed from the actual
removal. This is what my initial proposal did as well. Christoph wanted
me to decouple the whole process from the host_lock though and this is
what this patches do as well now.

> 
> James
> 
> 
> > Resulting in the following hard lockup.
> > 
> > Kernel panic - not syncing: Watchdog detected hard LOCKUP on cpu 0
> > [...]
> > Call Trace:
> >  [] dump_trace+0x7d/0x2d0
> >  [] show_stack_log_lvl+0x94/0x170
> >  [] show_stack+0x21/0x50
> >  [] dump_stack+0x41/0x51
> >  [] panic+0xc8/0x1d7
> >  [] watchdog_overflow_callback+0xba/0xc0
> >  [] __perf_event_overflow+0x88/0x240
> >  [] intel_pmu_handle_irq+0x1fa/0x3e0
> >  [] perf_event_nmi_handler+0x26/0x40
> >  [] nmi_handle.isra.2+0x8d/0x180
> >  [] do_nmi+0x126/0x3c0
> >  [] end_repeat_nmi+0x1a/0x1e
> >  [] scsi_remove_target+0x68/0x240 [scsi_mod]
> >  [] process_one_work+0x172/0x420
> >  [] worker_thread+0x11a/0x3c0
> >  [] kthread+0xb4/0xc0
> >  [] ret_from_fork+0x58/0x90
> > 
> > This series attacks the issue by 1) decoupling the __targets and
> > __devices
> > lists of struct Scsi_Host from the host_lock spinlock by
> > introducing spinlocks
> > for each list and 2) de-coupling the list traversals needed for
> > detecting
> > targets/devices to be removed from the actual removal by moving
> > list entries to
> > be deleted to a second list and perform the deletion there.
> > 
> > 
> > The whole series survived a nearly 48h test loop of:
> > while [ $not_done  ]; do
> > umount $mountpoint;
> > rmmod $module;
> > modprobe $module;
> > mount $mountpoint;
> > done
> > 
> > This is a follow up of the patch proposed here:
> > http://marc.info/?l=linux-scsi=144377409311774=2
> > incorporating Christoph's comment
> > 
> > Johannes Thumshirn (3):
> >   SCSI: Introduce device_lock and target_lock in Scsi_Host
> >   SCSI: Rework list handling in scsi_target_remove
> >   SCSI: Rework list handling in __scsi_target_remove
> > 
> >  drivers/scsi/53c700.c |  3 +++
> >  drivers/scsi/hosts.c  |  2 ++
> >  drivers/scsi/scsi.c   |  8 
> >  drivers/scsi/scsi_scan.c  | 10 +-
> >  drivers/scsi/scsi_sysfs.c | 43 +--
> > 
> >  include/scsi/scsi_host.h  |  2 ++
> >  6 files changed, 37 insertions(+), 31 deletions(-)
> > 
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi"
> in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] SCSI: Fix hard lockup in scsi_remove_target()

2015-10-15 Thread Johannes Thumshirn
On Wed, 2015-10-14 at 16:22 -0400, Ewan Milne wrote:
> On Wed, 2015-10-14 at 07:30 -0700, James Bottomley wrote:
> > On Wed, 2015-10-14 at 15:50 +0200, Johannes Thumshirn wrote:
> > > Removing a SCSI target via scsi_remove_target() suspected to be
> > > racy. When a
> > > sibling get's removed from the list it can occassionly happen
> > > that one CPU is
> > > stuck endlessly looping around this code block
> > > 
> > > list_for_each_entry(starget, >__targets, siblings) {
> > > if (starget->state == STARGET_DEL)
> > > continue;
> > 
> > How long is the __targets list?  It seems a bit unlikely that this
> > is
> > the exact cause, because for a short list all in STARGET_DEL that
> > loop
> > should exit very quickly.  Where in the code does
> > scsi_remove_target
> > +0x68/0x240 actually point to?
> > 
> > Is it not a bit more likely that we're following a removed list
> > element?
> > Since that points back to itself, the list_for_each_entry() would
> > then
> > circulate forever.  If that's the case the simple fix would be to
> > use
> > the safe version of the list traversal macro.
> > 
> > James
> 
> For what it's worth, I've seen a dump where this was exactly the
> case.
> starget was in STARGET_DEL state, starget->siblings pointed to
> itself,
> kref was 0, reap_ref was 0 (this was a while back).
> 

That's exactly what I have here as well.

I'll give Christoph's patch a shot today and report back.

> The problem was not able to be reproduced at the time.
> 
> -Ewan
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] SCSI: Fix hard lockup in scsi_remove_target()

2015-10-14 Thread Johannes Thumshirn

Zitat von James Bottomley <james.bottom...@hansenpartnership.com>:


On Wed, 2015-10-14 at 16:39 +0200, Johannes Thumshirn wrote:

On Wed, 2015-10-14 at 07:30 -0700, James Bottomley wrote:
> On Wed, 2015-10-14 at 15:50 +0200, Johannes Thumshirn wrote:
> > Removing a SCSI target via scsi_remove_target() suspected to be
> > racy. When a
> > sibling get's removed from the list it can occassionly happen that
> > one CPU is
> > stuck endlessly looping around this code block
> >
> > list_for_each_entry(starget, >__targets, siblings) {
> > if (starget->state == STARGET_DEL)
> > continue;
>
> How long is the __targets list?  It seems a bit unlikely that this is
> the exact cause, because for a short list all in STARGET_DEL that
> loop
> should exit very quickly.  Where in the code does scsi_remove_target
> +0x68/0x240 actually point to?
>
> Is it not a bit more likely that we're following a removed list
> element?
> Since that points back to itself, the list_for_each_entry() would
> then
> circulate forever.  If that's the case the simple fix would be to use
> the safe version of the list traversal macro.

Yes it is traversing a removed element and yes the patches 2/3 and 3/3
are introducing the safe version of list_for_each_entry(), but they
also decouple the search for elements to be removed from the actual
removal. This is what my initial proposal did as well. Christoph wanted
me to decouple the whole process from the host_lock though and this is
what this patches do as well now.


OK, so I really need you to separate the problems.  Fixing the bug
you're reporting does not require a complete rework of the locking
infrastructure; it just requires replacing the traversal macro with the
safe version, can you verify that and it can go into fixes?



Yes. I can sent a patch for it tomorrow.




Then we can discuss the merits of doing a locking rework in this area
separately from the idea that it's some sort of bug fix.

James


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html





--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] SCSI: Fix hard lockup in scsi_remove_target()

2015-10-14 Thread Johannes Thumshirn

Zitat von Christoph Hellwig <h...@infradead.org>:


On Wed, Oct 14, 2015 at 04:39:07PM +0200, Johannes Thumshirn wrote:

removal. This is what my initial proposal did as well. Christoph wanted
me to decouple the whole process from the host_lock though and this is
what this patches do as well now.


I think we've talked past each other, I didn't intend to say that and
my replies to you don't seem to imply that either.


OK, I think I misunderstood you then.



I'll draft a patch for what I meant.





--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: dm-multipath test scripts

2015-10-07 Thread Johannes Thumshirn
On Wed, 2015-10-07 at 05:39 +, Junichi Nomura wrote:
> This is a set of scripts for kernel-side dm-multipath testing.
> Current
> set of scripts are stress testing of extreme situation and its
> coverage
> is limited. But recently found dm-mpath regressions should be
> detectable
> with this. I hope this helps people working on dm-multipath related
> code
> as a regression test set.
> 
> Though this is created as a patch for linux kernel source, it's just
> for
> convenience of kernel developers (I don't have a place to host this
> kind
> of scripts). If there are better place to contribute this, please let
> me know.

Have you considered placing it under tools/testing/selftests/? I think
people are looking for testing there instead of Documentation.

Thanks,
Johannes

> 
> Please check README for how-to-run and possible improvements you
> could
> contribute in future.
> 
> ---
>  Documentation/device-mapper/mptest/COPYING | 345
> +
>  Documentation/device-mapper/mptest/README  |  61 
>  .../device-mapper/mptest/lib/backend_generic   |  28 ++
>  .../device-mapper/mptest/lib/backend_scsidebug |  43 +++
>  .../device-mapper/mptest/lib/backend_tcmloop   |  51 +++
>  .../device-mapper/mptest/lib/failpath_dm_message   |  43 +++
>  .../device-mapper/mptest/lib/failpath_sdev_delete  |  51 +++
>  .../device-mapper/mptest/lib/failpath_sdev_offline |  46 +++
>  .../device-mapper/mptest/lib/fio_validate  |  41 +++
>  .../device-mapper/mptest/lib/mpath_generic | 119 +++
>  .../device-mapper/mptest/lib/switchpg_dm_message   |  37 +++
>  Documentation/device-mapper/mptest/runtest |  32 ++
>  .../device-mapper/mptest/tests/test_00_no_failure  |  30 ++
>  .../mptest/tests/test_01_sdev_offline  |  33 ++
>  .../device-mapper/mptest/tests/test_02_sdev_delete |  33 ++
>  .../device-mapper/mptest/tests/test_03_dm_failpath |  33 ++
>  .../device-mapper/mptest/tests/test_04_dm_switchpg |  33 ++
>  17 files changed, 1059 insertions(+)
>  create mode 100644 Documentation/device-mapper/mptest/COPYING
>  create mode 100644 Documentation/device-mapper/mptest/README
>  create mode 100755 Documentation/device
> -mapper/mptest/lib/backend_generic
>  create mode 100755 Documentation/device
> -mapper/mptest/lib/backend_scsidebug
>  create mode 100755 Documentation/device
> -mapper/mptest/lib/backend_tcmloop
>  create mode 100755 Documentation/device
> -mapper/mptest/lib/failpath_dm_message
>  create mode 100755 Documentation/device
> -mapper/mptest/lib/failpath_sdev_delete
>  create mode 100755 Documentation/device
> -mapper/mptest/lib/failpath_sdev_offline
>  create mode 100755 Documentation/device
> -mapper/mptest/lib/fio_validate
>  create mode 100755 Documentation/device
> -mapper/mptest/lib/mpath_generic
>  create mode 100755 Documentation/device
> -mapper/mptest/lib/switchpg_dm_message
>  create mode 100755 Documentation/device-mapper/mptest/runtest
>  create mode 100755 Documentation/device
> -mapper/mptest/tests/test_00_no_failure
>  create mode 100755 Documentation/device
> -mapper/mptest/tests/test_01_sdev_offline
>  create mode 100755 Documentation/device
> -mapper/mptest/tests/test_02_sdev_delete
>  create mode 100755 Documentation/device
> -mapper/mptest/tests/test_03_dm_failpath
>  create mode 100755 Documentation/device
> -mapper/mptest/tests/test_04_dm_switchpg
> 
> diff --git a/Documentation/device-mapper/mptest/COPYING
> b/Documentation/device-mapper/mptest/COPYING
> new file mode 100644
> index 000..1114411
> --- /dev/null
> +++ b/Documentation/device-mapper/mptest/COPYING
> @@ -0,0 +1,345 @@
> + GNU GENERAL PUBLIC LICENSE
> +Version 2, June 1991
> +
> + Copyright (C) 1989, 1991 Free Software Foundation, Inc.
> + 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + Everyone is permitted to copy and distribute verbatim copies
> + of this license document, but changing it is not allowed.
> +
> + Preamble
> +
> +  The licenses for most software are designed to take away your
> +freedom to share and change it.  By contrast, the GNU General Public
> +License is intended to guarantee your freedom to share and change
> free
> +software--to make sure the software is free for all its users.  This
> +General Public License applies to most of the Free Software
> +Foundation's software and to any other program whose authors commit
> to
> +using it.  (Some other Free Software Foundation software is covered
> by
> +the GNU Library General Public License instead.)  You can apply it
> to
> +your programs, too.
> +
> +  When we speak of free software, we are referring to freedom, not
> +price.  Our General Public Licenses are designed to make sure that
> you
> +have the freedom to distribute copies of free software (and charge
> for
> +this service if you wish), that you receive source code or can get
> it
> +if you want it, that you can change the software or use 

Re: [PATCH 0/3] SCSI: Fix hard lockup in scsi_remove_target()

2015-10-16 Thread Johannes Thumshirn
On Wed, 2015-10-14 at 11:18 -0700, Christoph Hellwig wrote:
> On Wed, Oct 14, 2015 at 08:45:56AM -0700, James Bottomley wrote:
> > OK, so I really need you to separate the problems.  Fixing the bug

[..]

> 
> Johannes, can you test the patch below?

I've tested your patch and it doesn't show the lockup anymore, so far
so good. But it seems as if I have a problem in my test setup, because
I can't reproduce the bug on vanilla 4.3-rc5 either. I will ask the
original reporter if it is possible to test your patch on their side.

Appart from that it looks good to me (and much simpler than my changes)
.

> 
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index b89f..d3b34d8 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -1158,31 +1158,23 @@ static void __scsi_remove_target(struct
> scsi_target *starget)
>  void scsi_remove_target(struct device *dev)
>  {
>   struct Scsi_Host *shost = dev_to_shost(dev->parent);
> - struct scsi_target *starget, *last = NULL;
> + struct scsi_target *starget;
>   unsigned long flags;
>  
> - /* remove targets being careful to lookup next entry before
> -  * deleting the last
> -  */
> +restart:
>   spin_lock_irqsave(shost->host_lock, flags);
>   list_for_each_entry(starget, >__targets, siblings) {
>   if (starget->state == STARGET_DEL)
>   continue;
>   if (starget->dev.parent == dev || >dev ==
> dev) {
> - /* assuming new targets arrive at the end */
>   kref_get(>reap_ref);
>   spin_unlock_irqrestore(shost->host_lock,
> flags);
> - if (last)
> - scsi_target_reap(last);
> - last = starget;
>   __scsi_remove_target(starget);
> - spin_lock_irqsave(shost->host_lock, flags);
> + scsi_target_reap(starget);
> + goto restart;
>   }
>   }
>   spin_unlock_irqrestore(shost->host_lock, flags);
> -
> - if (last)
> - scsi_target_reap(last);
>  }
>  EXPORT_SYMBOL(scsi_remove_target);
>  
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi"
> in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: mvsas: fix misleading indentation

2015-10-20 Thread Johannes Thumshirn
On Mon, 2015-10-19 at 21:36 +0100, Luis de Bethencourt wrote:
> Fix a smatch warning:
> drivers/scsi/mvsas/mv_sas.c:740 mvs_task_prep() warn: curly braces
> intended?
> 
> The code is correct, the indention is misleading. When the device is
> not
> ready we want to return SAS_PHY_DOWN. But current indentation makes
> it
> look like we only do so in the else branch of if (mvi_dev).
> 
> Signed-off-by: Luis de Bethencourt <lui...@osg.samsung.com>
> ---
> 
> Hi,
> 
> The aim of this patch is to improve code readability, and at the same
> time
> silence the smatch warning.
> 
> Thanks for the review,
> Luis
> 
>  drivers/scsi/mvsas/mv_sas.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/mvsas/mv_sas.c
> b/drivers/scsi/mvsas/mv_sas.c
> index 454536c..b1c5dec 100644
> --- a/drivers/scsi/mvsas/mv_sas.c
> +++ b/drivers/scsi/mvsas/mv_sas.c
> @@ -737,8 +737,8 @@ static int mvs_task_prep(struct sas_task *task,
> struct mvs_info *mvi, int is_tmf
>   mv_dprintk("device %016llx not ready.\n",
>   SAS_ADDR(dev->sas_addr));
>  
> - rc = SAS_PHY_DOWN;
> - return rc;
> + rc = SAS_PHY_DOWN;
> + return rc;
>   }
>   tei.port = dev->port->lldd_port;
>   if (tei.port && !tei.port->port_attached && !tmf) {

Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv4 1/1] SCSI: hosts: update to use ida_simple for host_no management

2015-10-14 Thread Johannes Thumshirn
On Wed, 2015-10-07 at 16:51 -0700, Lee Duncan wrote:
> Update the SCSI hosts module to use the ida_simple*() routines
> to manage its host_no index instead of an ATOMIC integer. This
> means that the SCSI host number will now be reclaimable.
> 
> Signed-off-by: Lee Duncan <ldun...@suse.com>
> ---
>  drivers/scsi/hosts.c | 22 ++
>  1 file changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
> index 8bb173e01084..b6a5ffa886b7 100644
> --- a/drivers/scsi/hosts.c
> +++ b/drivers/scsi/hosts.c
> @@ -33,7 +33,7 @@
>  #include 
>  #include 
>  #include 
> -
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -42,7 +42,7 @@
>  #include "scsi_logging.h"
>  
>  
> -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0);  /*
> host_no for next new host */
> +static DEFINE_IDA(host_index_ida);
>  
>  
>  static void scsi_host_cls_release(struct device *dev)
> @@ -337,6 +337,8 @@ static void scsi_host_dev_release(struct device
> *dev)
>  
>   kfree(shost->shost_data);
>  
> + ida_simple_remove(_index_ida, shost->host_no);
> +
>   if (parent)
>   put_device(parent);
>   kfree(shost);
> @@ -370,6 +372,7 @@ struct Scsi_Host *scsi_host_alloc(struct
> scsi_host_template *sht, int privsize)
>  {
>   struct Scsi_Host *shost;
>   gfp_t gfp_mask = GFP_KERNEL;
> + int index;
>  
>   if (sht->unchecked_isa_dma && privsize)
>   gfp_mask |= __GFP_DMA;
> @@ -388,11 +391,11 @@ struct Scsi_Host *scsi_host_alloc(struct
> scsi_host_template *sht, int privsize)
>   init_waitqueue_head(>host_wait);
>   mutex_init(>scan_mutex);
>  
> - /*
> -  * subtract one because we increment first then return, but
> we need to
> -  * know what the next host number was before increment
> -  */
> - shost->host_no = atomic_inc_return(_host_next_hn) - 1;
> + index = ida_simple_get(_index_ida, 0, 0, GFP_KERNEL);
> + if (index < 0)
> + goto fail_kfree;
> + shost->host_no = index;
> +
>   shost->dma_channel = 0xff;
>  
>   /* These three are default values which can be overridden */
> @@ -477,7 +480,7 @@ struct Scsi_Host *scsi_host_alloc(struct
> scsi_host_template *sht, int privsize)
>   shost_printk(KERN_WARNING, shost,
>   "error handler thread failed to spawn, error
> = %ld\n",
>   PTR_ERR(shost->ehandler));
> - goto fail_kfree;
> + goto fail_index_remove;
>   }
>  
>   shost->tmf_work_q = alloc_workqueue("scsi_tmf_%d",
> @@ -493,6 +496,8 @@ struct Scsi_Host *scsi_host_alloc(struct
> scsi_host_template *sht, int privsize)
>  
>   fail_kthread:
>   kthread_stop(shost->ehandler);
> + fail_index_remove:
> +     ida_simple_remove(_index_ida, shost->host_no);
>   fail_kfree:
>   kfree(shost);
>   return NULL;
> @@ -588,6 +593,7 @@ int scsi_init_hosts(void)
>  void scsi_exit_hosts(void)
>  {
>   class_unregister(_class);
> + ida_destroy(_index_ida);
>  }
>  
>  int scsi_is_host_device(const struct device *dev)

Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] SCSI: Introduce device_lock and target_lock in Scsi_Host

2015-10-14 Thread Johannes Thumshirn
Introduce target_lock and device_lock to untangle the __devices and __targets
lists from the host_lock.

Signed-off-by: Johannes Thumshirn <jthumsh...@suse.de>
---
 drivers/scsi/53c700.c |  3 +++
 drivers/scsi/hosts.c  |  2 ++
 drivers/scsi/scsi.c   |  8 
 drivers/scsi/scsi_scan.c  | 10 +-
 drivers/scsi/scsi_sysfs.c | 18 --
 include/scsi/scsi_host.h  |  2 ++
 6 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index a209c34..e2b4d04 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -1093,6 +1093,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct 
scsi_cmnd *SCp,
struct NCR_700_command_slot *slot;
__u8 reselection_id = hostdata->reselection_id;
struct scsi_device *SDp;
+   unsigned long flags;
 
lun = hostdata->msgin[0] & 0x1f;
 
@@ -1100,7 +1101,9 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct 
scsi_cmnd *SCp,
DEBUG(("scsi%d: (%d:%d) RESELECTED!\n",
   host->host_no, reselection_id, lun));
/* clear the reselection indicator */
+   spin_lock_irqsave(host->device_lock, flags);
SDp = __scsi_device_lookup(host, 0, reselection_id, lun);
+   spin_unlock_irqrestore(host->device_lock, flags);
if(unlikely(SDp == NULL)) {
printk(KERN_ERR "scsi%d: (%d:%d) HAS NO device\n",
   host->host_no, reselection_id, lun);
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 8bb173e..6855434 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -380,6 +380,8 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template 
*sht, int privsize)
 
shost->host_lock = >default_lock;
spin_lock_init(shost->host_lock);
+   spin_lock_init(>device_lock);
+   spin_lock_init(>target_lock);
shost->shost_state = SHOST_CREATED;
INIT_LIST_HEAD(>__devices);
INIT_LIST_HEAD(>__targets);
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 207d6a7..0e1046a 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -970,7 +970,7 @@ struct scsi_device *__scsi_iterate_devices(struct Scsi_Host 
*shost,
struct scsi_device *next = NULL;
unsigned long flags;
 
-   spin_lock_irqsave(shost->host_lock, flags);
+   spin_lock_irqsave(>device_lock, flags);
while (list->next != >__devices) {
next = list_entry(list->next, struct scsi_device, siblings);
/* skip devices that we can't get a reference to */
@@ -979,7 +979,7 @@ struct scsi_device *__scsi_iterate_devices(struct Scsi_Host 
*shost,
next = NULL;
list = list->next;
}
-   spin_unlock_irqrestore(shost->host_lock, flags);
+   spin_unlock_irqrestore(>device_lock, flags);
 
if (prev)
scsi_device_put(prev);
@@ -1144,11 +1144,11 @@ struct scsi_device *scsi_device_lookup(struct Scsi_Host 
*shost,
struct scsi_device *sdev;
unsigned long flags;
 
-   spin_lock_irqsave(shost->host_lock, flags);
+   spin_lock_irqsave(>device_lock, flags);
sdev = __scsi_device_lookup(shost, channel, id, lun);
if (sdev && scsi_device_get(sdev))
sdev = NULL;
-   spin_unlock_irqrestore(shost->host_lock, flags);
+   spin_unlock_irqrestore(>device_lock, flags);
 
return sdev;
 }
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index f9f3f82..ac68531 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -441,14 +441,14 @@ static struct scsi_target *scsi_alloc_target(struct 
device *parent,
starget->scsi_level = SCSI_2;
starget->max_target_blocked = SCSI_DEFAULT_TARGET_BLOCKED;
  retry:
-   spin_lock_irqsave(shost->host_lock, flags);
+   spin_lock_irqsave(>target_lock, flags);
 
found_target = __scsi_find_target(parent, channel, id);
if (found_target)
goto found;
 
list_add_tail(>siblings, >__targets);
-   spin_unlock_irqrestore(shost->host_lock, flags);
+   spin_unlock_irqrestore(>target_lock, flags);
/* allocate and add */
transport_setup_device(dev);
if (shost->hostt->target_alloc) {
@@ -1854,15 +1854,15 @@ void scsi_forget_host(struct Scsi_Host *shost)
unsigned long flags;
 
  restart:
-   spin_lock_irqsave(shost->host_lock, flags);
+   spin_lock_irqsave(>device_lock, flags);
list_for_each_entry(sdev, >__devices, siblings) {
if (sdev->sdev_state == SDEV_DEL)
continue;
-   spin_unlock_irqrestore(s

[PATCH 2/3] SCSI: Rework list handling in scsi_target_remove

2015-10-14 Thread Johannes Thumshirn
Rework the list handling in scsi_target_remove(). The new version introduces a
reap list for targets. Targets that shall be removed are placed on the reap
list and can then be reaped later on.

Signed-off-by: Johannes Thumshirn <jthumsh...@suse.de>
---
 drivers/scsi/scsi_sysfs.c | 19 ---
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index d7afea9..b41dcb3 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1156,31 +1156,28 @@ static void __scsi_remove_target(struct scsi_target 
*starget)
 void scsi_remove_target(struct device *dev)
 {
struct Scsi_Host *shost = dev_to_shost(dev->parent);
-   struct scsi_target *starget, *last = NULL;
+   struct scsi_target *starget, *tmp;
unsigned long flags;
+   LIST_HEAD(reap_list);
 
/* remove targets being careful to lookup next entry before
 * deleting the last
 */
spin_lock_irqsave(>target_lock, flags);
-   list_for_each_entry(starget, >__targets, siblings) {
+   list_for_each_entry_safe(starget, tmp, >__targets, siblings) {
if (starget->state == STARGET_DEL)
continue;
if (starget->dev.parent == dev || >dev == dev) {
-   /* assuming new targets arrive at the end */
kref_get(>reap_ref);
-   spin_unlock_irqrestore(>target_lock, flags);
-   if (last)
-   scsi_target_reap(last);
-   last = starget;
-   __scsi_remove_target(starget);
-   spin_lock_irqsave(>target_lock, flags);
+   list_move_tail(>siblings, _list);
}
}
spin_unlock_irqrestore(>target_lock, flags);
 
-   if (last)
-   scsi_target_reap(last);
+   list_for_each_entry_safe(starget, tmp, _list, siblings) {
+   __scsi_remove_target(starget);
+   scsi_target_reap(starget);
+   }
 }
 EXPORT_SYMBOL(scsi_remove_target);
 
-- 
1.8.5.6

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] SCSI: Rework list handling in __scsi_target_remove

2015-10-14 Thread Johannes Thumshirn
Rework the list handling in __scsi_target_remove(). The new version introduces
a reap list for devices. Devices that shall be removed are placed on the reap
list and can then be removed later on.

Signed-off-by: Johannes Thumshirn <jthumsh...@suse.de>
---
 drivers/scsi/scsi_sysfs.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index b41dcb3..2bd88c6 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1129,20 +1129,24 @@ static void __scsi_remove_target(struct scsi_target 
*starget)
 {
struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
unsigned long flags;
-   struct scsi_device *sdev;
+   struct scsi_device *sdev, *tmp;
+   LIST_HEAD(reap_list);
 
spin_lock_irqsave(>device_lock, flags);
  restart:
-   list_for_each_entry(sdev, >__devices, siblings) {
+   list_for_each_entry_safe(sdev, tmp, >__devices, siblings) {
if (sdev->channel != starget->channel ||
sdev->id != starget->id ||
scsi_device_get(sdev))
continue;
-   scsi_remove_device(sdev);
+   list_move_tail(>siblings, _list);
scsi_device_put(sdev);
goto restart;
}
spin_unlock_irqrestore(>device_lock, flags);
+
+   list_for_each_entry_safe(sdev, tmp, _list, siblings)
+   scsi_remove_device(sdev);
 }
 
 /**
-- 
1.8.5.6

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] SCSI: Fix hard lockup in scsi_remove_target()

2015-10-14 Thread Johannes Thumshirn
Removing a SCSI target via scsi_remove_target() suspected to be racy. When a
sibling get's removed from the list it can occassionly happen that one CPU is
stuck endlessly looping around this code block

list_for_each_entry(starget, >__targets, siblings) {
if (starget->state == STARGET_DEL)
continue;

Resulting in the following hard lockup.

Kernel panic - not syncing: Watchdog detected hard LOCKUP on cpu 0
[...]
Call Trace:
 [] dump_trace+0x7d/0x2d0
 [] show_stack_log_lvl+0x94/0x170
 [] show_stack+0x21/0x50
 [] dump_stack+0x41/0x51
 [] panic+0xc8/0x1d7
 [] watchdog_overflow_callback+0xba/0xc0
 [] __perf_event_overflow+0x88/0x240
 [] intel_pmu_handle_irq+0x1fa/0x3e0
 [] perf_event_nmi_handler+0x26/0x40
 [] nmi_handle.isra.2+0x8d/0x180
 [] do_nmi+0x126/0x3c0
 [] end_repeat_nmi+0x1a/0x1e
 [] scsi_remove_target+0x68/0x240 [scsi_mod]
 [] process_one_work+0x172/0x420
 [] worker_thread+0x11a/0x3c0
 [] kthread+0xb4/0xc0
 [] ret_from_fork+0x58/0x90

This series attacks the issue by 1) decoupling the __targets and __devices
lists of struct Scsi_Host from the host_lock spinlock by introducing spinlocks
for each list and 2) de-coupling the list traversals needed for detecting
targets/devices to be removed from the actual removal by moving list entries to
be deleted to a second list and perform the deletion there.


The whole series survived a nearly 48h test loop of:
while [ $not_done  ]; do
umount $mountpoint;
rmmod $module;
modprobe $module;
mount $mountpoint;
done

This is a follow up of the patch proposed here:
http://marc.info/?l=linux-scsi=144377409311774=2
incorporating Christoph's comment

Johannes Thumshirn (3):
  SCSI: Introduce device_lock and target_lock in Scsi_Host
  SCSI: Rework list handling in scsi_target_remove
  SCSI: Rework list handling in __scsi_target_remove

 drivers/scsi/53c700.c |  3 +++
 drivers/scsi/hosts.c  |  2 ++
 drivers/scsi/scsi.c   |  8 
 drivers/scsi/scsi_scan.c  | 10 +-
 drivers/scsi/scsi_sysfs.c | 43 +--
 include/scsi/scsi_host.h  |  2 ++
 6 files changed, 37 insertions(+), 31 deletions(-)

-- 
1.8.5.6

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] SCSI: mvsas: Fix NULL pointer dereference in mvs_slot_task_free

2015-10-21 Thread Johannes Thumshirn
On Tue, 2015-10-20 at 20:41 +0300, Dāvis Mosāns wrote:
> 2015-08-21 7:29 GMT+03:00 Dāvis Mosāns <davis...@gmail.com>:
> > When pci_pool_alloc fails in mvs_task_prep then task->lldd_task
> > stays
> > NULL but it's later used in mvs_abort_task as slot which is passed
> > to mvs_slot_task_free causing NULL pointer dereference.
> > 
> > Just return from mvs_slot_task_free when passed with NULL slot.
> > 
> > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=101891
> > Signed-off-by: Dāvis Mosāns <davis...@gmail.com>
> > ---
> >  drivers/scsi/mvsas/mv_sas.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/scsi/mvsas/mv_sas.c
> > b/drivers/scsi/mvsas/mv_sas.c
> > index 454536c..9c78074 100644
> > --- a/drivers/scsi/mvsas/mv_sas.c
> > +++ b/drivers/scsi/mvsas/mv_sas.c
> > @@ -887,6 +887,8 @@ static void mvs_slot_free(struct mvs_info *mvi,
> > u32 rx_desc)
> >  static void mvs_slot_task_free(struct mvs_info *mvi, struct
> > sas_task *task,
> >   struct mvs_slot_info *slot, u32 slot_idx)
> >  {
> > +   if (!slot)
> > +   return;
> > if (!slot->task)
> > return;
> > if (!sas_protocol_ata(task->task_proto))
> > --
> > 2.5.0
> > 
> 
> Can this get merged?
> So far since august it have saved me from several kernel crashes.

If it saved you from several crashes, it probably should be tagged for
stable, shouldn't it?

Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>


> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" 
> in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] lpfc: Destroy lpfc_hba_index IDR on module exit

2015-07-08 Thread Johannes Thumshirn
Destroy lpfc_hba_index IDR on module exit, reclaiming the allocated memory.

This was detected by the following semantic patch (written by Luis Rodriguez
mcg...@suse.com)
SmPL
@ defines_module_init @
declarer name module_init, module_exit;
declarer name DEFINE_IDR;
identifier init;
@@

module_init(init);

@ defines_module_exit @
identifier exit;
@@

module_exit(exit);

@ declares_idr depends on defines_module_init  defines_module_exit @
identifier idr;
@@

DEFINE_IDR(idr);

@ on_exit_calls_destroy depends on declares_idr  defines_module_exit @
identifier declares_idr.idr, defines_module_exit.exit;
@@

exit(void)
{
 ...
 idr_destroy(idr);
 ...
}

@ missing_module_idr_destroy depends on declares_idr  defines_module_exit  
!on_exit_calls_destroy @
identifier declares_idr.idr, defines_module_exit.exit;
@@

exit(void)
{
 ...
 +idr_destroy(idr);
}
/SmPL

Signed-off-by: Johannes Thumshirn jthumsh...@suse.de
---
 drivers/scsi/lpfc/lpfc_init.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index f962118..4bedb06 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -11477,6 +11477,7 @@ lpfc_exit(void)
free_pages((unsigned long)_dump_buf_dif, _dump_buf_dif_order);
}
kfree(lpfc_used_cpu);
+   idr_destroy(lpfc_hba_index);
 }
 
 module_init(lpfc_init);
-- 
2.4.3

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] st: Destroy st_index_idr on module exit

2015-07-08 Thread Johannes Thumshirn
Destroy st_index_idr on module exit, reclaiming the allocated memory.

This was detected by the following semantic patch (written by Luis Rodriguez
mcg...@suse.com)
SmPL
@ defines_module_init @
declarer name module_init, module_exit;
declarer name DEFINE_IDR;
identifier init;
@@

module_init(init);

@ defines_module_exit @
identifier exit;
@@

module_exit(exit);

@ declares_idr depends on defines_module_init  defines_module_exit @
identifier idr;
@@

DEFINE_IDR(idr);

@ on_exit_calls_destroy depends on declares_idr  defines_module_exit @
identifier declares_idr.idr, defines_module_exit.exit;
@@

exit(void)
{
 ...
 idr_destroy(idr);
 ...
}

@ missing_module_idr_destroy depends on declares_idr  defines_module_exit  
!on_exit_calls_destroy @
identifier declares_idr.idr, defines_module_exit.exit;
@@

exit(void)
{
 ...
 +idr_destroy(idr);
}
/SmPL

Signed-off-by: Johannes Thumshirn jthumsh...@suse.de
---
 drivers/scsi/st.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 3f25b8f..79ac024 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4427,6 +4427,7 @@ static void __exit exit_st(void)
unregister_chrdev_region(MKDEV(SCSI_TAPE_MAJOR, 0),
 ST_MAX_TAPE_ENTRIES);
class_unregister(st_sysfs_class);
+   idr_destroy(st_index_idr);
printk(KERN_INFO st: Unloaded.\n);
 }
 
-- 
2.4.3

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   3   4   5   6   7   8   9   10   >