Re: [PATCH 04/28] 3w-sas: fully convert to the generic DMA API

2018-10-12 Thread adam radford
On Thu, Oct 11, 2018 at 12:38 PM Christoph Hellwig  wrote:
>
> The driver is currently using an odd mix of legacy PCI DMA API and
> generic DMA API calls, switch it over to the generic API entirely.
>
> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/scsi/3w-sas.c | 38 +-
>  1 file changed, 17 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
> index 40c1e6e64f58..266bdac75304 100644
> --- a/drivers/scsi/3w-sas.c
> +++ b/drivers/scsi/3w-sas.c
> @@ -644,8 +644,8 @@ static int twl_allocate_memory(TW_Device_Extension 
> *tw_dev, int size, int which)
> unsigned long *cpu_addr;
> int retval = 1;
>
> -   cpu_addr = pci_zalloc_consistent(tw_dev->tw_pci_dev, size * 
> TW_Q_LENGTH,
> -_handle);
> +   cpu_addr = dma_zalloc_coherent(_dev->tw_pci_dev->dev,
> +   size * TW_Q_LENGTH, _handle, GFP_KERNEL);
> if (!cpu_addr) {
> TW_PRINTK(tw_dev->host, TW_DRIVER, 0x5, "Memory allocation 
> failed");
> goto out;
> @@ -899,19 +899,19 @@ static int twl_fill_sense(TW_Device_Extension *tw_dev, 
> int i, int request_id, in
>  static void twl_free_device_extension(TW_Device_Extension *tw_dev)
>  {
> if (tw_dev->command_packet_virt[0])
> -   pci_free_consistent(tw_dev->tw_pci_dev,
> +   dma_free_coherent(_dev->tw_pci_dev->dev,
> sizeof(TW_Command_Full)*TW_Q_LENGTH,
> tw_dev->command_packet_virt[0],
> tw_dev->command_packet_phys[0]);
>
> if (tw_dev->generic_buffer_virt[0])
> -   pci_free_consistent(tw_dev->tw_pci_dev,
> +   dma_free_coherent(_dev->tw_pci_dev->dev,
> TW_SECTOR_SIZE*TW_Q_LENGTH,
> tw_dev->generic_buffer_virt[0],
> tw_dev->generic_buffer_phys[0]);
>
> if (tw_dev->sense_buffer_virt[0])
> -   pci_free_consistent(tw_dev->tw_pci_dev,
> +   dma_free_coherent(_dev->tw_pci_dev->dev,
> sizeof(TW_Command_Apache_Header)*
> TW_Q_LENGTH,
> tw_dev->sense_buffer_virt[0],
> @@ -1571,14 +1571,12 @@ static int twl_probe(struct pci_dev *pdev, const 
> struct pci_device_id *dev_id)
> pci_set_master(pdev);
> pci_try_set_mwi(pdev);
>
> -   if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
> -   || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)))
> -   if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))
> -   || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
> -   TW_PRINTK(host, TW_DRIVER, 0x18, "Failed to set dma 
> mask");
> -   retval = -ENODEV;
> -   goto out_disable_device;
> -   }
> +   if (dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(64)) ||
> +   dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32))) {
> +   TW_PRINTK(host, TW_DRIVER, 0x18, "Failed to set dma mask");
> +   retval = -ENODEV;
> +   goto out_disable_device;
> +   }
>
> host = scsi_host_alloc(_template, sizeof(TW_Device_Extension));
> if (!host) {
> @@ -1805,14 +1803,12 @@ static int twl_resume(struct pci_dev *pdev)
> pci_set_master(pdev);
> pci_try_set_mwi(pdev);
>
> -   if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
> -   || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)))
> -   if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))
> -   || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
> -   TW_PRINTK(host, TW_DRIVER, 0x25, "Failed to set dma 
> mask during resume");
> -   retval = -ENODEV;
> -   goto out_disable_device;
> -   }
> +   if (dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(64)) ||
> +   dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32))) {
> +   TW_PRINTK(host, TW_DRIVER, 0x25, "Failed to set dma mask 
> during resume");
> +   retval = -ENODEV;
> +   goto out_disable_device;
> +   }
>
> /* Initialize the card */
> if (twl_reset_sequence(tw_dev, 0)) {
> --
> 2.19.1
>

Acked-by: Adam Radford 


Re: [PATCH 02/28] 3w-9xxx: fully convert to the generic DMA API

2018-10-12 Thread adam radford
0, "Failed to set dma 
> mask during resume");
> -   retval = -ENODEV;
> -   goto out_disable_device;
> -   }
> +   if (dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(64)) ||
> +   dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32))) {
> +   TW_PRINTK(host, TW_DRIVER, 0x40, "Failed to set dma mask 
> during resume");
> +   retval = -ENODEV;
> +   goto out_disable_device;
> +   }
>
> /* Initialize the card */
> if (twa_reset_sequence(tw_dev, 0)) {
> --
> 2.19.1
>

Acked-by: Adam Radford 


Re: [PATCH 03/28] 3w-xxx: fully convert to the generic DMA API

2018-10-12 Thread adam radford
On Thu, Oct 11, 2018 at 12:38 PM Christoph Hellwig  wrote:
>
> The driver is currently using an odd mix of legacy PCI DMA API and
> generic DMA API calls, switch it over to the generic API entirely.
>
> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/scsi/3w-.c | 20 ++--
>  drivers/scsi/3w-.h |  1 -
>  2 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/scsi/3w-.c b/drivers/scsi/3w-.c
> index 471366945bd4..a58257645e94 100644
> --- a/drivers/scsi/3w-.c
> +++ b/drivers/scsi/3w-.c
> @@ -834,15 +834,17 @@ static int tw_allocate_memory(TW_Device_Extension 
> *tw_dev, int size, int which)
>
> dprintk(KERN_NOTICE "3w-: tw_allocate_memory()\n");
>
> -   cpu_addr = pci_alloc_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, 
> _handle);
> +   cpu_addr = dma_alloc_coherent(_dev->tw_pci_dev->dev,
> +   size * TW_Q_LENGTH, _handle, GFP_KERNEL);
> if (cpu_addr == NULL) {
> -   printk(KERN_WARNING "3w-: pci_alloc_consistent() 
> failed.\n");
> +   printk(KERN_WARNING "3w-: dma_alloc_coherent() 
> failed.\n");
> return 1;
> }
>
> if ((unsigned long)cpu_addr % (tw_dev->tw_pci_dev->device == 
> TW_DEVICE_ID ? TW_ALIGNMENT_6000 : TW_ALIGNMENT_7000)) {
> printk(KERN_WARNING "3w-: Couldn't allocate correctly 
> aligned memory.\n");
> -   pci_free_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, 
> cpu_addr, dma_handle);
> +   dma_free_coherent(_dev->tw_pci_dev->dev, size * 
> TW_Q_LENGTH,
> +   cpu_addr, dma_handle);
> return 1;
> }
>
> @@ -1062,10 +1064,16 @@ static void 
> tw_free_device_extension(TW_Device_Extension *tw_dev)
>
> /* Free command packet and generic buffer memory */
> if (tw_dev->command_packet_virtual_address[0])
> -   pci_free_consistent(tw_dev->tw_pci_dev, 
> sizeof(TW_Command)*TW_Q_LENGTH, tw_dev->command_packet_virtual_address[0], 
> tw_dev->command_packet_physical_address[0]);
> +   dma_free_coherent(_dev->tw_pci_dev->dev,
> +   sizeof(TW_Command) * TW_Q_LENGTH,
> +   tw_dev->command_packet_virtual_address[0],
> +   tw_dev->command_packet_physical_address[0]);
>
> if (tw_dev->alignment_virtual_address[0])
> -   pci_free_consistent(tw_dev->tw_pci_dev, 
> sizeof(TW_Sector)*TW_Q_LENGTH, tw_dev->alignment_virtual_address[0], 
> tw_dev->alignment_physical_address[0]);
> +   dma_free_coherent(_dev->tw_pci_dev->dev,
> +   sizeof(TW_Sector) * TW_Q_LENGTH,
> +   tw_dev->alignment_virtual_address[0],
> +   tw_dev->alignment_physical_address[0]);
>  } /* End tw_free_device_extension() */
>
>  /* This function will send an initconnection command to controller */
> @@ -2260,7 +2268,7 @@ static int tw_probe(struct pci_dev *pdev, const struct 
> pci_device_id *dev_id)
>
> pci_set_master(pdev);
>
> -   retval = pci_set_dma_mask(pdev, TW_DMA_MASK);
> +   retval = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32));
> if (retval) {
> printk(KERN_WARNING "3w-: Failed to set dma mask.");
> goto out_disable_device;
> diff --git a/drivers/scsi/3w-.h b/drivers/scsi/3w-.h
> index 69e80c1ed1ca..bd87fbacfbc7 100644
> --- a/drivers/scsi/3w-.h
> +++ b/drivers/scsi/3w-.h
> @@ -230,7 +230,6 @@ static unsigned char tw_sense_table[][4] =
>  #define TW_IOCTL_TIMEOUT  25 /* 25 seconds */
>  #define TW_IOCTL_CHRDEV_TIMEOUT   60 /* 60 seconds */
>  #define TW_IOCTL_CHRDEV_FREE  -1
> -#define TW_DMA_MASK  DMA_BIT_MASK(32)
>  #define TW_MAX_CDB_LEN   16
>
>  /* Bitmask macros to eliminate bitfields */
> --
> 2.19.1
>

Acked-by: Adam Radford 


Re: [PATCH v2] scsi: 3w-xxxx: fix a missing-check bug

2018-05-07 Thread adam radford
On Mon, May 7, 2018 at 5:54 PM, Wenwen Wang <wang6...@umn.edu> wrote:
> In tw_chrdev_ioctl(), the length of the data buffer is firstly copied from
> the userspace pointer 'argp' and saved to the kernel object
> 'data_buffer_length'. Then a security check is performed on it to make sure
> that the length is not more than 'TW_MAX_IOCTL_SECTORS * 512'. Otherwise,
> an error code -EINVAL is returned. If the security check is passed, the
> entire ioctl command is copied again from the 'argp' pointer and saved to
> the kernel object 'tw_ioctl'. Then, various operations are performed on
> 'tw_ioctl' according to the 'cmd'. Given that the 'argp' pointer resides in
> userspace, a malicious userspace process can race to change the buffer
> length between the two copies. This way, the user can bypass the security
> check and inject invalid data buffer length. This can cause potential
> security issues in the following execution.
>
> This patch checks for capable(CAP_SYS_ADMIN) in tw_chrdev_open() to avoid
> the above issues.
>
> Signed-off-by: Wenwen Wang <wang6...@umn.edu>
> ---
>  drivers/scsi/3w-.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/scsi/3w-.c b/drivers/scsi/3w-.c
> index 33261b6..f6179e3 100644
> --- a/drivers/scsi/3w-.c
> +++ b/drivers/scsi/3w-.c
> @@ -1033,6 +1033,9 @@ static int tw_chrdev_open(struct inode *inode, struct 
> file *file)
>
> dprintk(KERN_WARNING "3w-: tw_ioctl_open()\n");
>
> +   if (!capable(CAP_SYS_ADMIN))
> +   return -EACCES;
> +
> minor_number = iminor(inode);
> if (minor_number >= tw_device_extension_count)
> return -ENODEV;
> --
> 2.7.4
>

Acked-by: Adam Radford <aradf...@gmail.com>


Re: [PATCH v2] scsi: 3w-9xxx: fix a missing-check bug

2018-05-07 Thread adam radford
On Mon, May 7, 2018 at 5:46 PM, Wenwen Wang <wang6...@umn.edu> wrote:
> In twa_chrdev_ioctl(), the ioctl driver command is firstly copied from the
> userspace pointer 'argp' and saved to the kernel object 'driver_command'.
> Then a security check is performed on the data buffer size indicated by
> 'driver_command', which is 'driver_command.buffer_length'. If the security
> check is passed, the entire ioctl command is copied again from the 'argp'
> pointer and saved to the kernel object 'tw_ioctl'. Then, various operations
> are performed on 'tw_ioctl' according to the 'cmd'. Given that the 'argp'
> pointer resides in userspace, a malicious userspace process can race to
> change the buffer size between the two copies. This way, the user can
> bypass the security check and inject invalid data buffer size. This can
> cause potential security issues in the following execution.
>
> This patch checks for capable(CAP_SYS_ADMIN) in twa_chrdev_open()t o avoid
> the above issues.
>
> Signed-off-by: Wenwen Wang <wang6...@umn.edu>
> ---
>  drivers/scsi/3w-9xxx.c | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
> index b42c9c4..99ba4a7 100644
> --- a/drivers/scsi/3w-9xxx.c
> +++ b/drivers/scsi/3w-9xxx.c
> @@ -882,6 +882,11 @@ static int twa_chrdev_open(struct inode *inode, struct 
> file *file)
> unsigned int minor_number;
> int retval = TW_IOCTL_ERROR_OS_ENODEV;
>
> +   if (!capable(CAP_SYS_ADMIN)) {
> +   retval = -EACCES;
> +   goto out;
> +   }
> +
> minor_number = iminor(inode);
>     if (minor_number >= twa_device_extension_count)
> goto out;
> --
> 2.7.4
>

Acked-by: Adam Radford <aradf...@gmail.com>


Re: [PATCH] scsi: 3w-xxxx: fix a missing-check bug

2018-05-07 Thread adam radford
On Sat, May 5, 2018 at 10:48 PM, Wenwen Wang  wrote:
> In tw_chrdev_ioctl(), the length of the data buffer is firstly copied from
> the userspace pointer 'argp' and saved to the kernel object
> 'data_buffer_length'. Then a security check is performed on it to make sure
> that the length is not more than 'TW_MAX_IOCTL_SECTORS * 512'. Otherwise,
> an error code -EINVAL is returned. If the security check is passed, the
> entire ioctl command is copied again from the 'argp' pointer and saved to
> the kernel object 'tw_ioctl'. Then, various operations are performed on
> 'tw_ioctl' according to the 'cmd'. Given that the 'argp' pointer resides in
> userspace, a malicious userspace process can race to change the buffer
> length between the two copies. This way, the user can bypass the security
> check and inject invalid data buffer length. This can cause potential
> security issues in the following execution.
>
> This patch checks the buffer length obtained in the second copy. An error
> code -EINVAL will be returned if it is not same as the original one in the
> first copy.
>
> Signed-off-by: Wenwen Wang 
> ---
>  drivers/scsi/3w-.c | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/scsi/3w-.c b/drivers/scsi/3w-.c
> index 33261b6..ef79194 100644
> --- a/drivers/scsi/3w-.c
> +++ b/drivers/scsi/3w-.c
> @@ -919,6 +919,10 @@ static long tw_chrdev_ioctl(struct file *file, unsigned 
> int cmd, unsigned long a
> /* Now copy down the entire ioctl */
> if (copy_from_user(tw_ioctl, argp, data_buffer_length + 
> sizeof(TW_New_Ioctl) - 1))
> goto out2;
> +   if (tw_ioctl->data_buffer_length != data_buffer_length) {
> +   retval = -EINVAL;
> +   goto out2;
> +   }
>
> passthru = (TW_Passthru *)_ioctl->firmware_command;
>
> --
> 2.7.4
>

I would drop this patch and check for !capable(CAP_SYS_ADMIN) in
tw_chrdev_open() instead.

-Adam


Re: [PATCH] scsi: 3w-9xxx: fix a missing-check bug

2018-05-07 Thread adam radford
On Sat, May 5, 2018 at 8:43 PM, Wenwen Wang  wrote:
> In twa_chrdev_ioctl(), the ioctl driver command is firstly copied from the
> userspace pointer 'argp' and saved to the kernel object 'driver_command'.
> Then a security check is performed on the data buffer size indicated by
> 'driver_command', which is 'driver_command.buffer_length'. If the security
> check is passed, the entire ioctl command is copied again from the 'argp'
> pointer and saved to the kernel object 'tw_ioctl'. Then, various operations
> are performed on 'tw_ioctl' according to the 'cmd'. Given that the 'argp'
> pointer resides in userspace, a malicious userspace process can race to
> change the buffer size between the two copies. This way, the user can
> bypass the security check and inject invalid data buffer size. This can
> cause potential security issues in the following execution.
>
> This patch checks the buffer size obtained in the second copy. An error
> code -EINVAL will be returned if it is not same as the original one in the
> first copy.
>
> Signed-off-by: Wenwen Wang 
> ---
>  drivers/scsi/3w-9xxx.c | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
> index b42c9c4..8bc43db 100644
> --- a/drivers/scsi/3w-9xxx.c
> +++ b/drivers/scsi/3w-9xxx.c
> @@ -684,6 +684,12 @@ static long twa_chrdev_ioctl(struct file *file, unsigned 
> int cmd, unsigned long
> if (copy_from_user(tw_ioctl, argp, driver_command.buffer_length + 
> sizeof(TW_Ioctl_Buf_Apache) - 1))
> goto out3;
>
> +   if (tw_ioctl->driver_command.buffer_length
> +!= driver_command.buffer_length) {
> +   retval = TW_IOCTL_ERROR_OS_EINVAL;
> +   goto out3;
> +   }
> +
> /* See which ioctl we are doing */
> switch (cmd) {
> case TW_IOCTL_FIRMWARE_PASS_THROUGH:
> --
> 2.7.4
>

Drop this patch and create a new one that checks for:  if
!capable(CAP_SYS_ADMIN) in twa_chrdev_ioctl() (like 3w-sas.c does) and
I'll ack it.

-Adam


Re: [PATCH] scsi: 3ware: fix a missing-check bug

2018-05-07 Thread adam radford
On Sat, May 5, 2018 at 10:50 PM, Wenwen Wang  wrote:
> In twl_chrdev_ioctl(), the ioctl driver command is firstly copied from the
> userspace pointer 'argp' and saved to the kernel object 'driver_command'.
> Then a security check is performed on the data buffer size indicated by
> 'driver_command', which is 'driver_command.buffer_length'. If the security
> check is passed, the entire ioctl command is copied again from the 'argp'
> pointer and saved to the kernel object 'tw_ioctl'. Then, various operations
> are performed on 'tw_ioctl' according to the 'cmd'. Given that the 'argp'
> pointer resides in userspace, a malicious userspace process can race to
> change the buffer size between the two copies. This way, the user can
> bypass the security check and inject invalid data buffer size. This can
> cause potential security issues in the following execution.
>
> This patch checks the buffer size obtained in the second copy. An error
> code -EINVAL will be returned if it is not same as the original one in the
> first copy.
>
> Signed-off-by: Wenwen Wang 
> ---
>  drivers/scsi/3w-sas.c | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
> index cf9f2a0..ea41969 100644
> --- a/drivers/scsi/3w-sas.c
> +++ b/drivers/scsi/3w-sas.c
> @@ -757,6 +757,11 @@ static long twl_chrdev_ioctl(struct file *file, unsigned 
> int cmd, unsigned long
> /* Now copy down the entire ioctl */
> if (copy_from_user(tw_ioctl, argp, driver_command.buffer_length + 
> sizeof(TW_Ioctl_Buf_Apache) - 1))
> goto out3;
> +   if (tw_ioctl->driver_command.buffer_length !=
> +   driver_command.buffer_length) {
> +   retval = -EINVAL;
> +   goto out3;
> +   }
>
> /* See which ioctl we are doing */
> switch (cmd) {
> --
> 2.7.4
>

1. Returning -EINVAL after the copy_from_user() doesn't prevent any
invalid copy down to kernel mode from happening.
2. twl_chrdev_open() checks for capable(CAP_SYS_ADMIN):

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/scsi/3w-sas.c#n834

I don't see the point in this patch.

-Adam


Re: [PATCH 2/3] scsi: 3ware: use 64-bit times for FW time sync

2017-11-10 Thread adam radford
On Fri, Nov 10, 2017 at 7:58 AM, Arnd Bergmann <a...@arndb.de> wrote:
> The calculation of the number of seconds since Sunday 00:00:00 overflows
> in 2106, meaning that we instead will return the seconds since Wednesday
> 06:28:16 afterwards.
>
> Using 64-bit time stamps avoids this slight inconsistency, and the
> deprecated do_gettimeofday(), replacing it with the simpler
> ktime_get_real_seconds().
>
> Signed-off-by: Arnd Bergmann <a...@arndb.de>
> ---
>  drivers/scsi/3w-9xxx.c |  8 +++-
>  drivers/scsi/3w-sas.c  | 10 --
>  2 files changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
> index cb9af3f7b653..b1c9bd9c1bfd 100644
> --- a/drivers/scsi/3w-9xxx.c
> +++ b/drivers/scsi/3w-9xxx.c
> @@ -472,11 +472,10 @@ static char *twa_aen_severity_lookup(unsigned char 
> severity_code)
>  static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id)
>  {
> u32 schedulertime;
> -   struct timeval utc;
> TW_Command_Full *full_command_packet;
> TW_Command *command_packet;
> TW_Param_Apache *param;
> -   u32 local_time;
> +   time64_t local_time;
>
> /* Fill out the command packet */
> full_command_packet = tw_dev->command_packet_virt[request_id];
> @@ -498,9 +497,8 @@ static void twa_aen_sync_time(TW_Device_Extension 
> *tw_dev, int request_id)
>
> /* Convert system time in UTC to local time seconds since last
> Sunday 12:00AM */
> -   do_gettimeofday();
> -   local_time = (u32)(utc.tv_sec - (sys_tz.tz_minuteswest * 60));
> -   schedulertime = local_time - (3 * 86400);
> +   local_time = (ktime_get_real_seconds() - (sys_tz.tz_minuteswest * 
> 60));
> +   div_u64_rem(local_time - (3 * 86400), 604800, );
> schedulertime = cpu_to_le32(schedulertime % 604800);
>
> memcpy(param->data, , sizeof(u32));
> diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
> index c283fdb3cb24..cf9f2a09b47d 100644
> --- a/drivers/scsi/3w-sas.c
> +++ b/drivers/scsi/3w-sas.c
> @@ -407,11 +407,10 @@ static int twl_aen_read_queue(TW_Device_Extension 
> *tw_dev, int request_id)
>  static void twl_aen_sync_time(TW_Device_Extension *tw_dev, int request_id)
>  {
> u32 schedulertime;
> -   struct timeval utc;
> TW_Command_Full *full_command_packet;
> TW_Command *command_packet;
> TW_Param_Apache *param;
> -   u32 local_time;
> +   time64_t local_time;
>
> /* Fill out the command packet */
> full_command_packet = tw_dev->command_packet_virt[request_id];
> @@ -433,10 +432,9 @@ static void twl_aen_sync_time(TW_Device_Extension 
> *tw_dev, int request_id)
>
> /* Convert system time in UTC to local time seconds since last
> Sunday 12:00AM */
> -   do_gettimeofday();
> -   local_time = (u32)(utc.tv_sec - (sys_tz.tz_minuteswest * 60));
> -   schedulertime = local_time - (3 * 86400);
> -   schedulertime = cpu_to_le32(schedulertime % 604800);
> +   local_time = (ktime_get_real_seconds() - (sys_tz.tz_minuteswest * 
> 60));
> +   div_u64_rem(local_time - (3 * 86400), 604800, );
> +   schedulertime = cpu_to_le32(schedulertime);
>
> memcpy(param->data, , sizeof(u32));
>
> --
> 2.9.0
>

Acked-by: Adam Radford <aradf...@gmail.com>


Re: [PATCH 1/3] scsi: 3ware: fix 32-bit time calculations

2017-11-10 Thread adam radford
On Fri, Nov 10, 2017 at 7:58 AM, Arnd Bergmann <a...@arndb.de> wrote:
> twl_aen_queue_event/twa_aen_queue_event, we use do_gettimeofday()
> to read the lower 32 bits of the current time in seconds, to pass
> them to the TW_IOCTL_GET_NEXT_EVENT ioctl or the 3ware_aen_read
> sysfs file.
>
> This will overflow on all architectures in year 2106, there is
> not much we can do about that without breaking the ABI. User
> space has 90 years to learn to deal with it, so it's probably ok.
>
> I'm changing it to use ktime_get_real_seconds() with a comment
> to document what happens when.
>
> Signed-off-by: Arnd Bergmann <a...@arndb.de>
> ---
>  drivers/scsi/3w-9xxx.c | 5 ++---
>  drivers/scsi/3w-sas.c  | 5 ++---
>  2 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
> index 00e7968a1d70..cb9af3f7b653 100644
> --- a/drivers/scsi/3w-9xxx.c
> +++ b/drivers/scsi/3w-9xxx.c
> @@ -369,7 +369,6 @@ static int twa_aen_drain_queue(TW_Device_Extension 
> *tw_dev, int no_check_reset)
>  static void twa_aen_queue_event(TW_Device_Extension *tw_dev, 
> TW_Command_Apache_Header *header)
>  {
> u32 local_time;
> -   struct timeval time;
> TW_Event *event;
> unsigned short aen;
> char host[16];
> @@ -392,8 +391,8 @@ static void twa_aen_queue_event(TW_Device_Extension 
> *tw_dev, TW_Command_Apache_H
> memset(event, 0, sizeof(TW_Event));
>
> event->severity = TW_SEV_OUT(header->status_block.severity__reserved);
> -   do_gettimeofday();
> -   local_time = (u32)(time.tv_sec - (sys_tz.tz_minuteswest * 60));
> +   /* event->time_stamp_sec overflows in y2106 */
> +   local_time = (u32)(ktime_get_real_seconds() - (sys_tz.tz_minuteswest 
> * 60));
> event->time_stamp_sec = local_time;
> event->aen_code = aen;
> event->retrieved = TW_AEN_NOT_RETRIEVED;
> diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
> index b150e131b2e7..c283fdb3cb24 100644
> --- a/drivers/scsi/3w-sas.c
> +++ b/drivers/scsi/3w-sas.c
> @@ -221,7 +221,6 @@ static char *twl_aen_severity_lookup(unsigned char 
> severity_code)
>  static void twl_aen_queue_event(TW_Device_Extension *tw_dev, 
> TW_Command_Apache_Header *header)
>  {
> u32 local_time;
> -   struct timeval time;
> TW_Event *event;
> unsigned short aen;
> char host[16];
> @@ -240,8 +239,8 @@ static void twl_aen_queue_event(TW_Device_Extension 
> *tw_dev, TW_Command_Apache_H
> memset(event, 0, sizeof(TW_Event));
>
> event->severity = TW_SEV_OUT(header->status_block.severity__reserved);
> -   do_gettimeofday();
> -   local_time = (u32)(time.tv_sec - (sys_tz.tz_minuteswest * 60));
> +   /* event->time_stamp_sec overflows in y2106 */
> +   local_time = (u32)(ktime_get_real_seconds() - (sys_tz.tz_minuteswest 
> * 60));
> event->time_stamp_sec = local_time;
> event->aen_code = aen;
> event->retrieved = TW_AEN_NOT_RETRIEVED;
> --
> 2.9.0
>

Acked-by: Adam Radford <aradf...@gmail.com>


Re: [PATCH 3/3] scsi: 3w-9xxx: rework lock timeouts

2017-11-10 Thread adam radford
On Fri, Nov 10, 2017 at 7:58 AM, Arnd Bergmann <a...@arndb.de> wrote:
> The TW_IOCTL_GET_LOCK ioctl uses do_gettimeofday() to check whether
> a lock has expired. This can misbehave due to a concurrent
> settimeofday() call, as it is based on 'real' time, and it
> will overflow in y2038 on 32-bit architectures, producing
> unexpected results when used across the overflow time.
>
> This changes it to using monotonic time, using ktime_get()
> to simplify the code.
>
> Signed-off-by: Arnd Bergmann <a...@arndb.de>
> ---
>  drivers/scsi/3w-9xxx.c | 13 ++---
>  drivers/scsi/3w-9xxx.h |  2 +-
>  2 files changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
> index b1c9bd9c1bfd..b42c9c479d4b 100644
> --- a/drivers/scsi/3w-9xxx.c
> +++ b/drivers/scsi/3w-9xxx.c
> @@ -645,8 +645,7 @@ static long twa_chrdev_ioctl(struct file *file, unsigned 
> int cmd, unsigned long
> TW_Command_Full *full_command_packet;
> TW_Compatibility_Info *tw_compat_info;
> TW_Event *event;
> -   struct timeval current_time;
> -   u32 current_time_ms;
> +   ktime_t current_time;
> TW_Device_Extension *tw_dev = 
> twa_device_extension_list[iminor(inode)];
> int retval = TW_IOCTL_ERROR_OS_EFAULT;
> void __user *argp = (void __user *)arg;
> @@ -837,17 +836,17 @@ static long twa_chrdev_ioctl(struct file *file, 
> unsigned int cmd, unsigned long
> break;
> case TW_IOCTL_GET_LOCK:
> tw_lock = (TW_Lock *)tw_ioctl->data_buffer;
> -   do_gettimeofday(_time);
> -   current_time_ms = (current_time.tv_sec * 1000) + 
> (current_time.tv_usec / 1000);
> +   current_time = ktime_get();
>
> -   if ((tw_lock->force_flag == 1) || (tw_dev->ioctl_sem_lock == 
> 0) || (current_time_ms >= tw_dev->ioctl_msec)) {
> +   if ((tw_lock->force_flag == 1) || (tw_dev->ioctl_sem_lock == 
> 0) ||
> +   ktime_after(current_time, tw_dev->ioctl_time)) {
> tw_dev->ioctl_sem_lock = 1;
> -   tw_dev->ioctl_msec = current_time_ms + 
> tw_lock->timeout_msec;
> +   tw_dev->ioctl_time = ktime_add_ms(current_time, 
> tw_lock->timeout_msec);
> tw_ioctl->driver_command.status = 0;
> tw_lock->time_remaining_msec = tw_lock->timeout_msec;
> } else {
> tw_ioctl->driver_command.status = 
> TW_IOCTL_ERROR_STATUS_LOCKED;
> -   tw_lock->time_remaining_msec = tw_dev->ioctl_msec - 
> current_time_ms;
> +   tw_lock->time_remaining_msec = 
> ktime_ms_delta(tw_dev->ioctl_time, current_time);
> }
> break;
> case TW_IOCTL_RELEASE_LOCK:
> diff --git a/drivers/scsi/3w-9xxx.h b/drivers/scsi/3w-9xxx.h
> index b6c208cc474f..d88cd3499bd5 100644
> --- a/drivers/scsi/3w-9xxx.h
> +++ b/drivers/scsi/3w-9xxx.h
> @@ -666,7 +666,7 @@ typedef struct TAG_TW_Device_Extension {
> unsigned char   event_queue_wrapped;
> unsigned interror_sequence_id;
> int ioctl_sem_lock;
> -   u32         ioctl_msec;
> +   ktime_t ioctl_time;
> int chrdev_request_id;
> wait_queue_head_t   ioctl_wqueue;
> struct mutexioctl_lock;
> --
> 2.9.0
>

Looks good...  Thanks for this fix!

Acked-by: Adam Radford <aradf...@gmail.com>


[PATCH RESEND] Update 3ware driver email addresses

2016-12-09 Thread adam radford
This change updates the 3ware drivers (3w-, 3w-9xxx, 3w-sas) email
addresses from linuxr...@lsi.com to aradf...@gmail.com, since the old
email address doesn't exist.

This patch was updated to remove www.lsi.com text.

Signed-off-by: Adam Radford <aradf...@gmail.com>
---
 MAINTAINERS| 2 +-
 drivers/scsi/3w-9xxx.c | 9 +++--
 drivers/scsi/3w-9xxx.h | 9 +++--
 drivers/scsi/3w-sas.c  | 7 ++-
 drivers/scsi/3w-sas.h  | 7 ++-
 drivers/scsi/3w-.c | 7 ++-
 drivers/scsi/3w-.h | 7 ++-
 7 files changed, 15 insertions(+), 33 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index b3a7774..1b5ddd0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -138,7 +138,7 @@ S:  Maintained
 F: drivers/net/ethernet/3com/typhoon*

 3WARE SAS/SATA-RAID SCSI DRIVERS (3W-, 3W-9XXX, 3W-SAS)
-M:     Adam Radford <linuxr...@lsi.com>
+M: Adam Radford <aradf...@gmail.com>
 L: linux-scsi@vger.kernel.org
 W: http://www.lsi.com
 S: Supported
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index a56a7b2..316f87f 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -1,8 +1,8 @@
 /*
3w-9xxx.c -- 3ware 9000 Storage Controller device driver for Linux.

-   Written By: Adam Radford <linuxr...@lsi.com>
-   Modifications By: Tom Couch <linuxr...@lsi.com>
+   Written By: Adam Radford <aradf...@gmail.com>
+   Modifications By: Tom Couch

Copyright (C) 2004-2009 Applied Micro Circuits Corporation.
Copyright (C) 2010 LSI Corporation.
@@ -41,10 +41,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Bugs/Comments/Suggestions should be mailed to:
-   linuxr...@lsi.com
-
-   For more information, goto:
-   http://www.lsi.com
+   aradf...@gmail.com

Note: This version of the driver does not contain a bundled firmware
  image.
diff --git a/drivers/scsi/3w-9xxx.h b/drivers/scsi/3w-9xxx.h
index 0fdc83c..b6c208c 100644
--- a/drivers/scsi/3w-9xxx.h
+++ b/drivers/scsi/3w-9xxx.h
@@ -1,8 +1,8 @@
 /*
3w-9xxx.h -- 3ware 9000 Storage Controller device driver for Linux.

-   Written By: Adam Radford <linuxr...@lsi.com>
-   Modifications By: Tom Couch <linuxr...@lsi.com>
+   Written By: Adam Radford <aradf...@gmail.com>
+   Modifications By: Tom Couch

Copyright (C) 2004-2009 Applied Micro Circuits Corporation.
Copyright (C) 2010 LSI Corporation.
@@ -41,10 +41,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Bugs/Comments/Suggestions should be mailed to:
-   linuxr...@lsi.com
-
-   For more information, goto:
-   http://www.lsi.com
+   aradf...@gmail.com
 */

 #ifndef _3W_9XXX_H
diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index f837485..970d8fa 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -1,7 +1,7 @@
 /*
3w-sas.c -- LSI 3ware SAS/SATA-RAID Controller device driver for Linux.

-   Written By: Adam Radford <linuxr...@lsi.com>
+   Written By: Adam Radford <aradf...@gmail.com>

Copyright (C) 2009 LSI Corporation.

@@ -43,10 +43,7 @@
LSI 3ware 9750 6Gb/s SAS/SATA-RAID

Bugs/Comments/Suggestions should be mailed to:
-   linuxr...@lsi.com
-
-   For more information, goto:
-   http://www.lsi.com
+   aradf...@gmail.com

History
---
diff --git a/drivers/scsi/3w-sas.h b/drivers/scsi/3w-sas.h
index fec6449..05e77d8 100644
--- a/drivers/scsi/3w-sas.h
+++ b/drivers/scsi/3w-sas.h
@@ -1,7 +1,7 @@
 /*
3w-sas.h -- LSI 3ware SAS/SATA-RAID Controller device driver for Linux.

-   Written By: Adam Radford <linuxr...@lsi.com>
+   Written By: Adam Radford <aradf...@gmail.com>

Copyright (C) 2009 LSI Corporation.

@@ -39,10 +39,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Bugs/Comments/Suggestions should be mailed to:
-   linuxr...@lsi.com
-
-   For more information, goto:
-   http://www.lsi.com
+   aradf...@gmail.com
 */

 #ifndef _3W_SAS_H
diff --git a/drivers/scsi/3w-.c b/drivers/scsi/3w-.c
index 25aba16..26ab5c0 100644
--- a/drivers/scsi/3w-.c
+++ b/drivers/scsi/3w-.c
@@ -1,7 +1,7 @@
 /*
3w-xxxx.c -- 3ware Storage Controller device driver for Linux.

-   Written By: Adam Radford <linuxr...@lsi.com>
+   Written By: Adam Radford <aradf...@gmail.com>
Modifications By: Joel Jacobson <li...@3ware.com>
 Arnaldo Carvalho de Melo <a...@conectiva.com.br>
  Brad Strand <li...@3ware.com>
@@ -47,10 +47,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Bugs/Comments/Suggestions should be mailed to:
-   linuxr...@lsi.com
-
-   For more information, goto:
-   http://www.lsi.com
+   aradf...@gmail.com

History
---
diff --git a/drivers/scsi/3w-.h b/drivers/scsi/3w-.h
index 6f65e66..c2575c0 100644
--- a/drivers/scsi/3w-.h
+++ b/drivers/scsi/3w-xxxx.h
@@ -1,7 

Re: [PATCH] Update 3ware driver email addresses

2016-12-07 Thread adam radford
On Thu, Nov 10, 2016 at 4:23 PM, adam radford <aradf...@gmail.com> wrote:
> This change updates the 3ware drivers (3w-, 3w-9xxx, 3w-sas) email
> addresses from linuxr...@lsi.com to aradf...@gmail.com, since the old
> email address doesn't exist.
>
> Signed-off-by: Adam Radford <aradf...@gmail.com>
> ---
>  MAINTAINERS| 2 +-
>  drivers/scsi/3w-9xxx.c | 6 +++---
>  drivers/scsi/3w-9xxx.h | 6 +++---
>  drivers/scsi/3w-sas.c  | 4 ++--
>  drivers/scsi/3w-sas.h  | 4 ++--
>  drivers/scsi/3w-.c | 4 ++--
>  drivers/scsi/3w-.h | 4 ++--
>  7 files changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index b3a7774..1b5ddd0 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -138,7 +138,7 @@ S:  Maintained
>  F: drivers/net/ethernet/3com/typhoon*
>
>  3WARE SAS/SATA-RAID SCSI DRIVERS (3W-, 3W-9XXX, 3W-SAS)
> -M: Adam Radford <linuxr...@lsi.com>
> +M: Adam Radford <aradf...@gmail.com>
>  L: linux-scsi@vger.kernel.org
>  W: http://www.lsi.com
>  S: Supported
> diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
> index a56a7b2..6de3cab 100644
> --- a/drivers/scsi/3w-9xxx.c
> +++ b/drivers/scsi/3w-9xxx.c
> @@ -1,8 +1,8 @@
>  /*
> 3w-9xxx.c -- 3ware 9000 Storage Controller device driver for Linux.
>
> -   Written By: Adam Radford <linuxr...@lsi.com>
> -   Modifications By: Tom Couch <linuxr...@lsi.com>
> +   Written By: Adam Radford <aradf...@gmail.com>
> +   Modifications By: Tom Couch
>
> Copyright (C) 2004-2009 Applied Micro Circuits Corporation.
> Copyright (C) 2010 LSI Corporation.
> @@ -41,7 +41,7 @@
> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
>
> Bugs/Comments/Suggestions should be mailed to:
> -   linuxr...@lsi.com
> +   aradf...@gmail.com
>
> For more information, goto:
> http://www.lsi.com
> diff --git a/drivers/scsi/3w-9xxx.h b/drivers/scsi/3w-9xxx.h
> index 0fdc83c..5380ce4 100644
> --- a/drivers/scsi/3w-9xxx.h
> +++ b/drivers/scsi/3w-9xxx.h
> @@ -1,8 +1,8 @@
>  /*
> 3w-9xxx.h -- 3ware 9000 Storage Controller device driver for Linux.
>
> -   Written By: Adam Radford <linuxr...@lsi.com>
> -   Modifications By: Tom Couch <linuxr...@lsi.com>
> +   Written By: Adam Radford <aradf...@gmail.com>
> +   Modifications By: Tom Couch
>
> Copyright (C) 2004-2009 Applied Micro Circuits Corporation.
> Copyright (C) 2010 LSI Corporation.
> @@ -41,7 +41,7 @@
> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
>
> Bugs/Comments/Suggestions should be mailed to:
> -   linuxr...@lsi.com
> +   aradf...@gmail.com
>
> For more information, goto:
> http://www.lsi.com
> diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
> index f837485..6840217 100644
> --- a/drivers/scsi/3w-sas.c
> +++ b/drivers/scsi/3w-sas.c
> @@ -1,7 +1,7 @@
>  /*
> 3w-sas.c -- LSI 3ware SAS/SATA-RAID Controller device driver for Linux.
>
> -   Written By: Adam Radford <linuxr...@lsi.com>
> +   Written By: Adam Radford <aradf...@gmail.com>
>
> Copyright (C) 2009 LSI Corporation.
>
> @@ -43,7 +43,7 @@
> LSI 3ware 9750 6Gb/s SAS/SATA-RAID
>
> Bugs/Comments/Suggestions should be mailed to:
> -   linuxr...@lsi.com
> +   aradf...@gmail.com
>
> For more information, goto:
> http://www.lsi.com
> diff --git a/drivers/scsi/3w-sas.h b/drivers/scsi/3w-sas.h
> index fec6449..e7b7aec 100644
> --- a/drivers/scsi/3w-sas.h
> +++ b/drivers/scsi/3w-sas.h
> @@ -1,7 +1,7 @@
>  /*
> 3w-sas.h -- LSI 3ware SAS/SATA-RAID Controller device driver for Linux.
>
> -   Written By: Adam Radford <linuxr...@lsi.com>
> +   Written By: Adam Radford <aradf...@gmail.com>
>
> Copyright (C) 2009 LSI Corporation.
>
> @@ -39,7 +39,7 @@
> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
>
>     Bugs/Comments/Suggestions should be mailed to:
> -   linuxr...@lsi.com
> +   aradf...@gmail.com
>
> For more information, goto:
> http://www.lsi.com
> diff --git a/drivers/scsi/3w-.c b/drivers/scsi/3w-.c
> index 25aba16..374648d 100644
> --- a/drivers/scsi/3w-.c
> +++ b/drivers/scsi/3w-.c
> @@ -1,7 +1,7 @@
>  /*
> 3w-.c -- 3ware Storage Controller device driver for Linux.
>
> -   Written By: Adam Radford <linuxr...@lsi.com>
> +   Written By: Adam Radford <aradf...@gmail.com>
> Modifications By: Joel Jacobson <li...@3ware.com>
>  Arnaldo Carvalho de Melo <a...@conectiva.com.br>
>   

[PATCH] Update 3ware driver email addresses

2016-11-10 Thread adam radford
This change updates the 3ware drivers (3w-, 3w-9xxx, 3w-sas) email
addresses from linuxr...@lsi.com to aradf...@gmail.com, since the old
email address doesn't exist.

Signed-off-by: Adam Radford <aradf...@gmail.com>
---
 MAINTAINERS| 2 +-
 drivers/scsi/3w-9xxx.c | 6 +++---
 drivers/scsi/3w-9xxx.h | 6 +++---
 drivers/scsi/3w-sas.c  | 4 ++--
 drivers/scsi/3w-sas.h  | 4 ++--
 drivers/scsi/3w-.c | 4 ++--
 drivers/scsi/3w-.h | 4 ++--
 7 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index b3a7774..1b5ddd0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -138,7 +138,7 @@ S:  Maintained
 F: drivers/net/ethernet/3com/typhoon*

 3WARE SAS/SATA-RAID SCSI DRIVERS (3W-, 3W-9XXX, 3W-SAS)
-M:     Adam Radford <linuxr...@lsi.com>
+M: Adam Radford <aradf...@gmail.com>
 L: linux-scsi@vger.kernel.org
 W: http://www.lsi.com
 S: Supported
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index a56a7b2..6de3cab 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -1,8 +1,8 @@
 /*
3w-9xxx.c -- 3ware 9000 Storage Controller device driver for Linux.

-   Written By: Adam Radford <linuxr...@lsi.com>
-   Modifications By: Tom Couch <linuxr...@lsi.com>
+   Written By: Adam Radford <aradf...@gmail.com>
+   Modifications By: Tom Couch

Copyright (C) 2004-2009 Applied Micro Circuits Corporation.
Copyright (C) 2010 LSI Corporation.
@@ -41,7 +41,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Bugs/Comments/Suggestions should be mailed to:
-   linuxr...@lsi.com
+   aradf...@gmail.com

For more information, goto:
http://www.lsi.com
diff --git a/drivers/scsi/3w-9xxx.h b/drivers/scsi/3w-9xxx.h
index 0fdc83c..5380ce4 100644
--- a/drivers/scsi/3w-9xxx.h
+++ b/drivers/scsi/3w-9xxx.h
@@ -1,8 +1,8 @@
 /*
3w-9xxx.h -- 3ware 9000 Storage Controller device driver for Linux.

-   Written By: Adam Radford <linuxr...@lsi.com>
-   Modifications By: Tom Couch <linuxr...@lsi.com>
+   Written By: Adam Radford <aradf...@gmail.com>
+   Modifications By: Tom Couch

Copyright (C) 2004-2009 Applied Micro Circuits Corporation.
Copyright (C) 2010 LSI Corporation.
@@ -41,7 +41,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Bugs/Comments/Suggestions should be mailed to:
-   linuxr...@lsi.com
+   aradf...@gmail.com

For more information, goto:
http://www.lsi.com
diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index f837485..6840217 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -1,7 +1,7 @@
 /*
3w-sas.c -- LSI 3ware SAS/SATA-RAID Controller device driver for Linux.

-   Written By: Adam Radford <linuxr...@lsi.com>
+   Written By: Adam Radford <aradf...@gmail.com>

Copyright (C) 2009 LSI Corporation.

@@ -43,7 +43,7 @@
LSI 3ware 9750 6Gb/s SAS/SATA-RAID

Bugs/Comments/Suggestions should be mailed to:
-   linuxr...@lsi.com
+   aradf...@gmail.com

For more information, goto:
http://www.lsi.com
diff --git a/drivers/scsi/3w-sas.h b/drivers/scsi/3w-sas.h
index fec6449..e7b7aec 100644
--- a/drivers/scsi/3w-sas.h
+++ b/drivers/scsi/3w-sas.h
@@ -1,7 +1,7 @@
 /*
3w-sas.h -- LSI 3ware SAS/SATA-RAID Controller device driver for Linux.

-   Written By: Adam Radford <linuxr...@lsi.com>
+   Written By: Adam Radford <aradf...@gmail.com>

Copyright (C) 2009 LSI Corporation.

@@ -39,7 +39,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Bugs/Comments/Suggestions should be mailed to:
-   linuxr...@lsi.com
+   aradf...@gmail.com

For more information, goto:
http://www.lsi.com
diff --git a/drivers/scsi/3w-.c b/drivers/scsi/3w-.c
index 25aba16..374648d 100644
--- a/drivers/scsi/3w-.c
+++ b/drivers/scsi/3w-.c
@@ -1,7 +1,7 @@
 /*
3w-xxxx.c -- 3ware Storage Controller device driver for Linux.

-   Written By: Adam Radford <linuxr...@lsi.com>
+   Written By: Adam Radford <aradf...@gmail.com>
Modifications By: Joel Jacobson <li...@3ware.com>
 Arnaldo Carvalho de Melo <a...@conectiva.com.br>
  Brad Strand <li...@3ware.com>
@@ -47,7 +47,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Bugs/Comments/Suggestions should be mailed to:
-   linuxr...@lsi.com
+   aradf...@gmail.com

For more information, goto:
http://www.lsi.com
diff --git a/drivers/scsi/3w-.h b/drivers/scsi/3w-.h
index 6f65e66..5a5a5d2 100644
--- a/drivers/scsi/3w-.h
+++ b/drivers/scsi/3w-xxxx.h
@@ -1,7 +1,7 @@
 /*
3w-.h -- 3ware Storage Controller device driver for Linux.

-   Written By: Adam Radford <linuxr...@lsi.com>
+   Written By: Adam Radford <aradf...@gmail.com>
Modifications By: Joel Jacobson <li...@3ware.com>
  

Re: Delivery Status Notification for linuxr...@lsi.com

2016-11-10 Thread adam radford
On Thu, Nov 10, 2016 at 10:42 AM, James Bottomley
 wrote:
> It would look a lot better if you submitted the patch to change this
> rather than having git history show someone else dumping it on you ...

Sure, I will do that.

-Aadm
--
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: Delivery Status Notification for linuxr...@lsi.com

2016-11-10 Thread adam radford
On Thu, Nov 10, 2016 at 6:07 AM, Martin K. Petersen
 wrote:
> Ownership of these products is now with Broadcom. To my knowledge the
> 3ware product lines have been discontinued.

That is true.  I am still lurking on this list, if you want to update
the email address to:  aradf...@gmail.com, I'm fine with that.  I'll
probably reply if there is something I can help with.

-Adam
--
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] 3w-9xxx: don't unmap bounce buffered commands

2015-10-05 Thread adam radford
On Sat, Oct 3, 2015 at 10:16 AM, Christoph Hellwig <h...@lst.de> wrote:
> 3w controller don't dma map small single SGL entry commands but instead
> bounce buffer them.  Add a helper to identify these commands and don't
> call scsi_dma_unmap for them.
>
> Based on an earlier patch from James Bottomley.
>
> Fixes: 118c85 ("3w-9xxx: fix command completion race")
> Reported-by: T??th Attila <at...@atoth.sote.hu>
> Tested-by: T??th Attila <at...@atoth.sote.hu>
> Signed-off-by: Christoph Hellwig <h...@lst.de>
> ---
>  drivers/scsi/3w-9xxx.c | 28 +---
>  1 file changed, 21 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
> index add419d..a56a7b2 100644
> --- a/drivers/scsi/3w-9xxx.c
> +++ b/drivers/scsi/3w-9xxx.c
> @@ -212,6 +212,17 @@ static const struct file_operations twa_fops = {
> .llseek = noop_llseek,
>  };
>
> +/*
> + * The controllers use an inline buffer instead of a mapped SGL for small,
> + * single entry buffers.  Note that we treat a zero-length transfer like
> + * a mapped SGL.
> + */
> +static bool twa_command_mapped(struct scsi_cmnd *cmd)
> +{
> +   return scsi_sg_count(cmd) != 1 ||
> +   scsi_bufflen(cmd) >= TW_MIN_SGL_LENGTH;
> +}
> +
>  /* This function will complete an aen request from the isr */
>  static int twa_aen_complete(TW_Device_Extension *tw_dev, int request_id)
>  {
> @@ -1339,7 +1350,8 @@ static irqreturn_t twa_interrupt(int irq, void 
> *dev_instance)
> }
>
> /* Now complete the io */
> -   scsi_dma_unmap(cmd);
> +   if (twa_command_mapped(cmd))
> +   scsi_dma_unmap(cmd);
> cmd->scsi_done(cmd);
> tw_dev->state[request_id] = TW_S_COMPLETED;
> twa_free_request_id(tw_dev, request_id);
> @@ -1582,7 +1594,8 @@ static int 
> twa_reset_device_extension(TW_Device_Extension *tw_dev)
> struct scsi_cmnd *cmd = tw_dev->srb[i];
>
> cmd->result = (DID_RESET << 16);
> -   scsi_dma_unmap(cmd);
> +   if (twa_command_mapped(cmd))
> +   scsi_dma_unmap(cmd);
> cmd->scsi_done(cmd);
> }
> }
> @@ -1765,12 +1778,14 @@ static int twa_scsi_queue_lck(struct scsi_cmnd 
> *SCpnt, void (*done)(struct scsi_
> retval = twa_scsiop_execute_scsi(tw_dev, request_id, NULL, 0, NULL);
> switch (retval) {
> case SCSI_MLQUEUE_HOST_BUSY:
> -   scsi_dma_unmap(SCpnt);
> +   if (twa_command_mapped(SCpnt))
> +   scsi_dma_unmap(SCpnt);
> twa_free_request_id(tw_dev, request_id);
> break;
> case 1:
> SCpnt->result = (DID_ERROR << 16);
> -   scsi_dma_unmap(SCpnt);
> +   if (twa_command_mapped(SCpnt))
> +   scsi_dma_unmap(SCpnt);
> done(SCpnt);
> tw_dev->state[request_id] = TW_S_COMPLETED;
> twa_free_request_id(tw_dev, request_id);
> @@ -1831,8 +1846,7 @@ static int twa_scsiop_execute_scsi(TW_Device_Extension 
> *tw_dev, int request_id,
> /* Map sglist from scsi layer to cmd packet */
>
> if (scsi_sg_count(srb)) {
> -   if ((scsi_sg_count(srb) == 1) &&
> -   (scsi_bufflen(srb) < TW_MIN_SGL_LENGTH)) {
> +   if (!twa_command_mapped(srb)) {
> if (srb->sc_data_direction == DMA_TO_DEVICE ||
> srb->sc_data_direction == 
> DMA_BIDIRECTIONAL)
> scsi_sg_copy_to_buffer(srb,
> @@ -1905,7 +1919,7 @@ static void 
> twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int re
>  {
> struct scsi_cmnd *cmd = tw_dev->srb[request_id];
>
> -   if (scsi_bufflen(cmd) < TW_MIN_SGL_LENGTH &&
> +   if (!twa_command_mapped(cmd) &&
> (cmd->sc_data_direction == DMA_FROM_DEVICE ||
>  cmd->sc_data_direction == DMA_BIDIRECTIONAL)) {
> if (scsi_sg_count(cmd) == 1) {
> --
> 1.9.1
>

Christoph/James,

Thanks for fixing this.  The patch looks good to me.

Acked-by: Adam Radford <aradf...@gmail.com>

-Adam
--
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: twa generates WARNING upon boot

2015-09-27 Thread adam radford
On Sun, Sep 27, 2015 at 4:56 AM, "Tóth Attila"  wrote:
> After an unsuccessful attempt to contact linuxr...@lsi.com, I'm trying to
> seek assistance on this list.
>
> I've been seeing WARNINGs upon boot for a while now, without any obvious
> symptoms. I got some advice to report it upstream on the hardened-gentoo
> mailing list from PaX Team:
>
> "twa_interrupt is from the 3ware 9xxx driver and it seems that it wants to
> unmap a page it doesn't own. DEBUG_INFO and addr2line would help to
> identify the bad call in twa_interrupt ( in the below
> trace) then you can send it upstream ;)."
> Where  was an address taken from a previous trace.
>
> I've recompiled the kernel with DEBUG_INFO and FRAME_POINTERS enabled.
>
> Here is a current trace I see after booting that kernel:
> [ cut here ]
> WARNING: CPU: 0 PID: 1 at drivers/iommu/intel-iommu.c:3214
> intel_unmap+0x186/0x1f0()
> Driver unmaps unmatched page at PFN 0
> Modules linked in:
> CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.1.7-hardened-r1 #2
> Hardware name: System manufacturer System Product Name/Z8P(N)E-D12(X),
> BIOS 130206/25/2012
>  ab40bd6b   ab21608f
>  880237c03ca8 a4ed0fa6 15d2 880237c03d00
>  880237c03ce8 a40ad9a0  ab21608f
> Call Trace:
>[] dump_stack+0x45/0x5d
>  [] warn_slowpath_common+0x80/0xc0
>  [] warn_slowpath_fmt+0x64/0x90
>  [] intel_unmap+0x186/0x1f0
>  [] intel_unmap_sg+0x1a/0x30
>  [] scsi_dma_unmap+0x73/0x90
>  [] twa_interrupt+0x493/0x780
>  [] handle_irq_event_percpu+0x7a/0x130
>  [] handle_irq_event+0x39/0x60
>  [] handle_fasteoi_irq+0x89/0x1a0
>  [] handle_irq+0x85/0x160
>  [] do_IRQ+0x4c/0x100
>  [] common_interrupt+0x97/0x97
>[] ?
> default_send_IPI_mask_allbutself_phys+0xbc/0x100
>  [] physflat_send_IPI_allbutself+0x19/0x30
>  [] native_send_call_func_ipi+0x108/0x140
>  [] ? proc_dma_show+0x70/0x70
>  [] smp_call_function_many+0x1c4/0x270
>  [] kick_all_cpus_sync+0x21/0x30
>  [] __do_tune_cpucache+0x56/0x4d0
>  [] ? string.isra.3+0x47/0x100
>  [] do_tune_cpucache+0x37/0xb0
>  [] enable_cpucache+0x65/0x130
>  [] setup_cpu_cache+0x173/0x270
>  [] __kmem_cache_create+0x262/0x360
>  [] do_kmem_cache_create+0x92/0x1d0
>  [] kmem_cache_create+0x11e/0x1d0
>  [] ? twa_init+0x36/0x36
>  [] init_sd+0xd7/0x198
>  [] do_one_initcall+0x94/0x1a0
>  [] kernel_init_freeable+0x183/0x22f
>  [] ? rest_init+0x80/0x80
>  [] kernel_init+0x9/0xf0
>  [] ret_from_fork+0x3e/0x70
>  [] ? rest_init+0x80/0x80
> ---[ end trace a39a5826ea41aa47 ]---
>
> The 3ware card is a 9650SE-12ML running in a Asus Z8PE-D12X motherboard.
>
> I don't know the exact command I have to type to get a meaningful output
> for addr2line...
>
> Please let me know what else I should do in order to provide more info.

Can you re-try with Christoph's patch:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=118c855b5623f3e2e6204f02623d88c09e0c34de

-Adam
--
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] 3w-sas: fix command completion race

2015-04-23 Thread adam radford
 a/drivers/scsi/3w-sas.h b/drivers/scsi/3w-sas.h
 index d474892..fec6449 100644
 --- a/drivers/scsi/3w-sas.h
 +++ b/drivers/scsi/3w-sas.h
 @@ -103,10 +103,6 @@ static char *twl_aen_severity_table[] =
  #define TW_CURRENT_DRIVER_BUILD 0
  #define TW_CURRENT_DRIVER_BRANCH 0

 -/* Phase defines */
 -#define TW_PHASE_INITIAL 0
 -#define TW_PHASE_SGLIST  2
 -
  /* Misc defines */
  #define TW_SECTOR_SIZE512
  #define TW_MAX_UNITS 32
 --
 1.9.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

Christoph,

Thanks for the patches!  LGTM.

Acked-by: Adam Radford aradf...@gmail.com
--
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] 3w-9xxx: fix command completion race

2015-04-23 Thread adam radford
,
 command_packet-sg_list[0].address = 
 TW_CPU_TO_SGL(tw_dev-generic_buffer_phys[request_id]);
 command_packet-sg_list[0].length = 
 cpu_to_le32(TW_MIN_SGL_LENGTH);
 } else {
 -   sg_count = twa_map_scsi_sg_data(tw_dev, 
 request_id);
 -   if (sg_count == 0)
 +   sg_count = scsi_dma_map(srb);
 +   if (sg_count  0)
 goto out;

 scsi_for_each_sg(srb, sg, sg_count, i) {
 @@ -1979,15 +1957,6 @@ static char *twa_string_lookup(twa_message_type 
 *table, unsigned int code)
 return(table[index].text);
  } /* End twa_string_lookup() */

 -/* This function will perform a pci-dma unmap */
 -static void twa_unmap_scsi_data(TW_Device_Extension *tw_dev, int request_id)
 -{
 -   struct scsi_cmnd *cmd = tw_dev-srb[request_id];
 -
 -   if (cmd-SCp.phase == TW_PHASE_SGLIST)
 -   scsi_dma_unmap(cmd);
 -} /* End twa_unmap_scsi_data() */
 -
  /* This function gets called when a disk is coming on-line */
  static int twa_slave_configure(struct scsi_device *sdev)
  {
 diff --git a/drivers/scsi/3w-9xxx.h b/drivers/scsi/3w-9xxx.h
 index 040f721..0fdc83c 100644
 --- a/drivers/scsi/3w-9xxx.h
 +++ b/drivers/scsi/3w-9xxx.h
 @@ -324,11 +324,6 @@ static twa_message_type twa_error_table[] = {
  #define TW_CURRENT_DRIVER_BUILD 0
  #define TW_CURRENT_DRIVER_BRANCH 0

 -/* Phase defines */
 -#define TW_PHASE_INITIAL 0
 -#define TW_PHASE_SINGLE  1
 -#define TW_PHASE_SGLIST  2
 -
  /* Misc defines */
  #define TW_9550SX_DRAIN_COMPLETED0x
  #define TW_SECTOR_SIZE512
 --
 1.9.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

Acked-by: Adam Radford aradf...@gmail.com
--
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] 3w-xxxx: fix command completion race

2015-04-23 Thread adam radford
On Thu, Apr 23, 2015 at 12:48 AM, Christoph Hellwig h...@lst.de wrote:
 The 3w- driver needs to tear down the dma mappings before returning
 the command to the midlayer, as there is no guarantee the sglist and
 count are valid after that point.  Also remove the dma mapping helpers
 which have another inherent race due to the request_id index.

 Signed-off-by: Christoph Hellwig h...@lst.de
 Cc: sta...@vger.kernel.org
 ---
  drivers/scsi/3w-.c | 42 ++
  drivers/scsi/3w-.h |  5 -
  2 files changed, 6 insertions(+), 41 deletions(-)

 diff --git a/drivers/scsi/3w-.c b/drivers/scsi/3w-.c
 index c75f204..2940bd7 100644
 --- a/drivers/scsi/3w-.c
 +++ b/drivers/scsi/3w-.c
 @@ -1271,32 +1271,6 @@ static int 
 tw_initialize_device_extension(TW_Device_Extension *tw_dev)
 return 0;
  } /* End tw_initialize_device_extension() */

 -static int tw_map_scsi_sg_data(struct pci_dev *pdev, struct scsi_cmnd *cmd)
 -{
 -   int use_sg;
 -
 -   dprintk(KERN_WARNING 3w-: tw_map_scsi_sg_data()\n);
 -
 -   use_sg = scsi_dma_map(cmd);
 -   if (use_sg  0) {
 -   printk(KERN_WARNING 3w-: tw_map_scsi_sg_data(): 
 pci_map_sg() failed.\n);
 -   return 0;
 -   }
 -
 -   cmd-SCp.phase = TW_PHASE_SGLIST;
 -   cmd-SCp.have_data_in = use_sg;
 -
 -   return use_sg;
 -} /* End tw_map_scsi_sg_data() */
 -
 -static void tw_unmap_scsi_data(struct pci_dev *pdev, struct scsi_cmnd *cmd)
 -{
 -   dprintk(KERN_WARNING 3w-: tw_unmap_scsi_data()\n);
 -
 -   if (cmd-SCp.phase == TW_PHASE_SGLIST)
 -   scsi_dma_unmap(cmd);
 -} /* End tw_unmap_scsi_data() */
 -
  /* This function will reset a device extension */
  static int tw_reset_device_extension(TW_Device_Extension *tw_dev)
  {
 @@ -1319,8 +1293,8 @@ static int 
 tw_reset_device_extension(TW_Device_Extension *tw_dev)
 srb = tw_dev-srb[i];
 if (srb != NULL) {
 srb-result = (DID_RESET  16);
 -   tw_dev-srb[i]-scsi_done(tw_dev-srb[i]);
 -   tw_unmap_scsi_data(tw_dev-tw_pci_dev, 
 tw_dev-srb[i]);
 +   scsi_dma_unmap(srb);
 +   srb-scsi_done(srb);
 }
 }
 }
 @@ -1767,8 +1741,8 @@ static int tw_scsiop_read_write(TW_Device_Extension 
 *tw_dev, int request_id)
 command_packet-byte8.io.lba = lba;
 command_packet-byte6.block_count = num_sectors;

 -   use_sg = tw_map_scsi_sg_data(tw_dev-tw_pci_dev, 
 tw_dev-srb[request_id]);
 -   if (!use_sg)
 +   use_sg = scsi_dma_map(srb);
 +   if (use_sg = 0)
 return 1;

 scsi_for_each_sg(tw_dev-srb[request_id], sg, use_sg, i) {
 @@ -1955,9 +1929,6 @@ static int tw_scsi_queue_lck(struct scsi_cmnd *SCpnt, 
 void (*done)(struct scsi_c
 /* Save the scsi command for use by the ISR */
 tw_dev-srb[request_id] = SCpnt;

 -   /* Initialize phase to zero */
 -   SCpnt-SCp.phase = TW_PHASE_INITIAL;
 -
 switch (*command) {
 case READ_10:
 case READ_6:
 @@ -2185,12 +2156,11 @@ static irqreturn_t tw_interrupt(int irq, void 
 *dev_instance)

 /* Now complete the io */
 if ((error != TW_ISR_DONT_COMPLETE)) {
 +   
 scsi_dma_unmap(tw_dev-srb[request_id]);
 +   
 tw_dev-srb[request_id]-scsi_done(tw_dev-srb[request_id]);
 tw_dev-state[request_id] = 
 TW_S_COMPLETED;
 tw_state_request_finish(tw_dev, 
 request_id);
 tw_dev-posted_request_count--;
 -   
 tw_dev-srb[request_id]-scsi_done(tw_dev-srb[request_id]);
 -
 -   
 tw_unmap_scsi_data(tw_dev-tw_pci_dev, tw_dev-srb[request_id]);
 }
 }

 diff --git a/drivers/scsi/3w-.h b/drivers/scsi/3w-.h
 index 29b0b84e..6f65e66 100644
 --- a/drivers/scsi/3w-.h
 +++ b/drivers/scsi/3w-.h
 @@ -195,11 +195,6 @@ static unsigned char tw_sense_table[][4] =
  #define TW_AEN_SMART_FAIL0x000F
  #define TW_AEN_SBUF_FAIL 0x0024

 -/* Phase defines */
 -#define TW_PHASE_INITIAL 0
 -#define TW_PHASE_SINGLE 1
 -#define TW_PHASE_SGLIST 2
 -
  /* Misc defines */
  #define TW_ALIGNMENT_600064 /* 64 bytes */
  #define TW_ALIGNMENT_7000 4  /* 4 bytes */
 --
 1.9.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

Acked-by: Adam Radford aradf...@gmail.com

Re: [PATCH] scsi: 3w-9xxx.c: Cleaning up missing null-terminate in conjunction with strncpy

2014-12-22 Thread adam radford
On Mon, Dec 22, 2014 at 2:52 PM, Rickard Strandqvist
rickard_strandqv...@spectrumdigital.se wrote:
 2014-08-01 0:19 GMT+02:00 adam radford aradf...@gmail.com:
 On Sun, Jul 27, 2014 at 8:11 AM, Rickard Strandqvist
 rickard_strandqv...@spectrumdigital.se wrote:
 Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
 And use the sizeof on the to string rather than strlen on the from string.

 Signed-off-by: Rickard Strandqvist rickard_strandqv...@spectrumdigital.se
 ---
  drivers/scsi/3w-9xxx.c |3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

 diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
 index 0a73253..f4d2331 100644
 --- a/drivers/scsi/3w-9xxx.c
 +++ b/drivers/scsi/3w-9xxx.c
 @@ -621,7 +621,8 @@ static int twa_check_srl(TW_Device_Extension *tw_dev, 
 int *flashed)
 }

 /* Load rest of compatibility struct */
 -   strncpy(tw_dev-tw_compat_info.driver_version, TW_DRIVER_VERSION, 
 strlen(TW_DRIVER_VERSION));
 +   strlcpy(tw_dev-tw_compat_info.driver_version, TW_DRIVER_VERSION,
 +   sizeof(tw_dev-tw_compat_info.driver_version));
 tw_dev-tw_compat_info.driver_srl_high = TW_CURRENT_DRIVER_SRL;
 tw_dev-tw_compat_info.driver_branch_high = 
 TW_CURRENT_DRIVER_BRANCH;
 tw_dev-tw_compat_info.driver_build_high = TW_CURRENT_DRIVER_BUILD;
 --
 1.7.10.4

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

 Rickard,

 This patch looks fine.

 Acked-by: Adam Radford aradf...@gmail.com

 -Adam


 Hi Adam!

 What happened to this patch?

It just didn't get picked up into scsi.git/for-next for some reason.

All I can do is Ack it, which I already did :)

-Adam
--
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: [ANNOUNCE] scsi patch queue tree updated

2014-08-21 Thread adam radford
On Fri, Aug 1, 2014 at 5:20 AM, Christoph Hellwig h...@infradead.org wrote:
 I've pushed out updates to both the core-for-3.17 and drivers-for-3.17
 branches.  I think we're in a good shape for the merge window, but
 I'd still like to get reviewers attention for a few driver updates that
 I'd love to get in still:

  - my eata patch to remove the driver_lock
  - the partially reviewed megaraid series

Christoph,

Can we get someone to finish reviewing the megaraid_sas patch series ?
 Or let me know if anything else needs to be corrected ?

I know it has been reviewed by yourself and Martin Petersen so far,
however, I could not find the patch series in:

http://git.infradead.org/users/hch/scsi-queue.git/shortlog/refs/heads/drivers-for-3.18

-Adam
--
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: 3w-9xxx.c: Cleaning up missing null-terminate in conjunction with strncpy

2014-07-31 Thread adam radford
On Sun, Jul 27, 2014 at 8:11 AM, Rickard Strandqvist
rickard_strandqv...@spectrumdigital.se wrote:
 Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
 And use the sizeof on the to string rather than strlen on the from string.

 Signed-off-by: Rickard Strandqvist rickard_strandqv...@spectrumdigital.se
 ---
  drivers/scsi/3w-9xxx.c |3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

 diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
 index 0a73253..f4d2331 100644
 --- a/drivers/scsi/3w-9xxx.c
 +++ b/drivers/scsi/3w-9xxx.c
 @@ -621,7 +621,8 @@ static int twa_check_srl(TW_Device_Extension *tw_dev, int 
 *flashed)
 }

 /* Load rest of compatibility struct */
 -   strncpy(tw_dev-tw_compat_info.driver_version, TW_DRIVER_VERSION, 
 strlen(TW_DRIVER_VERSION));
 +   strlcpy(tw_dev-tw_compat_info.driver_version, TW_DRIVER_VERSION,
 +   sizeof(tw_dev-tw_compat_info.driver_version));
 tw_dev-tw_compat_info.driver_srl_high = TW_CURRENT_DRIVER_SRL;
 tw_dev-tw_compat_info.driver_branch_high = TW_CURRENT_DRIVER_BRANCH;
 tw_dev-tw_compat_info.driver_build_high = TW_CURRENT_DRIVER_BUILD;
 --
 1.7.10.4

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

Rickard,

This patch looks fine.

Acked-by: Adam Radford aradf...@gmail.com

-Adam
--
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 4/5] megaraid_sas: Add missing initial call to megasas_get_ld_vf_affiliation().

2014-07-09 Thread Adam Radford
The following patch for megaraid_sas adds a missing initial call to
megasas_get_ld_vf_affiliation() at the end of megasas_probe_one().

Signed-off-by: Adam Radford aradf...@gmail.com
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index b4c032c..6db5c12 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4992,6 +4992,10 @@ retry_irq_register:
goto fail_start_aen;
}
 
+   /* Get current SR-IOV LD/VF affiliation */
+   if (instance-requestorId)
+   megasas_get_ld_vf_affiliation(instance, 1);
+
return 0;
 
   fail_start_aen:
-- 
1.7.11.7

--
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 2/5] megaraid_sas: Remove unused variables in megasas_instance

2014-07-09 Thread Adam Radford
The following patch for megaraid_sas removes some unused variables from the 
megasas_instance structure.

Reviewed-by: Martin K. Petersen martin.peter...@oracle.com
Signed-off-by: Adam Radford aradf...@gmail.com
---
 drivers/scsi/megaraid/megaraid_sas.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 32166c2..7d722fb 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1633,8 +1633,6 @@ struct megasas_instance {
struct timer_list sriov_heartbeat_timer;
char skip_heartbeat_timer_del;
u8 requestorId;
-   u64 initiator_sas_address;
-   u64 ld_sas_address[64];
char PlasmaFW111;
char mpio;
int throttlequeuedepth;
-- 
1.7.11.7

--
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/5] megaraid_sas: Update for scsi for-next

2014-07-09 Thread Adam Radford
(Re-sending again based on feedback from Christoph Hellwig  Martin Petersen)

The following patch series for megaraid_sas brings the driver up to
v06.803.02.00-rc1.

1. Fix reset_mutex leak in megasas_reset_fusion().
2. Remove unused variables in megasas_instance.
3. Fix LD/VF affiliation parsing.
4. Add missing initial call to megasas_get_ld_vf_affiliation().
5. Version and Changelog update.

Adam Radford (5):
  megaraid_sas: Fix reset_mutex leak
  megaraid_sas: Remove unused variables in megasas_instance
  megaraid_sas: Fix LD/VF affiliation parsing
  megaraid_sas: Add missing initial call to
megasas_get_ld_vf_affiliation().
  megaraid_sas: Version and Changelog update

 Documentation/scsi/ChangeLog.megaraid_sas   |  14 ++
 drivers/scsi/megaraid/megaraid_sas.h|   9 +-
 drivers/scsi/megaraid/megaraid_sas_base.c   | 324 ++--
 drivers/scsi/megaraid/megaraid_sas_fusion.c |   1 +
 4 files changed, 231 insertions(+), 117 deletions(-)

-- 
1.7.11.7

--
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/5] megaraid_sas: Fix LD/VF affiliation parsing

2014-07-09 Thread Adam Radford
The following patch for megaraid_sas fixes the LD/VF affiliation policy parsing
code to account for LD targetId's and Hidden LD's (not yet affiliated with any
Virtual Functions).  This also breaks megasas_get_ld_vf_affiliation() into 2
separate functions:  megasas_get_ld_vf_affiliation_111() and
megasas_get_ld_Vf_affiliation_12() to reduce indentation levels.

Signed-off-by: Adam Radford aradf...@gmail.com
---
 drivers/scsi/megaraid/megaraid_sas.h  |   1 +
 drivers/scsi/megaraid/megaraid_sas_base.c | 318 +++---
 2 files changed, 208 insertions(+), 111 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 7d722fb..2e2fcb2 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1659,6 +1659,7 @@ struct MR_LD_VF_AFFILIATION {
 /* Plasma 1.11 FW backward compatibility structures */
 #define IOV_111_OFFSET 0x7CE
 #define MAX_VIRTUAL_FUNCTIONS 8
+#define MR_LD_ACCESS_HIDDEN 15
 
 struct IOV_111 {
u8 maxVFsSupported;
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 112799b..b4c032c 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1825,16 +1825,12 @@ void megasas_do_ocr(struct megasas_instance *instance)
process_fw_state_change_wq(instance-work_init);
 }
 
-/* This function will get the current SR-IOV LD/VF affiliation */
-static int megasas_get_ld_vf_affiliation(struct megasas_instance *instance,
-   int initial)
+static int megasas_get_ld_vf_affiliation_111(struct megasas_instance *instance,
+   int initial)
 {
struct megasas_cmd *cmd;
struct megasas_dcmd_frame *dcmd;
-   struct MR_LD_VF_AFFILIATION *new_affiliation = NULL;
struct MR_LD_VF_AFFILIATION_111 *new_affiliation_111 = NULL;
-   struct MR_LD_VF_MAP *newmap = NULL, *savedmap = NULL;
-   dma_addr_t new_affiliation_h;
dma_addr_t new_affiliation_111_h;
int ld, retval = 0;
u8 thisVf;
@@ -1842,15 +1838,15 @@ static int megasas_get_ld_vf_affiliation(struct 
megasas_instance *instance,
cmd = megasas_get_cmd(instance);
 
if (!cmd) {
-   printk(KERN_DEBUG megasas: megasas_get_ld_vf_
-  affiliation: Failed to get cmd for scsi%d.\n,
+   printk(KERN_DEBUG megasas: megasas_get_ld_vf_affiliation_111:
+  Failed to get cmd for scsi%d.\n,
instance-host-host_no);
return -ENOMEM;
}
 
dcmd = cmd-frame-dcmd;
 
-   if (!instance-vf_affiliation  !instance-vf_affiliation_111) {
+   if (!instance-vf_affiliation_111) {
printk(KERN_WARNING megasas: SR-IOV: Couldn't get LD/VF 
   affiliation for scsi%d.\n, instance-host-host_no);
megasas_return_cmd(instance, cmd);
@@ -1858,38 +1854,22 @@ static int megasas_get_ld_vf_affiliation(struct 
megasas_instance *instance,
}
 
if (initial)
-   if (instance-PlasmaFW111)
memset(instance-vf_affiliation_111, 0,
   sizeof(struct MR_LD_VF_AFFILIATION_111));
-   else
-   memset(instance-vf_affiliation, 0,
-  (MAX_LOGICAL_DRIVES + 1) *
-  sizeof(struct MR_LD_VF_AFFILIATION));
else {
-   if (instance-PlasmaFW111)
-   new_affiliation_111 =
-   pci_alloc_consistent(instance-pdev,
-sizeof(struct 
MR_LD_VF_AFFILIATION_111),
-new_affiliation_111_h);
-   else
-   new_affiliation =
-   pci_alloc_consistent(instance-pdev,
-(MAX_LOGICAL_DRIVES + 1) *
-sizeof(struct 
MR_LD_VF_AFFILIATION),
-new_affiliation_h);
-   if (!new_affiliation  !new_affiliation_111) {
+   new_affiliation_111 =
+   pci_alloc_consistent(instance-pdev,
+sizeof(struct 
MR_LD_VF_AFFILIATION_111),
+new_affiliation_111_h);
+   if (!new_affiliation_111) {
printk(KERN_DEBUG megasas: SR-IOV: Couldn't allocate 
   memory for new affiliation for scsi%d.\n,
-   instance-host-host_no);
+  instance-host-host_no);
megasas_return_cmd(instance, cmd);
return -ENOMEM;
}
-   if (instance

[PATCH 1/5] megaraid_sas: Fix reset_mutex leak

2014-07-09 Thread Adam Radford
The following patch for megaraid_sas fixes a reset_mutex leak in 
megasas_reset_fusion().

Reviewed-by: Martin K. Petersen martin.peter...@oracle.com
Signed-off-by: Adam Radford aradf...@gmail.com
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 2260041..0858851 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -2355,6 +2355,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int 
iotimeout)
printk(KERN_WARNING megaraid_sas: Hardware critical error, 
   returning FAILED for scsi%d.\n,
instance-host-host_no);
+   mutex_unlock(instance-reset_mutex);
return FAILED;
}
 
-- 
1.7.11.7

--
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 5/5] megaraid_sas: Version and Changelog update

2014-07-09 Thread Adam Radford
The following patch for megaraid_sas updates the driver version and
Documentation/scsi/ChangeLog.megaraid_sas.

Reviewed-by: Martin K. Petersen martin.peter...@oracle.com
Signed-off-by: Adam Radford aradf...@gmail.com
---
 Documentation/scsi/ChangeLog.megaraid_sas | 14 ++
 drivers/scsi/megaraid/megaraid_sas.h  |  6 +++---
 drivers/scsi/megaraid/megaraid_sas_base.c |  2 +-
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/Documentation/scsi/ChangeLog.megaraid_sas 
b/Documentation/scsi/ChangeLog.megaraid_sas
index 91ba58e..18b5709 100644
--- a/Documentation/scsi/ChangeLog.megaraid_sas
+++ b/Documentation/scsi/ChangeLog.megaraid_sas
@@ -1,3 +1,17 @@
+Release Date: Thu. Jun 19, 2014 17:00:00 PST 2014 -
+   (emaild-id:megaraidli...@lsi.com)
+   Adam Radford
+   Kashyap Desai
+   Sumit Saxena
+   Uday Lingala
+Current Version : 06.803.02.00-rc1
+Old Version : 06.803.01.00-rc1
+1. Fix reset_mutex leak in megasas_reset_fusion().
+2. Remove unused variables in megasas_instance.
+3. Fix LD/VF affiliation parsing.
+4. Add missing initial call to megasas_get_ld_vf_affiliation().
+5. Version and Changelog update.
+---
 Release Date: Mon. Mar 10, 2014 17:00:00 PST 2014 -
(emaild-id:megaraidli...@lsi.com)
Adam Radford
diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 2e2fcb2..bc7adcf 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -33,9 +33,9 @@
 /*
  * MegaRAID SAS Driver meta data
  */
-#define MEGASAS_VERSION06.803.01.00-rc1
-#define MEGASAS_RELDATEMar. 10, 2014
-#define MEGASAS_EXT_VERSIONMon. Mar. 10 17:00:00 PDT 2014
+#define MEGASAS_VERSION06.803.02.00-rc1
+#define MEGASAS_RELDATEJun. 19, 2014
+#define MEGASAS_EXT_VERSIONThu. Jun. 19 17:00:00 PDT 2014
 
 /*
  * Device IDs
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 6db5c12..a2263fd 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -18,7 +18,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  *
  *  FILE: megaraid_sas_base.c
- *  Version : 06.803.01.00-rc1
+ *  Version : 06.803.02.00-rc1
  *
  *  Authors: LSI Corporation
  *   Sreenivas Bagalkote
-- 
1.7.11.7

--
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/4] megaraid_sas: Fix LD/VF affiliation parsing

2014-07-03 Thread adam radford
On Thu, Jul 3, 2014 at 1:18 AM, Christoph Hellwig h...@infradead.org wrote:
 On Mon, Jun 30, 2014 at 05:19:57PM -0700, Adam Radford wrote:
 James/linux-scsi,

 The following patch for megaraid_sas fixes the LD/VF affiliation policy 
 parsing code to account for LD targetId's and Hidden LD's (not yet 
 affiliated with any Virtual Functions).

 Hi Adam,

 this doesn't address Martins comment about removing the initial != 0
 case.  And while we're at it there basically is no significant shared
 code between the PlasmaFW111 and !PlasmaFW111, so split these into
 two different functions.  With those two levels of indentation removed
 the code might actually become readable, too.

 Also please remove the James/linux-scsi, address in the individual
 patches, that's something that should just go into the cover letter,
 and make sure to include all Reviewed-by: and Acked-by: tags when
 resending already reviewd patches.

 Thanks,
 Christoph

Christoph,

Thanks for your and Martin's feedback.

Actually there is a missing call to megasas_get_ld_vf_affiliation()
with initial = 1 that should be at the bottom of megasas_probe_one().
This got dropped inadvertently during a manual merge.  I will add that
and split the megasas_get_ld_vf_affiliation() function into 2
functions (as you suggested) and resubmit the patch series while
including all currently received Reviewed-by and Acked-by messages
for the other patches and dropping the James/linux-scsi text.

-Adam
--
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 2/4] megaraid_sas: Removed unused variables in megasas_instance

2014-06-30 Thread Adam Radford
James/linux-scsi,

The following patch for megaraid_sas removes some unused variables from the 
megasas_instance structure.

Signed-off-by: Adam Radford aradf...@gmail.com
---
 drivers/scsi/megaraid/megaraid_sas.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 32166c2..7d722fb 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1633,8 +1633,6 @@ struct megasas_instance {
struct timer_list sriov_heartbeat_timer;
char skip_heartbeat_timer_del;
u8 requestorId;
-   u64 initiator_sas_address;
-   u64 ld_sas_address[64];
char PlasmaFW111;
char mpio;
int throttlequeuedepth;
-- 
1.7.11.7

--
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/4] megaraid_sas: Update for scsi for-next

2014-06-30 Thread Adam Radford
(Re-sending with git-send-email on advice of Martin Petersen @ Oracle)

James/linux-scsi,

The following patch series for megaraid_sas brings the driver up to
v06.803.02.00-rc1.

1. Fix reset_mutex leak in megasas_reset_fusion().
2. Remove unused variables in megasas_instance.
3. Fix LD/VF affiliation parsing.
4. Version and Changelog update.

Adam Radford (4):
  megaraid_sas: Fix reset_mutex leak
  megaraid_sas: Removed unused variables in megasas_instance
  megaraid_sas: Fix LD/VF affiliation parsing
  megaraid_sas: Version and Changelog update

 Documentation/scsi/ChangeLog.megaraid_sas   | 13 +
 drivers/scsi/megaraid/megaraid_sas.h|  9 ++-
 drivers/scsi/megaraid/megaraid_sas_base.c   | 90 -
 drivers/scsi/megaraid/megaraid_sas_fusion.c |  1 +
 4 files changed, 82 insertions(+), 31 deletions(-)

-- 
1.7.11.7

--
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/4] megaraid_sas: Fix reset_mutex leak

2014-06-30 Thread Adam Radford
James/linux-scsi,

The following patch for megaraid_sas fixes a reset_mutex leak in 
megasas_reset_fusion().

Signed-off-by: Adam Radford aradf...@gmail.com
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 2260041..0858851 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -2355,6 +2355,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int 
iotimeout)
printk(KERN_WARNING megaraid_sas: Hardware critical error, 
   returning FAILED for scsi%d.\n,
instance-host-host_no);
+   mutex_unlock(instance-reset_mutex);
return FAILED;
}
 
-- 
1.7.11.7

--
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/4] megaraid_sas: Fix LD/VF affiliation parsing

2014-06-30 Thread Adam Radford
James/linux-scsi,

The following patch for megaraid_sas fixes the LD/VF affiliation policy parsing 
code to account for LD targetId's and Hidden LD's (not yet affiliated with any 
Virtual Functions).

Signed-off-by: Adam Radford aradf...@gmail.com
---
 drivers/scsi/megaraid/megaraid_sas.h  |  1 +
 drivers/scsi/megaraid/megaraid_sas_base.c | 88 ++-
 2 files changed, 64 insertions(+), 25 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 7d722fb..2e2fcb2 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1659,6 +1659,7 @@ struct MR_LD_VF_AFFILIATION {
 /* Plasma 1.11 FW backward compatibility structures */
 #define IOV_111_OFFSET 0x7CE
 #define MAX_VIRTUAL_FUNCTIONS 8
+#define MR_LD_ACCESS_HIDDEN 15
 
 struct IOV_111 {
u8 maxVFsSupported;
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 112799b..8f62b30 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1836,7 +1836,7 @@ static int megasas_get_ld_vf_affiliation(struct 
megasas_instance *instance,
struct MR_LD_VF_MAP *newmap = NULL, *savedmap = NULL;
dma_addr_t new_affiliation_h;
dma_addr_t new_affiliation_111_h;
-   int ld, retval = 0;
+   int ld, i, j, retval = 0, found = 0, doscan = 0;
u8 thisVf;
 
cmd = megasas_get_cmd(instance);
@@ -1944,14 +1944,6 @@ static int megasas_get_ld_vf_affiliation(struct 
megasas_instance *instance,
 
if (!initial) {
if (instance-PlasmaFW111) {
-   if (!new_affiliation_111-vdCount) {
-   printk(KERN_WARNING megasas: SR-IOV: Got new 
-  LD/VF affiliation for passive path 
-  for scsi%d.\n,
-   instance-host-host_no);
-   retval = 1;
-   goto out;
-   }
thisVf = new_affiliation_111-thisVf;
for (ld = 0 ; ld  new_affiliation_111-vdCount; ld++)
if 
(instance-vf_affiliation_111-map[ld].policy[thisVf] != 
new_affiliation_111-map[ld].policy[thisVf]) {
@@ -1977,29 +1969,75 @@ static int megasas_get_ld_vf_affiliation(struct 
megasas_instance *instance,
newmap = new_affiliation-map;
savedmap = instance-vf_affiliation-map;
thisVf = new_affiliation-thisVf;
-   for (ld = 0 ; ld  new_affiliation-ldCount; ld++) {
-   if (savedmap-policy[thisVf] !=
-   newmap-policy[thisVf]) {
-   printk(KERN_WARNING megasas: SR-IOV: 
-  Got new LD/VF affiliation 
-  for scsi%d.\n,
-   instance-host-host_no);
-   memcpy(instance-vf_affiliation,
-  new_affiliation,
-  new_affiliation-size);
-   retval = 1;
+   for (i = 0 ; i  new_affiliation-ldCount; i++) {
+   found = 0;
+   for (j = 0;
+j  instance-vf_affiliation-ldCount;
+j++) {
+   if (newmap-ref.targetId ==
+   savedmap-ref.targetId) {
+   found = 1;
+   if (newmap-policy[thisVf] !=
+   savedmap-policy[thisVf]) {
+   doscan = 1;
+   goto out;
+   }
+   }
+   savedmap =
+ (struct MR_LD_VF_MAP *)
+ ((unsigned char *)savedmap +
+  savedmap-size);
+   }
+   if (!found  newmap-policy[thisVf] !=
+   MR_LD_ACCESS_HIDDEN) {
+   doscan = 1;
goto out;
}
-   savedmap = (struct MR_LD_VF_MAP *)
-   ((unsigned char *)savedmap +
-savedmap

[PATCH 4/4] megaraid_sas: Version and Changelog update

2014-06-30 Thread Adam Radford
James/linux-scsi,

The following patch for megaraid_sas updates the driver version and 
Documentation/scsi/ChangeLog.megaraid_sas.

Signed-off-by: Adam Radford aradf...@gmail.com
---
 Documentation/scsi/ChangeLog.megaraid_sas | 13 +
 drivers/scsi/megaraid/megaraid_sas.h  |  6 +++---
 drivers/scsi/megaraid/megaraid_sas_base.c |  2 +-
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/Documentation/scsi/ChangeLog.megaraid_sas 
b/Documentation/scsi/ChangeLog.megaraid_sas
index 91ba58e..2741efe 100644
--- a/Documentation/scsi/ChangeLog.megaraid_sas
+++ b/Documentation/scsi/ChangeLog.megaraid_sas
@@ -1,3 +1,16 @@
+Release Date: Thu. Jun 19, 2014 17:00:00 PST 2014 -
+   (emaild-id:megaraidli...@lsi.com)
+   Adam Radford
+   Kashyap Desai
+   Sumit Saxena
+   Uday Lingala
+Current Version : 06.803.02.00-rc1
+Old Version : 06.803.01.00-rc1
+1. Fix reset_mutex leak in megasas_reset_fusion().
+2. Remove unused variables in megasas_instance.
+3. Fix LD/VF affiliation parsing.
+4. Version and Changelog update.
+---
 Release Date: Mon. Mar 10, 2014 17:00:00 PST 2014 -
(emaild-id:megaraidli...@lsi.com)
Adam Radford
diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 2e2fcb2..bc7adcf 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -33,9 +33,9 @@
 /*
  * MegaRAID SAS Driver meta data
  */
-#define MEGASAS_VERSION06.803.01.00-rc1
-#define MEGASAS_RELDATEMar. 10, 2014
-#define MEGASAS_EXT_VERSIONMon. Mar. 10 17:00:00 PDT 2014
+#define MEGASAS_VERSION06.803.02.00-rc1
+#define MEGASAS_RELDATEJun. 19, 2014
+#define MEGASAS_EXT_VERSIONThu. Jun. 19 17:00:00 PDT 2014
 
 /*
  * Device IDs
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 8f62b30..222bab2 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -18,7 +18,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  *
  *  FILE: megaraid_sas_base.c
- *  Version : 06.803.01.00-rc1
+ *  Version : 06.803.02.00-rc1
  *
  *  Authors: LSI Corporation
  *   Sreenivas Bagalkote
-- 
1.7.11.7

--
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] 3w-xxxx: fix mis-aligned struct accesses

2014-06-27 Thread adam radford
On Thu, Jun 26, 2014 at 5:58 AM, Arnd Bergmann a...@arndb.de wrote:
 Building an allmodconfig ARM kernel, I get multiple such
 warnings because of a spinlock contained in packed structure
 in the 3w- driver:

 ../drivers/scsi/3w-.c: In function 'tw_chrdev_ioctl':
 ../drivers/scsi/3w-.c:1001:68: warning: mis-aligned access used for 
 structure member [-fstrict-volatile-bitfields]
 timeout = wait_event_timeout(tw_dev-ioctl_wqueue, 
 tw_dev-chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout);
 ^
 ../drivers/scsi/3w-.c:1001:68: note: when a volatile object spans 
 multiple type-sized locations, the compiler must choose between using a 
 single mis-aligned access to preserve the volatility, or using multiple 
 aligned accesses to avoid runtime faults; this code may fail at runtime if 
 the hardware does not allow this access

 The same bug apparently was present in 3w-sas and 3w-9xxx, but has been
 fixed in the past. This patch uses the same fix by moving the pragma
 in front of the TW_Device_Extension definition, so it only covers
 hardware structures.

 Signed-off-by: Arnd Bergmann a...@arndb.de
 Cc: Adam Radford linuxr...@lsi.com
 ---
 diff --git a/drivers/scsi/3w-.h b/drivers/scsi/3w-.h
 index 49dcf03..29b0b84e 100644
 --- a/drivers/scsi/3w-.h
 +++ b/drivers/scsi/3w-.h
 @@ -392,6 +392,8 @@ typedef struct TAG_TW_Passthru
 unsigned char padding[12];
  } TW_Passthru;

 +#pragma pack()
 +
  typedef struct TAG_TW_Device_Extension {
 u32 base_addr;
 unsigned long   *alignment_virtual_address[TW_Q_LENGTH];
 @@ -430,6 +432,4 @@ typedef struct TAG_TW_Device_Extension {
 wait_queue_head_t   ioctl_wqueue;
  } TW_Device_Extension;

 -#pragma pack()
 -
  #endif /* _3W__H */

 --
 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

Arnd,

Thanks for the patch to 3w-.  This looks good to me.

Acked-by: Adam Radford aradf...@gmail.com

-Adam
--
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 2/4] megaraid_sas: Remove unused variables in megasas_instance

2014-06-19 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas removes some unused variables
from the megasas_instance structure.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-for-next.old/drivers/scsi/megaraid/megaraid_sas.h
scsi-for-next.new/drivers/scsi/megaraid/megaraid_sas.h
--- scsi-for-next.old/drivers/scsi/megaraid/megaraid_sas.h 2014-06-19
15:03:05.0 -0700
+++ scsi-for-next.new/drivers/scsi/megaraid/megaraid_sas.h 2014-06-19
15:30:49.334075830 -0700
@@ -1633,8 +1633,6 @@
  struct timer_list sriov_heartbeat_timer;
  char skip_heartbeat_timer_del;
  u8 requestorId;
- u64 initiator_sas_address;
- u64 ld_sas_address[64];
  char PlasmaFW111;
  char mpio;
  int throttlequeuedepth;


megaraid_sas.patch2
Description: Binary data


[PATCH 0/4] megaraid_sas: Updates for scsi for-next

2014-06-19 Thread adam radford
James/linux-scsi,

The following patch series for megaraid_sas brings the driver up to
v06.803.02.00-rc1.

1. Fix reset_mutex leak in megasas_reset_fusion().
2. Remove unused variables in megasas_instance.
3. Fix LD/VF affiliation parsing.
4. Version and Changelog update.

-Adam
--
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/4] megaraid_sas: Fix reset_mutex leak

2014-06-19 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas fixes a reset_mutex leak in
megasas_reset_fusion().

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-for-next.old/drivers/scsi/megaraid/megaraid_sas_fusion.c
scsi-for-next.new/drivers/scsi/megaraid/megaraid_sas_fusion.c
--- scsi-for-next.old/drivers/scsi/megaraid/megaraid_sas_fusion.c
2014-06-19 15:03:05.0 -0700
+++ scsi-for-next.new/drivers/scsi/megaraid/megaraid_sas_fusion.c
2014-06-19 15:24:19.982075881 -0700
@@ -2355,6 +2355,7 @@
  printk(KERN_WARNING megaraid_sas: Hardware critical error, 
returning FAILED for scsi%d.\n,
  instance-host-host_no);
+ mutex_unlock(instance-reset_mutex);
  return FAILED;
  }


megaraid_sas.patch1
Description: Binary data


[PATCH 4/4] megaraid_sas: Version and Changelog update

2014-06-19 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas updates the driver version and
Documentation/scsi/ChangeLog.megaraid_sas.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-for-next.old/Documentation/scsi/ChangeLog.megaraid_sas
scsi-for-next.new/Documentation/scsi/ChangeLog.megaraid_sas
--- scsi-for-next.old/Documentation/scsi/ChangeLog.megaraid_sas
2014-06-19 15:03:01.0 -0700
+++ scsi-for-next.new/Documentation/scsi/ChangeLog.megaraid_sas
2014-06-19 16:00:07.867075774 -0700
@@ -1,3 +1,16 @@
+Release Date: Thu. Jun 19, 2014 17:00:00 PST 2014 -
+ (emaild-id:megaraidli...@lsi.com)
+ Adam Radford
+ Kashyap Desai
+ Sumit Saxena
+ Uday Lingala
+Current Version : 06.803.02.00-rc1
+Old Version : 06.803.01.00-rc1
+1. Fix reset_mutex leak in megasas_reset_fusion().
+2. Remove unused variables in megasas_instance.
+3. Fix LD/VF affiliation parsing.
+4. Version and Changelog update.
+---
 Release Date: Mon. Mar 10, 2014 17:00:00 PST 2014 -
  (emaild-id:megaraidli...@lsi.com)
  Adam Radford
diff -Naur scsi-for-next.old/drivers/scsi/megaraid/megaraid_sas_base.c
scsi-for-next.new/drivers/scsi/megaraid/megaraid_sas_base.c
--- scsi-for-next.old/drivers/scsi/megaraid/megaraid_sas_base.c
2014-06-19 15:55:05.470199777 -0700
+++ scsi-for-next.new/drivers/scsi/megaraid/megaraid_sas_base.c
2014-06-19 15:55:33.465167518 -0700
@@ -18,7 +18,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  *
  *  FILE: megaraid_sas_base.c
- *  Version : 06.803.01.00-rc1
+ *  Version : 06.803.02.00-rc1
  *
  *  Authors: LSI Corporation
  *   Sreenivas Bagalkote
diff -Naur scsi-for-next.old/drivers/scsi/megaraid/megaraid_sas.h
scsi-for-next.new/drivers/scsi/megaraid/megaraid_sas.h
--- scsi-for-next.old/drivers/scsi/megaraid/megaraid_sas.h 2014-06-19
15:55:05.499074636 -0700
+++ scsi-for-next.new/drivers/scsi/megaraid/megaraid_sas.h 2014-06-19
15:56:17.128075741 -0700
@@ -33,9 +33,9 @@
 /*
  * MegaRAID SAS Driver meta data
  */
-#define MEGASAS_VERSION 06.803.01.00-rc1
-#define MEGASAS_RELDATE Mar. 10, 2014
-#define MEGASAS_EXT_VERSION Mon. Mar. 10 17:00:00 PDT 2014
+#define MEGASAS_VERSION 06.803.02.00-rc1
+#define MEGASAS_RELDATE Jun. 19, 2014
+#define MEGASAS_EXT_VERSION Thu. Jun. 19 17:00:00 PDT 2014

 /*
  * Device IDs


megaraid_sas.patch4
Description: Binary data


[PATCH 3/4] megaraid_sas: Fix LD/VF affiliation parsing

2014-06-19 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas fixes the LD/VF affiliation
policy parsing code to account for LD targetId's and Hidden LD's (not
yet affiliated with any Virtual Functions).

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-for-next.old/drivers/scsi/megaraid/megaraid_sas_base.c
scsi-for-next.new/drivers/scsi/megaraid/megaraid_sas_base.c
--- scsi-for-next.old/drivers/scsi/megaraid/megaraid_sas_base.c
2014-06-19 15:03:05.0 -0700
+++ scsi-for-next.new/drivers/scsi/megaraid/megaraid_sas_base.c
2014-06-19 15:53:26.537229974 -0700
@@ -1836,7 +1836,7 @@
  struct MR_LD_VF_MAP *newmap = NULL, *savedmap = NULL;
  dma_addr_t new_affiliation_h;
  dma_addr_t new_affiliation_111_h;
- int ld, retval = 0;
+ int ld, i, j, retval = 0, found = 0, doscan = 0;
  u8 thisVf;

  cmd = megasas_get_cmd(instance);
@@ -1944,14 +1944,6 @@

  if (!initial) {
  if (instance-PlasmaFW111) {
- if (!new_affiliation_111-vdCount) {
- printk(KERN_WARNING megasas: SR-IOV: Got new 
-   LD/VF affiliation for passive path 
-   for scsi%d.\n,
- instance-host-host_no);
- retval = 1;
- goto out;
- }
  thisVf = new_affiliation_111-thisVf;
  for (ld = 0 ; ld  new_affiliation_111-vdCount; ld++)
  if (instance-vf_affiliation_111-map[ld].policy[thisVf] !=
new_affiliation_111-map[ld].policy[thisVf]) {
@@ -1977,29 +1969,75 @@
  newmap = new_affiliation-map;
  savedmap = instance-vf_affiliation-map;
  thisVf = new_affiliation-thisVf;
- for (ld = 0 ; ld  new_affiliation-ldCount; ld++) {
- if (savedmap-policy[thisVf] !=
-newmap-policy[thisVf]) {
- printk(KERN_WARNING megasas: SR-IOV: 
-   Got new LD/VF affiliation 
-   for scsi%d.\n,
- instance-host-host_no);
- memcpy(instance-vf_affiliation,
-   new_affiliation,
-   new_affiliation-size);
- retval = 1;
+ for (i = 0 ; i  new_affiliation-ldCount; i++) {
+ found = 0;
+ for (j = 0;
+ j  instance-vf_affiliation-ldCount;
+ j++) {
+ if (newmap-ref.targetId ==
+savedmap-ref.targetId) {
+ found = 1;
+ if (newmap-policy[thisVf] !=
+savedmap-policy[thisVf]) {
+ doscan = 1;
+ goto out;
+ }
+ }
+ savedmap =
+  (struct MR_LD_VF_MAP *)
+  ((unsigned char *)savedmap +
+   savedmap-size);
+ }
+ if (!found  newmap-policy[thisVf] !=
+MR_LD_ACCESS_HIDDEN) {
+ doscan = 1;
  goto out;
  }
- savedmap = (struct MR_LD_VF_MAP *)
- ((unsigned char *)savedmap +
- savedmap-size);
  newmap = (struct MR_LD_VF_MAP *)
- ((unsigned char *)newmap +
- newmap-size);
+  ((unsigned char *)newmap + newmap-size);
+ }
+
+ newmap = new_affiliation-map;
+ savedmap = instance-vf_affiliation-map;
+
+ for (i = 0 ; i  instance-vf_affiliation-ldCount;
+ i++) {
+ found = 0;
+ for (j = 0 ; j  new_affiliation-ldCount;
+ j++) {
+ if (savedmap-ref.targetId ==
+newmap-ref.targetId) {
+ found = 1;
+ if (savedmap-policy[thisVf] !=
+newmap-policy[thisVf]) {
+ doscan = 1;
+ goto out;
+ }
+ }
+ newmap = (struct MR_LD_VF_MAP *)
+  ((unsigned char *)newmap +
+   newmap-size);
+ }
+ if (!found  savedmap-policy[thisVf] !=
+MR_LD_ACCESS_HIDDEN) {
+ doscan = 1;
+ goto out;
+ }
+ savedmap = (struct MR_LD_VF_MAP *)
+  ((unsigned char *)savedmap +
+   savedmap-size);
  }
  }
  }
 out:
+ if (doscan) {
+ printk(KERN_WARNING megasas: SR-IOV: Got new LD/VF 
+   affiliation for scsi%d.\n, instance-host-host_no);
+ memcpy(instance-vf_affiliation, new_affiliation,
+   new_affiliation-size);
+ retval = 1;
+ }
+
  if (new_affiliation) {
  if (instance-PlasmaFW111)
  pci_free_consistent(instance-pdev,
diff -Naur scsi-for-next.old/drivers/scsi/megaraid/megaraid_sas.h
scsi-for-next.new/drivers/scsi/megaraid/megaraid_sas.h
--- scsi-for-next.old/drivers/scsi/megaraid/megaraid_sas.h 2014-06-19
15:31:49.110125604 -0700
+++ scsi-for-next.new/drivers/scsi/megaraid/megaraid_sas.h 2014-06-19
15:42:37.229075664 -0700
@@ -1659,6 +1659,7 @@
 /* Plasma 1.11 FW backward compatibility structures */
 #define IOV_111_OFFSET 0x7CE
 #define MAX_VIRTUAL_FUNCTIONS 8
+#define MR_LD_ACCESS_HIDDEN 15

 struct IOV_111 {
  u8 maxVFsSupported;


megaraid_sas.patch3
Description: Binary data


Re: [PATCH 13/39] megaraid: simplify internal command handling

2014-03-20 Thread adam radford
 the original allocation mask is vital because that's
 - * what determines which command pool we use to free the command.  Any
 - * mismatch will cause the system to BUG eventually.
 - */
 -void scsi_free_command(gfp_t gfp_mask, struct scsi_cmnd *cmd)
 -{
 -   struct scsi_host_cmd_pool *pool = scsi_get_host_cmd_pool(gfp_mask);
 -
 -   /*
 -* this could trigger if the mask to scsi_allocate_command
 -* doesn't match this mask.  Otherwise we're guaranteed that this
 -* succeeds because scsi_allocate_command must have taken a reference
 -* on the pool
 -*/
 -   BUG_ON(!pool);
 -
 -   scsi_pool_free_command(pool, cmd);
 -   /*
 -* scsi_put_host_cmd_pool is called twice; once to release the
 -* reference we took above, and once to release the reference
 -* originally taken by scsi_allocate_command
 -*/
 -   scsi_put_host_cmd_pool(gfp_mask);
 -   scsi_put_host_cmd_pool(gfp_mask);
 -}
 -EXPORT_SYMBOL(scsi_free_command);
 -
 -/**
   * scsi_setup_command_freelist - Setup the command freelist for a scsi host.
   * @shost: host to allocate the freelist for.
   *
 diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
 index 414edf9..dd7c998 100644
 --- a/include/scsi/scsi_cmnd.h
 +++ b/include/scsi/scsi_cmnd.h
 @@ -155,9 +155,6 @@ extern void scsi_release_buffers(struct scsi_cmnd *cmd);
  extern int scsi_dma_map(struct scsi_cmnd *cmd);
  extern void scsi_dma_unmap(struct scsi_cmnd *cmd);

 -struct scsi_cmnd *scsi_allocate_command(gfp_t gfp_mask);
 -void scsi_free_command(gfp_t gfp_mask, struct scsi_cmnd *cmd);
 -
  static inline unsigned scsi_sg_count(struct scsi_cmnd *cmd)
  {
 return cmd-sdb.table.nents;
 --
 1.7.10.4


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

Christoph/James,

I have reviewed this patch, and it looks good to me.
Please consider this ACK'd by the Megaraid driver team.

Acked-by: Adam Radford aradf...@gmail.com

-Adam
--
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/5] megaraid_sas: Updates for scsi-misc

2014-03-11 Thread adam radford
 Patch series is lacking coding style. Please re-check with
'./scripts/checkpatch.pl

I did run checkpatch against the whole patch series before submission.
Please see my comments about me leaving some lines  80 columns in
place to preserve code readability at the top of the largest patch,
here:

http://marc.info/?l=linux-scsim=139444512512929w=2

-Adam

On Mon, Mar 10, 2014 at 4:13 AM, Hannes Reinecke h...@suse.de wrote:
 On 03/10/2014 10:51 AM, adam radford wrote:
 James/linux-scsi,

 The following patch series for megaraid_sas brings the driver up to
 v06.803.01.00-rc1:

 1. Load correct raid context timeout value for multipathing and clustering.
 2. Fix megasas_ioc_init_fusion to use local stack variable.
 3. Return leaked MPT frames to MPT command pool.
 4. Add Dell PowerEdge VRTX SR-IOV VF device support.
 5. Version and Changelog update.

 This patch series apples on top of Sumit Saxena's latest patch series, which
 starts here:

 http://marc.info/?l=linux-scsim=139220849616649w=2

 and includes a small repost here:

 http://marc.info/?l=linux-scsim=139374736120535w=2

 Patch series is lacking coding style. Please re-check with
 './scripts/checkpatch.pl

 Cheers,

 Hannes
 --
 Dr. Hannes Reinecke   zSeries  Storage
 h...@suse.de  +49 911 74053 688
 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
 GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (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 0/5] megaraid_sas: Updates for scsi-misc

2014-03-10 Thread adam radford
James/linux-scsi,

The following patch series for megaraid_sas brings the driver up to
v06.803.01.00-rc1:

1. Load correct raid context timeout value for multipathing and clustering.
2. Fix megasas_ioc_init_fusion to use local stack variable.
3. Return leaked MPT frames to MPT command pool.
4. Add Dell PowerEdge VRTX SR-IOV VF device support.
5. Version and Changelog update.

This patch series apples on top of Sumit Saxena's latest patch series, which
starts here:

http://marc.info/?l=linux-scsim=139220849616649w=2

and includes a small repost here:

http://marc.info/?l=linux-scsim=139374736120535w=2

-Adam
--
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 2/5] megaraid_sas: Fix megasas_ioc_init_fusion

2014-03-10 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas fixes the megasas_ioc_init_fusion function
to use a local stack variable for the IOCinit frame physical address
instead of clobbering the first request descriptor.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fusion.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fusion.c
2014-03-09 21:07:03.893980795 -0700
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c
2014-03-09 21:30:32.104856111 -0700
@@ -585,7 +585,7 @@
  struct megasas_cmd *cmd;
  u8 ret;
  struct fusion_context *fusion;
- union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc;
+ union MEGASAS_REQUEST_DESCRIPTOR_UNION req_desc;
  int i;
  struct megasas_header *frame_hdr;

@@ -647,15 +647,12 @@
  init_frame-queue_info_new_phys_addr_lo = cpu_to_le32((u32)ioc_init_handle);
  init_frame-data_xfer_len = cpu_to_le32(sizeof(struct MPI2_IOC_INIT_REQUEST));

- req_desc =
-  (union MEGASAS_REQUEST_DESCRIPTOR_UNION *)fusion-req_frames_desc;
-
- req_desc-Words = 0;
- req_desc-MFAIo.RequestFlags =
+ req_desc.Words = 0;
+ req_desc.MFAIo.RequestFlags =
  (MEGASAS_REQ_DESCRIPT_FLAGS_MFA 
  MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
- cpu_to_le32s((u32 *)req_desc-MFAIo);
- req_desc-Words |= cpu_to_le64(cmd-frame_phys_addr);
+ cpu_to_le32s((u32 *)req_desc.MFAIo);
+ req_desc.Words |= cpu_to_le64(cmd-frame_phys_addr);

  /*
  * disable the intr before firing the init frame
@@ -669,8 +666,8 @@
  break;
  }

- instance-instancet-fire_cmd(instance, req_desc-u.low,
-  req_desc-u.high, instance-reg_set);
+ instance-instancet-fire_cmd(instance, req_desc.u.low,
+  req_desc.u.high, instance-reg_set);

  wait_and_poll(instance, cmd);


megaraid_sas.patch2
Description: Binary data


[PATCH 3/5] megaraid_sas: Return leaked MPT frames to MPT frame pool

2014-03-10 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas will return leaked MPT frames from any
polled DCMD's that timeout to the MPT frame pool.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fusion.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fusion.c
2014-03-09 21:31:26.710918424 -0700
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c
2014-03-09 21:45:22.598012009 -0700
@@ -2432,11 +2432,14 @@
  instance,
  cmd_mfi-context.smid
  -1);
- if (!req_desc)
+ if (!req_desc) {
  printk(KERN_WARNING
req_desc NULL
\n);
- else {
+ /* Return leaked MPT
+   frame */
+ megasas_return_cmd_fusion(instance, cmd_fusion);
+ } else {
  instance-instancet-
  fire_cmd(instance,
  req_desc-


megaraid_sas.patch3
Description: Binary data


[PATCH 1/5] megaraid_sas: Load correct raid context timeout

2014-03-10 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas loads the correct raid context timeout
value for multpathing and clustering.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fp.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fp.c
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fp.c 2014-03-09
21:06:56.499856130 -0700
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fp.c 2014-03-09
21:20:51.303858698 -0700
@@ -975,7 +975,10 @@
  regSize += stripSize;
  }

- pRAID_Context-timeoutValue = cpu_to_le16(map-raidMap.fpPdIoTimeoutSec);
+ pRAID_Context-timeoutValue =
+ cpu_to_le16(raid-fpIoTimeoutForLd ?
+raid-fpIoTimeoutForLd :
+map-raidMap.fpPdIoTimeoutSec);
  if ((instance-pdev-device == PCI_DEVICE_ID_LSI_INVADER) ||
  (instance-pdev-device == PCI_DEVICE_ID_LSI_FURY))
  pRAID_Context-regLockFlags = (isRead) ?


megaraid_sas.patch1
Description: Binary data


[PATCH 5/5] megaraid_sas: Version and Changelog update

2014-03-10 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas updates the driver version to
v06.803.01.00-rc1, and updates Documentation/scsi/ChangeLog.megaraid_sas.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc.old/Documentation/scsi/ChangeLog.megaraid_sas
scsi-misc.new/Documentation/scsi/ChangeLog.megaraid_sas
--- scsi-misc.old/Documentation/scsi/ChangeLog.megaraid_sas 2014-03-09
14:53:01.0 -0700
+++ scsi-misc.new/Documentation/scsi/ChangeLog.megaraid_sas 2014-03-10
01:27:05.779857022 -0700
@@ -1,3 +1,16 @@
+Release Date: Mon. Mar 10, 2014 17:00:00 PST 2014 -
+ (emaild-id:megaraidli...@lsi.com)
+ Adam Radford
+ Kashyap Desai
+ Sumit Saxena
+Current Version : 06.803.01.00-rc1
+Old Version : 06.700.06.00-rc1
+1. Load correct raid context timeout value for multipathing  clustering.
+2. Fix megasas_ioc_init_fusion to use local stack variable.
+3. Return leaked MPT frames to MPT command pool.
+4. Add Dell PowerEdge VRTX SR-IOV VF device support.
+5. Version and Changelog update.
+---
 Release Date: Sat. Aug 31, 2013 17:00:00 PST 2013 -
  (emaild-id:megaraidli...@lsi.com)
  Adam Radford
diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_base.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_base.c
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_base.c 2014-03-10
01:21:11.905980715 -0700
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_base.c 2014-03-10
01:21:52.868980752 -0700
@@ -18,7 +18,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  *
  *  FILE: megaraid_sas_base.c
- *  Version : 06.700.06.00-rc1
+ *  Version : 06.803.01.00-rc1
  *
  *  Authors: LSI Corporation
  *   Sreenivas Bagalkote
diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas.h
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas.h
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas.h 2014-03-10
01:21:11.907980210 -0700
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas.h 2014-03-10
01:22:31.744856918 -0700
@@ -33,9 +33,9 @@
 /*
  * MegaRAID SAS Driver meta data
  */
-#define MEGASAS_VERSION 06.700.06.00-rc1
-#define MEGASAS_RELDATE Aug. 31, 2013
-#define MEGASAS_EXT_VERSION Sat. Aug. 31 17:00:00 PDT 2013
+#define MEGASAS_VERSION 06.803.01.00-rc1
+#define MEGASAS_RELDATE Mar. 10, 2014
+#define MEGASAS_EXT_VERSION Mon. Mar. 10 17:00:00 PDT 2014

 /*
  * Device IDs


megaraid_sas.patch5
Description: Binary data


Re: Dell Shared PERC8 RAID Controller

2014-03-03 Thread adam radford
Istvan/Emmanuel,

 08:00.0 RAID bus controller [0104]: LSI Logic / Symbios Logic MegaRAID
SAS 2208 IOV [Thunderbolt] [1000:002f] (rev 05)

I will be sending a driver patch for megaraid_sas to support the Dell
PowerEdge VRTX/Shared PERC8 device later this week.  This will allow
you to run Linux with the megaraid_sas in Virtual Function (VF) mode
on the VRTX blades.

-Adam
--
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/2] megaraid_sas: Add High Availability clustering support using shared Logical Disks

2013-09-06 Thread adam radford
On 9/6/13, James Bottomley james.bottom...@hansenpartnership.com wrote:
 Checkpatch doesn't like this.  It thinks (correctly) that these should
 all be in megaraid_sas.h so we can't get the prototype different from
 the actual function without some type of warning.  Can you move them,
 please?

James,

Corrected patch is in-line below and also attached to this reply.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_base.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_base.c
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_base.c 2013-08-31
16:17:56.907172388 -0700
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_base.c 2013-08-31
16:23:31.077143117 -0700
@@ -92,6 +92,8 @@

 int megasas_transition_to_ready(struct megasas_instance *instance, int ocr);
 static int megasas_get_pd_list(struct megasas_instance *instance);
+static int megasas_ld_list_query(struct megasas_instance *instance,
+u8 query_type);
 static int megasas_issue_init_mfi(struct megasas_instance *instance);
 static int megasas_register_aen(struct megasas_instance *instance,
u32 seq_num, u32 class_locale_word);
@@ -3271,6 +3273,84 @@
 }

 /**
+ * megasas_ld_list_query - Returns FW's ld_list structure
+ * @instance:  Adapter soft state
+ * @ld_list:   ld_list structure
+ *
+ * Issues an internal command (DCMD) to get the FW's controller PD
+ * list structure.  This information is mainly used to find out SYSTEM
+ * supported by the FW.
+ */
+static int
+megasas_ld_list_query(struct megasas_instance *instance, u8 query_type)
+{
+   int ret = 0, ld_index = 0, ids = 0;
+   struct megasas_cmd *cmd;
+   struct megasas_dcmd_frame *dcmd;
+   struct MR_LD_TARGETID_LIST *ci;
+   dma_addr_t ci_h = 0;
+
+   cmd = megasas_get_cmd(instance);
+
+   if (!cmd) {
+   printk(KERN_WARNING
+  megasas:(megasas_ld_list_query): Failed to get cmd\n);
+   return -ENOMEM;
+   }
+
+   dcmd = cmd-frame-dcmd;
+
+   ci = pci_alloc_consistent(instance-pdev,
+ sizeof(struct MR_LD_TARGETID_LIST), ci_h);
+
+   if (!ci) {
+   printk(KERN_WARNING
+  megasas: Failed to alloc mem for ld_list_query\n);
+   megasas_return_cmd(instance, cmd);
+   return -ENOMEM;
+   }
+
+   memset(ci, 0, sizeof(*ci));
+   memset(dcmd-mbox.b, 0, MFI_MBOX_SIZE);
+
+   dcmd-mbox.b[0] = query_type;
+
+   dcmd-cmd = MFI_CMD_DCMD;
+   dcmd-cmd_status = 0xFF;
+   dcmd-sge_count = 1;
+   dcmd-flags = MFI_FRAME_DIR_READ;
+   dcmd-timeout = 0;
+   dcmd-data_xfer_len = sizeof(struct MR_LD_TARGETID_LIST);
+   dcmd-opcode = MR_DCMD_LD_LIST_QUERY;
+   dcmd-sgl.sge32[0].phys_addr = ci_h;
+   dcmd-sgl.sge32[0].length = sizeof(struct MR_LD_TARGETID_LIST);
+   dcmd-pad_0  = 0;
+
+   if (!megasas_issue_polled(instance, cmd)  !dcmd-cmd_status) {
+   ret = 0;
+   } else {
+   /* On failure, call older LD list DCMD */
+   ret = 1;
+   }
+
+   if ((ret == 0)  (ci-count = (MAX_LOGICAL_DRIVES))) {
+   memset(instance-ld_ids, 0xff, MEGASAS_MAX_LD_IDS);
+   for (ld_index = 0; ld_index  ci-count; ld_index++) {
+   ids = ci-targetId[ld_index];
+   instance-ld_ids[ids] = ci-targetId[ld_index];
+   }
+
+   }
+
+   pci_free_consistent(instance-pdev, sizeof(struct MR_LD_TARGETID_LIST),
+   ci, ci_h);
+
+   megasas_return_cmd(instance, cmd);
+
+   return ret;
+}
+
+/**
  * megasas_get_controller_info -   Returns FW's controller structure
  * @instance:  Adapter soft state
  * @ctrl_info: Controller information structure
@@ -3648,7 +3728,9 @@
megasas_get_pd_list(instance);

memset(instance-ld_ids, 0xff, MEGASAS_MAX_LD_IDS);
-   megasas_get_ld_list(instance);
+   if (megasas_ld_list_query(instance,
+ MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
+   megasas_get_ld_list(instance);

ctrl_info = kmalloc(sizeof(struct megasas_ctrl_info), GFP_KERNEL);

@@ -5389,7 +5471,9 @@
case MR_EVT_LD_OFFLINE:
case MR_EVT_CFG_CLEARED:
case MR_EVT_LD_DELETED:
-   megasas_get_ld_list(instance);
+   if (megasas_ld_list_query(instance,
+   MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
+   megasas_get_ld_list(instance);
for (i = 0; i  MEGASAS_MAX_LD_CHANNELS; i++) {
for (j = 0;
j  MEGASAS_MAX_DEV_PER_CHANNEL;
@@ -5399,7 +5483,7

[PATCH 1/2] megaraid_sas: Add High Availability clustering support using shared Logical Disks

2013-08-31 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas will add support for High
Availability (HA)/clustering using shared Logical Disks.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_base.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_base.c
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_base.c 2013-08-31
16:17:56.907172388 -0700
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_base.c 2013-08-31
16:23:31.077143117 -0700
@@ -92,6 +92,8 @@

 int megasas_transition_to_ready(struct megasas_instance *instance, int ocr);
 static int megasas_get_pd_list(struct megasas_instance *instance);
+static int megasas_ld_list_query(struct megasas_instance *instance,
+ u8 query_type);
 static int megasas_issue_init_mfi(struct megasas_instance *instance);
 static int megasas_register_aen(struct megasas_instance *instance,
  u32 seq_num, u32 class_locale_word);
@@ -3271,6 +3273,84 @@
 }

 /**
+ * megasas_ld_list_query - Returns FW's ld_list structure
+ * @instance: Adapter soft state
+ * @ld_list: ld_list structure
+ *
+ * Issues an internal command (DCMD) to get the FW's controller PD
+ * list structure.  This information is mainly used to find out SYSTEM
+ * supported by the FW.
+ */
+static int
+megasas_ld_list_query(struct megasas_instance *instance, u8 query_type)
+{
+ int ret = 0, ld_index = 0, ids = 0;
+ struct megasas_cmd *cmd;
+ struct megasas_dcmd_frame *dcmd;
+ struct MR_LD_TARGETID_LIST *ci;
+ dma_addr_t ci_h = 0;
+
+ cmd = megasas_get_cmd(instance);
+
+ if (!cmd) {
+ printk(KERN_WARNING
+   megasas:(megasas_ld_list_query): Failed to get cmd\n);
+ return -ENOMEM;
+ }
+
+ dcmd = cmd-frame-dcmd;
+
+ ci = pci_alloc_consistent(instance-pdev,
+  sizeof(struct MR_LD_TARGETID_LIST), ci_h);
+
+ if (!ci) {
+ printk(KERN_WARNING
+   megasas: Failed to alloc mem for ld_list_query\n);
+ megasas_return_cmd(instance, cmd);
+ return -ENOMEM;
+ }
+
+ memset(ci, 0, sizeof(*ci));
+ memset(dcmd-mbox.b, 0, MFI_MBOX_SIZE);
+
+ dcmd-mbox.b[0] = query_type;
+
+ dcmd-cmd = MFI_CMD_DCMD;
+ dcmd-cmd_status = 0xFF;
+ dcmd-sge_count = 1;
+ dcmd-flags = MFI_FRAME_DIR_READ;
+ dcmd-timeout = 0;
+ dcmd-data_xfer_len = sizeof(struct MR_LD_TARGETID_LIST);
+ dcmd-opcode = MR_DCMD_LD_LIST_QUERY;
+ dcmd-sgl.sge32[0].phys_addr = ci_h;
+ dcmd-sgl.sge32[0].length = sizeof(struct MR_LD_TARGETID_LIST);
+ dcmd-pad_0  = 0;
+
+ if (!megasas_issue_polled(instance, cmd)  !dcmd-cmd_status) {
+ ret = 0;
+ } else {
+ /* On failure, call older LD list DCMD */
+ ret = 1;
+ }
+
+ if ((ret == 0)  (ci-count = (MAX_LOGICAL_DRIVES))) {
+ memset(instance-ld_ids, 0xff, MEGASAS_MAX_LD_IDS);
+ for (ld_index = 0; ld_index  ci-count; ld_index++) {
+ ids = ci-targetId[ld_index];
+ instance-ld_ids[ids] = ci-targetId[ld_index];
+ }
+
+ }
+
+ pci_free_consistent(instance-pdev, sizeof(struct MR_LD_TARGETID_LIST),
+ci, ci_h);
+
+ megasas_return_cmd(instance, cmd);
+
+ return ret;
+}
+
+/**
  * megasas_get_controller_info - Returns FW's controller structure
  * @instance: Adapter soft state
  * @ctrl_info: Controller information structure
@@ -3648,7 +3728,9 @@
  megasas_get_pd_list(instance);

  memset(instance-ld_ids, 0xff, MEGASAS_MAX_LD_IDS);
- megasas_get_ld_list(instance);
+ if (megasas_ld_list_query(instance,
+  MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
+ megasas_get_ld_list(instance);

  ctrl_info = kmalloc(sizeof(struct megasas_ctrl_info), GFP_KERNEL);

@@ -5389,7 +5471,9 @@
  case MR_EVT_LD_OFFLINE:
  case MR_EVT_CFG_CLEARED:
  case MR_EVT_LD_DELETED:
- megasas_get_ld_list(instance);
+ if (megasas_ld_list_query(instance,
+ MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
+ megasas_get_ld_list(instance);
  for (i = 0; i  MEGASAS_MAX_LD_CHANNELS; i++) {
  for (j = 0;
  j  MEGASAS_MAX_DEV_PER_CHANNEL;
@@ -5399,7 +5483,7 @@
  (i * MEGASAS_MAX_DEV_PER_CHANNEL) + j;

  sdev1 = scsi_device_lookup(host,
- i + MEGASAS_MAX_LD_CHANNELS,
+ MEGASAS_MAX_PD_CHANNELS + i,
  j,
  0);

@@ -5418,7 +5502,9 @@
  doscan = 0;
  break;
  case MR_EVT_LD_CREATED:
- megasas_get_ld_list(instance);
+ if (megasas_ld_list_query(instance,
+ MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
+ megasas_get_ld_list(instance);
  for (i = 0; i  MEGASAS_MAX_LD_CHANNELS; i++) {
  for (j = 0;
  j  MEGASAS_MAX_DEV_PER_CHANNEL;
@@ -5427,14 +5513,14 @@
  (i * MEGASAS_MAX_DEV_PER_CHANNEL) + j;

  sdev1 = scsi_device_lookup(host,
- i+MEGASAS_MAX_LD_CHANNELS,
+ MEGASAS_MAX_PD_CHANNELS + i,
  j, 0);

  if (instance-ld_ids[ld_index] !=
  0xff) {
  if (!sdev1) {
  scsi_add_device(host,
- i + 2,
+ MEGASAS_MAX_PD_CHANNELS + i,
  j, 0);
  }
  }
@@ -5483,18 +5569,20 @@
  }
  }

- megasas_get_ld_list(instance);
+ if (megasas_ld_list_query(instance,
+  MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
+ megasas_get_ld_list(instance);
  for (i = 0; i  MEGASAS_MAX_LD_CHANNELS; i++) {
  for (j = 0; j  MEGASAS_MAX_DEV_PER_CHANNEL; j++) {
  ld_index =
  (i * MEGASAS_MAX_DEV_PER_CHANNEL) + j;

  sdev1 = scsi_device_lookup(host,
- i+MEGASAS_MAX_LD_CHANNELS, j, 0);
+ MEGASAS_MAX_PD_CHANNELS + i

[PATCH 0/2] megaraid_sas: Updates for scsi-misc

2013-08-31 Thread adam radford
James/linux-scsi,

The following small patch series for megaraid_sas brings the driver up
to v06.700.06.00-rc1:

1. Add High Availability clustering support using shared Logical Disks.
2. Version and Changelog update.

-Adam
--
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 2/2] megaraid_sas: Version and Changelog update

2013-08-31 Thread adam radford
James/linux-scsi,

This patch updates the megaraid_sas driver version and updates
Documentation/ChangeLog.megaraid_sas

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc.old/Documentation/scsi/ChangeLog.megaraid_sas
scsi-misc.new/Documentation/scsi/ChangeLog.megaraid_sas
--- scsi-misc.old/Documentation/scsi/ChangeLog.megaraid_sas 2013-08-25
17:43:22.0 -0700
+++ scsi-misc.new/Documentation/scsi/ChangeLog.megaraid_sas 2013-08-31
16:09:54.273079869 -0700
@@ -1,3 +1,13 @@
+Release Date: Sat. Aug 31, 2013 17:00:00 PST 2013 -
+ (emaild-id:megaraidli...@lsi.com)
+ Adam Radford
+ Kashyap Desai
+ Sumit Saxena
+Current Version : 06.700.06.00-rc1
+Old Version : 06.600.18.00-rc1
+1. Add High Availability clustering support using shared Logical Disks.
+2. Version and Changelog update.
+---
 Release Date: Wed. May 15, 2013 17:00:00 PST 2013 -
  (emaild-id:megaraidli...@lsi.com)
  Adam Radford
diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_base.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_base.c
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_base.c 2013-08-31
16:05:24.341172944 -0700
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_base.c 2013-08-31
16:07:04.985077563 -0700
@@ -18,7 +18,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  *
  *  FILE: megaraid_sas_base.c
- *  Version : 06.600.18.00-rc1
+ *  Version : 06.700.06.00-rc1
  *
  *  Authors: LSI Corporation
  *   Sreenivas Bagalkote
diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas.h
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas.h
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas.h 2013-08-31
16:05:24.394079466 -0700
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas.h 2013-08-31
16:06:48.461080925 -0700
@@ -33,9 +33,9 @@
 /*
  * MegaRAID SAS Driver meta data
  */
-#define MEGASAS_VERSION 06.600.18.00-rc1
-#define MEGASAS_RELDATE May. 15, 2013
-#define MEGASAS_EXT_VERSION Wed. May. 15 17:00:00 PDT 2013
+#define MEGASAS_VERSION 06.700.06.00-rc1
+#define MEGASAS_RELDATE Aug. 31, 2013
+#define MEGASAS_EXT_VERSION Sat. Aug. 31 17:00:00 PDT 2013

 /*
  * Device IDs


megaraid_sas.patch2
Description: Binary data


Re: [PATCH 0/3] [SCSI] megaraid: Remove local (struct pci_dev) pdev's

2013-07-22 Thread adam radford
On Tue, Jul 9, 2013 at 11:10 PM, James Bottomley
james.bottom...@hansenpartnership.com wrote:
 On Tue, 2013-07-09 at 15:12 -0700, adam radford wrote:
 On Tue, Jul 9, 2013 at 2:18 PM, James Bottomley
  Adam, you do drive by coding on this for LSI ... ack or reject, please.

 I have just now located my box of MegaRAID Parallel SCSI controllers.
 I will review and test the patch series from Myron and respond by next 
 Monday.

 Thanks,

 James



Unfortunately my box of MegaRAID Parallel SCSI controllers only
contains only cards intended for megaraid_mbox.c (I tested all 20 of
them),

and does not contain any of the following really old Symbios based
megaraid cards:

static struct pci_device_id megaraid_pci_tbl[] = {
{PCI_VENDOR_ID_AMI, PCI_DEVICE_ID_AMI_MEGARAID,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{PCI_VENDOR_ID_AMI, PCI_DEVICE_ID_AMI_MEGARAID2,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_AMI_MEGARAID3,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0,}
};

which I had located previously before the company headquarters moved.
 I cannot currently locate any of the above 3 controllers anywhere at
LSI headquarters after an exhaustive search, so I cannot test the
patches to megaraid.c from Myron @ RedHat.

Myron, do you actually have the hardware and have you tested the
patches yourself ?

-Adam
--
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] megaraid: Remove local (struct pci_dev) pdev's

2013-07-09 Thread adam radford
On Tue, Jul 9, 2013 at 2:18 PM, James Bottomley
james.bottom...@hansenpartnership.com wrote:
 On Tue, 2013-07-09 at 14:39 -0600, Myron Stowe wrote:
 Is the megaraid driver still actively used and maintained?  I originally
 posted this series on 06.07.2013 and after receiving no comments, pinged
 the list again on 06.17.2013 and still received no comments/feedback.

 Trying again as I believe there is a real issue here, which I'd like
 confirmation on, and we really should remove the local copy/usage of
 'struct pci_dev' that this driver currently maintains.


 While the megaraid device itself may be 64-bit DMA capable, 32-bit address
 restricted DMA buffers are apparently required for internal commands as
 is denoted by a couple of comments - For all internal commands, the
 buffer must be allocated in 4GB address range - within the driver.

 If the device is 64-bit DMA capable then, once it is setup, any subsequent
 DMA allocations for internal commands would not be properly restricted
 due to megaraid_probe_one() having called pci_set_dma_mask() on pdev with
 DMA_BIT_MASK(64).  The driver attempts to solve this by using
 make_local_pdev() to dynamically create local pci_dev structures which are
 then set and used for allocating 32-bit address space restricted DMA
 buffers[1] but I don't believe that the implementation works as intended.


 Assume that the megaraid device is 64-bit DMA capable.  While probing the
 device and attaching the megaraid driver, pci_set_dma_mask() is called
 with the originating pdev and a DMA_BIT_MASK of 64.  As a result, any
 subsequent dynamic DMA related allocations associated with the
 originating pdev will acquire 64-bit based buffers, which do not meet
 the addressing restrictions for internal commands.

   megaraid_probe_one(struct pci_dev *pdev, ...)
   ...
   pci_set_dma_mask(pdev, DMA_BIT_MASK(64));

 As mentioned, the driver attempts to solve this by using make_local_pdev()
 to dynamically create local pci_dev structures - local pdev's - which
 are set with a DMA_BIT_MASK of 32.

   make_local_pdev
   alloc_pci_dev
   memcpy
   pci_set_dma_mask
   dma_set_mask
   *dev-dma_mask = mask;

 The local pdev is then used in allocating a DMA buffer in an attempt to
 meet the  4 GB restriction.

 For a 64-bit DMA capable device, the originating pdev will have its
 'dma_mask' set to 0x after the driver attaches.
 Subsequently, when an internal command is initiated, make_local_pdev() is
 called.  make_local_pdev() uses the PCI's core to allocate a local pdev
 and then copies the originating pdev content into the newly allocated
 local pdev.  As a result of copying the originating pdev content into
 the local pdev, pdev-dev.dma_mask will be pointing back to the
 originating pdev's 'dma_mask' member, not the local pdev's as
 intended.  Thus, when make_local_pdev() calls pci_set_dma_mask() in an
 attempt to set the local pdev's DMA mask to 32 it will instead overwrite
 the originating pdev's DMA mask.  Thus, after any user initiated
 commands are issued, all subsequent DMA allocations will be 32-bit
 restricted from that point onward regardless of whether they are internal
 commands or otherwise.


 This patch fixes the issue by removing the setup of DMA_BIT_MASK to 64 in
 megaraid_probe_one(), leaving the driver with default 32-bit DMA
 capabilities, as it currently ends up in such a state anyway after any
 internal commands are initiated.


 [1] It seems strange that both mega_buffer/buf_dma_handle and
 make_local_pdev() both exist for internal commands but this has been
 the case for a long time - at least since 2.6.12-rc2.  Perhaps there
 is some coalescing that could be done.
 ---
 Myron Stowe (3):
   [SCSI] megaraid: Remove 64-bit DMA related dead code
   [SCSI] megaraid: Remove local pdev's
   [SCSI] megaraid: Remove 64-bit DMA_BIT_MASK capability

 Adam, you do drive by coding on this for LSI ... ack or reject, please.

 James



James,

I have just now located my box of MegaRAID Parallel SCSI controllers.
I will review and test the patch series from Myron and respond by next Monday.

-Adam
--
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: WRITE SAME failed. Manually zeroing with 3w-xxxx driver

2013-05-21 Thread adam radford
On Mon, Apr 29, 2013 at 9:13 AM, Martin K. Petersen
martin.peter...@oracle.com wrote:
 Florian == Florian Westphal f...@strlen.de writes:

 Florian After update to 3.8 dmesg is spammed with: kernel: [
 Florian 280.272094] 3w-: scsi8: Unknown scsi opcode: 0x41 kernel: [
 Florian 280.272107] sd 8:0:0:0: [sda] Unhandled error code kernel:

 Interesting. It looks like the 3ware handles this at the driver level
 instead of passing the command through to the disk and letting it
 fail. That in turn means that the logic we have in place to disable WS
 when the disk does not support it does not get triggered.

 The driver should really fill out the sense buffer in that case.

 Could you please test the patch below?


 Florian This goes on and on.

 The second question is what it is that's issuing these zeroouts at boot?
 Which filesystem are you using? What's your DM/MD config?

 --
 Martin K. Petersen  Oracle Linux Engineering


 3w-: Create sense buffer for unsupported commands

 Make the driver return appropriate sense data when an unsupported
 operation is queued. This will cause the SCSI layer to stop issuing the
 offending command.

 Reported-by: Florian Westphal f...@strlen.de
 CC: adam radford aradf...@gmail.com
 Signed-off-by: Martin K. Petersen martin.peter...@oracle.com

 diff --git a/drivers/scsi/3w-.c b/drivers/scsi/3w-.c
 index 56662ae..b9276d1 100644
 --- a/drivers/scsi/3w-.c
 +++ b/drivers/scsi/3w-.c
 @@ -216,6 +216,7 @@
  #include scsi/scsi_host.h
  #include scsi/scsi_tcq.h
  #include scsi/scsi_cmnd.h
 +#include scsi/scsi_eh.h
  #include 3w-.h

  /* Globals */
 @@ -2009,7 +2010,8 @@ static int tw_scsi_queue_lck(struct scsi_cmnd *SCpnt, 
 void (*done)(struct scsi_c
 printk(KERN_NOTICE 3w-: scsi%d: Unknown scsi 
 opcode: 0x%x\n, tw_dev-host-host_no, *command);
 tw_dev-state[request_id] = TW_S_COMPLETED;
 tw_state_request_finish(tw_dev, request_id);
 -   SCpnt-result = (DID_BAD_TARGET  16);
 +   SCpnt-result = (DRIVER_SENSE  24) | 
 SAM_STAT_CHECK_CONDITION;
 +   scsi_build_sense_buffer(1, SCpnt-sense_buffer, 
 ILLEGAL_REQUEST, 0x20, 0);
 done(SCpnt);
 retval = 0;
 }

Thanks Martin.  This patch looks good.

Acked-by: Adam Radford aradf...@gmail.com
--
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 01/22] [SCSI] megaraid_sas: Use correct #define for MSI-X capability

2013-04-22 Thread adam radford
On Mon, Apr 22, 2013 at 4:54 PM, Bjorn Helgaas bhelg...@google.com wrote:
 -- Forwarded message --
 From: Bjorn Helgaas bhelg...@google.com
 Date: Mon, Apr 22, 2013 at 5:10 PM
 Subject: [PATCH v4 01/22] [SCSI] megaraid_sas: Use correct #define for
 MSI-X capability
 To: linux-...@vger.kernel.org
 Cc: Neela Syam Kolli megaraidli...@lsi.com, Gavin Shan
 sha...@linux.vnet.ibm.com, James E.J. Bottomley
 jbottom...@parallels.com


 Previously we used PCI_MSI_FLAGS to locate a register in the MSI-X
 capability.  This did work because the MSI and MSI-X flags happen
 to be at the same offsets, but was confusing.

 PCI_MSIX_FLAGS_ENABLE is already defined in include/uapi/linux/pci_regs.h,
 so no need to define it again.

 Signed-off-by: Bjorn Helgaas bhelg...@google.com
 CC: Neela Syam Kolli megaraidli...@lsi.com
 CC: James E.J. Bottomley jbottom...@parallels.com
 ---
  drivers/scsi/megaraid/megaraid_sas.h  |3 ---
  drivers/scsi/megaraid/megaraid_sas_base.c |4 ++--
  2 files changed, 2 insertions(+), 5 deletions(-)

 diff --git a/drivers/scsi/megaraid/megaraid_sas.h
 b/drivers/scsi/megaraid/megaraid_sas.h
 index 408d254..684cc34 100644
 --- a/drivers/scsi/megaraid/megaraid_sas.h
 +++ b/drivers/scsi/megaraid/megaraid_sas.h
 @@ -1488,7 +1488,4 @@ struct megasas_mgmt_info {
 int max_index;
  };

 -#define msi_control_reg(base) (base + PCI_MSI_FLAGS)
 -#define PCI_MSIX_FLAGS_ENABLE (1  15)
 -
  #endif /*LSI_MEGARAID_SAS_H */
 diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c
 b/drivers/scsi/megaraid/megaraid_sas_base.c
 index 9d53540..7c90d57 100644
 --- a/drivers/scsi/megaraid/megaraid_sas_base.c
 +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
 @@ -3984,12 +3984,12 @@ static int megasas_probe_one(struct pci_dev *pdev,
 if (reset_devices) {
 pos = pci_find_capability(pdev, PCI_CAP_ID_MSIX);
 if (pos) {
 -   pci_read_config_word(pdev, msi_control_reg(pos),
 +   pci_read_config_word(pdev, pos + PCI_MSIX_FLAGS,
  control);
 if (control  PCI_MSIX_FLAGS_ENABLE) {
 dev_info(pdev-dev, resetting MSI-X\n);
 pci_write_config_word(pdev,
 - msi_control_reg(pos),
 + pos + PCI_MSIX_FLAGS,
   control 
   ~PCI_MSIX_FLAGS_ENABLE);
 }
 --
 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: Adam Radford aradf...@gmail.com

-Adam
--
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] megaraid_sas: release lock on error path

2013-04-16 Thread adam radford
On Tue, Apr 16, 2013 at 12:44 AM, Dan Carpenter
dan.carpen...@oracle.com wrote:
 We should unlock here before returning.

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

 diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
 b/drivers/scsi/megaraid/megaraid_sas_base.c
 index 9d53540..eb2385f 100644
 --- a/drivers/scsi/megaraid/megaraid_sas_base.c
 +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
 @@ -4931,11 +4931,12 @@ static int megasas_mgmt_ioctl_fw(struct file *file, 
 unsigned long arg)
 printk(KERN_ERR megaraid_sas: timed out while
 waiting for HBA to recover\n);
 error = -ENODEV;
 -   goto out_kfree_ioc;
 +   goto out_up;
 }
 spin_unlock_irqrestore(instance-hba_lock, flags);

 error = megasas_mgmt_fw_ioctl(instance, user_ioc, ioc);
 +  out_up:
 up(instance-ioctl_sem);

out_kfree_ioc:
 --
 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

Thanks Dan, this looks good.

Acked-by: Adam Radford aradf...@gmail.com

-Adam
--
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] megaraid_sas: Updates for scsi-misc

2013-02-09 Thread adam radford
James/linux-scsi,

The following small patch series for megaraid_sas brings the driver up
to v06.506.00.00-rc1:

1. Add 4k FastPath DIF support.
2. Dont load DevHandle unless FastPath enabled.
3. Version and Changelog update.

-Adam
--
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] megaraid_sas: Add 4k FastPath DIF support

2013-02-09 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas will allow Fastpath T10PI/DIF
frame builds to work with 4k sector size.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fusion.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fusion.c   2013-02-08
13:20:39.0 -0800
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c   2013-02-09
22:41:23.871865168 -0800
@@ -1206,7 +1206,7 @@
MPI2_SCSIIO_EEDPFLAGS_INSERT_OP;
}
io_request-Control |= (0x4  26);
-   io_request-EEDPBlockSize = MEGASAS_EEDPBLOCKSIZE;
+   io_request-EEDPBlockSize = scp-device-sector_size;
} else {
/* Some drives don't support 16/12 byte CDB's, convert to 10 */
if (((cdb_len == 12) || (cdb_len == 16)) 
diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fusion.h
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.h
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fusion.h   2013-02-08
13:20:39.0 -0800
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.h   2013-02-09
22:41:38.372866533 -0800
@@ -61,7 +61,6 @@
 #define MEGASAS_SCSI_ADDL_CDB_LEN   0x18
 #define MEGASAS_RD_WR_PROTECT_CHECK_ALL0x20
 #define MEGASAS_RD_WR_PROTECT_CHECK_NONE   0x60
-#define MEGASAS_EEDPBLOCKSIZE  512

 /*
  * Raid context flags


megaraid_sas.patch1
Description: Binary data


[PATCH 2/3] megaraid_sas: Dont load DevHandle unless FastPath enabled

2013-02-09 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas will fix an issue where the
driver should not be loading the DevHandle unless FastPath is enabled.
 If FastPath was not enabled, this means the hardware raid map
validation failed for some reason, or the map was corrupted, which
could mean the DevHandle could be invalid.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fusion.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fusion.c   2013-02-09
22:44:15.625191018 -0800
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c   2013-02-09
22:46:14.863866082 -0800
@@ -1511,7 +1511,8 @@
if (scmd-device-channel  MEGASAS_MAX_PD_CHANNELS 
instance-pd_list[pd_index].driveState == MR_PD_STATE_SYSTEM) {
io_request-Function = 0;
-   io_request-DevHandle =
+   if (fusion-fast_path_io)
+   io_request-DevHandle =
local_map_ptr-raidMap.devHndlInfo[device_id].curDevHdl;
io_request-RaidContext.timeoutValue =
local_map_ptr-raidMap.fpPdIoTimeoutSec;


megaraid_sas.patch2
Description: Binary data


[PATCH 3/3] megaraid_sas: Version and Changelog update

2013-02-09 Thread adam radford
James/linux-scsi,

This patch updates the megaraid_sas driver version and updates
Documentation/scsi/ChangeLog.megaraid_sas.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc.old/Documentation/scsi/ChangeLog.megaraid_sas
scsi-misc.new/Documentation/scsi/ChangeLog.megaraid_sas
--- scsi-misc.old/Documentation/scsi/ChangeLog.megaraid_sas 2013-02-08
13:20:39.0 -0800
+++ scsi-misc.new/Documentation/scsi/ChangeLog.megaraid_sas 2013-02-09
22:51:59.079867393 -0800
@@ -1,3 +1,12 @@
+Release Date: Sat. Feb 9, 2013 17:00:00 PST 2013 -
+   (emaild-id:megaraidli...@lsi.com)
+   Adam Radford
+Current Version : 06.506.00.00-rc1
+Old Version : 06.504.01.00-rc1
+1. Add 4k FastPath DIF support.
+2. Dont load DevHandle unless FastPath enabled.
+3. Version and Changelog update.
+---
 Release Date: Mon. Oct 1, 2012 17:00:00 PST 2012 -
(emaild-id:megaraidli...@lsi.com)
Adam Radford
diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_base.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_base.c
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_base.c 2013-02-08
13:20:39.0 -0800
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_base.c 2013-02-09
22:52:28.607810580 -0800
@@ -18,7 +18,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  *
  *  FILE: megaraid_sas_base.c
- *  Version : v06.504.01.00-rc1
+ *  Version : v06.506.00.00-rc1
  *
  *  Authors: LSI Corporation
  *   Sreenivas Bagalkote
diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas.h
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas.h
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas.h  2013-02-08
13:20:39.0 -0800
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas.h  2013-02-09
22:52:53.344866438 -0800
@@ -33,9 +33,9 @@
 /*
  * MegaRAID SAS Driver meta data
  */
-#define MEGASAS_VERSION06.504.01.00-rc1
-#define MEGASAS_RELDATEOct. 1, 2012
-#define MEGASAS_EXT_VERSIONMon. Oct. 1 17:00:00 PDT 2012
+#define MEGASAS_VERSION06.506.00.00-rc1
+#define MEGASAS_RELDATEFeb. 9, 2013
+#define MEGASAS_EXT_VERSIONSat. Feb. 9 17:00:00 PDT 2013

 /*
  * Device IDs


megaraid_sas.patch3
Description: Binary data


Re: [PATCH 4/6] scsi: megaraid: remove a useless call to memset().

2012-12-03 Thread adam radford
On Sat, Dec 1, 2012 at 6:40 PM, Cyril Roelandt tipec...@gmail.com wrote:
 This call is followed by a call to memcpy() on the same memory area, so it can
 be safely removed.

 Signed-off-by: Cyril Roelandt tipec...@gmail.com
 ---
  drivers/scsi/megaraid/megaraid_sas_fusion.c |2 --
  1 file changed, 2 deletions(-)

 diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
 b/drivers/scsi/megaraid/megaraid_sas_fusion.c
 index 74030af..71cc3eb 100644
 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
 +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
 @@ -1028,8 +1028,6 @@ map_cmd_status(struct megasas_cmd_fusion *cmd, u8 
 status, u8 ext_status)

 cmd-scmd-result = (DID_OK  16) | ext_status;
 if (ext_status == SAM_STAT_CHECK_CONDITION) {
 -   memset(cmd-scmd-sense_buffer, 0,
 -  SCSI_SENSE_BUFFERSIZE);
 memcpy(cmd-scmd-sense_buffer, cmd-sense,
SCSI_SENSE_BUFFERSIZE);
 cmd-scmd-result |= DRIVER_SENSE  24;
 --

Acked-by: Adam Radford aradf...@gmail.com
--
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,repost 07/10] megaraid_sas: use scsi_host_alloc_node

2012-12-03 Thread adam radford
On Tue, Nov 27, 2012 at 8:46 AM, Jeff Moyer jmo...@redhat.com wrote:

 Signed-off-by: Jeff Moyer jmo...@redhat.com
 ---
  drivers/scsi/megaraid/megaraid_sas_base.c |5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)

 diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
 b/drivers/scsi/megaraid/megaraid_sas_base.c
 index d2c5366..707a6cd 100644
 --- a/drivers/scsi/megaraid/megaraid_sas_base.c
 +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
 @@ -4020,8 +4020,9 @@ megasas_probe_one(struct pci_dev *pdev, const struct 
 pci_device_id *id)
 if (megasas_set_dma_mask(pdev))
 goto fail_set_dma_mask;

 -   host = scsi_host_alloc(megasas_template,
 -  sizeof(struct megasas_instance));
 +   host = scsi_host_alloc_node(megasas_template,
 +   sizeof(struct megasas_instance),
 +   dev_to_node(pdev-dev));

 if (!host) {
 printk(KERN_DEBUG megasas: scsi_host_alloc failed\n);

Acked-by: Adam Radford aradf...@gmail.com
--
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 memory leak if SGL has zero length entries

2012-12-03 Thread adam radford
On Wed, Nov 21, 2012 at 12:54 AM, Bjørn Mork bj...@mork.no wrote:
 commit 98cb7e44 ([SCSI] megaraid_sas: Sanity check user
 supplied length before passing it to dma_alloc_coherent())
 introduced a memory leak.  Memory allocated for entries
 following zero length SGL entries will not be freed.

 Reference: http://bugs.debian.org/688198
 Cc: sta...@vger.kernel.org
 Signed-off-by: Bjørn Mork bj...@mork.no
 ---
  drivers/scsi/megaraid/megaraid_sas_base.c |   10 ++
  1 file changed, 6 insertions(+), 4 deletions(-)

 diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
 b/drivers/scsi/megaraid/megaraid_sas_base.c
 index d2c5366..12b6be4 100644
 --- a/drivers/scsi/megaraid/megaraid_sas_base.c
 +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
 @@ -4854,10 +4854,12 @@ megasas_mgmt_fw_ioctl(struct megasas_instance 
 *instance,
 sense, sense_handle);
 }

 -   for (i = 0; i  ioc-sge_count  kbuff_arr[i]; i++) {
 -   dma_free_coherent(instance-pdev-dev,
 -   kern_sge32[i].length,
 -   kbuff_arr[i], kern_sge32[i].phys_addr);
 +   for (i = 0; i  ioc-sge_count; i++) {
 +   if (kbuff_arr[i])
 +   dma_free_coherent(instance-pdev-dev,
 + kern_sge32[i].length,
 + kbuff_arr[i],
 + kern_sge32[i].phys_addr);
 }

 megasas_return_cmd(instance, cmd);

Acked-by: Adam Radford aradf...@gmail.com
--
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/7] megaraid_sas: Updates for scsi for-next

2012-10-01 Thread adam radford
James/linux-scsi,

The following patch series for megaraid_sas brings the driver up to
v06.504.01.00-rc1:

1. Remove un-needed completion_lock spinlock calls.
2. Add module param for configurable MSI-X vector count.
3. Load io_request DataLength in bytes.
4. Add array boundary check for SystemPD.
5. Add SystemPD FastPath support.
6. Remove duplicate code.
7. Version, Changelog, Copyright update.

-Adam
--
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/7] megaraid_sas: Remove un-needed completion_lock spinlock calls

2012-10-01 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas removes some un-needed
completion_lock spinlock calls.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc/drivers/scsi/megaraid/megaraid_sas_fusion.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c
--- scsi-misc/drivers/scsi/megaraid/megaraid_sas_fusion.c   2012-10-01
15:51:15.218956132 -0700
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c   2012-10-01
16:52:32.515019501 -0700
@@ -1855,10 +1855,8 @@
}
spin_unlock_irqrestore(instance-hba_lock, flags);

-   spin_lock_irqsave(instance-completion_lock, flags);
for (MSIxIndex = 0 ; MSIxIndex  count; MSIxIndex++)
complete_cmd_fusion(instance, MSIxIndex);
-   spin_unlock_irqrestore(instance-completion_lock, flags);
 }

 /**


megaraid_sas.patch1
Description: Binary data


[PATCH 2/7] megaraid_sas: Add module param for configurable MSI-X vector count

2012-10-01 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas adds a module parameter for
configurable MSI-X vector count.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc/drivers/scsi/megaraid/megaraid_sas_base.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_base.c
--- scsi-misc/drivers/scsi/megaraid/megaraid_sas_base.c 2012-10-01
18:03:42.0 -0700
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_base.c 2012-10-01
18:05:20.831864155 -0700
@@ -71,6 +71,10 @@
 module_param(msix_disable, int, S_IRUGO);
 MODULE_PARM_DESC(msix_disable, Disable MSI-X interrupt handling. Default: 0);

+static unsigned int msix_vectors;
+module_param(msix_vectors, int, S_IRUGO);
+MODULE_PARM_DESC(msix_vectors, MSI-X max vector count. Default: Set by FW);
+
 static int throttlequeuedepth = MEGASAS_THROTTLE_QUEUE_DEPTH;
 module_param(throttlequeuedepth, int, S_IRUGO);
 MODULE_PARM_DESC(throttlequeuedepth,
@@ -3520,6 +3524,10 @@
instance-msix_vectors = (readl(instance-reg_set-
outbound_scratch_pad_2
  )  0x1F) + 1;
+   if (msix_vectors)
+   instance-msix_vectors =
+   min(msix_vectors,
+   instance-msix_vectors);
} else
instance-msix_vectors = 1;
/* Don't bother allocating more MSI-X vectors than cpus */


megaraid_sas.patch2
Description: Binary data


[PATCH 3/7] megaraid_sas: Load io_request DataLength in bytes

2012-10-01 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas loads io_request-DataLength in
bytes for newer firmware that supports high availability.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc/drivers/scsi/megaraid/megaraid_sas_fusion.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c
--- scsi-misc/drivers/scsi/megaraid/megaraid_sas_fusion.c   2012-10-01
16:53:27.302925502 -0700
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c   2012-10-01
17:02:57.316863262 -0700
@@ -1184,8 +1184,6 @@
io_request-CDB.EEDP32.PrimaryReferenceTag =
cpu_to_be32(ref_tag);
io_request-CDB.EEDP32.PrimaryApplicationTagMask = 0x;
-
-   io_request-DataLength = num_blocks * 512;
io_request-IoFlags = 32; /* Specify 32-byte cdb */

/* Transfer length */
@@ -1329,7 +1327,7 @@
  struct megasas_cmd_fusion *cmd)
 {
u8 fp_possible;
-   u32 start_lba_lo, start_lba_hi, device_id;
+   u32 start_lba_lo, start_lba_hi, device_id, datalength = 0;
struct MPI2_RAID_SCSI_IO_REQUEST *io_request;
union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc;
struct IO_REQUEST_INFO io_info;
@@ -1355,7 +1353,7 @@
 * 6-byte READ(0x08) or WRITE(0x0A) cdb
 */
if (scp-cmd_len == 6) {
-   io_request-DataLength = (u32) scp-cmnd[4];
+   datalength = (u32) scp-cmnd[4];
start_lba_lo = ((u32) scp-cmnd[1]  16) |
((u32) scp-cmnd[2]  8) | (u32) scp-cmnd[3];

@@ -1366,7 +1364,7 @@
 * 10-byte READ(0x28) or WRITE(0x2A) cdb
 */
else if (scp-cmd_len == 10) {
-   io_request-DataLength = (u32) scp-cmnd[8] |
+   datalength = (u32) scp-cmnd[8] |
((u32) scp-cmnd[7]  8);
start_lba_lo = ((u32) scp-cmnd[2]  24) |
((u32) scp-cmnd[3]  16) |
@@ -1377,7 +1375,7 @@
 * 12-byte READ(0xA8) or WRITE(0xAA) cdb
 */
else if (scp-cmd_len == 12) {
-   io_request-DataLength = ((u32) scp-cmnd[6]  24) |
+   datalength = ((u32) scp-cmnd[6]  24) |
((u32) scp-cmnd[7]  16) |
((u32) scp-cmnd[8]  8) | (u32) scp-cmnd[9];
start_lba_lo = ((u32) scp-cmnd[2]  24) |
@@ -1389,7 +1387,7 @@
 * 16-byte READ(0x88) or WRITE(0x8A) cdb
 */
else if (scp-cmd_len == 16) {
-   io_request-DataLength = ((u32) scp-cmnd[10]  24) |
+   datalength = ((u32) scp-cmnd[10]  24) |
((u32) scp-cmnd[11]  16) |
((u32) scp-cmnd[12]  8) | (u32) scp-cmnd[13];
start_lba_lo = ((u32) scp-cmnd[6]  24) |
@@ -1403,8 +1401,9 @@

memset(io_info, 0, sizeof(struct IO_REQUEST_INFO));
io_info.ldStartBlock = ((u64)start_lba_hi  32) | start_lba_lo;
-   io_info.numBlocks = io_request-DataLength;
+   io_info.numBlocks = datalength;
io_info.ldTgtId = device_id;
+   io_request-DataLength = scsi_bufflen(scp);

if (scp-sc_data_direction == PCI_DMA_FROMDEVICE)
io_info.isRead = 1;
@@ -1431,7 +1430,6 @@
if (fp_possible) {
megasas_set_pd_lba(io_request, scp-cmd_len, io_info, scp,
   local_map_ptr, start_lba_lo);
-   io_request-DataLength = scsi_bufflen(scp);
io_request-Function = MPI2_FUNCTION_SCSI_IO_REQUEST;
cmd-request_desc-SCSIIO.RequestFlags =
(MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY


megaraid_sas.patch3
Description: Binary data


[PATCH 4/7] megaraid_sas: Add array boundary check for SystemPD

2012-10-01 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas adds an array boundary check for
the SystemPD build path.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc/drivers/scsi/megaraid/megaraid_sas_fusion.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c
--- scsi-misc/drivers/scsi/megaraid/megaraid_sas_fusion.c   2012-10-01
17:05:01.643925591 -0700
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c   2012-10-01
17:06:40.300862878 -0700
@@ -1508,7 +1508,8 @@
local_map_ptr = fusion-ld_map[(instance-map_id  1)];

/* Check if this is a system PD I/O */
-   if (instance-pd_list[pd_index].driveState == MR_PD_STATE_SYSTEM) {
+   if (scmd-device-channel  MEGASAS_MAX_PD_CHANNELS 
+   instance-pd_list[pd_index].driveState == MR_PD_STATE_SYSTEM) {
io_request-Function = 0;
io_request-DevHandle =
local_map_ptr-raidMap.devHndlInfo[device_id].curDevHdl;


megaraid_sas.patch4
Description: Binary data


[PATCH 5/7] megaraid_sas: Add SystemPD FastPath support

2012-10-01 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas adds SystemPD FastPath support.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc/drivers/scsi/megaraid/megaraid_sas_fusion.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c
--- scsi-misc/drivers/scsi/megaraid/megaraid_sas_fusion.c   2012-10-01
17:07:36.228925449 -0700
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c   2012-10-01
17:09:12.628956305 -0700
@@ -1524,6 +1524,8 @@
cmd-request_desc-SCSIIO.RequestFlags =
(MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY 
 MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
+   cmd-request_desc-SCSIIO.DevHandle =
+   local_map_ptr-raidMap.devHndlInfo[device_id].curDevHdl;
} else {
io_request-Function  = MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST;
io_request-DevHandle = device_id;


megaraid_sas.patch5
Description: Binary data


[PATCH 6/7] megaraid_sas: Remove duplicate code

2012-10-01 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas removes some duplicate code.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc/drivers/scsi/megaraid/megaraid_sas_base.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_base.c
--- scsi-misc/drivers/scsi/megaraid/megaraid_sas_base.c 2012-10-01
16:59:31.089925547 -0700
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_base.c 2012-10-01
17:12:41.059956897 -0700
@@ -5241,7 +5241,6 @@

case MR_EVT_PD_REMOVED:
if (megasas_get_pd_list(instance) == 0) {
-   megasas_get_pd_list(instance);
for (i = 0; i  MEGASAS_MAX_PD_CHANNELS; i++) {
for (j = 0;
j  MEGASAS_MAX_DEV_PER_CHANNEL;
diff -Naur scsi-misc/drivers/scsi/megaraid/megaraid_sas_fusion.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c
--- scsi-misc/drivers/scsi/megaraid/megaraid_sas_fusion.c   2012-10-01
17:11:56.060925472 -0700
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c   2012-10-01
17:14:21.350863085 -0700
@@ -1733,8 +1733,6 @@
if (reply_descript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED)
return IRQ_NONE;

-   d_val.word = desc-Words;
-
num_completed = 0;

while ((d_val.u.low != UINT_MAX)  (d_val.u.high != UINT_MAX)) {


megaraid_sas.patch6
Description: Binary data


Re: [PATCH] megaraid_sas: combine kmalloc+memset into kzalloc

2012-08-24 Thread adam radford
On Fri, Aug 24, 2012 at 8:27 AM, Fengguang Wu fengguang...@intel.com wrote:
 Use kzalloc rather than kmalloc followed by memset with 0.

 Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

 Signed-off-by: Fengguang Wu fengguang...@intel.com
 ---
  drivers/scsi/megaraid/megaraid_sas_fusion.c |7 ++-
  1 file changed, 2 insertions(+), 5 deletions(-)

 --- linux.orig/drivers/scsi/megaraid/megaraid_sas_fusion.c  2012-06-07 
 05:39:57.418846382 +0800
 +++ linux/drivers/scsi/megaraid/megaraid_sas_fusion.c   2012-08-24 
 23:25:02.261560445 +0800
 @@ -461,8 +461,8 @@ megasas_alloc_cmds_fusion(struct megasas
  * Allocate the dynamic array first and then allocate individual
  * commands.
  */
 -   fusion-cmd_list = kmalloc(sizeof(struct megasas_cmd_fusion *)
 -  *max_cmd, GFP_KERNEL);
 +   fusion-cmd_list = kzalloc(sizeof(struct megasas_cmd_fusion *)
 +  * max_cmd, GFP_KERNEL);

 if (!fusion-cmd_list) {
 printk(KERN_DEBUG megasas: out of memory. Could not alloc 
 @@ -470,9 +470,6 @@ megasas_alloc_cmds_fusion(struct megasas
 goto fail_cmd_list;
 }

 -   memset(fusion-cmd_list, 0, sizeof(struct megasas_cmd_fusion *)
 -  *max_cmd);
 -
 max_cmd = instance-max_fw_cmds;
 for (i = 0; i  max_cmd; i++) {
 fusion-cmd_list[i] = kmalloc(sizeof(struct 
 megasas_cmd_fusion),

Acked-by: Adam Radford aradf...@gmail.com
--
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] [RFC] [SCSI] mpt fusion: add support for 0x1000/0x0055

2012-07-27 Thread adam radford
On 7/27/12, Jiri Kosina jkos...@suse.cz wrote:
 On Sat, 21 Jul 2012, Jiri Kosina wrote:

 The device identifies itself as

 0d:05.0 SCSI storage controller: LSI Logic / Symbios Logic SAS1068 PCI-X
 Fusion-MPT SAS (rev 01) Subsystem: NEC Corporation SAS1068

 and seems to be functionally compatible with 0x0054 PID.

 The request for support of this device has been raised on mailinglists
 several
 times in the past (see [1] [2] and more), but aparently the PCI ID never
 made it
 to mptsas_pci_table[].

 [1] http://comments.gmane.org/gmane.linux.scsi/63836
 [2] http://lkml.indiana.edu/hypermail/linux/kernel/0701.2/1715.html

 Signed-off-by: Jiri Kosina jkos...@suse.cz
 ---


 I guess the Subsystem: NEC Corporation is telling us some rebranding
 story, including the PID change ... ?

 Hi guys,

 any feedback on this please?

 Thanks.

NACK.

Vendor 0x1000, Device id 0x0055 is actually an old LSI MegaRAID 1068
based software raid board.  This device was never qualified nor
intended to be used with the mpt fusion driver.

-Adam
--
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] [RFC] [SCSI] mpt fusion: add support for 0x1000/0x0055

2012-07-27 Thread adam radford
On 7/27/12, Jiri Kosina jkos...@suse.cz wrote:
...

 So, what is the alternative?

 The only thing I know is that it works at least in basic mode (haven't
 tested performance at all).

The driver for your card is a closed source driver called 'megasr'.
Here is a link to the LSI download page for this card/driver:

http://www.lsi.com/support/Pages/Download-Results.aspx?productcode=P00041assettype=0component=Storage%20Componentproductfamily=Legacy%20RAID%20Controllersproductname=MegaRAID%20SAS%208208XLP

-Adam
--
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/5] megaraid_sas: Updates for scsi for-next

2012-07-17 Thread adam radford
James/linux-scsi,

The following patch series for megaraid_sas brings the driver up to v6.18-rc1:

1. Fix Copyright dates.
2. Add throttlequeuedepth module parameter.
3. Add resetwaittime module parameter.
4. Move poll_aen_lock initializer.
5. Version and Changelog update.

-Adam
--
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/5] megaraid_sas: Fix Copyright dates

2012-07-17 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas fixes the Copyright dates.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi/drivers/scsi/megaraid/megaraid_sas_base.c
scsi.new/drivers/scsi/megaraid/megaraid_sas_base.c
--- scsi/drivers/scsi/megaraid/megaraid_sas_base.c  2012-07-17
14:06:30.0 -0700
+++ scsi.new/drivers/scsi/megaraid/megaraid_sas_base.c  2012-07-17
14:30:14.102231138 -0700
@@ -1,7 +1,7 @@
 /*
  *  Linux MegaRAID driver for SAS based RAID controllers
  *
- *  Copyright (c) 2009-2011  LSI Corporation.
+ *  Copyright (c) 2003-2012  LSI Corporation.
  *
  *  This program is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU General Public License
diff -Naur scsi/drivers/scsi/megaraid/megaraid_sas_fp.c
scsi.new/drivers/scsi/megaraid/megaraid_sas_fp.c
--- scsi/drivers/scsi/megaraid/megaraid_sas_fp.c2012-07-17
14:06:30.0 -0700
+++ scsi.new/drivers/scsi/megaraid/megaraid_sas_fp.c2012-07-17
14:30:31.471232644 -0700
@@ -1,7 +1,7 @@
 /*
  *  Linux MegaRAID driver for SAS based RAID controllers
  *
- *  Copyright (c) 2009-2011  LSI Corporation.
+ *  Copyright (c) 2009-2012  LSI Corporation.
  *
  *  This program is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU General Public License
diff -Naur scsi/drivers/scsi/megaraid/megaraid_sas_fusion.c
scsi.new/drivers/scsi/megaraid/megaraid_sas_fusion.c
--- scsi/drivers/scsi/megaraid/megaraid_sas_fusion.c2012-07-17
14:06:30.0 -0700
+++ scsi.new/drivers/scsi/megaraid/megaraid_sas_fusion.c2012-07-17
14:30:46.026232550 -0700
@@ -1,7 +1,7 @@
 /*
  *  Linux MegaRAID driver for SAS based RAID controllers
  *
- *  Copyright (c) 2009-2011  LSI Corporation.
+ *  Copyright (c) 2009-2012  LSI Corporation.
  *
  *  This program is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU General Public License
diff -Naur scsi/drivers/scsi/megaraid/megaraid_sas_fusion.h
scsi.new/drivers/scsi/megaraid/megaraid_sas_fusion.h
--- scsi/drivers/scsi/megaraid/megaraid_sas_fusion.h2012-07-17
14:06:30.0 -0700
+++ scsi.new/drivers/scsi/megaraid/megaraid_sas_fusion.h2012-07-17
14:31:04.978232551 -0700
@@ -1,7 +1,7 @@
 /*
  *  Linux MegaRAID driver for SAS based RAID controllers
  *
- *  Copyright (c) 2009-2011  LSI Corporation.
+ *  Copyright (c) 2009-2012  LSI Corporation.
  *
  *  This program is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU General Public License
diff -Naur scsi/drivers/scsi/megaraid/megaraid_sas.h
scsi.new/drivers/scsi/megaraid/megaraid_sas.h
--- scsi/drivers/scsi/megaraid/megaraid_sas.h   2012-07-17
14:06:30.0 -0700
+++ scsi.new/drivers/scsi/megaraid/megaraid_sas.h   2012-07-17
14:31:19.255388683 -0700
@@ -1,7 +1,7 @@
 /*
  *  Linux MegaRAID driver for SAS based RAID controllers
  *
- *  Copyright (c) 2009-2011  LSI Corporation.
+ *  Copyright (c) 2003-2012  LSI Corporation.
  *
  *  This program is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU General Public License


megaraid_sas.patch1
Description: Binary data


[PATCH 2/5] megaraid_sas: Add throttlequeuedepth module parameter

2012-07-17 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas adds a throttlequeuedepth module
parameter.  This allows a user to adjust the queue depth of the
adapter when throttled due to I/O timeout.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi/drivers/scsi/megaraid/megaraid_sas_base.c
scsi.new/drivers/scsi/megaraid/megaraid_sas_base.c
--- scsi/drivers/scsi/megaraid/megaraid_sas_base.c  2012-07-17
14:33:50.681233390 -0700
+++ scsi.new/drivers/scsi/megaraid/megaraid_sas_base.c  2012-07-17
14:40:59.507233383 -0700
@@ -71,6 +71,11 @@
 module_param(msix_disable, int, S_IRUGO);
 MODULE_PARM_DESC(msix_disable, Disable MSI-X interrupt handling. Default: 0);

+static int throttlequeuedepth = MEGASAS_THROTTLE_QUEUE_DEPTH;
+module_param(throttlequeuedepth, int, S_IRUGO);
+MODULE_PARM_DESC(throttlequeuedepth,
+   Adapter queue depth when throttled due to I/O timeout. Default: 16);
+
 MODULE_LICENSE(GPL);
 MODULE_VERSION(MEGASAS_VERSION);
 MODULE_AUTHOR(megaraidli...@lsi.com);
@@ -1595,8 +1600,9 @@
 {
unsigned long flags;
if (instance-flag  MEGASAS_FW_BUSY
-time_after(jiffies, instance-last_time + 5 * HZ)
-atomic_read(instance-fw_outstanding)  17) {
+time_after(jiffies, instance-last_time + 5 * HZ)
+atomic_read(instance-fw_outstanding) 
+   instance-throttlequeuedepth + 1) {

spin_lock_irqsave(instance-host-host_lock, flags);
instance-flag = ~MEGASAS_FW_BUSY;
@@ -1914,7 +1920,7 @@
/* FW is busy, throttle IO */
spin_lock_irqsave(instance-host-host_lock, flags);

-   instance-host-can_queue = 16;
+   instance-host-can_queue = instance-throttlequeuedepth;
instance-last_time = jiffies;
instance-flag |= MEGASAS_FW_BUSY;

@@ -3577,6 +3583,24 @@

kfree(ctrl_info);

+   /* Check for valid throttlequeuedepth module parameter */
+   if (instance-pdev-device == PCI_DEVICE_ID_LSI_SAS0073SKINNY ||
+   instance-pdev-device == PCI_DEVICE_ID_LSI_SAS0071SKINNY) {
+   if (throttlequeuedepth  (instance-max_fw_cmds -
+ MEGASAS_SKINNY_INT_CMDS))
+   instance-throttlequeuedepth =
+   MEGASAS_THROTTLE_QUEUE_DEPTH;
+   else
+   instance-throttlequeuedepth = throttlequeuedepth;
+   } else {
+   if (throttlequeuedepth  (instance-max_fw_cmds -
+ MEGASAS_INT_CMDS))
+   instance-throttlequeuedepth =
+   MEGASAS_THROTTLE_QUEUE_DEPTH;
+   else
+   instance-throttlequeuedepth = throttlequeuedepth;
+   }
+
 /*
* Setup tasklet for cmd completion
*/
diff -Naur scsi/drivers/scsi/megaraid/megaraid_sas.h
scsi.new/drivers/scsi/megaraid/megaraid_sas.h
--- scsi/drivers/scsi/megaraid/megaraid_sas.h   2012-07-17
14:33:50.683231556 -0700
+++ scsi.new/drivers/scsi/megaraid/megaraid_sas.h   2012-07-17
14:42:44.066172702 -0700
@@ -747,6 +747,7 @@
 #defineMEGASAS_RESET_NOTICE_INTERVAL   5
 #define MEGASAS_IOCTL_CMD  0
 #define MEGASAS_DEFAULT_CMD_TIMEOUT90
+#define MEGASAS_THROTTLE_QUEUE_DEPTH   16

 /*
  * FW reports the maximum of number of commands that it can accept (maximum
@@ -1364,6 +1365,7 @@
unsigned long bar;
long reset_flags;
struct mutex reset_mutex;
+   int throttlequeuedepth;
 };

 enum {


megaraid_sas.patch2
Description: Binary data


[PATCH 3/5] megaraid_sas: Add resetwaittime module parameter

2012-07-17 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas adds support for a resetwaittime
module parameter.  This allows a user to adjust the wait time in
seconds after I/O timeout before resetting the adapter.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi/drivers/scsi/megaraid/megaraid_sas_base.c
scsi.new/drivers/scsi/megaraid/megaraid_sas_base.c
--- scsi/drivers/scsi/megaraid/megaraid_sas_base.c  2012-07-17
14:44:04.341294660 -0700
+++ scsi.new/drivers/scsi/megaraid/megaraid_sas_base.c  2012-07-17
14:50:41.503232158 -0700
@@ -76,6 +76,11 @@
 MODULE_PARM_DESC(throttlequeuedepth,
Adapter queue depth when throttled due to I/O timeout. Default: 16);

+int resetwaittime = MEGASAS_RESET_WAIT_TIME;
+module_param(resetwaittime, int, S_IRUGO);
+MODULE_PARM_DESC(resetwaittime, Wait time in seconds after I/O timeout 
+before resetting adapter. Default: 180);
+
 MODULE_LICENSE(GPL);
 MODULE_VERSION(MEGASAS_VERSION);
 MODULE_AUTHOR(megaraidli...@lsi.com);
@@ -1778,7 +1783,7 @@
return SUCCESS;
}

-   for (i = 0; i  wait_time; i++) {
+   for (i = 0; i  resetwaittime; i++) {

int outstanding = atomic_read(instance-fw_outstanding);

diff -Naur scsi/drivers/scsi/megaraid/megaraid_sas_fusion.c
scsi.new/drivers/scsi/megaraid/megaraid_sas_fusion.c
--- scsi/drivers/scsi/megaraid/megaraid_sas_fusion.c2012-07-17
14:33:50.682231505 -0700
+++ scsi.new/drivers/scsi/megaraid/megaraid_sas_fusion.c2012-07-17
14:54:56.487358768 -0700
@@ -94,6 +94,7 @@
 void megaraid_sas_kill_hba(struct megasas_instance *instance);

 extern u32 megasas_dbg_lvl;
+extern int resetwaittime;

 /**
  * megasas_enable_intr_fusion -Enables interrupts
@@ -2063,9 +2064,9 @@
 int megasas_wait_for_outstanding_fusion(struct megasas_instance *instance)
 {
int i, outstanding, retval = 0;
-   u32 fw_state, wait_time = MEGASAS_RESET_WAIT_TIME;
+   u32 fw_state;

-   for (i = 0; i  wait_time; i++) {
+   for (i = 0; i  resetwaittime; i++) {
/* Check if firmware is in fault state */
fw_state = instance-instancet-read_fw_status_reg(
instance-reg_set)  MFI_STATE_MASK;


megaraid_sas.patch3
Description: Binary data


[PATCH 4/5] megaraid_sas: Move poll_aen_lock initializer

2012-07-17 Thread adam radford
Cc: stable

James/linux-scsi,

The following patch from Kashyap Desai for megaraid_sas moves the
poll_aen_lock initializer from megasas_probe_one() to megasas_init().
This prevents a crash when a user loads the driver and tries to issue
a poll() system call on the ioctl interface with no adapters present.

Signed-off-by: Kashyap Desai kashyap.de...@lsi.com
Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi/drivers/scsi/megaraid/megaraid_sas_base.c
scsi.new/drivers/scsi/megaraid/megaraid_sas_base.c
--- scsi/drivers/scsi/megaraid/megaraid_sas_base.c  2012-07-17
14:57:32.890231627 -0700
+++ scsi.new/drivers/scsi/megaraid/megaraid_sas_base.c  2012-07-17
14:59:37.285232167 -0700
@@ -4095,7 +4095,6 @@
spin_lock_init(instance-cmd_pool_lock);
spin_lock_init(instance-hba_lock);
spin_lock_init(instance-completion_lock);
-   spin_lock_init(poll_aen_lock);

mutex_init(instance-aen_mutex);
mutex_init(instance-reset_mutex);
@@ -5421,6 +5420,8 @@
printk(KERN_INFO megasas: %s %s\n, MEGASAS_VERSION,
   MEGASAS_EXT_VERSION);

+   spin_lock_init(poll_aen_lock);
+
support_poll_for_event = 2;
support_device_change = 1;


megaraid_sas.patch4
Description: Binary data


[PATCH 5/5] megaraid_sas: Version and Changelog update

2012-07-17 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas updates the driver version and
Documentation/scsi/ChangeLog.megaraid_sas files.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi/Documentation/scsi/ChangeLog.megaraid_sas
scsi.new/Documentation/scsi/ChangeLog.megaraid_sas
--- scsi/Documentation/scsi/ChangeLog.megaraid_sas  2012-07-17
14:06:21.0 -0700
+++ scsi.new/Documentation/scsi/ChangeLog.megaraid_sas  2012-07-17
15:07:27.368388750 -0700
@@ -1,3 +1,13 @@
+Release Date: Tue. Jun 17, 2012 17:00:00 PST 2012 -
+   (emaild-id:megaraidli...@lsi.com)
+   Adam Radford/Kashyap Desai
+Current Version : 00.00.06.18-rc1
+Old Version : 00.00.06.15-rc1
+1. Fix Copyright dates.
+2. Add throttlequeuedepth module parameter.
+3. Add resetwaittime module parameter.
+4. Move poll_aen_lock initializer.
+---
 Release Date: Mon. Mar 19, 2012 17:00:00 PST 2012 -
(emaild-id:megaraidli...@lsi.com)
Adam Radford
diff -Naur scsi/drivers/scsi/megaraid/megaraid_sas_base.c
scsi.new/drivers/scsi/megaraid/megaraid_sas_base.c
--- scsi/drivers/scsi/megaraid/megaraid_sas_base.c  2012-07-17
15:01:15.136294781 -0700
+++ scsi.new/drivers/scsi/megaraid/megaraid_sas_base.c  2012-07-17
15:01:50.296168198 -0700
@@ -18,7 +18,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  *
  *  FILE: megaraid_sas_base.c
- *  Version : v00.00.06.15-rc1
+ *  Version : v00.00.06.18-rc1
  *
  *  Authors: LSI Corporation
  *   Sreenivas Bagalkote
diff -Naur scsi/drivers/scsi/megaraid/megaraid_sas.h
scsi.new/drivers/scsi/megaraid/megaraid_sas.h
--- scsi/drivers/scsi/megaraid/megaraid_sas.h   2012-07-17
14:44:04.342294076 -0700
+++ scsi.new/drivers/scsi/megaraid/megaraid_sas.h   2012-07-17
15:02:19.715232696 -0700
@@ -33,9 +33,9 @@
 /*
  * MegaRAID SAS Driver meta data
  */
-#define MEGASAS_VERSION00.00.06.15-rc1
-#define MEGASAS_RELDATEMar. 19, 2012
-#define MEGASAS_EXT_VERSIONMon. Mar. 19 17:00:00 PDT 2012
+#define MEGASAS_VERSION00.00.06.18-rc1
+#define MEGASAS_RELDATEJun. 17, 2012
+#define MEGASAS_EXT_VERSIONTue. Jun. 17 17:00:00 PDT 2012

 /*
  * Device IDs


megaraid_sas.patch5
Description: Binary data


Re: [PATCH 2.6.23] 3w-xxxx: Fix bad unaligned accesses on alpha SMP

2007-12-07 Thread adam radford
On Dec 6, 2007 6:07 PM, Gabriele Gorla [EMAIL PROTECTED] wrote:
 disable packing of the TAG_TW_Device_Extension
 structure to prevent kernel unaligned accesses when
 accessing the spinlock inside the ioctl_wqueue structure.
 Fixes smartmontools kernel panic on alpha SMP

 Signed-off-by: Gabriele Gorla [EMAIL PROTECTED]
 ---

 --- linux-2.6.23/drivers/scsi/3w-.h 2007-10-09 13:31:38.0 -0700
 +++ linux-2.6.23a/drivers/scsi/3w-.h 2007-12-06 17:46:05.0 -0800
 @@ -392,6 +392,8 @@
 unsigned char padding[12];
  } TW_Passthru;

 +#pragma pack()
 +
  typedef struct TAG_TW_Device_Extension {
 u32 base_addr;
 unsigned long   *alignment_virtual_address[TW_Q_LENGTH];
 @@ -430,6 +432,4 @@
 wait_queue_head_t   ioctl_wqueue;
  } TW_Device_Extension;

 -#pragma pack()
 -
  #endif /* _3W__H */




ACK  James, please apply.

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


Re: Patch submission question [not in the FAQ]

2007-12-06 Thread adam radford
On Dec 5, 2007 3:36 AM, Gabriele Gorla [EMAIL PROTECTED] wrote:
 Hello,
 I have submitted a patch for the 3x- driver on
 alpha several months ago to both the driver maintainer
 and the linux-scsi mailing list.
 I have read all the FAQ and I tried to stick to the
 instructions to the letter.
 However the patch has been completely ignored. No
 reply, no comment, no flames, absolutely nothing...

 the original email submission is at the end of the
 email.

 could anyone please explain what I am doing wrong?

 thanks,
 GG

Gabriele,

I ignored your patch because:

1. I do not believe you have the 3w- driver running on an
   alpha SMP system.

2. I removed the bitfields from the 3w- driver but I have
   yet to add full big endian support due to lack of demand.  I have
   such a patch for this driver (which already includes the unpacking
   of the wait_queue_head_t variable) but I have not submitted it to
   the main-line kernel.  The in-kernel 3w- driver is still missing
   the byte-swaps.

   The 3w-9xxx (9000 series 3ware driver) has full big endian support.

3. Your patch was garbled.

Is this an official request for big endian support for the 3w- driver or
are you looking for anybody who has a packed 'wait_queue_head_t' and
submitting a patch to fix it?

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


Re: [PATCH] 3w-9xxx: fix abysmal write performance on some motherboards

2007-11-09 Thread adam radford
On Nov 9, 2007 10:04 AM, Tony Battersby [EMAIL PROTECTED] wrote:
 The 3ware 9500S-8 SATA RAID controller exhibits terrible write
 performance when PCI memory-write-and-invalidate is disabled.  This is
 easy to demonstrate by replacing pci_try_set_mwi() in the patch below
 with pci_clear_mwi().  My benchmarks show the following:

 MWI disabled: 15 MB/s write, 330 MB/s read
 MWI enabled:  240 MB/s write, 330 MB/s read

 Most motherboards will enable MWI without the driver having to set it
 explicitly, so most people probably wouldn't encounter this problem.
 For the few motherboards that don't enable it, this patch could give a
 16x performance improvement for writing.

 This issue does not seem to affect the 9550SX controller, but the patch
 doesn't hurt it either.  I haven't tested any of the other 3ware
 controllers.

 Signed-off-by: Tony Battersby [EMAIL PROTECTED]
 ---
 --- linux-2.6.24-rc2/drivers/scsi/3w-9xxx.c.orig2007-11-09 
 12:32:32.0 -0500
 +++ linux-2.6.24-rc2/drivers/scsi/3w-9xxx.c 2007-11-09 12:33:20.0 
 -0500
 @@ -2010,6 +2010,7 @@ static int __devinit twa_probe(struct pc
}

pci_set_master(pdev);
 +   pci_try_set_mwi(pdev);

if (pci_set_dma_mask(pdev, DMA_64BIT_MASK)
|| pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))


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


ACK...

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


[PATCH 1/1] 3ware 8000 serialize reset code

2007-01-04 Thread adam radford

The attached patch for scsi-misc-2.6 updates the 3ware 8000 driver:

- Free irq handler in __tw_shutdown().
- Turn on RCD bit for caching mode page.
- Serialize reset code.

Signed-off-by: Adam Radford [EMAIL PROTECTED]

James, Please apply

Thanks!

-Adam

Note: The patch is attached as an attachment, and also included
in-line below.   The below may have line-wrap issues since I'm pasting
into gmail.

diff -Naur scsi-misc-2.6/drivers/scsi/3w-.c
scsi-misc-2.6.new/drivers/scsi/3w-.c
--- scsi-misc-2.6/drivers/scsi/3w-.c2006-11-29 13:57:37.0 
-0800
+++ scsi-misc-2.6.new/drivers/scsi/3w-.c2007-01-04 17:06:40.0 
-0800
@@ -6,7 +6,7 @@
 Arnaldo Carvalho de Melo [EMAIL PROTECTED]
 Brad Strand [EMAIL PROTECTED]

-   Copyright (C) 1999-2005 3ware Inc.
+   Copyright (C) 1999-2007 3ware Inc.

   Kernel compatiblity By:  Andre Hedrick [EMAIL PROTECTED]
   Non-Copyright (C) 2000   Andre Hedrick [EMAIL PROTECTED]
@@ -191,6 +191,9 @@
 before shutting down card.
 Change to new 'change_queue_depth' api.
 Fix 'handled=1' ISR usage, remove bogus IRQ check.
+   1.26.02.002 - Free irq handler in __tw_shutdown().
+ Turn on RCD bit for caching mode page.
+ Serialize reset code.
*/

#include linux/module.h
@@ -214,7 +217,7 @@
#include 3w-.h

/* Globals */
-#define TW_DRIVER_VERSION 1.26.02.001
+#define TW_DRIVER_VERSION 1.26.02.002
static TW_Device_Extension *tw_device_extension_list[TW_MAX_SLOT];
static int tw_device_extension_count = 0;
static int twe_major = -1;
@@ -226,7 +229,7 @@
MODULE_VERSION(TW_DRIVER_VERSION);

/* Function prototypes */
-static int tw_reset_device_extension(TW_Device_Extension *tw_dev, int
ioctl_reset);
+static int tw_reset_device_extension(TW_Device_Extension *tw_dev);

/* Functions */

@@ -984,24 +987,12 @@
/* Now wait for the command to complete */
timeout = wait_event_timeout(tw_dev-ioctl_wqueue,
tw_dev-chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout);

-   /* See if we reset while waiting for the ioctl to 
complete */
-   if (test_bit(TW_IN_RESET, tw_dev-flags)) {
-   clear_bit(TW_IN_RESET, tw_dev-flags);
-   retval = -ERESTARTSYS;
-   goto out2;
-   }
-
/* We timed out, and didn't get an interrupt */
if (tw_dev-chrdev_request_id != TW_IOCTL_CHRDEV_FREE) {
/* Now we need to reset the board */
printk(KERN_WARNING 3w-: scsi%d: Character 
ioctl (0x%x)
timed out, resetting card.\n, tw_dev-host-host_no, cmd);
retval = -EIO;
-   spin_lock_irqsave(tw_dev-host-host_lock, 
flags);
-   tw_dev-state[request_id] = TW_S_COMPLETED;
-   tw_state_request_finish(tw_dev, request_id);
-   tw_dev-posted_request_count--;
-   spin_unlock_irqrestore(tw_dev-host-host_lock, 
flags);
-   if (tw_reset_device_extension(tw_dev, 1)) {
+   if (tw_reset_device_extension(tw_dev)) {
printk(KERN_WARNING 3w-: 
tw_chrdev_ioctl(): Reset failed
for card %d.\n, tw_dev-host-host_no);
}
goto out2;
@@ -1336,7 +1327,7 @@
} /* End tw_unmap_scsi_data() */

/* This function will reset a device extension */
-static int tw_reset_device_extension(TW_Device_Extension *tw_dev, int
ioctl_reset)
+static int tw_reset_device_extension(TW_Device_Extension *tw_dev)
{
int i = 0;
struct scsi_cmnd *srb;
@@ -1382,15 +1373,10 @@
printk(KERN_WARNING 3w-: scsi%d: Reset sequence failed.\n,
tw_dev-host-host_no);
return 1;
}
-   TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev);

-   /* Wake up any ioctl that was pending before the reset */
-   if ((tw_dev-chrdev_request_id == TW_IOCTL_CHRDEV_FREE) || 
(ioctl_reset)) {
-   clear_bit(TW_IN_RESET, tw_dev-flags);
-   } else {
-   tw_dev-chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
-   wake_up(tw_dev-ioctl_wqueue);
-   }
+   TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev);
+   clear_bit(TW_IN_RESET, tw_dev-flags);
+   tw_dev-chrdev_request_id = TW_IOCTL_CHRDEV_FREE;

return 0;
} /* End tw_reset_device_extension() */
@@ -1437,14 +1423,18 @@
WARNING: Command (0x%x) timed out, resetting card.\n,
SCpnt-cmnd[0]);

+   /* Make sure we are not issuing an ioctl or resetting from ioctl */
+   mutex_lock(tw_dev-ioctl_lock);
+
/* Now reset the card and some

[PATCH 1/1] 3ware 9000 driver update for 2.6.13-git10

2005-09-09 Thread adam radford
The attached patch updates the driver for the 3ware 9000 series to do
the following:

- Correctly handle single sgl's with use_sg = 1.

This is needed with the latest scsi-block-2.6 merge otherwise the 3w-9xxx
driver will not work.  I tested the patch James sent a few weeks back to fix
this, and it had a bug where the request_buffer was accessed in
twa_scsiop_execute_scsi_complete() when it was invalid.  This is a corrected
variation of that patch.

Signed-off-by: Adam Radford [EMAIL PROTECTED]

James, Please apply

Thanks!

Note: The patch is attached as an attachment, and also included
in-line below.   The below
 may have line-wrap issues since I'm pasting into gmail.

diff -Naur linux-2.6.13-git9/drivers/scsi/3w-9xxx.c
linux-2.6.13-git10/drivers/scsi/3w-9xxx.c
--- linux-2.6.13-git9/drivers/scsi/3w-9xxx.c2005-08-28 16:41:01.0 
-0700
+++ linux-2.6.13-git10/drivers/scsi/3w-9xxx.c   2005-09-09
15:37:34.0 -0700
@@ -59,6 +59,7 @@
  Fix 'handled=1' ISR usage, remove bogus IRQ check.
  Remove un-needed eh_abort handler.
  Add support for embedded firmware error strings.
+   2.26.02.003 - Correctly handle single sgl's with use_sg=1.
 */
 
 #include linux/module.h
@@ -81,7 +82,7 @@
 #include 3w-9xxx.h
 
 /* Globals */
-#define TW_DRIVER_VERSION 2.26.02.002
+#define TW_DRIVER_VERSION 2.26.02.003
 static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT];
 static unsigned int twa_device_extension_count;
 static int twa_major = -1;
@@ -1805,6 +1806,8 @@
if (tw_dev-srb[request_id]-request_bufflen  
TW_MIN_SGL_LENGTH) {
command_packet-sg_list[0].address =
tw_dev-generic_buffer_phys[request_id];
command_packet-sg_list[0].length = 
TW_MIN_SGL_LENGTH;
+   if (tw_dev-srb[request_id]-sc_data_direction 
== DMA_TO_DEVICE
|| tw_dev-srb[request_id]-sc_data_direction == DMA_BIDIRECTIONAL)
+   
memcpy(tw_dev-generic_buffer_virt[request_id],
tw_dev-srb[request_id]-request_buffer,
tw_dev-srb[request_id]-request_bufflen);
} else {
buffaddr = twa_map_scsi_single_data(tw_dev, 
request_id);
if (buffaddr == 0)
@@ -1823,6 +1826,12 @@
 
if (tw_dev-srb[request_id]-use_sg  0) {
if ((tw_dev-srb[request_id]-use_sg == 1) 
(tw_dev-srb[request_id]-request_bufflen  TW_MIN_SGL_LENGTH)) {
+   if (tw_dev-srb[request_id]-sc_data_direction 
== DMA_TO_DEVICE
|| tw_dev-srb[request_id]-sc_data_direction == DMA_BIDIRECTIONAL) {
+   struct scatterlist *sg = (struct 
scatterlist
*)tw_dev-srb[request_id]-request_buffer;
+   char *buf = kmap_atomic(sg-page, 
KM_IRQ0) + sg-offset;
+   
memcpy(tw_dev-generic_buffer_virt[request_id], buf, sg-length);
+   kunmap_atomic(buf - sg-offset, 
KM_IRQ0);
+   }
command_packet-sg_list[0].address =
tw_dev-generic_buffer_phys[request_id];
command_packet-sg_list[0].length = 
TW_MIN_SGL_LENGTH;
} else {
@@ -1888,11 +1897,20 @@
 /* This function completes an execute scsi operation */
 static void twa_scsiop_execute_scsi_complete(TW_Device_Extension
*tw_dev, int request_id)
 {
-   /* Copy the response if too small */
-   if ((tw_dev-srb[request_id]-request_buffer) 
(tw_dev-srb[request_id]-request_bufflen  TW_MIN_SGL_LENGTH)) {
-   memcpy(tw_dev-srb[request_id]-request_buffer,
-  tw_dev-generic_buffer_virt[request_id],
-  tw_dev-srb[request_id]-request_bufflen);
+   if (tw_dev-srb[request_id]-request_bufflen  TW_MIN_SGL_LENGTH 
+   (tw_dev-srb[request_id]-sc_data_direction == DMA_FROM_DEVICE ||
+tw_dev-srb[request_id]-sc_data_direction == DMA_BIDIRECTIONAL)) {
+   if (tw_dev-srb[request_id]-use_sg == 0) {
+   memcpy(tw_dev-srb[request_id]-request_buffer,
+  tw_dev-generic_buffer_virt[request_id],
+  tw_dev-srb[request_id]-request_bufflen);
+   }
+   if (tw_dev-srb[request_id]-use_sg == 1) {
+   struct scatterlist *sg = (struct scatterlist
*)tw_dev-srb[request_id]-request_buffer;
+   char *buf = kmap_atomic(sg-page, KM_IRQ0) + sg-offset;
+   memcpy(buf, tw_dev-generic_buffer_virt[request_id], 
sg-length);
+   kunmap_atomic(buf - sg-offset, KM_IRQ0);
+   }
}
 } /* End twa_scsiop_execute_scsi_complete() */
diff -Naur linux-2.6.13-git9/drivers/scsi/3w-9xxx.c linux-2.6.13-git10/drivers/scsi/3w-9xxx.c

[PATCH 1/1] 3ware 9000 driver update for 2.6.13-rc6-git10

2005-08-17 Thread adam radford
The attached patch updates the driver for the 3ware 9000 series to do
the following:

- Add support for 9550SX controllers.

Signed-off-by: Adam Radford [EMAIL PROTECTED]

James, Please apply
diff -Naur linux-2.6.13-rc6-git9/drivers/scsi/3w-9xxx.c linux-2.6.13-rc6-git10/drivers/scsi/3w-9xxx.c
--- linux-2.6.13-rc6-git9/drivers/scsi/3w-9xxx.c	2005-08-07 10:39:29.0 -0700
+++ linux-2.6.13-rc6-git10/drivers/scsi/3w-9xxx.c	2005-08-07 10:41:59.0 -0700
@@ -59,6 +59,7 @@
  Fix 'handled=1' ISR usage, remove bogus IRQ check.
  Remove un-needed eh_abort handler.
  Add support for embedded firmware error strings.
+   2.26.02.003 - Add support for 9550SX controllers.
 */
 
 #include linux/module.h
@@ -81,7 +82,7 @@
 #include 3w-9xxx.h
 
 /* Globals */
-#define TW_DRIVER_VERSION 2.26.02.002
+#define TW_DRIVER_VERSION 2.26.02.003
 static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT];
 static unsigned int twa_device_extension_count;
 static int twa_major = -1;
@@ -891,11 +892,6 @@
 		writel(TW_CONTROL_CLEAR_QUEUE_ERROR, TW_CONTROL_REG_ADDR(tw_dev));
 	}
 
-	if (status_reg_value  TW_STATUS_SBUF_WRITE_ERROR) {
-		TW_PRINTK(tw_dev-host, TW_DRIVER, 0xf, SBUF Write Error: clearing);
-		writel(TW_CONTROL_CLEAR_SBUF_WRITE_ERROR, TW_CONTROL_REG_ADDR(tw_dev));
-	}
-
 	if (status_reg_value  TW_STATUS_MICROCONTROLLER_ERROR) {
 		if (tw_dev-reset_print == 0) {
 			TW_PRINTK(tw_dev-host, TW_DRIVER, 0x10, Microcontroller Error: clearing);
@@ -929,6 +925,36 @@
 	return retval;
 } /* End twa_empty_response_queue() */
 
+/* This function will clear the pchip/response queue on 9550SX */
+static int twa_empty_response_queue_large(TW_Device_Extension *tw_dev)
+{
+	u32 status_reg_value, response_que_value;
+	int count = 0, retval = 1;
+
+	if (tw_dev-tw_pci_dev-device == PCI_DEVICE_ID_3WARE_9550SX) {
+		status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
+
+		while (((status_reg_value  TW_STATUS_RESPONSE_QUEUE_EMPTY) == 0)  (count  TW_MAX_RESPONSE_DRAIN)) {
+			response_que_value = readl(TW_RESPONSE_QUEUE_REG_ADDR_LARGE(tw_dev));
+			if ((response_que_value  TW_9550SX_DRAIN_COMPLETED) == TW_9550SX_DRAIN_COMPLETED) {
+/* P-chip settle time */
+msleep(500);
+retval = 0;
+goto out;
+			}
+			status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
+			count++;
+		}
+		if (count == TW_MAX_RESPONSE_DRAIN)
+			goto out;
+		
+		retval = 0;
+	} else
+		retval = 0;
+out:
+	return retval;
+} /* End twa_empty_response_queue_large() */
+
 /* This function passes sense keys from firmware to scsi layer */
 static int twa_fill_sense(TW_Device_Extension *tw_dev, int request_id, int copy_sense, int print_host)
 {
@@ -1612,8 +1638,16 @@
 	int tries = 0, retval = 1, flashed = 0, do_soft_reset = soft_reset;
 
 	while (tries  TW_MAX_RESET_TRIES) {
-		if (do_soft_reset)
+		if (do_soft_reset) {
 			TW_SOFT_RESET(tw_dev);
+			/* Clear pchip/response queue on 9550SX */
+			if (twa_empty_response_queue_large(tw_dev)) {
+TW_PRINTK(tw_dev-host, TW_DRIVER, 0x36, Response queue (large) empty failed during reset sequence);
+do_soft_reset = 1;
+tries++;
+continue;
+			}
+		}
 
 		/* Make sure controller is in a good state */
 		if (twa_poll_status(tw_dev, TW_STATUS_MICROCONTROLLER_READY | (do_soft_reset == 1 ? TW_STATUS_ATTENTION_INTERRUPT : 0), 60)) {
@@ -2016,7 +2050,10 @@
 		goto out_free_device_extension;
 	}
 
-	mem_addr = pci_resource_start(pdev, 1);
+	if (pdev-device == PCI_DEVICE_ID_3WARE_9000)
+		mem_addr = pci_resource_start(pdev, 1);
+	else
+		mem_addr = pci_resource_start(pdev, 2);
 
 	/* Save base address */
 	tw_dev-base_addr = ioremap(mem_addr, PAGE_SIZE);
@@ -2130,6 +2167,8 @@
 static struct pci_device_id twa_pci_tbl[] __devinitdata = {
 	{ PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9000,
 	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{ PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9550SX,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
 	{ }
 };
 MODULE_DEVICE_TABLE(pci, twa_pci_tbl);
diff -Naur linux-2.6.13-rc6-git9/drivers/scsi/3w-9xxx.h linux-2.6.13-rc6-git10/drivers/scsi/3w-9xxx.h
--- linux-2.6.13-rc6-git9/drivers/scsi/3w-9xxx.h	2005-06-17 12:48:29.0 -0700
+++ linux-2.6.13-rc6-git10/drivers/scsi/3w-9xxx.h	2005-08-07 10:42:01.0 -0700
@@ -267,7 +267,6 @@
 #define TW_CONTROL_CLEAR_PARITY_ERROR  0x0080
 #define TW_CONTROL_CLEAR_QUEUE_ERROR   0x0040
 #define TW_CONTROL_CLEAR_PCI_ABORT 0x0010
-#define TW_CONTROL_CLEAR_SBUF_WRITE_ERROR  0x0008
 
 /* Status register bit definitions */
 #define TW_STATUS_MAJOR_VERSION_MASK	   0xF000
@@ -285,9 +284,8 @@
 #define TW_STATUS_MICROCONTROLLER_READY	   0x2000
 #define TW_STATUS_COMMAND_QUEUE_EMPTY	   0x1000
 #define TW_STATUS_EXPECTED_BITS		   0x2000
-#define TW_STATUS_UNEXPECTED_BITS	   0x00F8
-#define TW_STATUS_SBUF_WRITE_ERROR 0x0008
-#define TW_STATUS_VALID_INTERRUPT  0x00DF0008
+#define

[PATCH 1/1] 3ware 9000 driver update for linux-2.6.12-rc1-mm4

2005-03-28 Thread adam radford
The attached patch updates the driver for the 3ware 9000 series to do
the following:

- Add support for PAE mode.
- Add lun support.
- Fix twa_remove() to free irq handler/unregister_chrdev() before
shutting down the card.
- Change to new 'change_queue_depth' api. (From James)
- Fix 'handled=1' ISR usage, remove bogus IRQ check (from Jeff Garzik)
- Remove un-needed eh_abort handler.
- Add support for embedded firmware error strings.

Signed-off-by: Adam Radford [EMAIL PROTECTED]

James, Please apply


3ware_linux_2.6.12-rc1-mm4.patch
Description: Binary data


[PATCH 1/1] 3ware driver update for linux-2.6.12-rc1-bk2

2005-03-23 Thread adam radford
Re-sending this as an attachment due to copy/paste mangling between
firefox and gmail.
(If anybody knows how to work around this, let me know)

The attached patch updates the driver for the 3ware 5/6/7/8000 series to do
the following:

- Increase max ioctl buffer size to 512 sectors.
- Make tw_scsi_queue() return 0 for 'Unknown scsi opcode'.
- Fix tw_remove() to free irq handler/unregister_chrdev() before shutting down
 the card.
- Change to new 'change_queue_depth' api (from James).
- Fix 'handled=1' ISR usage, remove bogus IRQ check (from Jeff).

A smiliar patch for the 9000 series driver will follow shortly,
including a PAE fix,
and a few other things (that is why I want it to be a separate patch).

Signed-off-by: Adam Radford [EMAIL PROTECTED]

James, Please apply


3ware_linux_2.6.12-rc1-bk2.patch
Description: Binary data


[PATCH 1/1] 3ware driver update for linux-2.6.12-rc1-bk2

2005-03-21 Thread adam radford
This patch updates the driver for the 3ware 5/6/7/8000 series to do
the following:

- Increase max ioctl buffer size to 512 sectors.
- Make tw_scsi_queue() return 0 for 'Unknown scsi opcode'.
- Fix tw_remove() to free irq handler/unregister_chrdev() before shutting down
  the card.
- Change to new 'change_queue_depth' api (from James).
- Fix 'handled=1' ISR usage, remove bogus IRQ check (from Jeff).

A smiliar patch for the 9000 series driver will follow shortly,
including a PAE fix,
and a few other things (that is why I want it to be a separate patch).

Signed-off-by: Adam Radford [EMAIL PROTECTED]

James, Please apply

diff -Naur linux-2.6.12-rc1-bk1/drivers/scsi/3w-.c
linux-2.6.12-rc1-bk2/drivers/scsi/3w-.c
--- linux-2.6.12-rc1-bk1/drivers/scsi/3w-.c 2005-03-18
22:35:03.0 -0800
+++ linux-2.6.12-rc1-bk2/drivers/scsi/3w-.c 2005-03-21
19:19:36.0 -0800
@@ -6,7 +6,7 @@
 Arnaldo Carvalho de Melo [EMAIL PROTECTED]
  Brad Strand [EMAIL PROTECTED]
 
-   Copyright (C) 1999-2004 3ware Inc.
+   Copyright (C) 1999-2005 3ware Inc.
 
Kernel compatiblity By: Andre Hedrick [EMAIL PROTECTED]
Non-Copyright (C) 2000  Andre Hedrick [EMAIL PROTECTED]
@@ -185,6 +185,12 @@
  Fix data_buffer_length usage in tw_chrdev_ioctl().
  Update contact information.
1.26.02.000 - Convert driver to pci_driver format.
+   1.26.02.001 - Increase max ioctl buffer size to 512 sectors.
+ Make tw_scsi_queue() return 0 for 'Unknown scsi opcode'.
+ Fix tw_remove() to free irq handler/unregister_chrdev()
+ before shutting down card.
+ Change to new 'change_queue_depth' api.
+ Fix 'handled=1' ISR usage, remove bogus IRQ check.
 */
 
 #include linux/module.h
@@ -207,7 +213,7 @@
 #include 3w-.h
 
 /* Globals */
-#define TW_DRIVER_VERSION 1.26.02.000
+#define TW_DRIVER_VERSION 1.26.02.001
 static TW_Device_Extension *tw_device_extension_list[TW_MAX_SLOT];
 static int tw_device_extension_count = 0;
 static int twe_major = -1;
@@ -509,33 +515,13 @@
 } /* End tw_show_stats() */
 
 /* This function will set a devices queue depth */
-static ssize_t tw_store_queue_depth(struct device *dev, const char
*buf, size_t count)
+static int tw_change_queue_depth(struct scsi_device *sdev, int queue_depth)
 {
-   int queue_depth;
-   struct scsi_device *sdev = to_scsi_device(dev);
-
-   queue_depth = simple_strtoul(buf, NULL, 0);
if (queue_depth  TW_Q_LENGTH-2)
-   return -EINVAL;
+   queue_depth = TW_Q_LENGTH-2;
scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, queue_depth);
-
-   return count;
-} /* End tw_store_queue_depth() */
-
-/* Create sysfs 'queue_depth' entry */
-static struct device_attribute tw_queue_depth_attr = {
-   .attr = {
-   .name = queue_depth,
-   .mode = S_IRUSR | S_IWUSR,
-   },
-   .store = tw_store_queue_depth
-};
-
-/* Device attributes initializer */
-static struct device_attribute *tw_dev_attrs[] = {
-   tw_queue_depth_attr,
-   NULL,
-};
+   return queue_depth;
+} /* End tw_change_queue_depth() */
 
 /* Create sysfs 'stats' entry */
 static struct class_device_attribute tw_host_stats_attr = {
@@ -910,7 +896,7 @@
goto out;
 
/* Check size */
-   if (data_buffer_length  TW_MAX_SECTORS * 512) {
+   if (data_buffer_length  TW_MAX_IOCTL_SECTORS * 512) {
retval = -EINVAL;
goto out;
}
@@ -995,7 +981,7 @@
timeout = TW_IOCTL_CHRDEV_TIMEOUT*HZ;
 
/* Now wait for the command to complete */
-   timeout = 
wait_event_interruptible_timeout(tw_dev-ioctl_wqueue,
tw_dev-chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout);
+   timeout = wait_event_timeout(tw_dev-ioctl_wqueue,
tw_dev-chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout);
 
/* See if we reset while waiting for the ioctl to 
complete */
if (test_bit(TW_IN_RESET, tw_dev-flags)) {
@@ -1004,16 +990,11 @@
goto out2;
}
 
-   /* Check if we timed out, got a signal, or didn't get
-  an interrupt */
-   if ((timeout = 0)  (tw_dev-chrdev_request_id != 
TW_IOCTL_CHRDEV_FREE)) {
+   /* We timed out, and didn't get an interrupt */
+   if (tw_dev-chrdev_request_id != TW_IOCTL_CHRDEV_FREE) {
/* Now we need to reset the board */
-   if (timeout == -ERESTARTSYS) {
-   retval = timeout;
-   } else {
-   printk(KERN_WARNING 3w-: scsi%d: 
Character ioctl (0x%x)
timed out

3ware driver update for 2.6.11-rc2-mm2

2005-01-26 Thread adam radford
James,

Here is a patch to update a few bugs in the 3ware driver for
5/6/7/8000 controllers.

-Adam

diff -Naur linux-2.6.11-rc2-mm1/drivers/scsi/3w-.c linux-2.6.11-rc2-mm2/driv
ers/scsi/3w-.c
--- linux-2.6.11-rc2-mm1/drivers/scsi/3w-.c 2004-12-24 13:35:28.0 -0
800
+++ linux-2.6.11-rc2-mm2/drivers/scsi/3w-.c 2005-01-26 16:46:02.0 -0
800
@@ -6,7 +6,7 @@
 Arnaldo Carvalho de Melo [EMAIL PROTECTED]
  Brad Strand [EMAIL PROTECTED]
 
-   Copyright (C) 1999-2004 3ware Inc.
+   Copyright (C) 1999-2005 3ware Inc.
 
Kernel compatiblity By: Andre Hedrick [EMAIL PROTECTED]
Non-Copyright (C) 2000  Andre Hedrick [EMAIL PROTECTED]
@@ -185,6 +185,13 @@
  Fix data_buffer_length usage in tw_chrdev_ioctl().
  Update contact information.
1.26.02.000 - Convert driver to pci_driver format.
+   1.26.02.001 - Increase max ioctl buffer size to 512 sectors.
+ Make tw_scsi_queue() return 0 for 'Unknown scsi opcode'.
+ Fix tw_interrupt() to ignore interrupts from other devices
+ during reset.
+ Fix tw_scsi_queue() to BUSY io's during a reset.
+ Fix tw_remove() to free irq handler/unregister_chrdev()
+ before shutting down card.
 */
 
 #include linux/module.h
@@ -207,7 +214,7 @@
 #include 3w-.h
 
 /* Globals */
-#define TW_DRIVER_VERSION 1.26.02.000
+#define TW_DRIVER_VERSION 1.26.02.001
 static TW_Device_Extension *tw_device_extension_list[TW_MAX_SLOT];
 static int tw_device_extension_count = 0;
 static int twe_major = -1;
@@ -910,7 +917,7 @@
goto out;
 
/* Check size */
-   if (data_buffer_length  TW_MAX_SECTORS * 512) {
+   if (data_buffer_length  TW_MAX_IOCTL_SECTORS * 512) {
retval = -EINVAL;
goto out;
}
@@ -1366,6 +1373,7 @@
TW_DISABLE_INTERRUPTS(tw_dev);
TW_MASK_COMMAND_INTERRUPT(tw_dev);
spin_lock_irqsave(tw_dev-host-host_lock, flags);
+   tw_dev-online = 0;
 
/* Abort all requests that are in progress */
for (i=0;iTW_Q_LENGTH;i++) {
@@ -1401,6 +1409,7 @@
return 1;
}
TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev);
+   tw_dev-online = 1;
 
/* Wake up any ioctl that was pending before the reset */
if ((tw_dev-chrdev_request_id == TW_IOCTL_CHRDEV_FREE) || (ioctl_reset)
) {
@@ -2007,6 +2016,12 @@
int retval = 1;
TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt-device-host
-hostdata;
 
+   /* If we are off-line doing a reset, report as busy */
+   if (!tw_dev-online) {
+   retval = SCSI_MLQUEUE_HOST_BUSY;
+   goto out;
+   }
+
/* Save done function into Scsi_Cmnd struct */
SCpnt-scsi_done = done;
 
@@ -2060,7 +2075,7 @@
tw_state_request_finish(tw_dev, request_id);
SCpnt-result = (DID_BAD_TARGET  16);
done(SCpnt);
-   goto out;
+   retval = 0;
}
if (retval) {
tw_dev-state[request_id] = TW_S_COMPLETED;
@@ -2093,6 +2108,10 @@
 
handled = 1;
 
+   /* If card is offline, bail */
+   if (!tw_dev-online)
+   goto tw_interrupt_bail;
+
/* Read the registers */
status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev));
 
@@ -2407,6 +2426,7 @@
 
/* Re-enable interrupts on the card */
TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev);
+   tw_dev-online = 1;
 
/* Finally, scan the host */
scsi_scan_host(host);
@@ -2438,23 +2458,24 @@
 
scsi_remove_host(tw_dev-host);
 
-   __tw_shutdown(tw_dev);
+   /* Unregister character device */
+   if (twe_major = 0) {
+   unregister_chrdev(twe_major, twe);
+   twe_major = -1;
+   }
 
/* Free up the IRQ */
free_irq(tw_dev-tw_pci_dev-irq, tw_dev);
 
+   /* Shutdown the card */
+   __tw_shutdown(tw_dev);
+
/* Free up the mem region */
pci_release_regions(pdev);
 
/* Free up device extension resources */
tw_free_device_extension(tw_dev);
 
-   /* Unregister character device */
-   if (twe_major = 0) {
-   unregister_chrdev(twe_major, twe);
-   twe_major = -1;
-   }
-
scsi_host_put(tw_dev-host);
pci_disable_device(pdev);
tw_device_extension_count--;
diff -Naur linux-2.6.11-rc2-mm1/drivers/scsi/3w-.h linux-2.6.11-rc2-mm2/driv
ers/scsi/3w-.h
--- linux-2.6.11-rc2-mm1/drivers/scsi/3w-.h 2005-01-26 16:41:52.0 -0
800
+++ linux-2.6.11-rc2-mm2/drivers/scsi/3w-.h 2005-01-26 16:46:04.0 -0
800
@@ -6,7 +6,7 @@
 Arnaldo Carvalho de Melo [EMAIL PROTECTED]
  Brad Strand