Re: [PATCH v2 07/18] lpfc: NVME Initiator: Base modifications Part E

2017-02-08 Thread Hannes Reinecke
On 02/08/2017 08:13 PM, James Smart wrote:
> 
> On 2/8/2017 4:47 AM, Christoph Hellwig wrote:
>> On Tue, Feb 07, 2017 at 06:32:30PM -0800, James Smart wrote:
>>> I realize I cut these in a silly way.  In the v1 patches, I had a big
>>> patch
>>> that I then cut into 6 parts, by file.  In the v2 patches, I tried to
>>> keep
>>> the patches as is, and address the comments in the respective patch the
>>> comment came from. Which resulted in 3/8 with an old reference, but
>>> patch
>>> 8/8 being the one that reverted this reverence. Sorry..  I'll recut and
>>> repost.
>> This whole split doesn't make sense - either the patches are logically
>> split, in which case they can be posted separately, or they belong
>> together in which case they should be sent together.  But the size
>> of them suggest to me they probably need to be broken down to logically
>> separate patches.
>>
>> And can you please switch to using git-send-email to send the patches
>> straight from a git branch?  There are lot of patch formatting issues
>> with the lpfc patches, and that should fix most of them instantly.
>>
> 
> Ok. I will see if they can be further split. I don't have a lot of hope
> beyond a couple splits. So, the resulting patches will be large.
> 
Unfortunate, but should be okay.
We've reviewed the bulk of the patches already, so we'll live with that.

Cheers,

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


Re: [PATCH V2] mpt3sas: disable ASPM for MPI2 controllers

2017-02-08 Thread Sreekanth Reddy
On Wed, Dec 28, 2016 at 4:35 PM, ojab  wrote:
> MPI2 controllers sometimes got lost (i. e. disappears from
> /sys/bus/pci/devices) if ASMP is enabled.
>
> Signed-off-by: Slava Kardakov 
> Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=60644

>From some of our system engineers team, I came to known that ASPM
needs to be disabled.
So this patch looks good. Please consider this patch as

Acked-by: Sreekanth Reddy 

Thanks,
Sreekanth

> ---
> V2: use name in Signed-off-by
>
> Not sure if it's a complete fix, but at least I can't reproduce the issue
> locally with it applied.
>
> Also it's my first patch, so I've surely screwed up some formatting etc.
>
>  drivers/scsi/mpt3sas/mpt3sas_scsih.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
> b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> index b5c966e..203651a 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> @@ -51,6 +51,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -8734,6 +8735,8 @@ _scsih_probe(struct pci_dev *pdev, const struct 
> pci_device_id *id)
>
> switch (hba_mpi_version) {
> case MPI2_VERSION:
> +   pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S |
> +   PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
> /* Use mpt2sas driver host template for SAS 2.0 HBA's */
> shost = scsi_host_alloc(_driver_template,
>   sizeof(struct MPT3SAS_ADAPTER));
> --
> 2.10.0
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4] scsi/sd: release scan_mutex during sync_cache and start_stop

2017-02-08 Thread Song Liu
When a device is deleted through sysfs handle "delete", the code
locks shost->scan_mutex. If multiple devices are deleted at the
same time, these deletes will be handled in series.

On the other hand, sd_shutdown() sometimes issues long latency
commands: sync cache and start_stop. It is not necessary for these
commands to run in series.

To reduce latency of parallel "delete" requests, this patch unlock
shost->scan_mutex before calling sd_shutdown(), relock the mutex
afterwards.

Fixed bug from previous version.

Reported-by: kernel test robot 
Signed-off-by: Song Liu 
Cc: Christoph Hellwig 
Cc: Bart Van Assche 
---
 drivers/scsi/sd.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 9e0783b..61ea308 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3211,9 +3211,13 @@ static int sd_probe(struct device *dev)
 static int sd_remove(struct device *dev)
 {
struct scsi_disk *sdkp;
+   struct scsi_device *sdev;
+   struct Scsi_Host *shost;
dev_t devt;
 
sdkp = dev_get_drvdata(dev);
+   sdev = sdkp->device;
+   shost = sdev->host;
devt = disk_devt(sdkp->disk);
scsi_autopm_get_device(sdkp->device);
 
@@ -3221,7 +3225,9 @@ static int sd_remove(struct device *dev)
async_synchronize_full_domain(_sd_probe_domain);
device_del(>dev);
del_gendisk(sdkp->disk);
+   mutex_unlock(>scan_mutex);
sd_shutdown(dev);
+   mutex_lock(>scan_mutex);
 
sd_zbc_remove(sdkp);
 
-- 
2.9.3



Re: [lkp-robot] [scsi, block] 0dba1314d4: WARNING:at_fs/sysfs/dir.c:#sysfs_warn_dup

2017-02-08 Thread James Bottomley
On Mon, 2017-02-06 at 21:42 -0800, Dan Williams wrote:
> On Mon, Feb 6, 2017 at 8:09 PM, Jens Axboe  wrote:
> > On 02/06/2017 05:14 PM, James Bottomley wrote:
> > > On Sun, 2017-02-05 at 21:13 -0800, Dan Williams wrote:
> > > > On Sun, Feb 5, 2017 at 1:13 AM, Christoph Hellwig 
> > > > wrote:
> > > > > Dan,
> > > > > 
> > > > > can you please quote your emails?  I can't find any content
> > > > > inbetween all these quotes.
> > > > 
> > > > Sorry, I'm using gmail, but I'll switch to attaching the logs.
> > > > 
> > > > So with help from Xiaolong I was able to reproduce this, and it
> > > > does
> > > > not appear to be a regression. We simply change the failure
> > > > output of
> > > > an existing bug. Attached is a log of the same test on v4.10
> > > > -rc7
> > > > (i.e. without the recent block/scsi fixes), and it shows sda
> > > > being
> > > > registered twice.
> > > > 
> > > > "[6.647077] kobject (d5078ca4): tried to init an
> > > > initialized
> > > > object, something is seriously wrong."
> > > > 
> > > > The change that "scsi, block: fix duplicate bdi name
> > > > registration
> > > > crashes" makes is to properly try to register sdb since the sda
> > > > devt
> > > > is still alive. However that's not a fix because we've managed
> > > > to
> > > > call blk_register_queue() twice on the same queue.
> > > 
> > > OK, time to involve others: linux-scsi and linux-block cc'd and
> > > I've
> > > inserted the log below.
> > > 
> > > James
> > > 
> > > ---
> > > 
> > > [5.969672] scsi host0: scsi_debug: version 1.86 [20160430]
> > > [5.969672]   dev_size_mb=8, opts=0x0, submit_queues=1,
> > > statistics=0
> > > [5.971895] scsi 0:0:0:0: Direct-Access Linux   
> > >  scsi_debug   0186 PQ: 0 ANSI: 7
> > > [6.006983] sd 0:0:0:0: [sda] 16384 512-byte logical blocks:
> > > (8.39 MB/8.00 MiB)
> > > [6.026965] sd 0:0:0:0: [sda] Write Protect is off
> > > [6.027870] sd 0:0:0:0: [sda] Mode Sense: 73 00 10 08
> > > [6.066962] sd 0:0:0:0: [sda] Write cache: enabled, read
> > > cache: enabled, supports DPO and FUA
> > > [6.486962] sd 0:0:0:0: [sda] Attached SCSI disk
> > > [6.488377] sd 0:0:0:0: [sda] Synchronizing SCSI cache
> > > [6.489455] sd 0:0:0:0: Attached scsi generic sg0 type 0
> > > [6.526982] sd 0:0:0:0: [sda] 16384 512-byte logical blocks:
> > > (8.39 MB/8.00 MiB)
> > > [6.546964] sd 0:0:0:0: [sda] Write Protect is off
> > > [6.547873] sd 0:0:0:0: [sda] Mode Sense: 73 00 10 08
> > > [6.586963] sd 0:0:0:0: [sda] Write cache: enabled, read
> > > cache: enabled, supports DPO and FUA
> > > [6.647077] kobject (d5078ca4): tried to init an initialized
> > > object, something is seriously wrong.
> > 
> > So sda is probed twice, and hilarity ensues when we try to register
> > it
> > twice.  I can't reproduce this, using scsi_debug and with
> > scsi_async
> > enabled.
> > 
> > This is running linux-next? What's your .config?
> > 
> 
> The original failure report is here:
> 
> http://marc.info/?l=linux-kernel=148619222300774=2
> 
> ...but it reproduces on current mainline with the same config. I
> haven't spotted what makes scsi_debug behave like this.

Looking at the config, it's a static debug with report luns enabled. 
 Is it as simple as the fact that we probe lun 0 manually to see if the
target exists, but then we don't account for the fact that we already
did this, so if it turns up again in the report lun scan, we'll probe
it again leading to a double add.  If that theory is correct, this may
be the fix (compile tested only).

James

---

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 6f7128f..ba4be08 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1441,6 +1441,10 @@ static int scsi_report_lun_scan(struct scsi_target 
*starget, int bflags,
for (lunp = _data[1]; lunp <= _data[num_luns]; lunp++) {
lun = scsilun_to_int(lunp);
 
+   if (lun == 0)
+   /* already scanned LUN 0 */
+   continue;
+
if (lun > sdev->host->max_lun) {
sdev_printk(KERN_WARNING, sdev,
"lun%llu has a LUN larger than"


Re: Patch: lpfc: Modify Emulex lpfc LPFC_DEFAULT_SG_SEG_CNT to 128 for default larger sg_io capability

2017-02-08 Thread Laurence Oberman


- Original Message -
> From: "Laurence Oberman" 
> To: "Linux SCSI List" 
> Sent: Wednesday, February 8, 2017 3:07:12 PM
> Subject: Patch: lpfc: Modify Emulex lpfc LPFC_DEFAULT_SG_SEG_CNT to 128 for 
> default larger sg_io capability
> 
> We have been seeing issues with qemu_kvm virtual guests where if they issue
> I/O to direct attached SCSI passthrough LUNS with large I/O sizes such as
> 512K
> the sg_io will fail with -EINVAL.
> 
> Simple reproducer is here.
> 
> strace -e ioctl sg_dd if=/dev/zero of=/dev/sdae bpt=0x400 count=0x400
> blk_sgio=1
> Assume default 'bs' (block size) of 512 bytes
> ioctl(4, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[6]=[12, 00, 00, 00, 24, 00],
> mx_sb_len=64, iovec_count=0, dxfer_len=36, timeout=6, flags=0,
> data[36]=["\0\0\5\2\37\270\0\2LIO-ORG block-15"...], status=00,
> masked_status=00, sb[0]=[], host_status=0, driver_status=0, resid=0,
> duration=0, info=0}) = 0
> ioctl(4, SG_IO, {'S', SG_DXFER_TO_DEV, cmd[10]=[2a, 00, 00, 00, 00, 00, 00,
> 04, 00, 00], mx_sb_len=64, iovec_count=0, dxfer_len=524288, timeout=6,
> flags=0,
> data[524288]=["\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...]})
> = -1 EINVAL (Invalid argument)
> writing (SG_IO) on sg device, error: Invalid argument
> sg_write failed, seek=0
> Some error occurred,  remaining block count=1024
> 1024+0 records in
> 0+0 records out
> 
> Qlogic defaults to 128 so has not been seeing this but lpfc does not.
> Would like to avoid having to set this in the module parameters to 128.
> 
> Tested-by: Laurence Oberman 
> Signed-off-by: Laurence Oberman 
> 
> From 23996dcbdd9b505d18d59ecde961c87f76fc9c2e Mon Sep 17 00:00:00 2001
> From: Laurence Oberman 
> Date: Wed, 8 Feb 2017 14:49:05 -0500
> Subject: [PATCH] Modified LPFC_DEFAULT_SG_SEG_CNT to 128 to match Qlogic.
> This
>  will allow larger sg_io passthrough for qemu_kvm guests that expect the
>  larger setting for I/O large rthen 512k.
> 
> ---
>  drivers/scsi/lpfc/lpfc.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
> index 8a20b4e..8f86d41 100644
> --- a/drivers/scsi/lpfc/lpfc.h
> +++ b/drivers/scsi/lpfc/lpfc.h
> @@ -42,7 +42,7 @@
>  #define LPFC_MAX_NS_RETRY3   /* Number of retry attempts to contact
>  the NameServer  before giving up. */
>  #define LPFC_CMD_PER_LUN 3   /* max outstanding cmds per lun */
> -#define LPFC_DEFAULT_SG_SEG_CNT 64   /* sg element count per scsi cmnd */
> +#define LPFC_DEFAULT_SG_SEG_CNT 128  /* sg element count per scsi cmnd */
>  #define LPFC_DEFAULT_MENLO_SG_SEG_CNT 128/* sg element count per scsi
>   cmnd for menlo needs nearly twice as for firmware
>   downloads using bsg */
> --
> 1.8.3.1
> 
> 
> 
>  
> 

Replying to my own email

I was wondering if we could set it to 256 as the default.
This seems to pass sg_io all the way to 0x800

bpt=0x200
Assume default 'bs' (block size) of 512 bytes
ioctl(4, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[6]=[12, 00, 00, 00, 24, 00], 
mx_sb_len=64, iovec_count=0, dxfer_len=36, timeout=6, flags=0, 
data[36]=["\0\0\5\2\37\270\0\2LIO-ORG block-21"...], status=00, 
masked_status=00, sb[0]=[], host_status=0, driver_status=0, resid=0, 
duration=0, info=0}) = 0
ioctl(4, SG_IO, {'S', SG_DXFER_TO_DEV, cmd[10]=[2a, 00, 00, 00, 00, 00, 00, 02, 
00, 00], mx_sb_len=64, iovec_count=0, dxfer_len=262144, timeout=6, flags=0, 
data[262144]=["\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...],
 status=00, masked_status=00, sb[0]=[], host_status=0, driver_status=0, 
resid=0, duration=30, info=0}) = 0
512+0 records in
512+0 records out
+++ exited with 0 +++

bpt=0x400
Assume default 'bs' (block size) of 512 bytes
ioctl(4, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[6]=[12, 00, 00, 00, 24, 00], 
mx_sb_len=64, iovec_count=0, dxfer_len=36, timeout=6, flags=0, 
data[36]=["\0\0\5\2\37\270\0\2LIO-ORG block-21"...], status=00, 
masked_status=00, sb[0]=[], host_status=0, driver_status=0, resid=0, 
duration=0, info=0}) = 0
ioctl(4, SG_IO, {'S', SG_DXFER_TO_DEV, cmd[10]=[2a, 00, 00, 00, 00, 00, 00, 04, 
00, 00], mx_sb_len=64, iovec_count=0, dxfer_len=524288, timeout=6, flags=0, 
data[524288]=["\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...],
 status=00, masked_status=00, sb[0]=[], host_status=0, driver_status=0, 
resid=0, duration=43, info=0}) = 0
1024+0 records in
1024+0 records out
+++ exited with 0 +++

bpt=0x800
Assume default 'bs' (block size) of 512 bytes
ioctl(4, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[6]=[12, 00, 00, 00, 24, 00], 
mx_sb_len=64, iovec_count=0, dxfer_len=36, timeout=6, flags=0, 
data[36]=["\0\0\5\2\37\270\0\2LIO-ORG block-21"...], status=00, 
masked_status=00, sb[0]=[], host_status=0, driver_status=0, resid=0, 
duration=0, 

Re: [PATCH v3] scsi/sd: release scan_mutex during sync_cache and start_stop

2017-02-08 Thread Song Liu

> On Feb 8, 2017, at 2:58 PM, Bart Van Assche  
> wrote:
> 
> On Wed, 2017-02-08 at 14:53 -0800, Song Liu wrote:
>> +try_lock_scan_mutex = mutex_trylock(>scan_mutex);
> 
> This is at least as bad as the approach of your previous patch because
> whether or not this mutex_trylock() call succeeds not only depends on
> whether or not the caller holds the scan_mutex but also on whether any
> other thread accidentally holds that mutex. Please stop hacking and do
> what Christoph proposed, namely address the caller of this method.
> 
> Bart.
> Western Digital Corporation (and its subsidiaries) E-mail Confidentiality 
> Notice & Disclaimer:
> 
> This e-mail and any files transmitted with it may contain confidential or 
> legally privileged information of WDC and/or its affiliates, and are intended 
> solely for the use of the individual or entity to which they are addressed. 
> If you are not the intended recipient, any disclosure, copying, distribution 
> or any action taken or omitted to be taken in reliance on it, is prohibited. 
> If you have received this e-mail in error, please notify the sender 
> immediately and delete the e-mail in its entirety from your system.
> 

Thanks for the feedback. I will dig more in the caller side. 

Song

Re: [PATCH v3] scsi/sd: release scan_mutex during sync_cache and start_stop

2017-02-08 Thread Bart Van Assche
On Wed, 2017-02-08 at 14:53 -0800, Song Liu wrote:
> + try_lock_scan_mutex = mutex_trylock(>scan_mutex);

This is at least as bad as the approach of your previous patch because
whether or not this mutex_trylock() call succeeds not only depends on
whether or not the caller holds the scan_mutex but also on whether any
other thread accidentally holds that mutex. Please stop hacking and do
what Christoph proposed, namely address the caller of this method.

Bart.


Re: [PATCH v3] scsi/sd: release scan_mutex during sync_cache and start_stop

2017-02-08 Thread Song Liu
> On Feb 8, 2017, at 2:53 PM, Song Liu  wrote:
> 
> When a device is deleted through sysfs handle "delete", the code
> locks shost->scan_mutex. If multiple devices are deleted at the
> same time, these deletes will be handled in series.
> 
> On the other hand, sd_shutdown() sometimes issues long latency
> commands: sync cache and start_stop. It is not necessary for these
> commands to run in series.
> 
> To reduce latency of parallel "delete" requests, this patch unlock
> shost->scan_mutex before long latency commands and relock the mutex
> after the command.
> 
> Fixed bug from previous version.
> 
> Reported-by: kernel test robot 
> Signed-off-by: Song Liu 
> ---
> drivers/scsi/sd.c | 14 ++
> 1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 9e0783b..14c5815 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -3304,6 +3304,9 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, 
> int start)
> static void sd_shutdown(struct device *dev)
> {
>   struct scsi_disk *sdkp = dev_get_drvdata(dev);
> + struct scsi_device *sdev;
> + struct Scsi_Host *shost;
> + int try_lock_scan_mutex;
> 
>   if (!sdkp)
>   return; /* this can happen */
> @@ -3311,15 +3314,26 @@ static void sd_shutdown(struct device *dev)
>   if (pm_runtime_suspended(dev))
>   return;
> 
> + sdev = sdkp->device;
> + shost = sdev->host;
> + try_lock_scan_mutex = mutex_trylock(>scan_mutex);
> +
>   if (sdkp->WCE && sdkp->media_present) {
> + mutex_unlock(>scan_mutex);
>   sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
>   sd_sync_cache(sdkp);
> + mutex_lock(>scan_mutex);
>   }
> 
>   if (system_state != SYSTEM_RESTART && sdkp->device->manage_start_stop) {
> + mutex_unlock(>scan_mutex);
>   sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
>   sd_start_stop_device(sdkp, 0);
> + mutex_lock(>scan_mutex);
>   }
> +
> + if (try_lock_scan_mutex)
> + mutex_unlock(>scan_mutex);
> }
> 
> static int sd_suspend_common(struct device *dev, bool ignore_stop_errors)
> -- 
> 2.9.3
> 

Forgot to CC Christoph




Re: [RFC 10/19] scsi: lpfc: Replace PCI pool old API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:48PM +0100, Romain Perier wrote:
> The PCI pool API is deprecated. This commits replaces the PCI pool old
> API by the appropriated function with the DMA pool API.
> 
> Signed-off-by: Romain Perier 
> ---
>  drivers/scsi/lpfc/lpfc.h  | 10 +++
>  drivers/scsi/lpfc/lpfc_init.c |  6 ++---
>  drivers/scsi/lpfc/lpfc_mem.c  | 62 
> +--
>  drivers/scsi/lpfc/lpfc_scsi.c | 12 -
>  4 files changed, 45 insertions(+), 45 deletions(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
> index 6593b07..c391352 100644
> --- a/drivers/scsi/lpfc/lpfc.h
> +++ b/drivers/scsi/lpfc/lpfc.h
> @@ -862,11 +862,11 @@ struct lpfc_hba {
>   spinlock_t hbalock;
>  
>   /* pci_mem_pools */
> - struct pci_pool *lpfc_scsi_dma_buf_pool;
> - struct pci_pool *lpfc_mbuf_pool;
> - struct pci_pool *lpfc_hrb_pool; /* header receive buffer pool */
> - struct pci_pool *lpfc_drb_pool; /* data receive buffer pool */
> - struct pci_pool *lpfc_hbq_pool; /* SLI3 hbq buffer pool */
> + struct dma_pool *lpfc_scsi_dma_buf_pool;
> + struct dma_pool *lpfc_mbuf_pool;
> + struct dma_pool *lpfc_hrb_pool; /* header receive buffer pool */
> + struct dma_pool *lpfc_drb_pool; /* data receive buffer pool */
> + struct dma_pool *lpfc_hbq_pool; /* SLI3 hbq buffer pool */
>   struct lpfc_dma_pool lpfc_mbuf_safety_pool;
>  
>   mempool_t *mbox_mem_pool;
> diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
> index 64717c1..c38bc0b 100644
> --- a/drivers/scsi/lpfc/lpfc_init.c
> +++ b/drivers/scsi/lpfc/lpfc_init.c
> @@ -3108,7 +3108,7 @@ lpfc_scsi_free(struct lpfc_hba *phba)
>   list_for_each_entry_safe(sb, sb_next, >lpfc_scsi_buf_list_put,
>list) {
>   list_del(>list);
> - pci_pool_free(phba->lpfc_scsi_dma_buf_pool, sb->data,
> + dma_pool_free(phba->lpfc_scsi_dma_buf_pool, sb->data,
> sb->dma_handle);
>   kfree(sb);
>   phba->total_scsi_bufs--;
> @@ -3119,7 +3119,7 @@ lpfc_scsi_free(struct lpfc_hba *phba)
>   list_for_each_entry_safe(sb, sb_next, >lpfc_scsi_buf_list_get,
>list) {
>   list_del(>list);
> - pci_pool_free(phba->lpfc_scsi_dma_buf_pool, sb->data,
> + dma_pool_free(phba->lpfc_scsi_dma_buf_pool, sb->data,
> sb->dma_handle);
>   kfree(sb);
>   phba->total_scsi_bufs--;
> @@ -3283,7 +3283,7 @@ lpfc_sli4_xri_sgl_update(struct lpfc_hba *phba)
>   list_remove_head(_sgl_list, psb,
>struct lpfc_scsi_buf, list);
>   if (psb) {
> - pci_pool_free(phba->lpfc_scsi_dma_buf_pool,
> + dma_pool_free(phba->lpfc_scsi_dma_buf_pool,
> psb->data, psb->dma_handle);
>   kfree(psb);
>   }
> diff --git a/drivers/scsi/lpfc/lpfc_mem.c b/drivers/scsi/lpfc/lpfc_mem.c
> index 3fa6533..c87f64c 100644
> --- a/drivers/scsi/lpfc/lpfc_mem.c
> +++ b/drivers/scsi/lpfc/lpfc_mem.c
> @@ -91,22 +91,22 @@ lpfc_mem_alloc(struct lpfc_hba *phba, int align)
>   i = SLI4_PAGE_SIZE;
>  
>   phba->lpfc_scsi_dma_buf_pool =
> - pci_pool_create("lpfc_scsi_dma_buf_pool",
> - phba->pcidev,
> + dma_pool_create("lpfc_scsi_dma_buf_pool",
> + >pcidev->dev,
>   phba->cfg_sg_dma_buf_size,
>   i,
>   0);
>   } else {
>   phba->lpfc_scsi_dma_buf_pool =
> - pci_pool_create("lpfc_scsi_dma_buf_pool",
> - phba->pcidev, phba->cfg_sg_dma_buf_size,
> + dma_pool_create("lpfc_scsi_dma_buf_pool",
> + >pcidev->dev, phba->cfg_sg_dma_buf_size,
>   align, 0);
>   }
>  
>   if (!phba->lpfc_scsi_dma_buf_pool)
>   goto fail;
>  
> - phba->lpfc_mbuf_pool = pci_pool_create("lpfc_mbuf_pool", phba->pcidev,
> + phba->lpfc_mbuf_pool = dma_pool_create("lpfc_mbuf_pool", 
> >pcidev->dev,
Introduces line over 80 characters warning. Please fix and resubmit.

>   LPFC_BPL_SIZE,
>   align, 0);
>   if (!phba->lpfc_mbuf_pool)
> @@ -120,7 +120,7 @@ lpfc_mem_alloc(struct lpfc_hba *phba, int align)
>   pool->max_count = 0;
>   pool->current_count = 0;
>   for ( i = 0; i < LPFC_MBUF_POOL_SIZE; i++) {
> - pool->elements[i].virt = pci_pool_alloc(phba->lpfc_mbuf_pool,
> +   

[PATCH v3] scsi/sd: release scan_mutex during sync_cache and start_stop

2017-02-08 Thread Song Liu
When a device is deleted through sysfs handle "delete", the code
locks shost->scan_mutex. If multiple devices are deleted at the
same time, these deletes will be handled in series.

On the other hand, sd_shutdown() sometimes issues long latency
commands: sync cache and start_stop. It is not necessary for these
commands to run in series.

To reduce latency of parallel "delete" requests, this patch unlock
shost->scan_mutex before long latency commands and relock the mutex
after the command.

Fixed bug from previous version.

Reported-by: kernel test robot 
Signed-off-by: Song Liu 
---
 drivers/scsi/sd.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 9e0783b..14c5815 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3304,6 +3304,9 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, 
int start)
 static void sd_shutdown(struct device *dev)
 {
struct scsi_disk *sdkp = dev_get_drvdata(dev);
+   struct scsi_device *sdev;
+   struct Scsi_Host *shost;
+   int try_lock_scan_mutex;
 
if (!sdkp)
return; /* this can happen */
@@ -3311,15 +3314,26 @@ static void sd_shutdown(struct device *dev)
if (pm_runtime_suspended(dev))
return;
 
+   sdev = sdkp->device;
+   shost = sdev->host;
+   try_lock_scan_mutex = mutex_trylock(>scan_mutex);
+
if (sdkp->WCE && sdkp->media_present) {
+   mutex_unlock(>scan_mutex);
sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
sd_sync_cache(sdkp);
+   mutex_lock(>scan_mutex);
}
 
if (system_state != SYSTEM_RESTART && sdkp->device->manage_start_stop) {
+   mutex_unlock(>scan_mutex);
sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
sd_start_stop_device(sdkp, 0);
+   mutex_lock(>scan_mutex);
}
+
+   if (try_lock_scan_mutex)
+   mutex_unlock(>scan_mutex);
 }
 
 static int sd_suspend_common(struct device *dev, bool ignore_stop_errors)
-- 
2.9.3



Darlehen

2017-02-08 Thread made . anggraeni
Sie benötigen eine Finanzierung?

  Wir vergeben Darlehen. Bewerben Sie sich jetzt. Senden Sie

  uns u.a. Details zurück und Sie erhalten in Kürze Antwort



  Vorname:

  Familienname:

  Geschlecht:

  Land:

  Telefonnummer:

  benötigter Darlehensbetrag:

  Gewünschte Laufzeit:



  Mit freundlichen Grüßen


Re: [PATCH v2] scsi/sd: release scan_mutex during sync_cache and start_stop

2017-02-08 Thread Christoph Hellwig
On Wed, Feb 08, 2017 at 12:42:40PM -0800, Song Liu wrote:
> When a device is deleted through sysfs handle "delete", the code
> locks shost->scan_mutex. If multiple devices are deleted at the
> same time, these deletes will be handled in series.
> 
> On the other hand, sd_shutdown() sometimes issues long latency
> commands: sync cache and start_stop. It is not necessary for these
> commands to run in series.
> 
> To reduce latency of parallel "delete" requests, this patch unlock
> shost->scan_mutex before long latency commands and relock the mutex
> after the command.
> 
> Fixed bug from previous version.
> 
> Reported-by: kernel test robot 
> Signed-off-by: Song Liu 
> ---
>  drivers/scsi/sd.c | 15 +++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 9e0783b..22add77 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -3304,6 +3304,9 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, 
> int start)
>  static void sd_shutdown(struct device *dev)
>  {
>   struct scsi_disk *sdkp = dev_get_drvdata(dev);
> + struct scsi_device *sdev;
> + struct Scsi_Host *shost;
> + bool scan_mutex_locked;
>  
>   if (!sdkp)
>   return; /* this can happen */
> @@ -3311,14 +3314,26 @@ static void sd_shutdown(struct device *dev)
>   if (pm_runtime_suspended(dev))
>   return;
>  
> + sdev = sdkp->device;
> + shost = sdev->host;
> + scan_mutex_locked = mutex_is_locked(>scan_mutex);

The use of mutex_is_locked outside of asserts is always bogus.

The fix you want is most like in the caller of the method.


Re: [PATCH v2] scsi/sd: release scan_mutex during sync_cache and start_stop

2017-02-08 Thread Song Liu

> On Feb 8, 2017, at 1:02 PM, Christoph Hellwig  wrote:
> 
> On Wed, Feb 08, 2017 at 12:42:40PM -0800, Song Liu wrote:
>> When a device is deleted through sysfs handle "delete", the code
>> locks shost->scan_mutex. If multiple devices are deleted at the
>> same time, these deletes will be handled in series.
>> 
>> On the other hand, sd_shutdown() sometimes issues long latency
>> commands: sync cache and start_stop. It is not necessary for these
>> commands to run in series.
>> 
>> To reduce latency of parallel "delete" requests, this patch unlock
>> shost->scan_mutex before long latency commands and relock the mutex
>> after the command.
>> 
>> Fixed bug from previous version.
>> 
>> Reported-by: kernel test robot 
>> Signed-off-by: Song Liu 
>> ---
>> drivers/scsi/sd.c | 15 +++
>> 1 file changed, 15 insertions(+)
>> 
>> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
>> index 9e0783b..22add77 100644
>> --- a/drivers/scsi/sd.c
>> +++ b/drivers/scsi/sd.c
>> @@ -3304,6 +3304,9 @@ static int sd_start_stop_device(struct scsi_disk 
>> *sdkp, int start)
>> static void sd_shutdown(struct device *dev)
>> {
>>  struct scsi_disk *sdkp = dev_get_drvdata(dev);
>> +struct scsi_device *sdev;
>> +struct Scsi_Host *shost;
>> +bool scan_mutex_locked;
>> 
>>  if (!sdkp)
>>  return; /* this can happen */
>> @@ -3311,14 +3314,26 @@ static void sd_shutdown(struct device *dev)
>>  if (pm_runtime_suspended(dev))
>>  return;
>> 
>> +sdev = sdkp->device;
>> +shost = sdev->host;
>> +scan_mutex_locked = mutex_is_locked(>scan_mutex);
> 
> The use of mutex_is_locked outside of asserts is always bogus.
> 
> The fix you want is most like in the caller of the method.

Hi Christoph, 

Thanks for the feedback. The other caller (that does not hold scan_mutex) 
of sd_shutdown() is device_shutdown() in drivers/base/core.c. I could not 
think of a good way to lock scan_mutex there. 

Would some variation of mutex_trylock() be a better option here? 

Thanks,
Song




[PATCH v2] scsi/sd: release scan_mutex during sync_cache and start_stop

2017-02-08 Thread Song Liu
When a device is deleted through sysfs handle "delete", the code
locks shost->scan_mutex. If multiple devices are deleted at the
same time, these deletes will be handled in series.

On the other hand, sd_shutdown() sometimes issues long latency
commands: sync cache and start_stop. It is not necessary for these
commands to run in series.

To reduce latency of parallel "delete" requests, this patch unlock
shost->scan_mutex before long latency commands and relock the mutex
after the command.

Fixed bug from previous version.

Reported-by: kernel test robot 
Signed-off-by: Song Liu 
---
 drivers/scsi/sd.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 9e0783b..22add77 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3304,6 +3304,9 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, 
int start)
 static void sd_shutdown(struct device *dev)
 {
struct scsi_disk *sdkp = dev_get_drvdata(dev);
+   struct scsi_device *sdev;
+   struct Scsi_Host *shost;
+   bool scan_mutex_locked;
 
if (!sdkp)
return; /* this can happen */
@@ -3311,14 +3314,26 @@ static void sd_shutdown(struct device *dev)
if (pm_runtime_suspended(dev))
return;
 
+   sdev = sdkp->device;
+   shost = sdev->host;
+   scan_mutex_locked = mutex_is_locked(>scan_mutex);
+
if (sdkp->WCE && sdkp->media_present) {
+   if (scan_mutex_locked)
+   mutex_unlock(>scan_mutex);
sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
sd_sync_cache(sdkp);
+   if (scan_mutex_locked)
+   mutex_lock(>scan_mutex);
}
 
if (system_state != SYSTEM_RESTART && sdkp->device->manage_start_stop) {
+   if (scan_mutex_locked)
+   mutex_unlock(>scan_mutex);
sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
sd_start_stop_device(sdkp, 0);
+   if (scan_mutex_locked)
+   mutex_lock(>scan_mutex);
}
 }
 
-- 
2.9.3



Patch: lpfc: Modify Emulex lpfc LPFC_DEFAULT_SG_SEG_CNT to 128 for default larger sg_io capability

2017-02-08 Thread Laurence Oberman
We have been seeing issues with qemu_kvm virtual guests where if they issue 
I/O to direct attached SCSI passthrough LUNS with large I/O sizes such as 512K
the sg_io will fail with -EINVAL.

Simple reproducer is here.

strace -e ioctl sg_dd if=/dev/zero of=/dev/sdae bpt=0x400 count=0x400 blk_sgio=1
Assume default 'bs' (block size) of 512 bytes
ioctl(4, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[6]=[12, 00, 00, 00, 24, 00], 
mx_sb_len=64, iovec_count=0, dxfer_len=36, timeout=6, flags=0, 
data[36]=["\0\0\5\2\37\270\0\2LIO-ORG block-15"...], status=00, 
masked_status=00, sb[0]=[], host_status=0, driver_status=0, resid=0, 
duration=0, info=0}) = 0
ioctl(4, SG_IO, {'S', SG_DXFER_TO_DEV, cmd[10]=[2a, 00, 00, 00, 00, 00, 00, 04, 
00, 00], mx_sb_len=64, iovec_count=0, dxfer_len=524288, timeout=6, flags=0, 
data[524288]=["\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...]})
 = -1 EINVAL (Invalid argument)
writing (SG_IO) on sg device, error: Invalid argument
sg_write failed, seek=0
Some error occurred,  remaining block count=1024
1024+0 records in
0+0 records out

Qlogic defaults to 128 so has not been seeing this but lpfc does not.
Would like to avoid having to set this in the module parameters to 128.

Tested-by: Laurence Oberman 
Signed-off-by: Laurence Oberman 

>From 23996dcbdd9b505d18d59ecde961c87f76fc9c2e Mon Sep 17 00:00:00 2001
From: Laurence Oberman 
Date: Wed, 8 Feb 2017 14:49:05 -0500
Subject: [PATCH] Modified LPFC_DEFAULT_SG_SEG_CNT to 128 to match Qlogic. This
 will allow larger sg_io passthrough for qemu_kvm guests that expect the
 larger setting for I/O large rthen 512k.

---
 drivers/scsi/lpfc/lpfc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 8a20b4e..8f86d41 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -42,7 +42,7 @@
 #define LPFC_MAX_NS_RETRY  3   /* Number of retry attempts to contact
   the NameServer  before giving up. */
 #define LPFC_CMD_PER_LUN   3   /* max outstanding cmds per lun */
-#define LPFC_DEFAULT_SG_SEG_CNT 64 /* sg element count per scsi cmnd */
+#define LPFC_DEFAULT_SG_SEG_CNT 128/* sg element count per scsi cmnd */
 #define LPFC_DEFAULT_MENLO_SG_SEG_CNT 128  /* sg element count per scsi
cmnd for menlo needs nearly twice as for firmware
downloads using bsg */
-- 
1.8.3.1



 


Re: [RFC 19/19] checkpatch: warn for use of old PCI pool API

2017-02-08 Thread Joe Perches
On Wed, 2017-02-08 at 19:55 +0100, Peter Senna Tschudin wrote:
> On Wed, Feb 08, 2017 at 05:34:57PM +0100, Romain Perier wrote:
> > pci_pool_*() functions should be replaced by the corresponding functions
> > in the DMA pool API. This adds support to check for use of these pci
> > functions and display a warning when it is the case.
> 
> Don't know if relevant, but did not catch the struct. Other than that
> works fine.
> 
> > 
> > Signed-off-by: Romain Perier 
> > ---
> >  scripts/checkpatch.pl | 5 +
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index 8e96af5..026920e 100755
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -6058,6 +6058,11 @@ sub process {
> > WARN("USE_DEVICE_INITCALL",
> >  "please use device_initcall() or more appropriate 
> > function instead of __initcall() (see include/linux/init.h)\n" . $herecurr);
> > }
> > +# check for old PCI api pci_pool_*(), use dma_pool_*() instead
> > +   if ($line =~ /\bpci_pool_.+\(/) {
> > +   WARN("USE_PCI_POOL",
> > +"please use the dma pool api or more appropriate 
> > function instead of the old pci pool api\n" . $herecurr);
> > +   }
> >  
> >  # check for various structs that are normally const (ops, kgdb, 
> > device_tree)
> > if ($line !~ /\bconst\b/ &&
> > -- 
> > 2.9.3
> > 

Did this patch get to lkml?

Perhaps this would be more complete:

 scripts/checkpatch.pl | 9 +
 1 file changed, 9 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8e96af53611c..600f81cc1ec1 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6059,6 +6059,15 @@ sub process {
     "please use device_initcall() or more appropriate 
function instead of __initcall() (see include/linux/init.h)\n" . $herecurr);
    }
 
+# check for old PCI api pci_pool_*(), use dma_pool_*() instead
+   if ($line =~ 
/\bpci_pool(?:_(?:create|destroy|alloc|zalloc|free)|)\b/) {
+   if (WARN("USE_DMA_POOL",
+    "please use the dma pool api or more 
appropriate function instead of the old pci pool api\n" . $herecurr) &&
+   $fix) {
+   while ($fixed[$fixlinenr] =~ 
s/\bpci_pool(_(?:create|destroy|alloc|zalloc|free)|)\b/dma_pool$1/) {}
+   }
+   }
+
 # check for various structs that are normally const (ops, kgdb, device_tree)
    if ($line !~ /\bconst\b/ &&
    $line =~ /\bstruct\s+($const_structs)\b/) {



Re: [PATCH net-next v2 00/12] net: dsa: remove unnecessary phy.h include

2017-02-08 Thread Florian Fainelli
On 02/08/2017 08:11 AM, Kalle Valo wrote:
> David Miller  writes:
> 
>> From: Florian Fainelli 
>> Date: Tue,  7 Feb 2017 15:02:53 -0800
>>
>>> I'm hoping this doesn't conflict with what's already in net-next...
>>>
>>> David, this should probably go via your tree considering the diffstat.
>>
>> I think you need one more respin.  Are you doing an allmodconfig build?

I did not, instead tried to test each driver individually in different
configurations...

>> If not, for something like this it's a must:
>>
>> drivers/net/wireless/ath/wil6210/cfg80211.c:24:30: error: expected ‘)’ 
>> before ‘bool’
>>  module_param(disable_ap_sme, bool, 0444);
>>   ^
>> drivers/net/wireless/ath/wil6210/cfg80211.c:25:34: error: expected ‘)’ 
>> before string constant
>>  MODULE_PARM_DESC(disable_ap_sme, " let user space handle AP mode SME");
>>   ^
>> Like like that file needs linux/module.h included.
> 
> Johannes already fixed a similar (or same) problem in my tree:
> 
> wil6210: include moduleparam.h
> 
> https://git.kernel.org/cgit/linux/kernel/git/kvalo/wireless-drivers-next.git/commit/?id=949c2d0096753d518ef6e0bd8418c8086747196b
> 
> I'm planning to send you a pull request tomorrow which contains that
> one.

Thanks Kalle!

David, can you hold on this series until Kalle's pull request gets
submitted? Past this error, allmodconfig builds fine with this patch
series (just tested). Thanks!
-- 
Florian


Re: [PATCH v2 07/18] lpfc: NVME Initiator: Base modifications Part E

2017-02-08 Thread James Smart


On 2/8/2017 4:47 AM, Christoph Hellwig wrote:

On Tue, Feb 07, 2017 at 06:32:30PM -0800, James Smart wrote:

I realize I cut these in a silly way.  In the v1 patches, I had a big patch
that I then cut into 6 parts, by file.  In the v2 patches, I tried to keep
the patches as is, and address the comments in the respective patch the
comment came from. Which resulted in 3/8 with an old reference, but patch
8/8 being the one that reverted this reverence. Sorry..  I'll recut and
repost.

This whole split doesn't make sense - either the patches are logically
split, in which case they can be posted separately, or they belong
together in which case they should be sent together.  But the size
of them suggest to me they probably need to be broken down to logically
separate patches.

And can you please switch to using git-send-email to send the patches
straight from a git branch?  There are lot of patch formatting issues
with the lpfc patches, and that should fix most of them instantly.



Ok. I will see if they can be further split. I don't have a lot of hope 
beyond a couple splits. So, the resulting patches will be large.


git-send-email: I'll talk to you offline.

-- james



Re: [RFC 03/19] IB/mthca: Replace PCI pool old API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:41PM +0100, Romain Perier wrote:
> The PCI pool API is deprecated. This commits replaces the PCI pool old
> API by the appropriated function with the DMA pool API.

Tested by compilation only.

Acked-by: Peter Senna Tschudin 
Tested-by: Peter Senna Tschudin 
> 
> Signed-off-by: Romain Perier 
> ---
>  drivers/infiniband/hw/mthca/mthca_av.c  | 10 +-
>  drivers/infiniband/hw/mthca/mthca_cmd.c |  8 
>  drivers/infiniband/hw/mthca/mthca_dev.h |  4 ++--
>  3 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mthca/mthca_av.c 
> b/drivers/infiniband/hw/mthca/mthca_av.c
> index c9f0f36..9d041b6 100644
> --- a/drivers/infiniband/hw/mthca/mthca_av.c
> +++ b/drivers/infiniband/hw/mthca/mthca_av.c
> @@ -186,7 +186,7 @@ int mthca_create_ah(struct mthca_dev *dev,
>  
>  on_hca_fail:
>   if (ah->type == MTHCA_AH_PCI_POOL) {
> - ah->av = pci_pool_zalloc(dev->av_table.pool,
> + ah->av = dma_pool_zalloc(dev->av_table.pool,
>GFP_ATOMIC, >avdma);
>   if (!ah->av)
>   return -ENOMEM;
> @@ -245,7 +245,7 @@ int mthca_destroy_ah(struct mthca_dev *dev, struct 
> mthca_ah *ah)
>   break;
>  
>   case MTHCA_AH_PCI_POOL:
> - pci_pool_free(dev->av_table.pool, ah->av, ah->avdma);
> + dma_pool_free(dev->av_table.pool, ah->av, ah->avdma);
>   break;
>  
>   case MTHCA_AH_KMALLOC:
> @@ -333,7 +333,7 @@ int mthca_init_av_table(struct mthca_dev *dev)
>   if (err)
>   return err;
>  
> - dev->av_table.pool = pci_pool_create("mthca_av", dev->pdev,
> + dev->av_table.pool = dma_pool_create("mthca_av", >pdev->dev,
>MTHCA_AV_SIZE,
>MTHCA_AV_SIZE, 0);
>   if (!dev->av_table.pool)
> @@ -353,7 +353,7 @@ int mthca_init_av_table(struct mthca_dev *dev)
>   return 0;
>  
>   out_free_pool:
> - pci_pool_destroy(dev->av_table.pool);
> + dma_pool_destroy(dev->av_table.pool);
>  
>   out_free_alloc:
>   mthca_alloc_cleanup(>av_table.alloc);
> @@ -367,6 +367,6 @@ void mthca_cleanup_av_table(struct mthca_dev *dev)
>  
>   if (dev->av_table.av_map)
>   iounmap(dev->av_table.av_map);
> - pci_pool_destroy(dev->av_table.pool);
> + dma_pool_destroy(dev->av_table.pool);
>   mthca_alloc_cleanup(>av_table.alloc);
>  }
> diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c 
> b/drivers/infiniband/hw/mthca/mthca_cmd.c
> index c7f49bb..7f219c8 100644
> --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
> +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
> @@ -530,7 +530,7 @@ int mthca_cmd_init(struct mthca_dev *dev)
>   return -ENOMEM;
>   }
>  
> - dev->cmd.pool = pci_pool_create("mthca_cmd", dev->pdev,
> + dev->cmd.pool = dma_pool_create("mthca_cmd", >pdev->dev,
>   MTHCA_MAILBOX_SIZE,
>   MTHCA_MAILBOX_SIZE, 0);
>   if (!dev->cmd.pool) {
> @@ -543,7 +543,7 @@ int mthca_cmd_init(struct mthca_dev *dev)
>  
>  void mthca_cmd_cleanup(struct mthca_dev *dev)
>  {
> - pci_pool_destroy(dev->cmd.pool);
> + dma_pool_destroy(dev->cmd.pool);
>   iounmap(dev->hcr);
>   if (dev->cmd.flags & MTHCA_CMD_POST_DOORBELLS)
>   iounmap(dev->cmd.dbell_map);
> @@ -613,7 +613,7 @@ struct mthca_mailbox *mthca_alloc_mailbox(struct 
> mthca_dev *dev,
>   if (!mailbox)
>   return ERR_PTR(-ENOMEM);
>  
> - mailbox->buf = pci_pool_alloc(dev->cmd.pool, gfp_mask, >dma);
> + mailbox->buf = dma_pool_alloc(dev->cmd.pool, gfp_mask, >dma);
>   if (!mailbox->buf) {
>   kfree(mailbox);
>   return ERR_PTR(-ENOMEM);
> @@ -627,7 +627,7 @@ void mthca_free_mailbox(struct mthca_dev *dev, struct 
> mthca_mailbox *mailbox)
>   if (!mailbox)
>   return;
>  
> - pci_pool_free(dev->cmd.pool, mailbox->buf, mailbox->dma);
> + dma_pool_free(dev->cmd.pool, mailbox->buf, mailbox->dma);
>   kfree(mailbox);
>  }
>  
> diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h 
> b/drivers/infiniband/hw/mthca/mthca_dev.h
> index 4393a02..8c3f6ed 100644
> --- a/drivers/infiniband/hw/mthca/mthca_dev.h
> +++ b/drivers/infiniband/hw/mthca/mthca_dev.h
> @@ -118,7 +118,7 @@ enum {
>  };
>  
>  struct mthca_cmd {
> - struct pci_pool  *pool;
> + struct dma_pool  *pool;
>   struct mutex  hcr_mutex;
>   struct semaphore  poll_sem;
>   struct semaphore  event_sem;
> @@ -263,7 +263,7 @@ struct mthca_qp_table {
>  };
>  
>  struct mthca_av_table {
> - struct pci_pool   *pool;
> + struct dma_pool   *pool;
>   intnum_ddr_avs;
>   u64ddr_av_base;
>   void 

Re: [PATCH v2 10/14] qla2xxx: Fix request queue corruption.

2017-02-08 Thread Bart Van Assche
On Fri, 2017-02-03 at 14:40 -0800, Himanshu Madhani wrote:
> From: Quinn Tran 
> 
> When FW notify driver or driver detects low FW resource,
> driver tries to send out Busy SCSI Status to tell Initiator
> side to back off. During the send process, the lock was not held.
> 
> Signed-off-by: Quinn Tran 
> Signed-off-by: Himanshu Madhani 
> ---
>  drivers/scsi/qla2xxx/qla_target.c | 12 +---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_target.c 
> b/drivers/scsi/qla2xxx/qla_target.c
> index b61cbb8..b5fb9c55 100644
> --- a/drivers/scsi/qla2xxx/qla_target.c
> +++ b/drivers/scsi/qla2xxx/qla_target.c
> @@ -5170,16 +5170,22 @@ static int __qlt_send_busy(struct scsi_qla_host *vha,
>  
>  static int
>  qlt_chk_qfull_thresh_hold(struct scsi_qla_host *vha,
> - struct atio_from_isp *atio)
> + struct atio_from_isp *atio, uint8_t ha_locked)
>  {
>   struct qla_hw_data *ha = vha->hw;
>   uint16_t status;
> + unsigned long flags;
>  
>   if (ha->tgt.num_pend_cmds < Q_FULL_THRESH_HOLD(ha))
>   return 0;
>  
> + if (!ha_locked)
> + spin_lock_irqsave(>hardware_lock, flags);
>   status = temp_sam_status;
>   qlt_send_busy(vha, atio, status);
> + if (!ha_locked)
> + spin_unlock_irqrestore(>hardware_lock, flags);
> +
>   return 1;
>  }
>  
> @@ -5224,7 +5230,7 @@ static void qlt_24xx_atio_pkt(struct scsi_qla_host *vha,
>  
>  
>   if (likely(atio->u.isp24.fcp_cmnd.task_mgmt_flags == 0)) {
> - rc = qlt_chk_qfull_thresh_hold(vha, atio);
> + rc = qlt_chk_qfull_thresh_hold(vha, atio, ha_locked);
>   if (rc != 0) {
>   tgt->atio_irq_cmd_count--;
>   return;
> @@ -5347,7 +5353,7 @@ static void qlt_response_pkt(struct scsi_qla_host *vha, 
> response_t *pkt)
>   break;
>   }
>  
> - rc = qlt_chk_qfull_thresh_hold(vha, atio);
> + rc = qlt_chk_qfull_thresh_hold(vha, atio, 1);
>   if (rc != 0) {
>   tgt->irq_cmd_count--;
>   return;

Hello Quinn,

Please consider to use bool instead of uint8_t for ha_locked and true /
false instead of 1 / 0.

Bart.


Re: [PATCH v2 04/14] qla2xxx: Use IOCB interface to submit non-critical MBX.

2017-02-08 Thread Madhani, Himanshu

On 2/8/17, 10:48 AM, "Bart Van Assche"  wrote:

>On Fri, 2017-02-03 at 14:40 -0800, Himanshu Madhani wrote:
>> diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
>> index db6bd92..4225256 100644
>> --- a/drivers/scsi/qla2xxx/qla_mbx.c
>> +++ b/drivers/scsi/qla2xxx/qla_mbx.c
>> @@ -10,6 +10,29 @@
>>  #include 
>>  #include 
>>  
>> +static struct mb_cmd_name {
>> +uint16_t cmd;
>> +char *str;
>> +} mb_str[] = {
>> +{0x,"unknown"},
>> +{MBC_GET_PORT_DATABASE, "GPDB"},
>> +{MBC_GET_ID_LIST,   "GIDList"},
>> +{MBC_GET_LINK_PRIV_STATS, "Stats"},
>> +};
>> +
>> +static char *mb_to_str(uint16_t cmd)
>> +{
>> +int i;
>> +struct mb_cmd_name *e;
>> +
>> +for (i = 0; i < ARRAY_SIZE(mb_str); i++) {
>> +e = mb_str + i;
>> +if (cmd == e->cmd)
>> +return e->str;
>> +}
>> +return mb_str[0].str; /* unknown */
>> +}
>
>Please use const char * instead of char * in the struct definition and for
>the mb_to_str() function return type. Please also leave out the element with
>index 0x from the mb_str[] array and make mb_to_str() return "unknown"
>instead of mb_str[0].str if lookup fails.

Will update patch and resend. 

>
>Bart.
>Western Digital Corporation (and its subsidiaries) E-mail Confidentiality 
>Notice & Disclaimer:
>
>This e-mail and any files transmitted with it may contain confidential or 
>legally privileged information of WDC and/or its affiliates, and are intended 
>solely for the use of the individual or entity to which they are addressed. If 
>you are not the intended recipient, any disclosure, copying, distribution or 
>any action taken or omitted to be taken in reliance on it, is prohibited. If 
>you have received this e-mail in error, please notify the sender immediately 
>and delete the e-mail in its entirety from your system.
>


RE: [PATCH v2 03/39] megaraid_sas: raid 1 fast path code optimize

2017-02-08 Thread Kashyap Desai
> > +static inline void
> > +megasas_complete_r1_command(struct megasas_instance *instance,
> > +   struct megasas_cmd_fusion *cmd) {
> > +   u8 *sense, status, ex_status;
> > +   u32 data_length;
> > +   u16 peer_smid;
> > +   struct fusion_context *fusion;
> > +   struct megasas_cmd_fusion *r1_cmd = NULL;
> > +   struct scsi_cmnd *scmd_local = NULL;
> > +   struct RAID_CONTEXT_G35 *rctx_g35;
> > +
> > +   rctx_g35 = >io_request->RaidContext.raid_context_g35;
> > +   fusion = instance->ctrl_context;
> > +   peer_smid = le16_to_cpu(rctx_g35->smid.peer_smid);
> > +
> > +   r1_cmd = fusion->cmd_list[peer_smid - 1];
> > +   scmd_local = cmd->scmd;
> > +   status = rctx_g35->status;
> > +   ex_status = rctx_g35->ex_status;
> > +   data_length = cmd->io_request->DataLength;
> > +   sense = cmd->sense;
> > +
> > +   cmd->cmd_completed = true;
>
> Please help me understand how this works
> - there are two peer commands sent to the controller
> - both are completed and the later calls scsi_done and returns both
r1_cmd
> + cmd
> - if both commands can be completed at the same time, is it possible
that
> the
>   above line is executed at the same moment for both completions ?
> How is the code  protected against a double completion when both
> completed commands see the peer cmd_completed as set ?


Tomas,  cmd and r1_cmd (part of  same Raid 1 FP) will be always completed
on same reply queue by firmware. That is one of the key requirement here
for raid 1 fast path.
What you ask is possible if FW completes cmd and r1_cmd on different reply
queue. If you notice when we clone r1_cmd, we also clone MSI-x index from
parent command.
So eventually, FW is aware of binding of both cmd and r1_cmd w.r.t reply
queue index.

` Kashyap

>
> > +


Re: [PATCH v2 02/14] qla2xxx: Allow relogin to proceed if remote login did not finish

2017-02-08 Thread Madhani, Himanshu


On 2/8/17, 10:42 AM, "Bart Van Assche"  wrote:

>The above code occurs two times in this patch. We try to avoid duplicating
>code in the Linux kernel, especially code that contains hardcoded constants.
>Have you considered to change the name of plogi_nack_done_jiff into e.g.
>plogi_done_deadline and to assign jiffies + HZ to that variable instead of
>jiffies?

Thanks for the review. Will update patch and resend series. 


Re: [PATCH v2 04/14] qla2xxx: Use IOCB interface to submit non-critical MBX.

2017-02-08 Thread Bart Van Assche
On Fri, 2017-02-03 at 14:40 -0800, Himanshu Madhani wrote:
> diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
> index db6bd92..4225256 100644
> --- a/drivers/scsi/qla2xxx/qla_mbx.c
> +++ b/drivers/scsi/qla2xxx/qla_mbx.c
> @@ -10,6 +10,29 @@
>  #include 
>  #include 
>  
> +static struct mb_cmd_name {
> + uint16_t cmd;
> + char *str;
> +} mb_str[] = {
> + {0x,"unknown"},
> + {MBC_GET_PORT_DATABASE, "GPDB"},
> + {MBC_GET_ID_LIST,   "GIDList"},
> + {MBC_GET_LINK_PRIV_STATS, "Stats"},
> +};
> +
> +static char *mb_to_str(uint16_t cmd)
> +{
> + int i;
> + struct mb_cmd_name *e;
> +
> + for (i = 0; i < ARRAY_SIZE(mb_str); i++) {
> + e = mb_str + i;
> + if (cmd == e->cmd)
> + return e->str;
> + }
> + return mb_str[0].str; /* unknown */
> +}

Please use const char * instead of char * in the struct definition and for
the mb_to_str() function return type. Please also leave out the element with
index 0x from the mb_str[] array and make mb_to_str() return "unknown"
instead of mb_str[0].str if lookup fails.

Bart.


Re: [RFC 11/19] scsi: megaraid: Replace PCI pool old API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:49PM +0100, Romain Perier wrote:
> The PCI pool API is deprecated. This commits replaces the PCI pool old
> API by the appropriated function with the DMA pool API.
> 
> Signed-off-by: Romain Perier 
> ---
>  drivers/scsi/megaraid/megaraid_mbox.c   | 30 ++--
>  drivers/scsi/megaraid/megaraid_mm.c | 28 +-
>  drivers/scsi/megaraid/megaraid_sas_base.c   | 24 
>  drivers/scsi/megaraid/megaraid_sas_fusion.c | 44 
> ++---
>  4 files changed, 63 insertions(+), 63 deletions(-)
> 
> diff --git a/drivers/scsi/megaraid/megaraid_mbox.c 
> b/drivers/scsi/megaraid/megaraid_mbox.c
> index f0987f2..6d0bd3a 100644
> --- a/drivers/scsi/megaraid/megaraid_mbox.c
> +++ b/drivers/scsi/megaraid/megaraid_mbox.c
> @@ -1153,8 +1153,8 @@ megaraid_mbox_setup_dma_pools(adapter_t *adapter)
>  
>  
>   // Allocate memory for 16-bytes aligned mailboxes
> - raid_dev->mbox_pool_handle = pci_pool_create("megaraid mbox pool",
> - adapter->pdev,
> + raid_dev->mbox_pool_handle = dma_pool_create("megaraid mbox pool",
> + >pdev->dev,
>   sizeof(mbox64_t) + 16,
>   16, 0);
>  
> @@ -1164,7 +1164,7 @@ megaraid_mbox_setup_dma_pools(adapter_t *adapter)
>  
>   mbox_pci_blk = raid_dev->mbox_pool;
>   for (i = 0; i < MBOX_MAX_SCSI_CMDS; i++) {
> - mbox_pci_blk[i].vaddr = pci_pool_alloc(
> + mbox_pci_blk[i].vaddr = dma_pool_alloc(
>   raid_dev->mbox_pool_handle,
>   GFP_KERNEL,
>   _pci_blk[i].dma_addr);
> @@ -1181,8 +1181,8 @@ megaraid_mbox_setup_dma_pools(adapter_t *adapter)
>* share common memory pool. Passthru structures piggyback on memory
>* allocted to extended passthru since passthru is smaller of the two
>*/
> - raid_dev->epthru_pool_handle = pci_pool_create("megaraid mbox pthru",
> - adapter->pdev, sizeof(mraid_epassthru_t), 128, 0);
> + raid_dev->epthru_pool_handle = dma_pool_create("megaraid mbox pthru",
> + >pdev->dev, sizeof(mraid_epassthru_t), 128, 0);
>  
>   if (raid_dev->epthru_pool_handle == NULL) {
>   goto fail_setup_dma_pool;
> @@ -1190,7 +1190,7 @@ megaraid_mbox_setup_dma_pools(adapter_t *adapter)
>  
>   epthru_pci_blk = raid_dev->epthru_pool;
>   for (i = 0; i < MBOX_MAX_SCSI_CMDS; i++) {
> - epthru_pci_blk[i].vaddr = pci_pool_alloc(
> + epthru_pci_blk[i].vaddr = dma_pool_alloc(
>   raid_dev->epthru_pool_handle,
>   GFP_KERNEL,
>   _pci_blk[i].dma_addr);
> @@ -1202,8 +1202,8 @@ megaraid_mbox_setup_dma_pools(adapter_t *adapter)
>  
>   // Allocate memory for each scatter-gather list. Request for 512 bytes
>   // alignment for each sg list
> - raid_dev->sg_pool_handle = pci_pool_create("megaraid mbox sg",
> - adapter->pdev,
> + raid_dev->sg_pool_handle = dma_pool_create("megaraid mbox sg",
> + >pdev->dev,
>   sizeof(mbox_sgl64) * MBOX_MAX_SG_SIZE,
>   512, 0);
>  
> @@ -1213,7 +1213,7 @@ megaraid_mbox_setup_dma_pools(adapter_t *adapter)
>  
>   sg_pci_blk = raid_dev->sg_pool;
>   for (i = 0; i < MBOX_MAX_SCSI_CMDS; i++) {
> - sg_pci_blk[i].vaddr = pci_pool_alloc(
> + sg_pci_blk[i].vaddr = dma_pool_alloc(
>   raid_dev->sg_pool_handle,
>   GFP_KERNEL,
>   _pci_blk[i].dma_addr);
> @@ -1249,29 +1249,29 @@ megaraid_mbox_teardown_dma_pools(adapter_t *adapter)
>  
>   sg_pci_blk = raid_dev->sg_pool;
>   for (i = 0; i < MBOX_MAX_SCSI_CMDS && sg_pci_blk[i].vaddr; i++) {
> - pci_pool_free(raid_dev->sg_pool_handle, sg_pci_blk[i].vaddr,
> + dma_pool_free(raid_dev->sg_pool_handle, sg_pci_blk[i].vaddr,
>   sg_pci_blk[i].dma_addr);
>   }
>   if (raid_dev->sg_pool_handle)
dma_pool_destroy(NULL) is safe and this check is probably not required

> - pci_pool_destroy(raid_dev->sg_pool_handle);
> + dma_pool_destroy(raid_dev->sg_pool_handle);
>  
>  
>   epthru_pci_blk = raid_dev->epthru_pool;
>   for (i = 0; i < MBOX_MAX_SCSI_CMDS && epthru_pci_blk[i].vaddr; i++) {
> - pci_pool_free(raid_dev->epthru_pool_handle,
> + dma_pool_free(raid_dev->epthru_pool_handle,
>   

Re: [PATCH v2 06/14] qla2xxx: Improve T10-DIF/PI handling in driver.

2017-02-08 Thread Madhani, Himanshu
Hi Nic,



On 2/7/17, 8:13 PM, "Nicholas A. Bellinger"  wrote:

>On Fri, 2017-02-03 at 14:40 -0800, Himanshu Madhani wrote:
>> From: Quinn Tran 
>> 
>> Add routines to support T10 DIF tag.
>> 
>> Signed-off-by: Quinn Tran 
>> Signed-off-by: Anil Gurumurthy 
>> Signed-off-by: Himanshu Madhani 
>> ---
>>  drivers/scsi/qla2xxx/qla_dbg.h |   1 +
>>  drivers/scsi/qla2xxx/qla_def.h |  17 ++
>>  drivers/scsi/qla2xxx/qla_target.c  | 598 
>> +
>>  drivers/scsi/qla2xxx/qla_target.h  |  37 ++-
>>  drivers/scsi/qla2xxx/tcm_qla2xxx.c |  84 +-
>>  5 files changed, 465 insertions(+), 272 deletions(-)
>> 
>> diff --git a/drivers/scsi/qla2xxx/qla_dbg.h b/drivers/scsi/qla2xxx/qla_dbg.h
>> index e1fc4e6..c6bffe9 100644
>> --- a/drivers/scsi/qla2xxx/qla_dbg.h
>> +++ b/drivers/scsi/qla2xxx/qla_dbg.h
>> @@ -348,6 +348,7 @@ void __attribute__((format (printf, 4, 5)))
>>  #define ql_dbg_tgt  0x4000 /* Target mode */
>>  #define ql_dbg_tgt_mgt  0x2000 /* Target mode management */
>>  #define ql_dbg_tgt_tmr  0x1000 /* Target mode task management */
>> +#define ql_dbg_tgt_dif  0x0800 /* Target mode dif */
>>  
>>  extern int qla27xx_dump_mpi_ram(struct qla_hw_data *, uint32_t, uint32_t *,
>>  uint32_t, void **);
>> diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
>> index 8bc..d6436fc 100644
>> --- a/drivers/scsi/qla2xxx/qla_def.h
>> +++ b/drivers/scsi/qla2xxx/qla_def.h
>> @@ -2189,6 +2189,23 @@ struct qlt_plogi_ack_t {
>>  void*fcport;
>>  };
>>  
>> +enum qla_tgt_prot_op {
>> +QLA_PROT_NORMAL  = 0,
>> +QLA_PROT_DIN_INSERT,
>> +QLA_PROT_DOUT_INSERT,
>> +QLA_PROT_DIN_STRIP,
>> +QLA_PROT_DOUT_STRIP,
>> +QLA_PROT_DIN_PASS,
>> +QLA_PROT_DOUT_PASS,
>> +};
>> +
>> +enum qla_tgt_prot_type {
>> +QLA_TGT_PROT_TYPE0,
>> +QLA_TGT_PROT_TYPE1,
>> +QLA_TGT_PROT_TYPE2,
>> +QLA_TGT_PROT_TYPE3,
>> +};
>> +
>
>I don't get it, why are you duplicating target_prot_op and
>target_prot_type..?

We will fix it and resubmit this. 

Thanks,
Himanshu


Re: [RFC 14/19] scsi: pmcraid: Replace PCI pool old API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:52PM +0100, Romain Perier wrote:
> The PCI pool API is deprecated. This commits replaces the PCI pool old
> API by the appropriated function with the DMA pool API.
> 
Tested by compilation only.

Acked-by: Peter Senna Tschudin 
Tested-by: Peter Senna Tschudin 
> Signed-off-by: Romain Perier 
> ---
>  drivers/scsi/pmcraid.c | 10 +-
>  drivers/scsi/pmcraid.h |  2 +-
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
> index 49e70a3..0f893c4 100644
> --- a/drivers/scsi/pmcraid.c
> +++ b/drivers/scsi/pmcraid.c
> @@ -4699,13 +4699,13 @@ pmcraid_release_control_blocks(
>   return;
>  
>   for (i = 0; i < max_index; i++) {
> - pci_pool_free(pinstance->control_pool,
> + dma_pool_free(pinstance->control_pool,
> pinstance->cmd_list[i]->ioa_cb,
> pinstance->cmd_list[i]->ioa_cb_bus_addr);
>   pinstance->cmd_list[i]->ioa_cb = NULL;
>   pinstance->cmd_list[i]->ioa_cb_bus_addr = 0;
>   }
> - pci_pool_destroy(pinstance->control_pool);
> + dma_pool_destroy(pinstance->control_pool);
>   pinstance->control_pool = NULL;
>  }
>  
> @@ -4762,8 +4762,8 @@ static int pmcraid_allocate_control_blocks(struct 
> pmcraid_instance *pinstance)
>   pinstance->host->unique_id);
>  
>   pinstance->control_pool =
> - pci_pool_create(pinstance->ctl_pool_name,
> - pinstance->pdev,
> + dma_pool_create(pinstance->ctl_pool_name,
> + >pdev->dev,
>   sizeof(struct pmcraid_control_block),
>   PMCRAID_IOARCB_ALIGNMENT, 0);
>  
> @@ -4772,7 +4772,7 @@ static int pmcraid_allocate_control_blocks(struct 
> pmcraid_instance *pinstance)
>  
>   for (i = 0; i < PMCRAID_MAX_CMD; i++) {
>   pinstance->cmd_list[i]->ioa_cb =
> - pci_pool_alloc(
> + dma_pool_alloc(
>   pinstance->control_pool,
>   GFP_KERNEL,
>   &(pinstance->cmd_list[i]->ioa_cb_bus_addr));
> diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
> index 568b18a..acf5a7b 100644
> --- a/drivers/scsi/pmcraid.h
> +++ b/drivers/scsi/pmcraid.h
> @@ -755,7 +755,7 @@ struct pmcraid_instance {
>  
>   /* structures related to command blocks */
>   struct kmem_cache *cmd_cachep;  /* cache for cmd blocks */
> - struct pci_pool *control_pool;  /* pool for control blocks */
> + struct dma_pool *control_pool;  /* pool for control blocks */
>   char   cmd_pool_name[64];   /* name of cmd cache */
>   char   ctl_pool_name[64];   /* name of control cache */
>  
> -- 
> 2.9.3
> 


Re: [PATCH v2 06/14] qla2xxx: Improve T10-DIF/PI handling in driver.

2017-02-08 Thread Madhani, Himanshu
Hi Bart, 



On 2/8/17, 10:57 AM, "Bart Van Assche"  wrote:

>On Fri, 2017-02-03 at 14:40 -0800, Himanshu Madhani wrote:
>> +/* Response code and sense key */
>> +((uint32_t *)ctio->u.status1.sense_data)[0] =
>> +cpu_to_le32((0x70 << 24) | (sense_key << 8));
>> +/* Additional sense length */
>> +((uint32_t *)ctio->u.status1.sense_data)[1] = cpu_to_le32(0x0a);
>> +/* ASC and ASCQ */
>> +((uint32_t *)ctio->u.status1.sense_data)[3] =
>> +cpu_to_le32((asc << 24) | (ascq << 16));
>
>Please use put_unaligned_le32() instead of open-coding it.
>
>>  struct qla_tgt_cmd {
>> @@ -885,11 +895,25 @@ struct qla_tgt_cmd {
>>  struct list_head cmd_list;
>>  
>>  struct atio_from_isp atio;
>> -/* t10dif */
>> +
>> +/* T10-DIF */
>> +#define DIF_ERR_NONE 0
>> +#define DIF_ERR_GRD 1
>> +#define DIF_ERR_REF 2
>> +#define DIF_ERR_APP 3
>> +int8_t dif_err_code;
>>  struct scatterlist *prot_sg;
>>  uint32_t prot_sg_cnt;
>> -uint32_t blk_sz;
>> +uint32_t blk_sz, num_blks;
>> +uint8_t scsi_status, sense_key, asc, ascq;
>> +
>>  struct crc_context *ctx;
>> +uint32_tprot_op;
>> +uint32_tprot_type;
>> +uint8_t *cdb;
>> +uint64_tlba;
>> +uint16_ta_guard, e_guard, a_app_tag, e_app_tag;
>> +uint32_ta_ref_tag, e_ref_tag;
>>  
>>  uint64_t jiffies_at_alloc;
>>  uint64_t jiffies_at_free;
>
>There are already equivalents of prot_op, prot_type, cdb and lba in struct
>se_cmd. I think a few weeks ago Christoph had asked you not to duplicate
>se_cmd fields into struct qla_tgt_cmd?

Thanks for the review comments.  Looks like that was a miss in rebasing with 
latest patch. 

Will fix up patch and resend. 

>
>Bart.
>Western Digital Corporation (and its subsidiaries) E-mail Confidentiality 
>Notice & Disclaimer:
>
>This e-mail and any files transmitted with it may contain confidential or 
>legally privileged information of WDC and/or its affiliates, and are intended 
>solely for the use of the individual or entity to which they are addressed. If 
>you are not the intended recipient, any disclosure, copying, distribution or 
>any action taken or omitted to be taken in reliance on it, is prohibited. If 
>you have received this e-mail in error, please notify the sender immediately 
>and delete the e-mail in its entirety from your system.
>


Re: [RFC 19/19] checkpatch: warn for use of old PCI pool API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:57PM +0100, Romain Perier wrote:
> pci_pool_*() functions should be replaced by the corresponding functions
> in the DMA pool API. This adds support to check for use of these pci
> functions and display a warning when it is the case.

Don't know if relevant, but did not catch the struct. Other than that
works fine.

> 
> Signed-off-by: Romain Perier 
> ---
>  scripts/checkpatch.pl | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 8e96af5..026920e 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -6058,6 +6058,11 @@ sub process {
>   WARN("USE_DEVICE_INITCALL",
>"please use device_initcall() or more appropriate 
> function instead of __initcall() (see include/linux/init.h)\n" . $herecurr);
>   }
> +# check for old PCI api pci_pool_*(), use dma_pool_*() instead
> + if ($line =~ /\bpci_pool_.+\(/) {
> + WARN("USE_PCI_POOL",
> +  "please use the dma pool api or more appropriate 
> function instead of the old pci pool api\n" . $herecurr);
> + }
>  
>  # check for various structs that are normally const (ops, kgdb, device_tree)
>   if ($line !~ /\bconst\b/ &&
> -- 
> 2.9.3
> 


Re: [PATCH v2 03/14] qla2xxx: Allow vref count to timeout on vport delete.

2017-02-08 Thread Madhani, Himanshu

On 2/8/17, 5:03 AM, "Christoph Hellwig"  wrote:

>On Fri, Feb 03, 2017 at 02:40:44PM -0800, Himanshu Madhani wrote:
>> -spin_lock_irqsave(>vport_slock, flags);
>> -while (atomic_read(>vref_count)) {
>> -spin_unlock_irqrestore(>vport_slock, flags);
>> -
>> +while (count-- && atomic_read(>vref_count))
>>  msleep(500);
>
>Please add a wait queue to skeep on while waiting for vref_count to
>drop to zero.  

Thanks for the review. Will update patch and resend series.


Re: [RFC 00/19] Replace PCI pool by DMA pool API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:38PM +0100, Romain Perier wrote:
Hi Romain,

Nice set of patches! Thank you.

I sent a few comments, but basically you missed to run checkpatch.pl on
your patches. Also you can take the chance to fix some white space
issues that are on the lines you are changing like space before , and
trailing white space.

But maybe the part that I missed more is that you can also adrress the
fact that dma_pool_destroy(NULL) is safe and that checking for NULL may
not be needed. So I would fix this NULL test at least on all files that
you are changing, not only around your changes, but on the entire file.

Peter
> The current PCI pool API are simple macro functions direct expanded to
> the appropriated dma pool functions. The prototypes are almost the same
> and semantically, they are very similar. I propose to use the DMA pool
> API directly and get rid of the old API.
> 
> This set of patches, replaces the old API by the dma pool API, adds
> support to warn about this old API in checkpath.pl and remove the
> defines.
> 
> Romain Perier (19):
>   block: DAC960: Replace PCI pool old API
>   dmaengine: pch_dma: Replace PCI pool old API
>   IB/mthca: Replace PCI pool old API
>   net: e100: Replace PCI pool old API
>   mlx4: Replace PCI pool old API
>   mlx5: Replace PCI pool old API
>   wireless: ipw2200: Replace PCI pool old API
>   scsi: be2iscsi: Replace PCI pool old API
>   scsi: csiostor: Replace PCI pool old API
>   scsi: lpfc: Replace PCI pool old API
>   scsi: megaraid: Replace PCI pool old API
>   scsi: mpt3sas: Replace PCI pool old API
>   scsi: mvsas: Replace PCI pool old API
>   scsi: pmcraid: Replace PCI pool old API
>   usb: gadget: amd5536udc: Replace PCI pool old API
>   usb: gadget: net2280: Replace PCI pool old API
>   usb: gadget: pch_udc: Replace PCI pool old API
>   PCI: Remove PCI pool macro functions
>   checkpatch: warn for use of old PCI pool API
> 
>  drivers/block/DAC960.c| 36 +++
>  drivers/block/DAC960.h|  4 +-
>  drivers/dma/pch_dma.c | 12 ++---
>  drivers/infiniband/hw/mthca/mthca_av.c| 10 ++---
>  drivers/infiniband/hw/mthca/mthca_cmd.c   |  8 ++--
>  drivers/infiniband/hw/mthca/mthca_dev.h   |  4 +-
>  drivers/net/ethernet/intel/e100.c | 12 ++---
>  drivers/net/ethernet/mellanox/mlx4/cmd.c  | 10 ++---
>  drivers/net/ethernet/mellanox/mlx4/mlx4.h |  2 +-
>  drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 10 ++---
>  drivers/net/wireless/intel/ipw2x00/ipw2200.c  | 12 ++---
>  drivers/scsi/be2iscsi/be_iscsi.c  |  6 +--
>  drivers/scsi/be2iscsi/be_main.c   |  6 +--
>  drivers/scsi/be2iscsi/be_main.h   |  2 +-
>  drivers/scsi/csiostor/csio_hw.h   |  2 +-
>  drivers/scsi/csiostor/csio_init.c |  4 +-
>  drivers/scsi/csiostor/csio_scsi.c |  6 +--
>  drivers/scsi/lpfc/lpfc.h  | 10 ++---
>  drivers/scsi/lpfc/lpfc_init.c |  6 +--
>  drivers/scsi/lpfc/lpfc_mem.c  | 62 +-
>  drivers/scsi/lpfc/lpfc_scsi.c | 12 ++---
>  drivers/scsi/megaraid/megaraid_mbox.c | 30 ++---
>  drivers/scsi/megaraid/megaraid_mm.c   | 28 ++--
>  drivers/scsi/megaraid/megaraid_sas_base.c | 24 +-
>  drivers/scsi/megaraid/megaraid_sas_fusion.c   | 44 +-
>  drivers/scsi/mpt3sas/mpt3sas_base.c   | 64 
> +--
>  drivers/scsi/mvsas/mv_init.c  |  4 +-
>  drivers/scsi/mvsas/mv_sas.c   |  6 +--
>  drivers/scsi/pmcraid.c| 10 ++---
>  drivers/scsi/pmcraid.h|  2 +-
>  drivers/usb/gadget/udc/amd5536udc.c   |  8 ++--
>  drivers/usb/gadget/udc/amd5536udc.h   |  4 +-
>  drivers/usb/gadget/udc/net2280.c  | 12 ++---
>  drivers/usb/gadget/udc/net2280.h  |  2 +-
>  drivers/usb/gadget/udc/pch_udc.c  | 28 ++--
>  include/linux/mlx5/driver.h   |  2 +-
>  include/linux/pci.h   |  9 
>  scripts/checkpatch.pl |  5 +++
>  38 files changed, 257 insertions(+), 261 deletions(-)
> 
> -- 
> 2.9.3
> 


Re: [PATCH v2 06/14] qla2xxx: Improve T10-DIF/PI handling in driver.

2017-02-08 Thread Bart Van Assche
On Fri, 2017-02-03 at 14:40 -0800, Himanshu Madhani wrote:
> + /* Response code and sense key */
> + ((uint32_t *)ctio->u.status1.sense_data)[0] =
> + cpu_to_le32((0x70 << 24) | (sense_key << 8));
> + /* Additional sense length */
> + ((uint32_t *)ctio->u.status1.sense_data)[1] = cpu_to_le32(0x0a);
> + /* ASC and ASCQ */
> + ((uint32_t *)ctio->u.status1.sense_data)[3] =
> + cpu_to_le32((asc << 24) | (ascq << 16));

Please use put_unaligned_le32() instead of open-coding it.

>  struct qla_tgt_cmd {
> @@ -885,11 +895,25 @@ struct qla_tgt_cmd {
>   struct list_head cmd_list;
>  
>   struct atio_from_isp atio;
> - /* t10dif */
> +
> + /* T10-DIF */
> +#define DIF_ERR_NONE 0
> +#define DIF_ERR_GRD 1
> +#define DIF_ERR_REF 2
> +#define DIF_ERR_APP 3
> + int8_t dif_err_code;
>   struct scatterlist *prot_sg;
>   uint32_t prot_sg_cnt;
> - uint32_t blk_sz;
> + uint32_t blk_sz, num_blks;
> + uint8_t scsi_status, sense_key, asc, ascq;
> +
>   struct crc_context *ctx;
> + uint32_tprot_op;
> + uint32_tprot_type;
> + uint8_t *cdb;
> + uint64_tlba;
> + uint16_ta_guard, e_guard, a_app_tag, e_app_tag;
> + uint32_ta_ref_tag, e_ref_tag;
>  
>   uint64_t jiffies_at_alloc;
>   uint64_t jiffies_at_free;

There are already equivalents of prot_op, prot_type, cdb and lba in struct
se_cmd. I think a few weeks ago Christoph had asked you not to duplicate
se_cmd fields into struct qla_tgt_cmd?

Bart.


Re: [RFC 05/19] mlx4: Replace PCI pool old API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:43PM +0100, Romain Perier wrote:
> The PCI pool API is deprecated. This commits replaces the PCI pool old
> API by the appropriated function with the DMA pool API.

Tested by compilation only.

Acked-by: Peter Senna Tschudin 
Tested-by: Peter Senna Tschudin 
> Signed-off-by: Romain Perier 
> ---
>  drivers/net/ethernet/mellanox/mlx4/cmd.c  | 10 +-
>  drivers/net/ethernet/mellanox/mlx4/mlx4.h |  2 +-
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c 
> b/drivers/net/ethernet/mellanox/mlx4/cmd.c
> index a49072b4..d400cde 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
> @@ -2515,8 +2515,8 @@ int mlx4_cmd_init(struct mlx4_dev *dev)
>   }
>  
>   if (!priv->cmd.pool) {
> - priv->cmd.pool = pci_pool_create("mlx4_cmd",
> -  dev->persist->pdev,
> + priv->cmd.pool = dma_pool_create("mlx4_cmd",
> +  >persist->pdev->dev,
>MLX4_MAILBOX_SIZE,
>MLX4_MAILBOX_SIZE, 0);
>   if (!priv->cmd.pool)
> @@ -2587,7 +2587,7 @@ void mlx4_cmd_cleanup(struct mlx4_dev *dev, int 
> cleanup_mask)
>   struct mlx4_priv *priv = mlx4_priv(dev);
>  
>   if (priv->cmd.pool && (cleanup_mask & MLX4_CMD_CLEANUP_POOL)) {
> - pci_pool_destroy(priv->cmd.pool);
> + dma_pool_destroy(priv->cmd.pool);
>   priv->cmd.pool = NULL;
>   }
>  
> @@ -2679,7 +2679,7 @@ struct mlx4_cmd_mailbox *mlx4_alloc_cmd_mailbox(struct 
> mlx4_dev *dev)
>   if (!mailbox)
>   return ERR_PTR(-ENOMEM);
>  
> - mailbox->buf = pci_pool_zalloc(mlx4_priv(dev)->cmd.pool, GFP_KERNEL,
> + mailbox->buf = dma_pool_zalloc(mlx4_priv(dev)->cmd.pool, GFP_KERNEL,
>  >dma);
>   if (!mailbox->buf) {
>   kfree(mailbox);
> @@ -2696,7 +2696,7 @@ void mlx4_free_cmd_mailbox(struct mlx4_dev *dev,
>   if (!mailbox)
>   return;
>  
> - pci_pool_free(mlx4_priv(dev)->cmd.pool, mailbox->buf, mailbox->dma);
> + dma_pool_free(mlx4_priv(dev)->cmd.pool, mailbox->buf, mailbox->dma);
>   kfree(mailbox);
>  }
>  EXPORT_SYMBOL_GPL(mlx4_free_cmd_mailbox);
> diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h 
> b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
> index b4f1bc5..69c8764 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
> +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
> @@ -628,7 +628,7 @@ struct mlx4_mgm {
>  };
>  
>  struct mlx4_cmd {
> - struct pci_pool*pool;
> + struct dma_pool*pool;
>   void __iomem   *hcr;
>   struct mutexslave_cmd_mutex;
>   struct semaphorepoll_sem;
> -- 
> 2.9.3
> 


Re: [RFC 04/19] net: e100: Replace PCI pool old API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:42PM +0100, Romain Perier wrote:
> The PCI pool API is deprecated. This commits replaces the PCI pool old
> API by the appropriated function with the DMA pool API.

Tested by compilation only.

Acked-by: Peter Senna Tschudin 
Tested-by: Peter Senna Tschudin 
> Signed-off-by: Romain Perier 
> ---
>  drivers/net/ethernet/intel/e100.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/e100.c 
> b/drivers/net/ethernet/intel/e100.c
> index 2b7323d..d1002c2 100644
> --- a/drivers/net/ethernet/intel/e100.c
> +++ b/drivers/net/ethernet/intel/e100.c
> @@ -607,7 +607,7 @@ struct nic {
>   struct mem *mem;
>   dma_addr_t dma_addr;
>  
> - struct pci_pool *cbs_pool;
> + struct dma_pool *cbs_pool;
>   dma_addr_t cbs_dma_addr;
>   u8 adaptive_ifs;
>   u8 tx_threshold;
> @@ -1892,7 +1892,7 @@ static void e100_clean_cbs(struct nic *nic)
>   nic->cb_to_clean = nic->cb_to_clean->next;
>   nic->cbs_avail++;
>   }
> - pci_pool_free(nic->cbs_pool, nic->cbs, nic->cbs_dma_addr);
> + dma_pool_free(nic->cbs_pool, nic->cbs, nic->cbs_dma_addr);
>   nic->cbs = NULL;
>   nic->cbs_avail = 0;
>   }
> @@ -1910,7 +1910,7 @@ static int e100_alloc_cbs(struct nic *nic)
>   nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = NULL;
>   nic->cbs_avail = 0;
>  
> - nic->cbs = pci_pool_alloc(nic->cbs_pool, GFP_KERNEL,
> + nic->cbs = dma_pool_alloc(nic->cbs_pool, GFP_KERNEL,
> >cbs_dma_addr);
>   if (!nic->cbs)
>   return -ENOMEM;
> @@ -2958,8 +2958,8 @@ static int e100_probe(struct pci_dev *pdev, const 
> struct pci_device_id *ent)
>   netif_err(nic, probe, nic->netdev, "Cannot register net device, 
> aborting\n");
>   goto err_out_free;
>   }
> - nic->cbs_pool = pci_pool_create(netdev->name,
> -nic->pdev,
> + nic->cbs_pool = dma_pool_create(netdev->name,
> +>pdev->dev,
>  nic->params.cbs.max * sizeof(struct cb),
>  sizeof(u32),
>  0);
> @@ -2999,7 +2999,7 @@ static void e100_remove(struct pci_dev *pdev)
>   unregister_netdev(netdev);
>   e100_free(nic);
>   pci_iounmap(pdev, nic->csr);
> - pci_pool_destroy(nic->cbs_pool);
> + dma_pool_destroy(nic->cbs_pool);
>   free_netdev(netdev);
>   pci_release_regions(pdev);
>   pci_disable_device(pdev);
> -- 
> 2.9.3
> 


Re: [RFC 15/19] usb: gadget: amd5536udc: Replace PCI pool old API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:53PM +0100, Romain Perier wrote:
> The PCI pool API is deprecated. This commits replaces the PCI pool old
> API by the appropriated function with the DMA pool API.
> 
Tested by compilation only.

Acked-by: Peter Senna Tschudin 
Tested-by: Peter Senna Tschudin 
> Signed-off-by: Romain Perier 
> ---
>  drivers/usb/gadget/udc/amd5536udc.c | 8 
>  drivers/usb/gadget/udc/amd5536udc.h | 4 ++--
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/amd5536udc.c 
> b/drivers/usb/gadget/udc/amd5536udc.c
> index ea03ca7..270876b 100644
> --- a/drivers/usb/gadget/udc/amd5536udc.c
> +++ b/drivers/usb/gadget/udc/amd5536udc.c
> @@ -583,7 +583,7 @@ udc_alloc_request(struct usb_ep *usbep, gfp_t gfp)
>  
>   if (ep->dma) {
>   /* ep0 in requests are allocated from data pool here */
> - dma_desc = pci_pool_alloc(ep->dev->data_requests, gfp,
> + dma_desc = dma_pool_alloc(ep->dev->data_requests, gfp,
>   >td_phys);
>   if (!dma_desc) {
>   kfree(req);
> @@ -622,7 +622,7 @@ static int udc_free_dma_chain(struct udc *dev, struct 
> udc_request *req)
>   td = phys_to_virt(td_last->next);
>  
>   for (i = 1; i < req->chain_len; i++) {
> - pci_pool_free(dev->data_requests, td,
> + dma_pool_free(dev->data_requests, td,
> (dma_addr_t)td_last->next);
>   td_last = td;
>   td = phys_to_virt(td_last->next);
> @@ -652,7 +652,7 @@ udc_free_request(struct usb_ep *usbep, struct usb_request 
> *usbreq)
>   if (req->chain_len > 1)
>   udc_free_dma_chain(ep->dev, req);
>  
> - pci_pool_free(ep->dev->data_requests, req->td_data,
> + dma_pool_free(ep->dev->data_requests, req->td_data,
>   req->td_phys);
>   }
>   kfree(req);
> @@ -847,7 +847,7 @@ static int udc_create_dma_chain(
>   for (i = buf_len; i < bytes; i += buf_len) {
>   /* create or determine next desc. */
>   if (create_new_chain) {
> - td = pci_pool_alloc(ep->dev->data_requests,
> + td = dma_pool_alloc(ep->dev->data_requests,
>   gfp_flags, _addr);
>   if (!td)
>   return -ENOMEM;
> diff --git a/drivers/usb/gadget/udc/amd5536udc.h 
> b/drivers/usb/gadget/udc/amd5536udc.h
> index 4638d70..85d5aa5 100644
> --- a/drivers/usb/gadget/udc/amd5536udc.h
> +++ b/drivers/usb/gadget/udc/amd5536udc.h
> @@ -545,8 +545,8 @@ struct udc {
>   u32 __iomem *txfifo;
>  
>   /* DMA desc pools */
> - struct pci_pool *data_requests;
> - struct pci_pool *stp_requests;
> + struct dma_pool *data_requests;
> + struct dma_pool *stp_requests;
>  
>   /* device data */
>   unsigned long   phys_addr;
> -- 
> 2.9.3
> 


Re: [RFC 17/19] usb: gadget: pch_udc: Replace PCI pool old API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:55PM +0100, Romain Perier wrote:
> The PCI pool API is deprecated. This commits replaces the PCI pool old
> API by the appropriated function with the DMA pool API.
> 
> Signed-off-by: Romain Perier 
> ---
>  drivers/usb/gadget/udc/pch_udc.c | 28 ++--
>  1 file changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/pch_udc.c 
> b/drivers/usb/gadget/udc/pch_udc.c
> index a97da64..37045fc 100644
> --- a/drivers/usb/gadget/udc/pch_udc.c
> +++ b/drivers/usb/gadget/udc/pch_udc.c
> @@ -355,8 +355,8 @@ struct pch_udc_dev {
>   vbus_session:1,
>   set_cfg_not_acked:1,
>   waiting_zlp_ack:1;
> - struct pci_pool *data_requests;
> - struct pci_pool *stp_requests;
> + struct dma_pool *data_requests;
> + struct dma_pool *stp_requests;
>   dma_addr_t  dma_addr;
>   struct usb_ctrlrequest  setup_data;
>   void __iomem*base_addr;
> @@ -1522,7 +1522,7 @@ static void pch_udc_free_dma_chain(struct pch_udc_dev 
> *dev,
>   /* do not free first desc., will be done by free for request */
>   td = phys_to_virt(addr);
>   addr2 = (dma_addr_t)td->next;
> - pci_pool_free(dev->data_requests, td, addr);
> + dma_pool_free(dev->data_requests, td, addr);
>   td->next = 0x00;
>   addr = addr2;
>   }
> @@ -1565,7 +1565,7 @@ static int pch_udc_create_dma_chain(struct pch_udc_ep 
> *ep,
>   if (bytes <= buf_len)
>   break;
>   last = td;
> - td = pci_pool_alloc(ep->dev->data_requests, gfp_flags,
> + td = dma_pool_alloc(ep->dev->data_requests, gfp_flags,
>   _addr);
>   if (!td)
>   goto nomem;
> @@ -1770,7 +1770,7 @@ static struct usb_request *pch_udc_alloc_request(struct 
> usb_ep *usbep,
>   if (!ep->dev->dma_addr)
>   return >req;
>   /* ep0 in requests are allocated from data pool here */
> - dma_desc = pci_pool_alloc(ep->dev->data_requests, gfp,
> + dma_desc = dma_pool_alloc(ep->dev->data_requests, gfp,
> >td_data_phys);
>   if (NULL == dma_desc) {
>   kfree(req);
> @@ -1809,7 +1809,7 @@ static void pch_udc_free_request(struct usb_ep *usbep,
>   if (req->td_data != NULL) {
>   if (req->chain_len > 1)
>   pch_udc_free_dma_chain(ep->dev, req);
> - pci_pool_free(ep->dev->data_requests, req->td_data,
> + dma_pool_free(ep->dev->data_requests, req->td_data,
> req->td_data_phys);
>   }
>   kfree(req);
> @@ -2914,7 +2914,7 @@ static int init_dma_pools(struct pch_udc_dev *dev)
>   void*ep0out_buf;
>  
>   /* DMA setup */
> - dev->data_requests = pci_pool_create("data_requests", dev->pdev,
> + dev->data_requests = dma_pool_create("data_requests", >pdev->dev,
>   sizeof(struct pch_udc_data_dma_desc), 0, 0);
>   if (!dev->data_requests) {
>   dev_err(>pdev->dev, "%s: can't get request data pool\n",
> @@ -2923,7 +2923,7 @@ static int init_dma_pools(struct pch_udc_dev *dev)
>   }
>  
>   /* dma desc for setup data */
> - dev->stp_requests = pci_pool_create("setup requests", dev->pdev,
> + dev->stp_requests = dma_pool_create("setup requests", >pdev->dev,
>   sizeof(struct pch_udc_stp_dma_desc), 0, 0);
>   if (!dev->stp_requests) {
>   dev_err(>pdev->dev, "%s: can't get setup request pool\n",
> @@ -2931,7 +2931,7 @@ static int init_dma_pools(struct pch_udc_dev *dev)
>   return -ENOMEM;
>   }
>   /* setup */
> - td_stp = pci_pool_alloc(dev->stp_requests, GFP_KERNEL,
> + td_stp = dma_pool_alloc(dev->stp_requests, GFP_KERNEL,
>   >ep[UDC_EP0OUT_IDX].td_stp_phys);
>   if (!td_stp) {
>   dev_err(>pdev->dev,
> @@ -2941,7 +2941,7 @@ static int init_dma_pools(struct pch_udc_dev *dev)
>   dev->ep[UDC_EP0OUT_IDX].td_stp = td_stp;
>  
>   /* data: 0 packets !? */
> - td_data = pci_pool_alloc(dev->data_requests, GFP_KERNEL,
> + td_data = dma_pool_alloc(dev->data_requests, GFP_KERNEL,
>   >ep[UDC_EP0OUT_IDX].td_data_phys);
>   if (!td_data) {
>   dev_err(>pdev->dev,
> @@ -3022,21 +3022,21 @@ static void pch_udc_remove(struct pci_dev *pdev)
>   "%s: gadget driver still bound!!!\n", __func__);
>   /* dma pool cleanup */
>   if (dev->data_requests)
dma_pool_destroy(NULL) is safe and this check is probably not required.
Other than that looks good. Tested by compiling it.

> - pci_pool_destroy(dev->data_requests);
> +   

Re: [RFC 02/19] dmaengine: pch_dma: Replace PCI pool old API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:40PM +0100, Romain Perier wrote:
> The PCI pool API is deprecated. This commits replaces the PCI pool old
> API by the appropriated function with the DMA pool API.
> 

Tested by compilation only.

Acked-by: Peter Senna Tschudin 
Tested-by: Peter Senna Tschudin 
> Signed-off-by: Romain Perier 
> ---
>  drivers/dma/pch_dma.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/dma/pch_dma.c b/drivers/dma/pch_dma.c
> index f9028e9..afd8f27 100644
> --- a/drivers/dma/pch_dma.c
> +++ b/drivers/dma/pch_dma.c
> @@ -123,7 +123,7 @@ struct pch_dma_chan {
>  struct pch_dma {
>   struct dma_device   dma;
>   void __iomem *membase;
> - struct pci_pool *pool;
> + struct dma_pool *pool;
>   struct pch_dma_regs regs;
>   struct pch_dma_desc_regs ch_regs[MAX_CHAN_NR];
>   struct pch_dma_chan channels[MAX_CHAN_NR];
> @@ -437,7 +437,7 @@ static struct pch_dma_desc *pdc_alloc_desc(struct 
> dma_chan *chan, gfp_t flags)
>   struct pch_dma *pd = to_pd(chan->device);
>   dma_addr_t addr;
>  
> - desc = pci_pool_zalloc(pd->pool, flags, );
> + desc = dma_pool_zalloc(pd->pool, flags, );
>   if (desc) {
>   INIT_LIST_HEAD(>tx_list);
>   dma_async_tx_descriptor_init(>txd, chan);
> @@ -549,7 +549,7 @@ static void pd_free_chan_resources(struct dma_chan *chan)
>   spin_unlock_irq(_chan->lock);
>  
>   list_for_each_entry_safe(desc, _d, _list, desc_node)
> - pci_pool_free(pd->pool, desc, desc->txd.phys);
> + dma_pool_free(pd->pool, desc, desc->txd.phys);
>  
>   pdc_enable_irq(chan, 0);
>  }
> @@ -880,7 +880,7 @@ static int pch_dma_probe(struct pci_dev *pdev,
>   goto err_iounmap;
>   }
>  
> - pd->pool = pci_pool_create("pch_dma_desc_pool", pdev,
> + pd->pool = dma_pool_create("pch_dma_desc_pool", >dev,
>  sizeof(struct pch_dma_desc), 4, 0);
>   if (!pd->pool) {
>   dev_err(>dev, "Failed to alloc DMA descriptors\n");
> @@ -931,7 +931,7 @@ static int pch_dma_probe(struct pci_dev *pdev,
>   return 0;
>  
>  err_free_pool:
> - pci_pool_destroy(pd->pool);
> + dma_pool_destroy(pd->pool);
>  err_free_irq:
>   free_irq(pdev->irq, pd);
>  err_iounmap:
> @@ -963,7 +963,7 @@ static void pch_dma_remove(struct pci_dev *pdev)
>   tasklet_kill(_chan->tasklet);
>   }
>  
> - pci_pool_destroy(pd->pool);
> + dma_pool_destroy(pd->pool);
>   pci_iounmap(pdev, pd->membase);
>   pci_release_regions(pdev);
>   pci_disable_device(pdev);
> -- 
> 2.9.3
> 


Re: [RFC 18/19] PCI: Remove PCI pool macro functions

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:56PM +0100, Romain Perier wrote:
> Now that all the drivers use dma pool API, we can remove the macro
> functions for PCI pool.

Good news: make allyesconfig;make succeed after the changes until this
point, but:

$ grep -R pci_pool
...
drivers/usb/gadget/udc/pch_udc.c: * -ENOMEM:pci_pool_alloc
invocation fails
drivers/usb/host/oxu210hp-hcd.c: * pci_pool consistent memory
always uses segment zero.
drivers/usb/host/fotg210-hcd.c:  * pci_pool consistent memory always
uses segment zero.
drivers/usb/host/ehci-hcd.c: * pci_pool consistent memory always
uses segment zero.
drivers/scsi/lpfc/lpfc_mem.c: * Allocates from generic pci_pool_alloc
function first and if that fails and
drivers/scsi/csiostor/csio_init.c:  hw->scsi_pci_pool =
dma_pool_create("csio_scsi_pci_pool", >pdev->dev,
drivers/scsi/csiostor/csio_init.c:  if (!hw->scsi_pci_pool)
drivers/scsi/csiostor/csio_init.c:
dma_pool_destroy(hw->scsi_pci_pool);
drivers/scsi/csiostor/csio_init.c:  hw->scsi_pci_pool = NULL;
drivers/scsi/csiostor/csio_scsi.c:  dma_buf->vaddr =
dma_pool_alloc(hw->scsi_pci_pool, GFP_KERNEL,
drivers/scsi/csiostor/csio_scsi.c:
dma_pool_free(hw->scsi_pci_pool, dma_buf->vaddr,
drivers/scsi/csiostor/csio_scsi.c:
dma_pool_free(scm->hw->scsi_pci_pool, dma_buf->vaddr,
drivers/scsi/csiostor/csio_hw.h:struct dma_pool
*scsi_pci_pool; /* PCI pool for SCSI */

this can be updated or removed, needs to check:
scripts/coccinelle/api/alloc/pool_zalloc-simple.cocci

> 
> Signed-off-by: Romain Perier 
> ---
>  include/linux/pci.h | 9 -
>  1 file changed, 9 deletions(-)
> 
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 11d15d4..c3a93e4 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1284,15 +1284,6 @@ int pci_set_vga_state(struct pci_dev *pdev, bool 
> decode,
>  #include 
>  #include 
>  
> -#define  pci_pool dma_pool
> -#define pci_pool_create(name, pdev, size, align, allocation) \
> - dma_pool_create(name, >dev, size, align, allocation)
> -#define  pci_pool_destroy(pool) dma_pool_destroy(pool)
> -#define  pci_pool_alloc(pool, flags, handle) dma_pool_alloc(pool, flags, 
> handle)
> -#define  pci_pool_zalloc(pool, flags, handle) \
> - dma_pool_zalloc(pool, flags, handle)
> -#define  pci_pool_free(pool, vaddr, addr) dma_pool_free(pool, vaddr, 
> addr)
> -
>  struct msix_entry {
>   u32 vector; /* kernel uses to write allocated vector */
>   u16 entry;  /* driver uses to specify entry, OS writes */
> -- 
> 2.9.3
> 


Re: [PATCH v2 02/14] qla2xxx: Allow relogin to proceed if remote login did not finish

2017-02-08 Thread Bart Van Assche
On Fri, 2017-02-03 at 14:40 -0800, Himanshu Madhani wrote:
> + if (fcport->fw_login_state == DSC_LS_PLOGI_COMP) {
> + unsigned long t = fcport->plogi_nack_done_jiff + HZ;
> +
> + if (time_before_eq(jiffies, t))
> + return;
> + }

The above code occurs two times in this patch. We try to avoid duplicating
code in the Linux kernel, especially code that contains hardcoded constants.
Have you considered to change the name of plogi_nack_done_jiff into e.g.
plogi_done_deadline and to assign jiffies + HZ to that variable instead of
jiffies?

Bart.


Re: [RFC 16/19] usb: gadget: net2280: Replace PCI pool old API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:54PM +0100, Romain Perier wrote:
> The PCI pool API is deprecated. This commits replaces the PCI pool old
> API by the appropriated function with the DMA pool API.
> 
Tested by compilation only.

Acked-by: Peter Senna Tschudin 
Tested-by: Peter Senna Tschudin 
> Signed-off-by: Romain Perier 
> ---
>  drivers/usb/gadget/udc/net2280.c | 12 ++--
>  drivers/usb/gadget/udc/net2280.h |  2 +-
>  2 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/net2280.c 
> b/drivers/usb/gadget/udc/net2280.c
> index 8550441..089081e 100644
> --- a/drivers/usb/gadget/udc/net2280.c
> +++ b/drivers/usb/gadget/udc/net2280.c
> @@ -569,7 +569,7 @@ static struct usb_request
>   if (ep->dma) {
>   struct net2280_dma  *td;
>  
> - td = pci_pool_alloc(ep->dev->requests, gfp_flags,
> + td = dma_pool_alloc(ep->dev->requests, gfp_flags,
>   >td_dma);
>   if (!td) {
>   kfree(req);
> @@ -597,7 +597,7 @@ static void net2280_free_request(struct usb_ep *_ep, 
> struct usb_request *_req)
>   req = container_of(_req, struct net2280_request, req);
>   WARN_ON(!list_empty(>queue));
>   if (req->td)
> - pci_pool_free(ep->dev->requests, req->td, req->td_dma);
> + dma_pool_free(ep->dev->requests, req->td, req->td_dma);
>   kfree(req);
>  }
>  
> @@ -3578,10 +3578,10 @@ static void net2280_remove(struct pci_dev *pdev)
>   for (i = 1; i < 5; i++) {
>   if (!dev->ep[i].dummy)
>   continue;
> - pci_pool_free(dev->requests, dev->ep[i].dummy,
> + dma_pool_free(dev->requests, dev->ep[i].dummy,
>   dev->ep[i].td_dma);
>   }
> - pci_pool_destroy(dev->requests);
> + dma_pool_destroy(dev->requests);
>   }
>   if (dev->got_irq)
>   free_irq(pdev->irq, dev);
> @@ -3723,7 +3723,7 @@ static int net2280_probe(struct pci_dev *pdev, const 
> struct pci_device_id *id)
>  
>   /* DMA setup */
>   /* NOTE:  we know only the 32 LSBs of dma addresses may be nonzero */
> - dev->requests = pci_pool_create("requests", pdev,
> + dev->requests = dma_pool_create("requests", >dev,
>   sizeof(struct net2280_dma),
>   0 /* no alignment requirements */,
>   0 /* or page-crossing issues */);
> @@ -3735,7 +3735,7 @@ static int net2280_probe(struct pci_dev *pdev, const 
> struct pci_device_id *id)
>   for (i = 1; i < 5; i++) {
>   struct net2280_dma  *td;
>  
> - td = pci_pool_alloc(dev->requests, GFP_KERNEL,
> + td = dma_pool_alloc(dev->requests, GFP_KERNEL,
>   >ep[i].td_dma);
>   if (!td) {
>   ep_dbg(dev, "can't get dummy %d\n", i);
> diff --git a/drivers/usb/gadget/udc/net2280.h 
> b/drivers/usb/gadget/udc/net2280.h
> index 2736a95..1088c37 100644
> --- a/drivers/usb/gadget/udc/net2280.h
> +++ b/drivers/usb/gadget/udc/net2280.h
> @@ -187,7 +187,7 @@ struct net2280 {
>   struct usb338x_ll_chi_regs  __iomem *ll_chicken_reg;
>   struct usb338x_pl_regs  __iomem *plregs;
>  
> - struct pci_pool *requests;
> + struct dma_pool *requests;
>   /* statistics...*/
>  };
>  
> -- 
> 2.9.3
> 


Re: [RFC 13/19] scsi: mvsas: Replace PCI pool old API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:51PM +0100, Romain Perier wrote:
> The PCI pool API is deprecated. This commits replaces the PCI pool old
> API by the appropriated function with the DMA pool API.
> 
> Signed-off-by: Romain Perier 
> ---
>  drivers/scsi/mvsas/mv_init.c | 4 ++--
>  drivers/scsi/mvsas/mv_sas.c  | 6 +++---
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
> index 8280046..451ba93 100644
> --- a/drivers/scsi/mvsas/mv_init.c
> +++ b/drivers/scsi/mvsas/mv_init.c
> @@ -126,7 +126,7 @@ static void mvs_free(struct mvs_info *mvi)
>   slot_nr = MVS_CHIP_SLOT_SZ;
>  
>   if (mvi->dma_pool)
dma_pool_destroy(NULL) is safe and this check is probably not required

> - pci_pool_destroy(mvi->dma_pool);
> + dma_pool_destroy(mvi->dma_pool);
>  
>   if (mvi->tx)
>   dma_free_coherent(mvi->dev,
> @@ -296,7 +296,7 @@ static int mvs_alloc(struct mvs_info *mvi, struct 
> Scsi_Host *shost)
>   goto err_out;
>  
>   sprintf(pool_name, "%s%d", "mvs_dma_pool", mvi->id);
> - mvi->dma_pool = pci_pool_create(pool_name, mvi->pdev, MVS_SLOT_BUF_SZ, 
> 16, 0);
> + mvi->dma_pool = dma_pool_create(pool_name, >pdev->dev, 
> MVS_SLOT_BUF_SZ, 16, 0);
line over 80.

>   if (!mvi->dma_pool) {
>   printk(KERN_DEBUG "failed to create dma pool %s.\n", 
> pool_name);
>   goto err_out;
> diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
> index c7cc803..ee81d10 100644
> --- a/drivers/scsi/mvsas/mv_sas.c
> +++ b/drivers/scsi/mvsas/mv_sas.c
> @@ -790,7 +790,7 @@ static int mvs_task_prep(struct sas_task *task, struct 
> mvs_info *mvi, int is_tmf
>   slot->n_elem = n_elem;
>   slot->slot_tag = tag;
>  
> - slot->buf = pci_pool_alloc(mvi->dma_pool, GFP_ATOMIC, >buf_dma);
> + slot->buf = dma_pool_alloc(mvi->dma_pool, GFP_ATOMIC, >buf_dma);
>   if (!slot->buf) {
>   rc = -ENOMEM;
>   goto err_out_tag;
> @@ -840,7 +840,7 @@ static int mvs_task_prep(struct sas_task *task, struct 
> mvs_info *mvi, int is_tmf
>   return rc;
>  
>  err_out_slot_buf:
> - pci_pool_free(mvi->dma_pool, slot->buf, slot->buf_dma);
> + dma_pool_free(mvi->dma_pool, slot->buf, slot->buf_dma);
>  err_out_tag:
>   mvs_tag_free(mvi, tag);
>  err_out:
> @@ -918,7 +918,7 @@ static void mvs_slot_task_free(struct mvs_info *mvi, 
> struct sas_task *task,
>   }
>  
>   if (slot->buf) {
> - pci_pool_free(mvi->dma_pool, slot->buf, slot->buf_dma);
> + dma_pool_free(mvi->dma_pool, slot->buf, slot->buf_dma);
>   slot->buf = NULL;
>   }
>   list_del_init(>entry);
> -- 
> 2.9.3
> 


Re: [RFC 12/19] scsi: mpt3sas: Replace PCI pool old API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:50PM +0100, Romain Perier wrote:
> The PCI pool API is deprecated. This commits replaces the PCI pool old
> API by the appropriated function with the DMA pool API.
> 
> Signed-off-by: Romain Perier 
> ---
>  drivers/scsi/mpt3sas/mpt3sas_base.c | 64 
> ++---
>  1 file changed, 32 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
> b/drivers/scsi/mpt3sas/mpt3sas_base.c
> index a3fe1fb..092bf31 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
> @@ -3210,9 +3210,9 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc)
>   }
>  
>   if (ioc->sense) {
> - pci_pool_free(ioc->sense_dma_pool, ioc->sense, ioc->sense_dma);
> + dma_pool_free(ioc->sense_dma_pool, ioc->sense, ioc->sense_dma);
>   if (ioc->sense_dma_pool)
dma_pool_destroy(NULL) is safe and this check is probably not required

> - pci_pool_destroy(ioc->sense_dma_pool);
> + dma_pool_destroy(ioc->sense_dma_pool);
>   dexitprintk(ioc, pr_info(MPT3SAS_FMT
>   "sense_pool(0x%p): free\n",
>   ioc->name, ioc->sense));
> @@ -3220,9 +3220,9 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc)
>   }
>  
>   if (ioc->reply) {
> - pci_pool_free(ioc->reply_dma_pool, ioc->reply, ioc->reply_dma);
> + dma_pool_free(ioc->reply_dma_pool, ioc->reply, ioc->reply_dma);
>   if (ioc->reply_dma_pool)
dma_pool_destroy(NULL) is safe and this check is probably not required

> - pci_pool_destroy(ioc->reply_dma_pool);
> + dma_pool_destroy(ioc->reply_dma_pool);
>   dexitprintk(ioc, pr_info(MPT3SAS_FMT
>   "reply_pool(0x%p): free\n",
>   ioc->name, ioc->reply));
> @@ -3230,10 +3230,10 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER 
> *ioc)
>   }
>  
>   if (ioc->reply_free) {
> - pci_pool_free(ioc->reply_free_dma_pool, ioc->reply_free,
> + dma_pool_free(ioc->reply_free_dma_pool, ioc->reply_free,
>   ioc->reply_free_dma);
>   if (ioc->reply_free_dma_pool)
dma_pool_destroy(NULL) is safe and this check is probably not required

> - pci_pool_destroy(ioc->reply_free_dma_pool);
> + dma_pool_destroy(ioc->reply_free_dma_pool);
>   dexitprintk(ioc, pr_info(MPT3SAS_FMT
>   "reply_free_pool(0x%p): free\n",
>   ioc->name, ioc->reply_free));
> @@ -3244,7 +3244,7 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc)
>   do {
>   rps = >reply_post[i];
>   if (rps->reply_post_free) {
> - pci_pool_free(
> + dma_pool_free(
>   ioc->reply_post_free_dma_pool,
>   rps->reply_post_free,
>   rps->reply_post_free_dma);
> @@ -3257,7 +3257,7 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc)
>  (++i < ioc->reply_queue_count));
>  
>   if (ioc->reply_post_free_dma_pool)
dma_pool_destroy(NULL) is safe and this check is probably not required

> - pci_pool_destroy(ioc->reply_post_free_dma_pool);
> + dma_pool_destroy(ioc->reply_post_free_dma_pool);
>   kfree(ioc->reply_post);
>   }
>  
> @@ -3278,12 +3278,12 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER 
> *ioc)
>   if (ioc->chain_lookup) {
>   for (i = 0; i < ioc->chain_depth; i++) {
>   if (ioc->chain_lookup[i].chain_buffer)
> - pci_pool_free(ioc->chain_dma_pool,
> + dma_pool_free(ioc->chain_dma_pool,
>   ioc->chain_lookup[i].chain_buffer,
>   ioc->chain_lookup[i].chain_buffer_dma);
>   }
>   if (ioc->chain_dma_pool)
dma_pool_destroy(NULL) is safe and this check is probably not required

> - pci_pool_destroy(ioc->chain_dma_pool);
> + dma_pool_destroy(ioc->chain_dma_pool);
>   free_pages((ulong)ioc->chain_lookup, ioc->chain_pages);
>   ioc->chain_lookup = NULL;
>   }
> @@ -3458,23 +3458,23 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER 
> *ioc)
>   ioc->name);
>   goto out;
>   }
> - ioc->reply_post_free_dma_pool = pci_pool_create("reply_post_free pool",
> - ioc->pdev, sz, 16, 0);
> + ioc->reply_post_free_dma_pool = dma_pool_create("reply_post_free pool",
> + >pdev->dev, sz, 16, 0);
>   if (!ioc->reply_post_free_dma_pool) {
>   

Re: [PATCH v2 01/14] qla2xxx: Fix delayed response to command for loop mode/direct connect.

2017-02-08 Thread Bart Van Assche
On Fri, 2017-02-03 at 14:40 -0800, Himanshu Madhani wrote:
> +static void qla2x00_iocb_work_fn(struct work_struct *work)
> +{
> + struct scsi_qla_host *vha = container_of(work,
> + struct scsi_qla_host, iocb_work);
> + unsigned long flags;
> + int cnt = 0;
> +
> + while (!list_empty(>work_list)) {
> + qla2x00_do_work(vha);
> + cnt++;
> + if (cnt > 10)
> + break;
> + }
> +
> + spin_lock_irqsave(>work_lock, flags);
> + vha->flags.iocb_work_sheduled = 0;
> + spin_unlock_irqrestore(>work_lock, flags);
> +}
> +
> +void qla2x00_schedule_work(struct scsi_qla_host *vha)
> +{
> + unsigned long flags;
> +
> + spin_lock_irqsave(>work_lock, flags);
> + if (vha->flags.iocb_work_sheduled) {
> + spin_unlock_irqrestore(>work_lock, flags);
> + return;
> + }
> + vha->flags.iocb_work_sheduled = 1;
> + spin_unlock_irqrestore(>work_lock, flags);
> +
> + /*
> +  * We're in the middle of bringing up the adapter.
> +  * the scheduled work need to go out now.
> +  */
> + INIT_WORK(>iocb_work, qla2x00_iocb_work_fn);
> + schedule_work(>iocb_work);
> +}

Please move the INIT_WORK() call to an initialization function such that
is executed once instead of during every qla2x00_schedule_work() call. Please
also remove the iocb_work_sheduled variable and all code that tests and sets
it. schedule_work() already checks whether or not a work item has been
scheduled.

> @@ -4564,7 +4568,8 @@ static int qlt_24xx_handle_els(struct scsi_qla_host 
> *vha,
>   }
>  
>   if (sess != NULL) {
> - if (sess->fw_login_state == DSC_LS_PLOGI_PEND) {
> + if ((sess->fw_login_state != DSC_LS_PLOGI_PEND) &&
> + (sess->fw_login_state != DSC_LS_PLOGI_COMP)) {

The != operator has a higher precedence than the && operator so the parentheses
around the inequality test are not needed.

Bart.


Re: [RFC 01/19] block: DAC960: Replace PCI pool old API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:39PM +0100, Romain Perier wrote:
> The PCI pool API is deprecated. This commits replaces the PCI pool old
> API by the appropriated function with the DMA pool API.
> 
> Signed-off-by: Romain Perier 

Tested by compilation only. Some whitespace errors, but the patch do not
add new ones.

Acked-by: Peter Senna Tschudin 
Tested-by: Peter Senna Tschudin 
> ---
>  drivers/block/DAC960.c | 36 ++--
>  drivers/block/DAC960.h |  4 ++--
>  2 files changed, 20 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
> index 26a51be..2b221cc 100644
> --- a/drivers/block/DAC960.c
> +++ b/drivers/block/DAC960.c
> @@ -268,17 +268,17 @@ static bool 
> DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
>void *AllocationPointer = NULL;
>void *ScatterGatherCPU = NULL;
>dma_addr_t ScatterGatherDMA;
> -  struct pci_pool *ScatterGatherPool;
> +  struct dma_pool *ScatterGatherPool;
>void *RequestSenseCPU = NULL;
>dma_addr_t RequestSenseDMA;
> -  struct pci_pool *RequestSensePool = NULL;
> +  struct dma_pool *RequestSensePool = NULL;
>  
>if (Controller->FirmwareType == DAC960_V1_Controller)
>  {
>CommandAllocationLength = offsetof(DAC960_Command_T, V1.EndMarker);
>CommandAllocationGroupSize = DAC960_V1_CommandAllocationGroupSize;
> -  ScatterGatherPool = pci_pool_create("DAC960_V1_ScatterGather",
> - Controller->PCIDevice,
> +  ScatterGatherPool = dma_pool_create("DAC960_V1_ScatterGather",
> + >PCIDevice->dev,
>   DAC960_V1_ScatterGatherLimit * sizeof(DAC960_V1_ScatterGatherSegment_T),
>   sizeof(DAC960_V1_ScatterGatherSegment_T), 0);
>if (ScatterGatherPool == NULL)
> @@ -290,18 +290,18 @@ static bool 
> DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
>  {
>CommandAllocationLength = offsetof(DAC960_Command_T, V2.EndMarker);
>CommandAllocationGroupSize = DAC960_V2_CommandAllocationGroupSize;
> -  ScatterGatherPool = pci_pool_create("DAC960_V2_ScatterGather",
> - Controller->PCIDevice,
> +  ScatterGatherPool = dma_pool_create("DAC960_V2_ScatterGather",
> + >PCIDevice->dev,
>   DAC960_V2_ScatterGatherLimit * sizeof(DAC960_V2_ScatterGatherSegment_T),
>   sizeof(DAC960_V2_ScatterGatherSegment_T), 0);
>if (ScatterGatherPool == NULL)
>   return DAC960_Failure(Controller,
>   "AUXILIARY STRUCTURE CREATION (SG)");
> -  RequestSensePool = pci_pool_create("DAC960_V2_RequestSense",
> - Controller->PCIDevice, sizeof(DAC960_SCSI_RequestSense_T),
> +  RequestSensePool = dma_pool_create("DAC960_V2_RequestSense",
> + >PCIDevice->dev, sizeof(DAC960_SCSI_RequestSense_T),
>   sizeof(int), 0);
>if (RequestSensePool == NULL) {
> - pci_pool_destroy(ScatterGatherPool);
> + dma_pool_destroy(ScatterGatherPool);
>   return DAC960_Failure(Controller,
>   "AUXILIARY STRUCTURE CREATION (SG)");
>}
> @@ -335,16 +335,16 @@ static bool 
> DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
>Command->Next = Controller->FreeCommands;
>Controller->FreeCommands = Command;
>Controller->Commands[CommandIdentifier-1] = Command;
> -  ScatterGatherCPU = pci_pool_alloc(ScatterGatherPool, GFP_ATOMIC,
> +  ScatterGatherCPU = dma_pool_alloc(ScatterGatherPool, GFP_ATOMIC,
>   );
>if (ScatterGatherCPU == NULL)
> return DAC960_Failure(Controller, "AUXILIARY STRUCTURE CREATION");
>  
>if (RequestSensePool != NULL) {
> -   RequestSenseCPU = pci_pool_alloc(RequestSensePool, GFP_ATOMIC,
> +   RequestSenseCPU = dma_pool_alloc(RequestSensePool, GFP_ATOMIC,
>   );
> if (RequestSenseCPU == NULL) {
> -pci_pool_free(ScatterGatherPool, ScatterGatherCPU,
> +dma_pool_free(ScatterGatherPool, ScatterGatherCPU,
>  ScatterGatherDMA);
>   return DAC960_Failure(Controller,
>   "AUXILIARY STRUCTURE CREATION");
> @@ -379,8 +379,8 @@ static bool 
> DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
>  static void DAC960_DestroyAuxiliaryStructures(DAC960_Controller_T 
> *Controller)
>  {
>int i;
> -  struct pci_pool *ScatterGatherPool = Controller->ScatterGatherPool;
> -  struct pci_pool *RequestSensePool = NULL;
> +  struct dma_pool *ScatterGatherPool = Controller->ScatterGatherPool;
> +  struct dma_pool *RequestSensePool = NULL;
>void *ScatterGatherCPU;
>dma_addr_t ScatterGatherDMA;
>void *RequestSenseCPU;
> @@ -411,9 +411,9 @@ static void 
> 

Re: [RFC 09/19] scsi: csiostor: Replace PCI pool old API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:47PM +0100, Romain Perier wrote:
> The PCI pool API is deprecated. This commits replaces the PCI pool old
> API by the appropriated function with the DMA pool API.
> 
> Signed-off-by: Romain Perier 
> ---
>  drivers/scsi/csiostor/csio_hw.h   | 2 +-
>  drivers/scsi/csiostor/csio_init.c | 4 ++--
>  drivers/scsi/csiostor/csio_scsi.c | 6 +++---
>  3 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/scsi/csiostor/csio_hw.h b/drivers/scsi/csiostor/csio_hw.h
> index 029bef8..c35c7bf 100644
> --- a/drivers/scsi/csiostor/csio_hw.h
> +++ b/drivers/scsi/csiostor/csio_hw.h
> @@ -465,7 +465,7 @@ struct csio_hw {
>   struct csio_pport   pport[CSIO_MAX_PPORTS]; /* Ports (XGMACs) */
>   struct csio_hw_params   params; /* Hw parameters */
>  
> - struct pci_pool *scsi_pci_pool; /* PCI pool for SCSI */
> + struct dma_pool *scsi_pci_pool; /* PCI pool for SCSI */
>   mempool_t   *mb_mempool;/* Mailbox memory pool*/
>   mempool_t   *rnode_mempool; /* rnode memory pool */
>  
> diff --git a/drivers/scsi/csiostor/csio_init.c 
> b/drivers/scsi/csiostor/csio_init.c
> index dbe416f..6206a72 100644
> --- a/drivers/scsi/csiostor/csio_init.c
> +++ b/drivers/scsi/csiostor/csio_init.c
> @@ -485,7 +485,7 @@ csio_resource_alloc(struct csio_hw *hw)
>   if (!hw->rnode_mempool)
>   goto err_free_mb_mempool;
>  
> - hw->scsi_pci_pool = pci_pool_create("csio_scsi_pci_pool", hw->pdev,
> + hw->scsi_pci_pool = dma_pool_create("csio_scsi_pci_pool", 
> >pdev->dev,
Introduces line over 80 characters warning. Please fix and resubmit.
Other than that looks good. Tested by compiling it.

>   CSIO_SCSI_RSP_LEN, 8, 0);
>   if (!hw->scsi_pci_pool)
>   goto err_free_rn_pool;
> @@ -505,7 +505,7 @@ csio_resource_alloc(struct csio_hw *hw)
>  static void
>  csio_resource_free(struct csio_hw *hw)
>  {
> - pci_pool_destroy(hw->scsi_pci_pool);
> + dma_pool_destroy(hw->scsi_pci_pool);
>   hw->scsi_pci_pool = NULL;
>   mempool_destroy(hw->rnode_mempool);
>   hw->rnode_mempool = NULL;
> diff --git a/drivers/scsi/csiostor/csio_scsi.c 
> b/drivers/scsi/csiostor/csio_scsi.c
> index a1ff75f..49b36b0 100644
> --- a/drivers/scsi/csiostor/csio_scsi.c
> +++ b/drivers/scsi/csiostor/csio_scsi.c
> @@ -2445,7 +2445,7 @@ csio_scsim_init(struct csio_scsim *scm, struct csio_hw 
> *hw)
>  
>   /* Allocate Dma buffers for Response Payload */
>   dma_buf = >dma_buf;
> - dma_buf->vaddr = pci_pool_alloc(hw->scsi_pci_pool, GFP_KERNEL,
> + dma_buf->vaddr = dma_pool_alloc(hw->scsi_pci_pool, GFP_KERNEL,
>   _buf->paddr);
>   if (!dma_buf->vaddr) {
>   csio_err(hw,
> @@ -2485,7 +2485,7 @@ csio_scsim_init(struct csio_scsim *scm, struct csio_hw 
> *hw)
>   ioreq = (struct csio_ioreq *)tmp;
>  
>   dma_buf = >dma_buf;
> - pci_pool_free(hw->scsi_pci_pool, dma_buf->vaddr,
> + dma_pool_free(hw->scsi_pci_pool, dma_buf->vaddr,
> dma_buf->paddr);
>  
>   kfree(ioreq);
> @@ -2516,7 +2516,7 @@ csio_scsim_exit(struct csio_scsim *scm)
>   ioreq = (struct csio_ioreq *)tmp;
>  
>   dma_buf = >dma_buf;
> - pci_pool_free(scm->hw->scsi_pci_pool, dma_buf->vaddr,
> + dma_pool_free(scm->hw->scsi_pci_pool, dma_buf->vaddr,
> dma_buf->paddr);
>  
>   kfree(ioreq);
> -- 
> 2.9.3
> 


Re: [RFC 06/19] mlx5: Replace PCI pool old API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:44PM +0100, Romain Perier wrote:
> The PCI pool API is deprecated. This commits replaces the PCI pool old
> API by the appropriated function with the DMA pool API.



> 
> Signed-off-by: Romain Perier 
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 10 +-
>  include/linux/mlx5/driver.h   |  2 +-
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c 
> b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
> index caa837e..7885e2b 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
> @@ -1061,7 +1061,7 @@ static struct mlx5_cmd_mailbox *alloc_cmd_box(struct 
> mlx5_core_dev *dev,
>   if (!mailbox)
>   return ERR_PTR(-ENOMEM);
>  
> - mailbox->buf = pci_pool_zalloc(dev->cmd.pool, flags,
> + mailbox->buf = dma_pool_zalloc(dev->cmd.pool, flags,
>  >dma);
>   if (!mailbox->buf) {
>   mlx5_core_dbg(dev, "failed allocation\n");
> @@ -1076,7 +1076,7 @@ static struct mlx5_cmd_mailbox *alloc_cmd_box(struct 
> mlx5_core_dev *dev,
>  static void free_cmd_box(struct mlx5_core_dev *dev,
>struct mlx5_cmd_mailbox *mailbox)
>  {
> - pci_pool_free(dev->cmd.pool, mailbox->buf, mailbox->dma);
> + dma_pool_free(dev->cmd.pool, mailbox->buf, mailbox->dma);
>   kfree(mailbox);
>  }
>  
> @@ -1696,7 +1696,7 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
>   return -EINVAL;
>   }
>  
> - cmd->pool = pci_pool_create("mlx5_cmd", dev->pdev, size, align, 0);
> + cmd->pool = dma_pool_create("mlx5_cmd", >pdev->dev, size, align, 
> 0);
This introduces line over 80 characters warning. Please fix and
resubmit. Other than that, looks good. I tested by compiling it.

>   if (!cmd->pool)
>   return -ENOMEM;
>  
> @@ -1786,7 +1786,7 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
>   free_cmd_page(dev, cmd);
>  
>  err_free_pool:
> - pci_pool_destroy(cmd->pool);
> + dma_pool_destroy(cmd->pool);
>  
>   return err;
>  }
> @@ -1800,6 +1800,6 @@ void mlx5_cmd_cleanup(struct mlx5_core_dev *dev)
>   destroy_workqueue(cmd->wq);
>   destroy_msg_cache(dev);
>   free_cmd_page(dev, cmd);
> - pci_pool_destroy(cmd->pool);
> + dma_pool_destroy(cmd->pool);
>  }
>  EXPORT_SYMBOL(mlx5_cmd_cleanup);
> diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
> index 2fcff6b..13a267c 100644
> --- a/include/linux/mlx5/driver.h
> +++ b/include/linux/mlx5/driver.h
> @@ -284,7 +284,7 @@ struct mlx5_cmd {
>   struct semaphore pages_sem;
>   int mode;
>   struct mlx5_cmd_work_ent *ent_arr[MLX5_MAX_COMMANDS];
> - struct pci_pool *pool;
> + struct dma_pool *pool;
>   struct mlx5_cmd_debug dbg;
>   struct cmd_msg_cache cache[MLX5_NUM_COMMAND_CACHES];
>   int checksum_disabled;
> -- 
> 2.9.3
> 


Re: [RFC 08/19] scsi: be2iscsi: Replace PCI pool old API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:46PM +0100, Romain Perier wrote:
> The PCI pool API is deprecated. This commits replaces the PCI pool old
> API by the appropriated function with the DMA pool API.
> 
Tested by compilation only.

Acked-by: Peter Senna Tschudin 
Tested-by: Peter Senna Tschudin 
> Signed-off-by: Romain Perier 
> ---
>  drivers/scsi/be2iscsi/be_iscsi.c | 6 +++---
>  drivers/scsi/be2iscsi/be_main.c  | 6 +++---
>  drivers/scsi/be2iscsi/be_main.h  | 2 +-
>  3 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/scsi/be2iscsi/be_iscsi.c 
> b/drivers/scsi/be2iscsi/be_iscsi.c
> index a484457..d76ef77 100644
> --- a/drivers/scsi/be2iscsi/be_iscsi.c
> +++ b/drivers/scsi/be2iscsi/be_iscsi.c
> @@ -87,8 +87,8 @@ struct iscsi_cls_session *beiscsi_session_create(struct 
> iscsi_endpoint *ep,
>   return NULL;
>   sess = cls_session->dd_data;
>   beiscsi_sess = sess->dd_data;
> - beiscsi_sess->bhs_pool =  pci_pool_create("beiscsi_bhs_pool",
> -phba->pcidev,
> + beiscsi_sess->bhs_pool =  dma_pool_create("beiscsi_bhs_pool",
> +>pcidev->dev,
>  sizeof(struct be_cmd_bhs),
>  64, 0);
>   if (!beiscsi_sess->bhs_pool)
> @@ -113,7 +113,7 @@ void beiscsi_session_destroy(struct iscsi_cls_session 
> *cls_session)
>   struct beiscsi_session *beiscsi_sess = sess->dd_data;
>  
>   printk(KERN_INFO "In beiscsi_session_destroy\n");
> - pci_pool_destroy(beiscsi_sess->bhs_pool);
> + dma_pool_destroy(beiscsi_sess->bhs_pool);
>   iscsi_session_teardown(cls_session);
>  }
>  
> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> index 32b2713..dd43480 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -4307,7 +4307,7 @@ static void beiscsi_cleanup_task(struct iscsi_task 
> *task)
>   pwrb_context = _ctrlr->wrb_context[cri_index];
>  
>   if (io_task->cmd_bhs) {
> - pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs,
> + dma_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs,
> io_task->bhs_pa.u.a64.address);
>   io_task->cmd_bhs = NULL;
>   task->hdr = NULL;
> @@ -4424,7 +4424,7 @@ static int beiscsi_alloc_pdu(struct iscsi_task *task, 
> uint8_t opcode)
>   struct beiscsi_session *beiscsi_sess = beiscsi_conn->beiscsi_sess;
>   dma_addr_t paddr;
>  
> - io_task->cmd_bhs = pci_pool_alloc(beiscsi_sess->bhs_pool,
> + io_task->cmd_bhs = dma_pool_alloc(beiscsi_sess->bhs_pool,
> GFP_ATOMIC, );
>   if (!io_task->cmd_bhs)
>   return -ENOMEM;
> @@ -4551,7 +4551,7 @@ static int beiscsi_alloc_pdu(struct iscsi_task *task, 
> uint8_t opcode)
>   if (io_task->pwrb_handle)
>   free_wrb_handle(phba, pwrb_context, io_task->pwrb_handle);
>   io_task->pwrb_handle = NULL;
> - pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs,
> + dma_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs,
> io_task->bhs_pa.u.a64.address);
>   io_task->cmd_bhs = NULL;
>   return -ENOMEM;
> diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
> index 2188579..cf58d31 100644
> --- a/drivers/scsi/be2iscsi/be_main.h
> +++ b/drivers/scsi/be2iscsi/be_main.h
> @@ -446,7 +446,7 @@ struct beiscsi_hba {
>test_bit(BEISCSI_HBA_ONLINE, >state))
>  
>  struct beiscsi_session {
> - struct pci_pool *bhs_pool;
> + struct dma_pool *bhs_pool;
>  };
>  
>  /**
> -- 
> 2.9.3
> 


Re: [RFC 07/19] wireless: ipw2200: Replace PCI pool old API

2017-02-08 Thread Peter Senna Tschudin
On Wed, Feb 08, 2017 at 05:34:45PM +0100, Romain Perier wrote:
> The PCI pool API is deprecated. This commits replaces the PCI pool old
> API by the appropriated function with the DMA pool API.



> 
> Signed-off-by: Romain Perier 
> ---
>  drivers/net/wireless/intel/ipw2x00/ipw2200.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2200.c 
> b/drivers/net/wireless/intel/ipw2x00/ipw2200.c
> index 5ef3c5c..6d77870 100644
> --- a/drivers/net/wireless/intel/ipw2x00/ipw2200.c
> +++ b/drivers/net/wireless/intel/ipw2x00/ipw2200.c
> @@ -3211,7 +3211,7 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 
> * data, size_t len)
>   struct fw_chunk *chunk;
>   int total_nr = 0;
>   int i;
> - struct pci_pool *pool;
> + struct dma_pool *pool;
>   void **virts;
>   dma_addr_t *phys;
>  
> @@ -3228,9 +3228,9 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 
> * data, size_t len)
>   kfree(virts);
>   return -ENOMEM;
>   }
> - pool = pci_pool_create("ipw2200", priv->pci_dev, CB_MAX_LENGTH, 0, 0);
> + pool = dma_pool_create("ipw2200", >pci_dev->dev, CB_MAX_LENGTH, 
> 0, 0);
Introduces line over 80 characters warning. Please fix and resubmit.
Other than that looks good. Tested by compiling it.
>   if (!pool) {
> - IPW_ERROR("pci_pool_create failed\n");
> + IPW_ERROR("dma_pool_create failed\n");
>   kfree(phys);
>   kfree(virts);
>   return -ENOMEM;
> @@ -3255,7 +3255,7 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 
> * data, size_t len)
>  
>   nr = (chunk_len + CB_MAX_LENGTH - 1) / CB_MAX_LENGTH;
>   for (i = 0; i < nr; i++) {
> - virts[total_nr] = pci_pool_alloc(pool, GFP_KERNEL,
> + virts[total_nr] = dma_pool_alloc(pool, GFP_KERNEL,
>[total_nr]);
>   if (!virts[total_nr]) {
>   ret = -ENOMEM;
> @@ -3299,9 +3299,9 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 
> * data, size_t len)
>   }
>   out:
>   for (i = 0; i < total_nr; i++)
> - pci_pool_free(pool, virts[i], phys[i]);
> + dma_pool_free(pool, virts[i], phys[i]);
>  
> - pci_pool_destroy(pool);
> + dma_pool_destroy(pool);
>   kfree(phys);
>   kfree(virts);
>  
> -- 
> 2.9.3
> 


Re: [PATCH v2 00/14] qla2xxx: Bug Fixes and updates for target.

2017-02-08 Thread Madhani, Himanshu
Hi Bart, 



On 2/8/17, 7:02 AM, "Bart Van Assche"  wrote:

>On Fri, 2017-02-03 at 14:40 -0800, Himanshu Madhani wrote:
>> Please consider this series for inclusion in target-pending.
>
>Hello Himanshu,
>
>I gave this patch series a try on a system equipped with two QLogic FC HBAs
>where an FC cable connects both HBAs to each other. qlini_mode has been set
>to "dual" such that both ports support initiator and target mode. Without this
>patch series both ports log in to each other and lsscsi shows several LUNs.
>With this patch series applied the two ports do not log in to each other
>anymore and strange messages appear in the kernel log:
>
>[ cut here ]
>WARNING: CPU: 0 PID: 5 at lib/kobject.c:244 kobject_add_internal+0x118/0x350
>kobject_add_internal failed for 3:0:0:0 (error: -2 parent: target3:0:0)
>Modules linked in: target_core_pscsi target_core_iblock target_core_file 
>tcm_qla2xxx target_core_mod fcoe libfcoe libfc qla2xxx scsi_transport_fc 
>netconsole af_packet hid_generic usbhid hid sg virtio_balloon i2c_piix4 
>acpi_cpufreq button ib_iser rdma_cm iw_cm ib_cm ib_core configfs iscsi_tcp 
>libiscsi_tcp libiscsi scsi_transport_iscsi autofs4 ext4 crc16 jbd2 mbcache 
>sr_mod cdrom ata_generic pata_acpi virtio_net virtio_blk virtio_gpu 
>drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm drm i2c_core 
>ata_piix xhci_pci libata xhci_hcd intel_agp usbcore intel_gtt virtio_pci 
>scsi_mod virtio_ring usb_common agpgart virtio
>CPU: 0 PID: 5 Comm: kworker/u16:0 Not tainted 4.10.0-rc6-dbg+ #1
>Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
>Workqueue: scsi_wq_3 fc_scsi_scan_rport [scsi_transport_fc]
>Call Trace:
> dump_stack+0x85/0xc2
> __warn+0xcb/0xf0
> warn_slowpath_fmt+0x4f/0x60
> kobject_add_internal+0x118/0x350
> kobject_add+0x68/0xb0
> device_add+0xfa/0x600
> scsi_sysfs_add_sdev+0x8e/0x270 [scsi_mod]
> scsi_probe_and_add_lun+0xca1/0xe30 [scsi_mod]
> __scsi_scan_target+0xd3/0x5f0 [scsi_mod]
> scsi_scan_target+0xf1/0x100 [scsi_mod]
> fc_scsi_scan_rport+0xc0/0xd0 [scsi_transport_fc]
> process_one_work+0x1f4/0x6e0
> worker_thread+0x4e/0x4a0
> kthread+0x10c/0x140
> ret_from_fork+0x31/0x40
>---[ end trace 86f40b52873f9529 ]---
>scsi 3:0:0:0: failed to add device: -2

I’ll try to reproduce this. We have not see this issue in our testing and post 
update. 

Thanks,
Himanshu

>
>Bart.
>Western Digital Corporation (and its subsidiaries) E-mail Confidentiality 
>Notice & Disclaimer:
>
>This e-mail and any files transmitted with it may contain confidential or 
>legally privileged information of WDC and/or its affiliates, and are intended 
>solely for the use of the individual or entity to which they are addressed. If 
>you are not the intended recipient, any disclosure, copying, distribution or 
>any action taken or omitted to be taken in reliance on it, is prohibited. If 
>you have received this e-mail in error, please notify the sender immediately 
>and delete the e-mail in its entirety from your system.


Re: [PATCH 1/5] target: Don't BUG_ON during NodeACL dynamic -> explicit conversion

2017-02-08 Thread Nicholas A. Bellinger
On Tue, 2017-02-07 at 14:44 -0800, Christoph Hellwig wrote:
> On Tue, Feb 07, 2017 at 01:17:46PM +, Nicholas A. Bellinger wrote:
> > +   if (orig->se_lun_acl != NULL) {
> > +   pr_warn_ratelimited("Detected existing explicit"
> > +   " se_lun_acl->se_lun_group reference for %s"
> > +   " mapped_lun: %llu, ignoring\n",
> > +nacl->initiatorname, mapped_lun);
> 
> The ignoring in the message confused the heck out of me first.  But it 
> seems that's just an incorrect leftover from the original message, as the
> changelog also says fail instead.  With that fixed up (and maybe the
> whole message in a single string literal on a single line):
> 

Fixed up the message to use 'failed'.




Re: [PATCH net-next v2 00/12] net: dsa: remove unnecessary phy.h include

2017-02-08 Thread Kalle Valo
David Miller  writes:

> From: Florian Fainelli 
> Date: Tue,  7 Feb 2017 15:02:53 -0800
>
>> I'm hoping this doesn't conflict with what's already in net-next...
>> 
>> David, this should probably go via your tree considering the diffstat.
>
> I think you need one more respin.  Are you doing an allmodconfig build?
> If not, for something like this it's a must:
>
> drivers/net/wireless/ath/wil6210/cfg80211.c:24:30: error: expected ‘)’ before 
> ‘bool’
>  module_param(disable_ap_sme, bool, 0444);
>   ^
> drivers/net/wireless/ath/wil6210/cfg80211.c:25:34: error: expected ‘)’ before 
> string constant
>  MODULE_PARM_DESC(disable_ap_sme, " let user space handle AP mode SME");
>   ^
> Like like that file needs linux/module.h included.

Johannes already fixed a similar (or same) problem in my tree:

wil6210: include moduleparam.h

https://git.kernel.org/cgit/linux/kernel/git/kvalo/wireless-drivers-next.git/commit/?id=949c2d0096753d518ef6e0bd8418c8086747196b

I'm planning to send you a pull request tomorrow which contains that
one.

-- 
Kalle Valo


[PATCH -next] scsi: sd: make sd_devt_release() static

2017-02-08 Thread Wei Yongjun
From: Wei Yongjun 

Fixes the following sparse warning:

drivers/scsi/sd.c:3087:6: warning:
 symbol 'sd_devt_release' was not declared. Should it be static?

Signed-off-by: Wei Yongjun 
---
 drivers/scsi/sd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index cb6e68d..b9b32f58 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3084,7 +3084,7 @@ struct sd_devt {
struct disk_devt disk_devt;
 };
 
-void sd_devt_release(struct disk_devt *disk_devt)
+static void sd_devt_release(struct disk_devt *disk_devt)
 {
struct sd_devt *sd_devt = container_of(disk_devt, struct sd_devt,
disk_devt);



Re: [PATCH 4/5] target: Fix multi-session dynamic se_node_acl double free OOPs

2017-02-08 Thread Nicholas A. Bellinger
On Tue, 2017-02-07 at 19:46 -0800, Nicholas A. Bellinger wrote:
> On Tue, 2017-02-07 at 15:12 -0800, Christoph Hellwig wrote:
> > And the real patch after compile fixing it is here of course:
> > 
> 
> Getting rid of the extra se_node_acl->acl_free_comp seems to make sense
> here..
> 
> The only potential issue is if returning from configfs syscall
> rmdir /sys/kernel/config/target/$FABRIC/$WWN/$TPGT/acls/$INITIATOR/
> before se_node_acl memory is released has implications when the
> underlying ../$WWN/$TPGT/ is removed immediately after.
> 
> In any event, I'll verify this patch with the original test case and use
> it instead if everything looks OK.

Ok, I remember why se_node_acl->acl_free_comp is needed now..

The issue is when se_node_acl is being explicitly removed from configfs
while se_sessions associated with se_node_acl are still active.

The se_node_acl->acl_group configfs_group_operations->drop_item()
callback must block until all associated se_sessions have done their
target_put_nacl() and completed se_node_acl->acl_free_comp, otherwise
there is nothing preventing parent config_groups of se_node_acl from
being removed while the se_sessions are still active.

That said, dropping the unnecessary list_del_init() usage, but otherwise
keeping the patch as-is.





Re: [PATCH net-next v2 00/12] net: dsa: remove unnecessary phy.h include

2017-02-08 Thread David Miller
From: Florian Fainelli 
Date: Tue,  7 Feb 2017 15:02:53 -0800

> I'm hoping this doesn't conflict with what's already in net-next...
> 
> David, this should probably go via your tree considering the diffstat.

I think you need one more respin.  Are you doing an allmodconfig build?
If not, for something like this it's a must:

drivers/net/wireless/ath/wil6210/cfg80211.c:24:30: error: expected ‘)’ before 
‘bool’
 module_param(disable_ap_sme, bool, 0444);
  ^
drivers/net/wireless/ath/wil6210/cfg80211.c:25:34: error: expected ‘)’ before 
string constant
 MODULE_PARM_DESC(disable_ap_sme, " let user space handle AP mode SME");
  ^
Like like that file needs linux/module.h included.

Thanks.


Re: [PATCH v2 08/39] megaraid_sas: megasas_get_request_descriptor always return valid desc

2017-02-08 Thread Tomas Henzl
On 8.2.2017 10:29, Shivasharan S wrote:
> fix in v2 - split patches into two. 
> discussed below 
> http://marc.info/?l=linux-scsi=148638999110404=2
>
> No functional change. Code clean up. Removing error code which is not
> valid scenario.
> In megasas_get_request_descriptor we can remove the error handling
> which is not required.
> With fusion controllers, if there is a valid message frame available,
> we are guaranteed to get a corresponding request descriptor.
>
> Signed-off-by: Shivasharan S 
> Signed-off-by: Kashyap Desai 

Reviewed-by: Tomas Henzl 

Tomas



Re: [PATCH v2 10/39] megaraid_sas: NVME Interface detection and prop settings

2017-02-08 Thread Tomas Henzl
On 8.2.2017 10:29, Shivasharan S wrote:
> New functionality
> Adding detection logic for NVME device attached behind Ventura controller.
> Driver set HostPageSize in IOC_INIT frame to inform about page size for NVME 
> devices.
> Firmware reports NVME page size to the driver.
> PD INFO DCMD provide new interface type NVME_PD. Driver set property of NVME 
> device.
>
> Signed-off-by: Shivasharan S 
> Signed-off-by: Kashyap Desai 

Reviewed-by: Tomas Henzl 

Tomas



Re: [PATCH v2 00/14] qla2xxx: Bug Fixes and updates for target.

2017-02-08 Thread Bart Van Assche
On Fri, 2017-02-03 at 14:40 -0800, Himanshu Madhani wrote:
> Please consider this series for inclusion in target-pending.

Hello Himanshu,

I gave this patch series a try on a system equipped with two QLogic FC HBAs
where an FC cable connects both HBAs to each other. qlini_mode has been set
to "dual" such that both ports support initiator and target mode. Without this
patch series both ports log in to each other and lsscsi shows several LUNs.
With this patch series applied the two ports do not log in to each other
anymore and strange messages appear in the kernel log:

[ cut here ]
WARNING: CPU: 0 PID: 5 at lib/kobject.c:244 kobject_add_internal+0x118/0x350
kobject_add_internal failed for 3:0:0:0 (error: -2 parent: target3:0:0)
Modules linked in: target_core_pscsi target_core_iblock target_core_file 
tcm_qla2xxx target_core_mod fcoe libfcoe libfc qla2xxx scsi_transport_fc 
netconsole af_packet hid_generic usbhid hid sg virtio_balloon i2c_piix4 
acpi_cpufreq button ib_iser rdma_cm iw_cm ib_cm ib_core configfs iscsi_tcp 
libiscsi_tcp libiscsi scsi_transport_iscsi autofs4 ext4 crc16 jbd2 mbcache 
sr_mod cdrom ata_generic pata_acpi virtio_net virtio_blk virtio_gpu 
drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm drm i2c_core 
ata_piix xhci_pci libata xhci_hcd intel_agp usbcore intel_gtt virtio_pci 
scsi_mod virtio_ring usb_common agpgart virtio
CPU: 0 PID: 5 Comm: kworker/u16:0 Not tainted 4.10.0-rc6-dbg+ #1
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
Workqueue: scsi_wq_3 fc_scsi_scan_rport [scsi_transport_fc]
Call Trace:
 dump_stack+0x85/0xc2
 __warn+0xcb/0xf0
 warn_slowpath_fmt+0x4f/0x60
 kobject_add_internal+0x118/0x350
 kobject_add+0x68/0xb0
 device_add+0xfa/0x600
 scsi_sysfs_add_sdev+0x8e/0x270 [scsi_mod]
 scsi_probe_and_add_lun+0xca1/0xe30 [scsi_mod]
 __scsi_scan_target+0xd3/0x5f0 [scsi_mod]
 scsi_scan_target+0xf1/0x100 [scsi_mod]
 fc_scsi_scan_rport+0xc0/0xd0 [scsi_transport_fc]
 process_one_work+0x1f4/0x6e0
 worker_thread+0x4e/0x4a0
 kthread+0x10c/0x140
 ret_from_fork+0x31/0x40
---[ end trace 86f40b52873f9529 ]---
scsi 3:0:0:0: failed to add device: -2

Bart.

Re: [PATCH v2 09/39] megaraid_sas: change issue_dcmd to return void from int

2017-02-08 Thread Tomas Henzl
On 8.2.2017 10:29, Shivasharan S wrote:
> fix in v2 : 
> 1. split patches into two as discussed below 
> http://marc.info/?l=linux-scsi=148638999110404=2
> 2. issue_dcmd return type changed from int to void.
>
>
> With the changes to remove checks for a valid request descriptor,
> issue_dcmd will now always return DCMD_SUCCESS. This patch changes
> return type of issue_dcmd to void and change all callers
> appropriately.
>
> Signed-off-by: Shivasharan S 
> Signed-off-by: Kashyap Desai 

Reviewed-by: Tomas Henzl 

Tomas



Re: [PATCH v2 06/39] megaraid_sas: RAID map is accessed for SYS PDs when use_seqnum_jbod_fp is not set

2017-02-08 Thread Tomas Henzl
On 8.2.2017 10:29, Shivasharan S wrote:
> Signed-off-by: Shivasharan S 
> Signed-off-by: Kashyap Desai 

Reviewed-by: Tomas Henzl 

Tomas



[PATCH] zfcp: fix use-after-free by not tracing WKA port open/close on failed send

2017-02-08 Thread Steffen Maier
Dan Carpenter kindly reported:

The patch d27a7cb91960: "zfcp: trace on request for open and close of
WKA port" from Aug 10, 2016, leads to the following static checker
warning:

drivers/s390/scsi/zfcp_fsf.c:1615 zfcp_fsf_open_wka_port()
warn: 'req' was already freed.

drivers/s390/scsi/zfcp_fsf.c
  1609  zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
  1610  retval = zfcp_fsf_req_send(req);
  1611  if (retval)
  1612  zfcp_fsf_req_free(req);
  ^^^
Freed.

  1613  out:
  1614  spin_unlock_irq(>req_q_lock);
  1615  if (req && !IS_ERR(req))
  1616  zfcp_dbf_rec_run_wka("fsowp_1", wka_port, req->req_id);
  ^^^
Use after free.

  1617  return retval;
  1618  }

Same thing for zfcp_fsf_close_wka_port() as well.


Rather than relying on req being NULL (or ERR_PTR) for all cases where
we don't want to trace or should not trace,
simply check retval which is unconditionally initialized with -EIO != 0
and it can only become 0 on successful retval = zfcp_fsf_req_send(req).
With that we can also remove the then again unnecessary unconditional
initialization of req which was introduced with that earlier commit.

Reported-by: Dan Carpenter 
Suggested-by: Benjamin Block 
Signed-off-by: Steffen Maier 
Fixes: d27a7cb91960 ("zfcp: trace on request for open and close of WKA port")
Cc:  #2.6.38+
Reviewed-by: Benjamin Block 
Reviewed-by: Jens Remus 
---
 drivers/s390/scsi/zfcp_fsf.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -1583,7 +1583,7 @@ out:
 int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port)
 {
struct zfcp_qdio *qdio = wka_port->adapter->qdio;
-   struct zfcp_fsf_req *req = NULL;
+   struct zfcp_fsf_req *req;
int retval = -EIO;
 
spin_lock_irq(>req_q_lock);
@@ -1612,7 +1612,7 @@ int zfcp_fsf_open_wka_port(struct zfcp_f
zfcp_fsf_req_free(req);
 out:
spin_unlock_irq(>req_q_lock);
-   if (req && !IS_ERR(req))
+   if (!retval)
zfcp_dbf_rec_run_wka("fsowp_1", wka_port, req->req_id);
return retval;
 }
@@ -1638,7 +1638,7 @@ static void zfcp_fsf_close_wka_port_hand
 int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port)
 {
struct zfcp_qdio *qdio = wka_port->adapter->qdio;
-   struct zfcp_fsf_req *req = NULL;
+   struct zfcp_fsf_req *req;
int retval = -EIO;
 
spin_lock_irq(>req_q_lock);
@@ -1667,7 +1667,7 @@ int zfcp_fsf_close_wka_port(struct zfcp_
zfcp_fsf_req_free(req);
 out:
spin_unlock_irq(>req_q_lock);
-   if (req && !IS_ERR(req))
+   if (!retval)
zfcp_dbf_rec_run_wka("fscwp_1", wka_port, req->req_id);
return retval;
 }



Re: [PATCH v2 03/39] megaraid_sas: raid 1 fast path code optimize

2017-02-08 Thread Tomas Henzl
On 8.2.2017 10:28, Shivasharan S wrote:
> fix in v2 - ex_status and status was wrongly re-used in 
> megasas_complete_r1_command.
> discussed below -
> http://marc.info/?l=linux-scsi=148638763409385=2
>
>
> No functional change. Code refactor.
> Remove function megasas_fpio_to_ldio as we never require to convert fpio to 
> ldio because of frame unavailability.
> Grab extra frame of raid 1 write fast path before it creates first frame as 
> Fast Path.
> Removed is_raid_1_fp_write flag as raid 1 write fast path command is decided 
> using r1_alt_dev_handle only.
> Move resetting megasas_cmd_fusion fields at common function 
> megasas_return_cmd_fusion.
>
>
> Signed-off-by: Shivasharan S 
> Signed-off-by: Kashyap Desai 
> Reviewed-by: Hannes Reinecke 
> ---
>  drivers/scsi/megaraid/megaraid_sas_fp.c |  14 +-
>  drivers/scsi/megaraid/megaraid_sas_fusion.c | 349 
> +---
>  drivers/scsi/megaraid/megaraid_sas_fusion.h |   3 +-
>  3 files changed, 118 insertions(+), 248 deletions(-)
>
> diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c 
> b/drivers/scsi/megaraid/megaraid_sas_fp.c
> index f1384b0..24258af 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_fp.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
> @@ -1338,20 +1338,8 @@ MR_BuildRaidContext(struct megasas_instance *instance,
>   ref_in_start_stripe, io_info,
>   pRAID_Context, map);
>   /* If IO on an invalid Pd, then FP is not possible.*/
> - if (io_info->devHandle == cpu_to_le16(MR_PD_INVALID))
> + if (io_info->devHandle == MR_DEVHANDLE_INVALID)
>   io_info->fpOkForIo = FALSE;
> - /* if FP possible, set the SLUD bit in
> -  *  regLockFlags for ventura
> -  */
> - else if ((instance->is_ventura) && (!isRead) &&
> - (raid->writeMode == MR_RL_WRITE_BACK_MODE) &&
> - (raid->capability.fp_cache_bypass_capable))
> - ((struct RAID_CONTEXT_G35 *) 
> pRAID_Context)->routing_flags.bits.sld = 1;
> - /* set raid 1/10 fast path write capable bit in io_info */
> - if (io_info->fpOkForIo &&
> - (io_info->r1_alt_dev_handle != MR_PD_INVALID) &&
> - (raid->level == 1) && !isRead)
> - io_info->is_raid_1_fp_write = 1;
>   return retval;
>   } else if (isRead) {
>   uint stripIdx;
> diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
> b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> index 514c306..7516589 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> @@ -181,7 +181,9 @@ inline void megasas_return_cmd_fusion(struct 
> megasas_instance *instance,
>   struct megasas_cmd_fusion *cmd)
>  {
>   cmd->scmd = NULL;
> - memset(cmd->io_request, 0, sizeof(struct MPI2_RAID_SCSI_IO_REQUEST));
> + memset(cmd->io_request, 0, MEGA_MPI2_RAID_DEFAULT_IO_FRAME_SIZE);
> + cmd->r1_alt_dev_handle = MR_DEVHANDLE_INVALID;
> + cmd->cmd_completed = false;
>  }
>  
>  /**
> @@ -701,7 +703,7 @@ megasas_alloc_cmds_fusion(struct megasas_instance 
> *instance)
>   memset(cmd->io_request, 0,
>  sizeof(struct MPI2_RAID_SCSI_IO_REQUEST));
>   cmd->io_request_phys_addr = io_req_base_phys + offset;
> - cmd->is_raid_1_fp_write = 0;
> + cmd->r1_alt_dev_handle = MR_DEVHANDLE_INVALID;
>   }
>  
>   if (megasas_create_sg_sense_fusion(instance))
> @@ -1984,7 +1986,7 @@ megasas_build_ldio_fusion(struct megasas_instance 
> *instance,
>   io_info.ldStartBlock = ((u64)start_lba_hi << 32) | start_lba_lo;
>   io_info.numBlocks = datalength;
>   io_info.ldTgtId = device_id;
> - io_info.r1_alt_dev_handle = MR_PD_INVALID;
> + io_info.r1_alt_dev_handle = MR_DEVHANDLE_INVALID;
>   scsi_buff_len = scsi_bufflen(scp);
>   io_request->DataLength = cpu_to_le32(scsi_buff_len);
>  
> @@ -2025,7 +2027,7 @@ megasas_build_ldio_fusion(struct megasas_instance 
> *instance,
>   io_info.isRead && io_info.ra_capable)
>   fp_possible = false;
>  
> - if (io_info.r1_alt_dev_handle != MR_PD_INVALID) {
> + if (io_info.r1_alt_dev_handle != MR_DEVHANDLE_INVALID) {
>   mrdev_priv = scp->device->hostdata;
>  
>   if (atomic_inc_return(>fw_outstanding) >
> @@ -2090,9 +2092,10 @@ megasas_build_ldio_fusion(struct megasas_instance 
> *instance,
>   } else
>   scp->SCp.Status &= ~MEGASAS_LOAD_BALANCE_FLAG;
>  
> - cmd->is_raid_1_fp_write = io_info.is_raid_1_fp_write;
> - if (io_info.is_raid_1_fp_write)
> + if (instance->is_ventura)
> 

Re: [PATCH v2 07/18] lpfc: NVME Initiator: Base modifications Part E

2017-02-08 Thread Christoph Hellwig
On Tue, Feb 07, 2017 at 06:32:30PM -0800, James Smart wrote:
> I realize I cut these in a silly way.  In the v1 patches, I had a big patch
> that I then cut into 6 parts, by file.  In the v2 patches, I tried to keep
> the patches as is, and address the comments in the respective patch the
> comment came from. Which resulted in 3/8 with an old reference, but patch
> 8/8 being the one that reverted this reverence. Sorry..  I'll recut and
> repost.

This whole split doesn't make sense - either the patches are logically
split, in which case they can be posted separately, or they belong
together in which case they should be sent together.  But the size
of them suggest to me they probably need to be broken down to logically
separate patches.

And can you please switch to using git-send-email to send the patches
straight from a git branch?  There are lot of patch formatting issues
with the lpfc patches, and that should fix most of them instantly.


Re: [PATCH v2 03/14] qla2xxx: Allow vref count to timeout on vport delete.

2017-02-08 Thread Christoph Hellwig
On Fri, Feb 03, 2017 at 02:40:44PM -0800, Himanshu Madhani wrote:
> - spin_lock_irqsave(>vport_slock, flags);
> - while (atomic_read(>vref_count)) {
> - spin_unlock_irqrestore(>vport_slock, flags);
> -
> + while (count-- && atomic_read(>vref_count))
>   msleep(500);

Please add a wait queue to skeep on while waiting for vref_count to
drop to zero.  


Re: [PATCH v2 02/18] lpfc: use pci_irq_alloc_vectors and pci_irq_free_vectors

2017-02-08 Thread Christoph Hellwig
On Mon, Feb 06, 2017 at 03:08:51PM -0800, James Smart wrote:
> 
> I replaced the v1 patch with Christoph's original
> 
>   james
> 
> From: Christoph Hellwig 

Everything above this from line should not go into the mail sent
to the list.  Note that git-send-email will automatically do the right
thing for you as long as the patch has been properly applied to your
local tree.


Re: [PATCH v2 01/18] lpfc: Correct WQ creation for pagesize

2017-02-08 Thread Christoph Hellwig
Looks fine,

Reviewed-by: Christoph Hellwig 


On Mon, Feb 06, 2017 at 03:08:50PM -0800, James Smart wrote:
> 
> Correct WQ creation for pagesize

Except that the (partial) subject should not be repeated in the body.


Re: [PATCH v2 06/39] megaraid_sas: RAID map is accessed for SYS PDs when use_seqnum_jbod_fp is not set

2017-02-08 Thread Hannes Reinecke
On 02/08/2017 10:29 AM, Shivasharan S wrote:
> Signed-off-by: Shivasharan S 
> Signed-off-by: Kashyap Desai 
> ---
>  drivers/scsi/megaraid/megaraid_sas_base.c | 25 ++---
>  1 file changed, 14 insertions(+), 11 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v2 10/39] megaraid_sas: NVME Interface detection and prop settings

2017-02-08 Thread Hannes Reinecke
On 02/08/2017 10:29 AM, Shivasharan S wrote:
> New functionality
> Adding detection logic for NVME device attached behind Ventura controller.
> Driver set HostPageSize in IOC_INIT frame to inform about page size for NVME 
> devices.
> Firmware reports NVME page size to the driver.
> PD INFO DCMD provide new interface type NVME_PD. Driver set property of NVME 
> device.
> 
> Signed-off-by: Shivasharan S 
> Signed-off-by: Kashyap Desai 
> ---
>  drivers/scsi/megaraid/megaraid_sas.h|  23 ++--
>  drivers/scsi/megaraid/megaraid_sas_base.c   | 170 
> 
>  drivers/scsi/megaraid/megaraid_sas_fusion.c |   6 +-
>  drivers/scsi/megaraid/megaraid_sas_fusion.h |   2 +-
>  4 files changed, 142 insertions(+), 59 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v2 08/39] megaraid_sas: megasas_get_request_descriptor always return valid desc

2017-02-08 Thread Hannes Reinecke
On 02/08/2017 10:29 AM, Shivasharan S wrote:
> fix in v2 - split patches into two. 
> discussed below 
> http://marc.info/?l=linux-scsi=148638999110404=2
> 
> No functional change. Code clean up. Removing error code which is not
> valid scenario.
> In megasas_get_request_descriptor we can remove the error handling
> which is not required.
> With fusion controllers, if there is a valid message frame available,
> we are guaranteed to get a corresponding request descriptor.
> 
> Signed-off-by: Shivasharan S 
> Signed-off-by: Kashyap Desai 
> ---
>  drivers/scsi/megaraid/megaraid_sas_fusion.c | 24 ++--
>  1 file changed, 2 insertions(+), 22 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v2 04/39] megaraid_sas: 32 bit descriptor fire cmd optimization

2017-02-08 Thread Hannes Reinecke
On 02/08/2017 10:28 AM, Shivasharan S wrote:
> No functional change. Code refactor.
> megasas_fire_cmd_fusion can always use 32 bit descriptor write for ventura. 
> No need to pass extra flag.
> Only IOC INIT required 64 bit Descriptor write.
> 
> Signed-off-by: Shivasharan S 
> Signed-off-by: Kashyap Desai 
> Reviewed-by: Tomas Henzl 
> ---
>  drivers/scsi/megaraid/megaraid_sas_fusion.c | 65 
> +++--
>  1 file changed, 33 insertions(+), 32 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v2 09/39] megaraid_sas: change issue_dcmd to return void from int

2017-02-08 Thread Hannes Reinecke
On 02/08/2017 10:29 AM, Shivasharan S wrote:
> fix in v2 : 
> 1. split patches into two as discussed below 
> http://marc.info/?l=linux-scsi=148638999110404=2
> 2. issue_dcmd return type changed from int to void.
> 
> 
> With the changes to remove checks for a valid request descriptor,
> issue_dcmd will now always return DCMD_SUCCESS. This patch changes
> return type of issue_dcmd to void and change all callers
> appropriately.
> 
> Signed-off-by: Shivasharan S 
> Signed-off-by: Kashyap Desai 
> ---
>  drivers/scsi/megaraid/megaraid_sas.h|  2 +-
>  drivers/scsi/megaraid/megaraid_sas_base.c   | 19 +++
>  drivers/scsi/megaraid/megaraid_sas_fusion.c |  8 
>  3 files changed, 16 insertions(+), 13 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

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


[PATCH v2 08/39] megaraid_sas: megasas_get_request_descriptor always return valid desc

2017-02-08 Thread Shivasharan S
fix in v2 - split patches into two. 
discussed below 
http://marc.info/?l=linux-scsi=148638999110404=2

No functional change. Code clean up. Removing error code which is not
valid scenario.
In megasas_get_request_descriptor we can remove the error handling
which is not required.
With fusion controllers, if there is a valid message frame available,
we are guaranteed to get a corresponding request descriptor.

Signed-off-by: Shivasharan S 
Signed-off-by: Kashyap Desai 
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 24 ++--
 1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 6ec7a18..b6c5dc5 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -2438,18 +2438,12 @@ megasas_build_io_fusion(struct megasas_instance 
*instance,
return 0;
 }
 
-union MEGASAS_REQUEST_DESCRIPTOR_UNION *
+static union MEGASAS_REQUEST_DESCRIPTOR_UNION *
 megasas_get_request_descriptor(struct megasas_instance *instance, u16 index)
 {
u8 *p;
struct fusion_context *fusion;
 
-   if (index >= instance->max_mpt_cmds) {
-   dev_err(>pdev->dev, "Invalid SMID (0x%x)request for "
-  "descriptor for scsi%d\n", index,
-   instance->host->host_no);
-   return NULL;
-   }
fusion = instance->ctrl_context;
p = fusion->req_frames_desc +
sizeof(union MEGASAS_REQUEST_DESCRIPTOR_UNION) * index;
@@ -2960,7 +2954,7 @@ build_mpt_mfi_pass_thru(struct megasas_instance *instance,
 union MEGASAS_REQUEST_DESCRIPTOR_UNION *
 build_mpt_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd)
 {
-   union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc;
+   union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc = NULL;
u16 index;
 
if (build_mpt_mfi_pass_thru(instance, cmd)) {
@@ -2972,9 +2966,6 @@ build_mpt_cmd(struct megasas_instance *instance, struct 
megasas_cmd *cmd)
 
req_desc = megasas_get_request_descriptor(instance, index - 1);
 
-   if (!req_desc)
-   return NULL;
-
req_desc->Words = 0;
req_desc->SCSIIO.RequestFlags = (MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO <<
 MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
@@ -2997,11 +2988,6 @@ megasas_issue_dcmd_fusion(struct megasas_instance 
*instance,
union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc;
 
req_desc = build_mpt_cmd(instance, cmd);
-   if (!req_desc) {
-   dev_info(>pdev->dev, "Failed from %s %d\n",
-   __func__, __LINE__);
-   return DCMD_NOT_FIRED;
-   }
 
megasas_fire_cmd_fusion(instance, req_desc);
return DCMD_SUCCESS;
@@ -3438,12 +3424,6 @@ megasas_issue_tm(struct megasas_instance *instance, u16 
device_handle,
 
req_desc = megasas_get_request_descriptor(instance,
(cmd_fusion->index - 1));
-   if (!req_desc) {
-   dev_err(>pdev->dev, "Failed from %s %d\n",
-   __func__, __LINE__);
-   megasas_return_cmd(instance, cmd_mfi);
-   return -ENOMEM;
-   }
 
cmd_fusion->request_desc = req_desc;
req_desc->Words = 0;
-- 
2.8.3



[PATCH v2 02/39] megaraid_sas: cpu select rework.

2017-02-08 Thread Shivasharan S
No functional change. Code refactor.

Signed-off-by: Shivasharan S 
Signed-off-by: Kashyap Desai 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 175 
 1 file changed, 100 insertions(+), 75 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 54728b3..514c306 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -1819,6 +1819,73 @@ static void megasas_stream_detect(struct 
megasas_instance *instance,
 }
 
 /**
+ * megasas_set_raidflag_cpu_affinity - This function sets the cpu
+ * affinity (cpu of the controller) and raid_flags in the raid context
+ * based on IO type.
+ *
+ * @praid_context: IO RAID context
+ * @raid:  LD raid map
+ * @fp_possible:   Is fast path possible?
+ * @is_read:   Is read IO?
+ *
+ */
+static void
+megasas_set_raidflag_cpu_affinity(union RAID_CONTEXT_UNION *praid_context,
+ struct MR_LD_RAID *raid, bool fp_possible,
+ u8 is_read)
+{
+   u8 cpu_sel = MR_RAID_CTX_CPUSEL_0;
+   struct RAID_CONTEXT_G35 *rctx_g35;
+
+   rctx_g35 = _context->raid_context_g35;
+   if (fp_possible) {
+   if (is_read) {
+   if ((raid->cpuAffinity.pdRead.cpu0) &&
+   (raid->cpuAffinity.pdRead.cpu1))
+   cpu_sel = MR_RAID_CTX_CPUSEL_FCFS;
+   else if (raid->cpuAffinity.pdRead.cpu1)
+   cpu_sel = MR_RAID_CTX_CPUSEL_1;
+   } else {
+   if ((raid->cpuAffinity.pdWrite.cpu0) &&
+   (raid->cpuAffinity.pdWrite.cpu1))
+   cpu_sel = MR_RAID_CTX_CPUSEL_FCFS;
+   else if (raid->cpuAffinity.pdWrite.cpu1)
+   cpu_sel = MR_RAID_CTX_CPUSEL_1;
+   /* Fast path cache by pass capable R0/R1 VD */
+   if ((raid->level <= 1) &&
+   (raid->capability.fp_cache_bypass_capable)) {
+   rctx_g35->routing_flags.bits.sld = 1;
+   rctx_g35->raid_flags =
+   (MR_RAID_FLAGS_IO_SUB_TYPE_CACHE_BYPASS
+   << 
MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT);
+   }
+   }
+   } else {
+   if (is_read) {
+   if ((raid->cpuAffinity.ldRead.cpu0) &&
+   (raid->cpuAffinity.ldRead.cpu1))
+   cpu_sel = MR_RAID_CTX_CPUSEL_FCFS;
+   else if (raid->cpuAffinity.ldRead.cpu1)
+   cpu_sel = MR_RAID_CTX_CPUSEL_1;
+   } else {
+   if ((raid->cpuAffinity.ldWrite.cpu0) &&
+   (raid->cpuAffinity.ldWrite.cpu1))
+   cpu_sel = MR_RAID_CTX_CPUSEL_FCFS;
+   else if (raid->cpuAffinity.ldWrite.cpu1)
+   cpu_sel = MR_RAID_CTX_CPUSEL_1;
+
+   if (rctx_g35->stream_detected &&
+   (raid->level == 5) &&
+   (raid->writeMode == MR_RL_WRITE_THROUGH_MODE) &&
+   (cpu_sel == MR_RAID_CTX_CPUSEL_FCFS))
+   cpu_sel = MR_RAID_CTX_CPUSEL_0;
+   }
+   }
+
+   rctx_g35->routing_flags.bits.cpu_sel = cpu_sel;
+}
+
+/**
  * megasas_build_ldio_fusion - Prepares IOs to devices
  * @instance:  Adapter soft state
  * @scp:   SCSI command
@@ -1832,8 +1899,10 @@ megasas_build_ldio_fusion(struct megasas_instance 
*instance,
  struct scsi_cmnd *scp,
  struct megasas_cmd_fusion *cmd)
 {
-   u8 fp_possible;
-   u32 start_lba_lo, start_lba_hi, device_id, datalength = 0, ld;
+   bool fp_possible;
+   u16 ld;
+   u32 start_lba_lo, start_lba_hi, device_id, datalength = 0;
+   u32 scsi_buff_len;
struct MPI2_RAID_SCSI_IO_REQUEST *io_request;
union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc;
struct IO_REQUEST_INFO io_info;
@@ -1842,7 +1911,8 @@ megasas_build_ldio_fusion(struct megasas_instance 
*instance,
u8 *raidLUN;
unsigned long spinlock_flags;
union RAID_CONTEXT_UNION *praid_context;
-   struct MR_LD_RAID *raid;
+   struct MR_LD_RAID *raid = NULL;
+   struct MR_PRIV_DEVICE *mrdev_priv;
 
device_id = MEGASAS_DEV_INDEX(scp);
 
@@ -1858,7 +1928,7 @@ megasas_build_ldio_fusion(struct megasas_instance 
*instance,
 
start_lba_lo = 0;
start_lba_hi 

[PATCH v2 07/39] megaraid_sas: Use DID_REQUEUE

2017-02-08 Thread Shivasharan S
Moving to use DID_REQUEUE return type for reliable unconditional retries.
Driver wants unconditional re-queue, so replace DID_RESET with DID_REQUEUE
Discussed below -
https://www.spinics.net/lists/linux-scsi/msg102848.html

Signed-off-by: Shivasharan S 
Signed-off-by: Kashyap Desai 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_base.c   | 4 ++--
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 67a205a..80fcdf5 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1668,7 +1668,7 @@ megasas_queue_command(struct Scsi_Host *shost, struct 
scsi_cmnd *scmd)
/* Check for an mpio path and adjust behavior */
if (atomic_read(>adprecovery) == MEGASAS_ADPRESET_SM_INFAULT) 
{
if (megasas_check_mpio_paths(instance, scmd) ==
-   (DID_RESET << 16)) {
+   (DID_REQUEUE << 16)) {
return SCSI_MLQUEUE_HOST_BUSY;
} else {
scmd->result = DID_NO_CONNECT << 16;
@@ -2492,7 +2492,7 @@ static int megasas_wait_for_outstanding(struct 
megasas_instance *instance)
struct megasas_cmd, list);
list_del_init(_cmd->list);
if (reset_cmd->scmd) {
-   reset_cmd->scmd->result = DID_RESET << 16;
+   reset_cmd->scmd->result = DID_REQUEUE << 16;
dev_notice(>pdev->dev, "%d:%p reset 
[%02x]\n",
reset_index, reset_cmd,
reset_cmd->scmd->cmnd[0]);
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 675afc9..6ec7a18 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -3770,7 +3770,7 @@ int megasas_check_mpio_paths(struct megasas_instance 
*instance,
struct scsi_cmnd *scmd)
 {
struct megasas_instance *peer_instance = NULL;
-   int retval = (DID_RESET << 16);
+   int retval = (DID_REQUEUE << 16);
 
if (instance->peerIsPresent) {
peer_instance = megasas_get_peer_instance(instance);
-- 
2.8.3



[PATCH v2 04/39] megaraid_sas: 32 bit descriptor fire cmd optimization

2017-02-08 Thread Shivasharan S
No functional change. Code refactor.
megasas_fire_cmd_fusion can always use 32 bit descriptor write for ventura. No 
need to pass extra flag.
Only IOC INIT required 64 bit Descriptor write.

Signed-off-by: Shivasharan S 
Signed-off-by: Kashyap Desai 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 65 +++--
 1 file changed, 33 insertions(+), 32 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 7516589..24b72c5 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -188,40 +188,35 @@ inline void megasas_return_cmd_fusion(struct 
megasas_instance *instance,
 
 /**
  * megasas_fire_cmd_fusion -   Sends command to the FW
+ * @instance:  Adapter soft state
+ * @req_desc:  32bit or 64bit Request descriptor
+ *
+ * Perform PCI Write. Ventura supports 32 bit Descriptor.
+ * Prior to Ventura (12G) MR controller supports 64 bit Descriptor.
  */
+
 static void
 megasas_fire_cmd_fusion(struct megasas_instance *instance,
-   union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc, bool is_32bit)
+   union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc)
 {
-   struct megasas_register_set __iomem *regs = instance->reg_set;
-   unsigned long flags;
-
-   if (is_32bit)
+   if (instance->is_ventura)
writel(le32_to_cpu(req_desc->u.low),
-   &(regs)->inbound_single_queue_port);
-   else if (instance->is_ventura) {
+   >reg_set->inbound_single_queue_port);
+   else {
+#if defined(writeq) && defined(CONFIG_64BIT)
+   u64 req_data = (((u64)le32_to_cpu(req_desc->u.high) << 32) |
+   le32_to_cpu(req_desc->u.low));
+
+   writeq(req_data, >reg_set->inbound_low_queue_port);
+#else
+   unsigned long flags;
spin_lock_irqsave(>hba_lock, flags);
writel(le32_to_cpu(req_desc->u.low),
-   &(regs)->inbound_low_queue_port);
+   >reg_set->inbound_low_queue_port);
writel(le32_to_cpu(req_desc->u.high),
-   &(regs)->inbound_high_queue_port);
+   >reg_set->inbound_high_queue_port);
mmiowb();
spin_unlock_irqrestore(>hba_lock, flags);
-   } else {
-#if defined(writeq) && defined(CONFIG_64BIT)
-   u64 req_data = (((u64)le32_to_cpu(req_desc->u.high) << 32) |
-   le32_to_cpu(req_desc->u.low));
-
-   writeq(req_data, >reg_set->inbound_low_queue_port);
-#else
-
-   spin_lock_irqsave(>hba_lock, flags);
-   writel(le32_to_cpu(req_desc->u.low),
-   >reg_set->inbound_low_queue_port);
-   writel(le32_to_cpu(req_desc->u.high),
-   >reg_set->inbound_high_queue_port);
-   mmiowb();
-   spin_unlock_irqrestore(>hba_lock, flags);
 #endif
}
 }
@@ -771,6 +766,7 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
const char *sys_info;
MFI_CAPABILITIES *drv_ops;
u32 scratch_pad_2;
+   unsigned long flags;
 
fusion = instance->ctrl_context;
 
@@ -897,7 +893,14 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
break;
}
 
-   megasas_fire_cmd_fusion(instance, _desc, false);
+   /* For Ventura also IOC INIT required 64 bit Descriptor write. */
+   spin_lock_irqsave(>hba_lock, flags);
+   writel(le32_to_cpu(req_desc.u.low),
+  >reg_set->inbound_low_queue_port);
+   writel(le32_to_cpu(req_desc.u.high),
+  >reg_set->inbound_high_queue_port);
+   mmiowb();
+   spin_unlock_irqrestore(>hba_lock, flags);
 
wait_and_poll(instance, cmd, MFI_POLL_TIMEOUT_SECS);
 
@@ -2577,11 +2580,10 @@ megasas_build_and_issue_cmd_fusion(struct 
megasas_instance *instance,
 * Issue the command to the FW
 */
 
-   megasas_fire_cmd_fusion(instance, req_desc, instance->is_ventura);
+   megasas_fire_cmd_fusion(instance, req_desc);
 
if (r1_cmd)
-   megasas_fire_cmd_fusion(instance, r1_cmd->request_desc,
-   instance->is_ventura);
+   megasas_fire_cmd_fusion(instance, r1_cmd->request_desc);
 
 
return 0;
@@ -3001,7 +3003,7 @@ megasas_issue_dcmd_fusion(struct megasas_instance 
*instance,
return DCMD_NOT_FIRED;
}
 
-   megasas_fire_cmd_fusion(instance, req_desc, instance->is_ventura);
+   megasas_fire_cmd_fusion(instance, req_desc);
return DCMD_SUCCESS;
 }
 
@@ -3294,8 +3296,7 @@ void megasas_refire_mgmt_cmd(struct megasas_instance 
*instance)
cpu_to_le32(MR_DCMD_SYSTEM_PD_MAP_GET_INFO)))
 

[PATCH v2 38/39] megaraid_sas: Change RAID_1_10_RMW_CMDS to RAID_1_PEER_CMDS and set value to 2

2017-02-08 Thread Shivasharan S
For RAID1 FastPath writes, driver needs to allocate extra commands
internally to accommodate for the extra peer command being sent.
Currently driver is allocating 2 extra commands for each but only
one extra command is necessary.
Set RAID_1_10_RMW_CMDS to 2 and also change macro name to
RAID_1_PEER_CMDS.

Signed-off-by: Kashyap Desai 
Signed-off-by: Shivasharan S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 2 +-
 drivers/scsi/megaraid/megaraid_sas_fusion.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index abd11c3..3f198b5 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -293,7 +293,7 @@ megasas_fusion_update_can_queue(struct megasas_instance 
*instance, int fw_boot_c
 
if (instance->is_ventura)
instance->max_mpt_cmds =
-   instance->max_fw_cmds * RAID_1_10_RMW_CMDS;
+   instance->max_fw_cmds * RAID_1_PEER_CMDS;
else
instance->max_mpt_cmds = instance->max_fw_cmds;
 }
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h 
b/drivers/scsi/megaraid/megaraid_sas_fusion.h
index 60566e4..c36f9f7 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.h
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h
@@ -101,7 +101,7 @@ enum MR_RAID_FLAGS_IO_SUB_TYPE {
 #define MEGASAS_FP_CMD_LEN 16
 #define MEGASAS_FUSION_IN_RESET 0
 #define THRESHOLD_REPLY_COUNT 50
-#define RAID_1_10_RMW_CMDS 3
+#define RAID_1_PEER_CMDS 2
 #define JBOD_MAPS_COUNT2
 
 enum MR_FUSION_ADAPTER_TYPE {
-- 
2.8.3



[PATCH v2 06/39] megaraid_sas: RAID map is accessed for SYS PDs when use_seqnum_jbod_fp is not set

2017-02-08 Thread Shivasharan S
Signed-off-by: Shivasharan S 
Signed-off-by: Kashyap Desai 
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 25 ++---
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 6ca49ef..67a205a 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1756,28 +1756,31 @@ void megasas_update_sdev_properties(struct scsi_device 
*sdev)
fusion = instance->ctrl_context;
mr_device_priv_data = sdev->hostdata;
 
-   if (!fusion)
+   if (!fusion || !mr_device_priv_data)
return;
 
-   if (!MEGASAS_IS_LOGICAL(sdev) &&
-   instance->use_seqnum_jbod_fp) {
-   pd_index = (sdev->channel * MEGASAS_MAX_DEV_PER_CHANNEL) +
-   sdev->id;
-   pd_sync = (void *)fusion->pd_seq_sync
-   [(instance->pd_seq_map_id - 1) & 1];
-   mr_device_priv_data->is_tm_capable =
-   pd_sync->seq[pd_index].capability.tmCapable;
-   } else {
+   if (MEGASAS_IS_LOGICAL(sdev)) {
device_id = ((sdev->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL)
+ sdev->id;
local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)];
ld = MR_TargetIdToLdGet(device_id, local_map_ptr);
+   if (ld >= instance->fw_supported_vd_count)
+   return;
raid = MR_LdRaidGet(ld, local_map_ptr);
 
if (raid->capability.ldPiMode == MR_PROT_INFO_TYPE_CONTROLLER)
-   blk_queue_update_dma_alignment(sdev->request_queue, 0x7);
+   blk_queue_update_dma_alignment(sdev->request_queue,
+  0x7);
+
mr_device_priv_data->is_tm_capable =
raid->capability.tmCapable;
+   } else if (instance->use_seqnum_jbod_fp) {
+   pd_index = (sdev->channel * MEGASAS_MAX_DEV_PER_CHANNEL) +
+   sdev->id;
+   pd_sync = (void *)fusion->pd_seq_sync
+   [(instance->pd_seq_map_id - 1) & 1];
+   mr_device_priv_data->is_tm_capable =
+   pd_sync->seq[pd_index].capability.tmCapable;
}
 }
 
-- 
2.8.3



[PATCH v2 39/39] megaraid_sas: driver version upgrade

2017-02-08 Thread Shivasharan S
Signed-off-by: Kashyap Desai 
Signed-off-by: Shivasharan S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 8c06cbf..e7e5974 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -35,8 +35,8 @@
 /*
  * MegaRAID SAS Driver meta data
  */
-#define MEGASAS_VERSION"07.700.00.00-rc1"
-#define MEGASAS_RELDATE"November 29, 2016"
+#define MEGASAS_VERSION"07.701.16.00-rc1"
+#define MEGASAS_RELDATE"February 2, 2017"
 
 /*
  * Device IDs
-- 
2.8.3



[PATCH v2 00/39] megaraid_sas: Updates for scsi-next

2017-02-08 Thread Shivasharan S
Changes in v2:
Patch 3: Fix to update status and ex_status from failed r1_cmd
Patch 8: Split into two separate patches,
 1. megasas_get_request_descriptor will always return valid
request descriptor
 2. With above changes, issue_dcmd always return DCMD_SUCCESS.
Change return type to void and update all callers.
Patch 11: Update commit description, remove reference to dependent patch.
Patch 12: Update with correct commit description
Patch 14: Fix typo in commit description
Patch 19: Correction to commit description
Drop patch 33 of last patch series which added call for flush_scheduled_work

Shivasharan S (39):
  Revert "scsi: megaraid_sas: Enable or Disable Fast path based on the
PCI Threshold Bandwidth"
  megaraid_sas: cpu select rework.
  megaraid_sas: raid 1 fast path code optimize
  megaraid_sas: 32 bit descriptor fire cmd optimization
  megaraid_sas: Refactor MEGASAS_IS_LOGICAL macro using sdev
  megaraid_sas: RAID map is accessed for SYS PDs when use_seqnum_jbod_fp
is not set
  megaraid_sas: Use DID_REQUEUE
  megaraid_sas: megasas_get_request_descriptor always return valid desc
  megaraid_sas: change issue_dcmd to return void from int
  megaraid_sas: NVME Interface detection and prop settings
  megaraid_sas: NVME interface target prop added
  megaraid_sas: NVME fast path io support
  megaraid_sas: raid 1 write performance for large io
  megaraid_sas: set residual bytes count during IO completion
  megaraid_sas: enhance debug logs in OCR context
  megaraid_sas: add print in device removal path
  megaraid_sas: reduce size of fusion_context and use vmalloc if kmalloc
fails
  megaraid_sas: In validate raid map, raid capability is not converted
to cpu format for all lds
  megaraid_sas: MR_TargetIdToLdGet u8 to u16 and avoid invalid raid-map
access
  megaraid_sas: Big endian RDPQ mode fix
  megaraid_sas: big endian support changes
  megaraid_sas: avoid unaligned access in ioctl path
  megaraid_sas: latest controller OCR capability from FW before sending
shutdown DCMD
  megaraid_sas: set pd_after_lb from MR_BuildRaidContext and initialize
pDevHandle to MR_DEVHANDLE_INVALID
  megaraid_sas: Change max_cmd from u32 to u16 in all functions
  megaraid_sas: update can_queue only if the new value is less
  megaraid_sas: max_fw_cmds are decremented twice, remove duplicate
  megaraid_sas: megasas_return_cmd does not memset IO frame to zero
  megaraid_sas: Remove unused pd_index from
megasas_build_ld_nonrw_fusion
  megaraid_sas: Do not set fp_possible if TM capable for non-RW syspdIO,
change fp_possible to bool
  megaraid_sas: During OCR, if get_ctrl_info fails do not continue with
OCR
  megaraid_sas: Change build_mpt_mfi_pass_thru to return void
  megaraid_sas: Bail out the driver load if ld_list_query fails
  megaraid_sas: Use synchronize_irq to wait for IRQs to complete
  megaraid_sas: Increase internal command pool
  megaraid_sas: Cleanup VD_EXT_DEBUG and SPAN_DEBUG related debug prints
  megaraid_sas: Indentation and smatch warning fixes
  megaraid_sas: Change RAID_1_10_RMW_CMDS to RAID_1_PEER_CMDS and set
value to 2
  megaraid_sas: driver version upgrade

 drivers/scsi/megaraid/megaraid_sas.h|   82 +-
 drivers/scsi/megaraid/megaraid_sas_base.c   |  548 +++
 drivers/scsi/megaraid/megaraid_sas_fp.c |  427 ++---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 1352 ---
 drivers/scsi/megaraid/megaraid_sas_fusion.h |  144 ++-
 5 files changed, 1434 insertions(+), 1119 deletions(-)

-- 
2.8.3



[PATCH v2 01/39] Revert "scsi: megaraid_sas: Enable or Disable Fast path based on the PCI Threshold Bandwidth"

2017-02-08 Thread Shivasharan S
This reverts
commit "3e5eadb1a881" ("scsi: megaraid_sas: Enable or Disable Fast path based 
on the PCI Threshold Bandwidth")

This patch was aimed to increase performance of R1 Write operation for large IO 
size.
Since this method used timer approach, it turn on/off fast path did not work as 
expected.
Patch 0013 describes new algorithm and performance number.

Signed-off-by: Shivasharan S 
Signed-off-by: Kashyap Desai 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas.h|  8 -
 drivers/scsi/megaraid/megaraid_sas_base.c   | 48 -
 drivers/scsi/megaraid/megaraid_sas_fp.c |  7 -
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 16 --
 drivers/scsi/megaraid/megaraid_sas_fusion.h |  2 +-
 5 files changed, 7 insertions(+), 74 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index ba9fbb7..f5c4742 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1477,8 +1477,6 @@ enum FW_BOOT_CONTEXT {
 #define MFI_1068_FW_HANDSHAKE_OFFSET   0x64
 #define MFI_1068_FW_READY  0x
 
-#define MEGASAS_RAID1_FAST_PATH_STATUS_CHECK_INTERVAL HZ
-
 #define MR_MAX_REPLY_QUEUES_OFFSET  0X001F
 #define MR_MAX_REPLY_QUEUES_EXT_OFFSET  0X003FC000
 #define MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT14
@@ -2154,10 +2152,6 @@ struct megasas_instance {
atomic_t ldio_outstanding;
atomic_t fw_reset_no_pci_access;
 
-   atomic64_t bytes_wrote; /* used for raid1 fast path enable or disable */
-   atomic_t r1_write_fp_capable;
-
-
struct megasas_instance_template *instancet;
struct tasklet_struct isr_tasklet;
struct work_struct work_init;
@@ -2199,7 +2193,6 @@ struct megasas_instance {
long reset_flags;
struct mutex reset_mutex;
struct timer_list sriov_heartbeat_timer;
-   struct timer_list r1_fp_hold_timer;
char skip_heartbeat_timer_del;
u8 requestorId;
char PlasmaFW111;
@@ -2216,7 +2209,6 @@ struct megasas_instance {
bool is_ventura;
bool msix_combined;
u16 max_raid_mapsize;
-   u64 pci_threshold_bandwidth; /* used to control the fp writes */
 };
 struct MR_LD_VF_MAP {
u32 size;
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 70891a7..3ed876a 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1940,9 +1940,6 @@ void megaraid_sas_kill_hba(struct megasas_instance 
*instance)
}
/* Complete outstanding ioctls when adapter is killed */
megasas_complete_outstanding_ioctls(instance);
-   if (instance->is_ventura)
-   del_timer_sync(>r1_fp_hold_timer);
-
 }
 
  /**
@@ -2441,24 +2438,6 @@ void megasas_sriov_heartbeat_handler(unsigned long 
instance_addr)
}
 }
 
-/*Handler for disabling/enabling raid 1 fast paths*/
-void megasas_change_r1_fp_status(unsigned long instance_addr)
-{
-   struct megasas_instance *instance =
-   (struct megasas_instance *)instance_addr;
-   if (atomic64_read(>bytes_wrote) >=
-   instance->pci_threshold_bandwidth) {
-
-   atomic64_set(>bytes_wrote, 0);
-   atomic_set(>r1_write_fp_capable, 0);
-   } else {
-   atomic64_set(>bytes_wrote, 0);
-   atomic_set(>r1_write_fp_capable, 1);
-   }
-   mod_timer(>r1_fp_hold_timer,
-jiffies + MEGASAS_RAID1_FAST_PATH_STATUS_CHECK_INTERVAL);
-}
-
 /**
  * megasas_wait_for_outstanding -  Wait for all outstanding cmds
  * @instance:  Adapter soft state
@@ -5386,17 +5365,6 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
instance->skip_heartbeat_timer_del = 1;
}
 
-   if (instance->is_ventura) {
-   atomic64_set(>bytes_wrote, 0);
-   atomic_set(>r1_write_fp_capable, 1);
-   megasas_start_timer(instance,
-   >r1_fp_hold_timer,
-   megasas_change_r1_fp_status,
-   MEGASAS_RAID1_FAST_PATH_STATUS_CHECK_INTERVAL);
-   dev_info(>pdev->dev, "starting the 
raid 1 fp timer with interval %d\n",
-   MEGASAS_RAID1_FAST_PATH_STATUS_CHECK_INTERVAL);
-   }
-
return 0;
 
 fail_get_ld_pd_list:
@@ -6187,9 +6155,6 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state)
if (instance->requestorId && !instance->skip_heartbeat_timer_del)
del_timer_sync(>sriov_heartbeat_timer);
 
-   if (instance->is_ventura)
-   del_timer_sync(>r1_fp_hold_timer);
-
  

[PATCH v2 35/39] megaraid_sas: Increase internal command pool

2017-02-08 Thread Shivasharan S
Fix - increase internal command pool to 8.

Signed-off-by: Kashyap Desai 
Signed-off-by: Shivasharan S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas.h| 2 +-
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 508516d..42c0e1f 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1460,7 +1460,7 @@ enum FW_BOOT_CONTEXT {
  */
 #define MEGASAS_INT_CMDS   32
 #define MEGASAS_SKINNY_INT_CMDS5
-#define MEGASAS_FUSION_INTERNAL_CMDS   5
+#define MEGASAS_FUSION_INTERNAL_CMDS   8
 #define MEGASAS_FUSION_IOCTL_CMDS  3
 #define MEGASAS_MFI_IOCTL_CMDS 27
 
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index a9a6e5d..d8877c0 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -1350,7 +1350,7 @@ megasas_init_adapter_fusion(struct megasas_instance 
*instance)
fusion->last_reply_idx[i] = 0;
 
/*
-* For fusion adapters, 3 commands for IOCTL and 5 commands
+* For fusion adapters, 3 commands for IOCTL and 8 commands
 * for driver's internal DCMDs.
 */
instance->max_scsi_cmds = instance->max_fw_cmds -
-- 
2.8.3



[PATCH v2 32/39] megaraid_sas: Change build_mpt_mfi_pass_thru to return void

2017-02-08 Thread Shivasharan S
Code refactoring to build_mpt_mfi_pass_thru to return void.

Signed-off-by: Kashyap Desai 
Signed-off-by: Shivasharan S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 00e52a3..b69200b 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -3229,7 +3229,7 @@ irqreturn_t megasas_isr_fusion(int irq, void *devp)
  * mfi_cmd:megasas_cmd pointer
  *
  */
-u8
+void
 build_mpt_mfi_pass_thru(struct megasas_instance *instance,
struct megasas_cmd *mfi_cmd)
 {
@@ -3279,8 +3279,6 @@ build_mpt_mfi_pass_thru(struct megasas_instance *instance,
MPI2_IEEE_SGE_FLAGS_IOCPLBNTA_ADDR;
 
mpi25_ieee_chain->Length = cpu_to_le32(instance->max_chain_frame_sz);
-
-   return 0;
 }
 
 /**
@@ -3295,11 +3293,7 @@ build_mpt_cmd(struct megasas_instance *instance, struct 
megasas_cmd *cmd)
union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc = NULL;
u16 index;
 
-   if (build_mpt_mfi_pass_thru(instance, cmd)) {
-   dev_err(>pdev->dev, "Couldn't build MFI pass thru 
cmd\n");
-   return NULL;
-   }
-
+   build_mpt_mfi_pass_thru(instance, cmd);
index = cmd->context.smid;
 
req_desc = megasas_get_request_descriptor(instance, index - 1);
-- 
2.8.3



[PATCH v2 14/39] megaraid_sas: set residual bytes count during IO completion

2017-02-08 Thread Shivasharan S
Fixing issue of not setting residual bytes correctly.

Signed-off-by: Shivasharan S 
Signed-off-by: Kashyap Desai 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index edbecc5..4628671 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -1445,6 +1445,7 @@ map_cmd_status(struct fusion_context *fusion,
struct scsi_cmnd *scmd, u8 status, u8 ext_status,
u32 data_length, u8 *sense)
 {
+   int resid;
 
switch (status) {
 
@@ -1467,6 +1468,15 @@ map_cmd_status(struct fusion_context *fusion,
   SCSI_SENSE_BUFFERSIZE);
scmd->result |= DRIVER_SENSE << 24;
}
+
+   /*
+* If the  IO request is partially completed, then MR FW will
+* update "io_request->DataLength" field with actual number of
+* bytes transferred.Driver will set residual bytes count in
+* SCSI command structure.
+*/
+   resid = (scsi_bufflen(scmd) - data_length);
+   scsi_set_resid(scmd, resid);
break;
 
case MFI_STAT_LD_OFFLINE:
-- 
2.8.3



[PATCH v2 21/39] megaraid_sas: big endian support changes

2017-02-08 Thread Shivasharan S
Fix endiannes fixes for Ventura specific.

Signed-off-by: Shivasharan S 
Signed-off-by: Kashyap Desai 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_fp.c |  15 ++--
 drivers/scsi/megaraid/megaraid_sas_fusion.c |  70 ++---
 drivers/scsi/megaraid/megaraid_sas_fusion.h | 115 +---
 3 files changed, 122 insertions(+), 78 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c 
b/drivers/scsi/megaraid/megaraid_sas_fp.c
index 9d5d485..68582d9 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -210,7 +210,7 @@ void MR_PopulateDrvRaidMap(struct megasas_instance 
*instance)
le32_to_cpu(fw_map_dyn->desc_table_size),
le32_to_cpu(fw_map_dyn->desc_table_num_elements));
dev_dbg(>pdev->dev, "drv map %p ldCount %d\n",
-   drv_map, fw_map_dyn->ld_count);
+   drv_map, le16_to_cpu(fw_map_dyn->ld_count));
 #endif
desc_table =
(struct MR_RAID_MAP_DESC_TABLE *)((void *)fw_map_dyn + 
le32_to_cpu(fw_map_dyn->desc_table_offset));
@@ -222,7 +222,8 @@ void MR_PopulateDrvRaidMap(struct megasas_instance 
*instance)
pDrvRaidMap->ldCount = (__le16)cpu_to_le16(ld_count);
pDrvRaidMap->fpPdIoTimeoutSec =
fw_map_dyn->fp_pd_io_timeout_sec;
-   pDrvRaidMap->totalSize = sizeof(struct MR_DRV_RAID_MAP_ALL);
+   pDrvRaidMap->totalSize =
+   cpu_to_le32(sizeof(struct MR_DRV_RAID_MAP_ALL));
/* point to actual data starting point*/
raid_map_data = (void *)fw_map_dyn +
le32_to_cpu(fw_map_dyn->desc_table_offset) +
@@ -234,11 +235,11 @@ void MR_PopulateDrvRaidMap(struct megasas_instance 
*instance)
dev_dbg(>pdev->dev, "desc table %p\n",
desc_table);
dev_dbg(>pdev->dev, "raidmap type %d, 
raidmapOffset 0x%x\n",
-   desc_table->raid_map_desc_type,
-   desc_table->raid_map_desc_offset);
+   le32_to_cpu(desc_table->raid_map_desc_type),
+   le32_to_cpu(desc_table->raid_map_desc_offset));
dev_dbg(>pdev->dev, "raid map number of 
elements 0%x, raidmapsize 0x%x\n",
-   desc_table->raid_map_desc_elements,
-   desc_table->raid_map_desc_buffer_size);
+   le32_to_cpu(desc_table->raid_map_desc_elements),
+   
le32_to_cpu(desc_table->raid_map_desc_buffer_size));
 #endif
switch (le32_to_cpu(desc_table->raid_map_desc_type)) {
case RAID_MAP_DESC_TYPE_DEVHDL_INFO:
@@ -263,7 +264,7 @@ void MR_PopulateDrvRaidMap(struct megasas_instance 
*instance)
 #endif
for (j = 0; j < 
le32_to_cpu(desc_table->raid_map_desc_elements); j++) {
pDrvRaidMap->ldTgtIdToLd[j] =
-   fw_map_dyn->ld_tgt_id_to_ld[j];
+   
le16_to_cpu(fw_map_dyn->ld_tgt_id_to_ld[j]);
 #if VD_EXT_DEBUG
dev_dbg(>pdev->dev, " %d drv 
ldTgtIdToLd %d\n",
j, pDrvRaidMap->ldTgtIdToLd[j]);
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index b26ee85..f8b4898 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -2080,7 +2080,7 @@ static void megasas_stream_detect(struct megasas_instance 
*instance,
 */
continue;
 
-   cmd->io_request->RaidContext.raid_context_g35.stream_detected = 
true;
+   
SET_STREAM_DETECTED(cmd->io_request->RaidContext.raid_context_g35);
current_sd->next_seq_lba =
io_info->ldStartBlock + io_info->numBlocks;
/*
@@ -2154,7 +2154,8 @@ megasas_set_raidflag_cpu_affinity(union 
RAID_CONTEXT_UNION *praid_context,
/* Fast path cache by pass capable R0/R1 VD */
if ((raid->level <= 1) &&
(raid->capability.fp_cache_bypass_capable)) {
-   rctx_g35->routing_flags.bits.sld = 1;
+   rctx_g35->routing_flags |=
+   (1 << 
MR_RAID_CTX_ROUTINGFLAGS_SLD_SHIFT);
rctx_g35->raid_flags =
(MR_RAID_FLAGS_IO_SUB_TYPE_CACHE_BYPASS

[PATCH v2 26/39] megaraid_sas: update can_queue only if the new value is less

2017-02-08 Thread Shivasharan S
Minor Optimization: No need to update HBA can_queue value
if the current max FW commands is equal to earlier value.

Signed-off-by: Kashyap Desai 
Signed-off-by: Shivasharan S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index b8591de..02a23d9 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -259,7 +259,7 @@ megasas_fusion_update_can_queue(struct megasas_instance 
*instance, int fw_boot_c
 
if (fw_boot_context == OCR_CONTEXT) {
cur_max_fw_cmds = cur_max_fw_cmds - 1;
-   if (cur_max_fw_cmds <= instance->max_fw_cmds) {
+   if (cur_max_fw_cmds < instance->max_fw_cmds) {
instance->cur_can_queue =
cur_max_fw_cmds - (MEGASAS_FUSION_INTERNAL_CMDS 
+
MEGASAS_FUSION_IOCTL_CMDS);
-- 
2.8.3



[PATCH v2 37/39] megaraid_sas: Indentation and smatch warning fixes

2017-02-08 Thread Shivasharan S
Fix indentation issues and smatch warning reported by Dan Carpenter
for previous series as discussed below.
http://www.spinics.net/lists/linux-scsi/msg103635.html
http://www.spinics.net/lists/linux-scsi/msg103603.html

Reported-by: Dan Carpenter 
Signed-off-by: Kashyap Desai 
Signed-off-by: Sasikumar Chandrasekaran 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas.h|  2 +-
 drivers/scsi/megaraid/megaraid_sas_base.c   | 10 ++--
 drivers/scsi/megaraid/megaraid_sas_fp.c | 57 +-
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 92 ++---
 drivers/scsi/megaraid/megaraid_sas_fusion.h |  2 +-
 5 files changed, 80 insertions(+), 83 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index dc331e8..8c06cbf 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1376,7 +1376,7 @@ struct megasas_ctrl_info {
u16 reserved:8;
#endif
} adapter_operations4;
-   u8 pad[0x800-0x7FE]; /* 0x7FE pad to 2K for expansion */
+   u8 pad[0x800 - 0x7FE]; /* 0x7FE pad to 2K for expansion */
 } __packed;
 
 /*
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 5e0dea1..dc9f42e 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -5343,14 +5343,14 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS);
 
/* stream detection initialization */
-   if (instance->is_ventura) {
+   if (instance->is_ventura && fusion) {
fusion->stream_detect_by_ld =
-   kzalloc(sizeof(struct LD_STREAM_DETECT *)
-   * MAX_LOGICAL_DRIVES_EXT,
-   GFP_KERNEL);
+   kzalloc(sizeof(struct LD_STREAM_DETECT *)
+   * MAX_LOGICAL_DRIVES_EXT,
+   GFP_KERNEL);
if (!fusion->stream_detect_by_ld) {
dev_err(>pdev->dev,
-   "unable to allocate stream detection 
for pool of LDs\n");
+   "unable to allocate stream detection for pool 
of LDs\n");
goto fail_get_ld_pd_list;
}
for (i = 0; i < MAX_LOGICAL_DRIVES_EXT; ++i) {
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c 
b/drivers/scsi/megaraid/megaraid_sas_fp.c
index 7dc7708..62affa7 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -197,7 +197,7 @@ void MR_PopulateDrvRaidMap(struct megasas_instance 
*instance)
 
memset(drv_map, 0, fusion->drv_map_sz);
memset(pDrvRaidMap->ldTgtIdToLd,
-   0xff, (sizeof(u16) * MAX_LOGICAL_DRIVES_DYN));
+  0xff, (sizeof(u16) * MAX_LOGICAL_DRIVES_DYN));
 
if (instance->max_raid_mapsize) {
fw_map_dyn = fusion->ld_map[(instance->map_id & 1)];
@@ -224,34 +224,37 @@ void MR_PopulateDrvRaidMap(struct megasas_instance 
*instance)
fw_map_dyn->dev_hndl_info =
(struct MR_DEV_HANDLE_INFO *)(raid_map_data + 
le32_to_cpu(desc_table->raid_map_desc_offset));
memcpy(pDrvRaidMap->devHndlInfo,
-   fw_map_dyn->dev_hndl_info,
-   sizeof(struct MR_DEV_HANDLE_INFO) *
-   
le32_to_cpu(desc_table->raid_map_desc_elements));
+   fw_map_dyn->dev_hndl_info,
+   sizeof(struct MR_DEV_HANDLE_INFO) *
+   
le32_to_cpu(desc_table->raid_map_desc_elements));
break;
case RAID_MAP_DESC_TYPE_TGTID_INFO:
fw_map_dyn->ld_tgt_id_to_ld =
-   (u16 *) (raid_map_data +
-   le32_to_cpu(desc_table->raid_map_desc_offset));
-   for (j = 0; j < 
le32_to_cpu(desc_table->raid_map_desc_elements); j++) {
-   pDrvRaidMap->ldTgtIdToLd[j] =
-   
le16_to_cpu(fw_map_dyn->ld_tgt_id_to_ld[j]);
-   }
+   (u16 *)(raid_map_data +
+   
le32_to_cpu(desc_table->raid_map_desc_offset));
+   for (j = 0; j < 
le32_to_cpu(desc_table->raid_map_desc_elements); j++) {
+   pDrvRaidMap->ldTgtIdToLd[j] =
+   
le16_to_cpu(fw_map_dyn->ld_tgt_id_to_ld[j]);
+

[PATCH v2 25/39] megaraid_sas: Change max_cmd from u32 to u16 in all functions

2017-02-08 Thread Shivasharan S
Since maximum supported FW commands are all defined as u16, change
all local variables referring to max_cmd from u32 to u16.

Signed-off-by: Kashyap Desai 
Signed-off-by: Shivasharan S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_base.c   | 10 +-
 drivers/scsi/megaraid/megaraid_sas_fusion.c |  5 +++--
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index cd9d223..06001b4 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1549,7 +1549,7 @@ megasas_dump_pending_frames(struct megasas_instance 
*instance)
struct megasas_io_frame *ldio;
struct megasas_pthru_frame *pthru;
u32 sgcount;
-   u32 max_cmd = instance->max_fw_cmds;
+   u16 max_cmd = instance->max_fw_cmds;
 
dev_err(>pdev->dev, "[%d]: Dumping Frame Phys Address of all 
pending cmds in FW\n",instance->host->host_no);
dev_err(>pdev->dev, "[%d]: Total OS Pending cmds : 
%d\n",instance->host->host_no,atomic_read(>fw_outstanding));
@@ -3467,7 +3467,7 @@ megasas_internal_reset_defer_cmds(struct megasas_instance 
*instance)
 {
struct megasas_cmd *cmd;
int i;
-   u32 max_cmd = instance->max_fw_cmds;
+   u16 max_cmd = instance->max_fw_cmds;
u32 defer_index;
unsigned long flags;
 
@@ -3843,7 +3843,7 @@ megasas_transition_to_ready(struct megasas_instance 
*instance, int ocr)
 static void megasas_teardown_frame_pool(struct megasas_instance *instance)
 {
int i;
-   u32 max_cmd = instance->max_mfi_cmds;
+   u16 max_cmd = instance->max_mfi_cmds;
struct megasas_cmd *cmd;
 
if (!instance->frame_dma_pool)
@@ -3887,7 +3887,7 @@ static void megasas_teardown_frame_pool(struct 
megasas_instance *instance)
 static int megasas_create_frame_pool(struct megasas_instance *instance)
 {
int i;
-   u32 max_cmd;
+   u16 max_cmd;
u32 sge_sz;
u32 total_sz;
u32 frame_count;
@@ -4021,7 +4021,7 @@ int megasas_alloc_cmds(struct megasas_instance *instance)
 {
int i;
int j;
-   u32 max_cmd;
+   u16 max_cmd;
struct megasas_cmd *cmd;
struct fusion_context *fusion;
 
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index f8b4898..b8591de 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -367,7 +367,7 @@ megasas_free_cmds_fusion(struct megasas_instance *instance)
 static int megasas_create_sg_sense_fusion(struct megasas_instance *instance)
 {
int i;
-   u32 max_cmd;
+   u16 max_cmd;
struct fusion_context *fusion;
struct megasas_cmd_fusion *cmd;
 
@@ -1274,7 +1274,8 @@ megasas_init_adapter_fusion(struct megasas_instance 
*instance)
 {
struct megasas_register_set __iomem *reg_set;
struct fusion_context *fusion;
-   u32 max_cmd, scratch_pad_2;
+   u16 max_cmd;
+   u32 scratch_pad_2;
int i = 0, count;
 
fusion = instance->ctrl_context;
-- 
2.8.3



[PATCH v2 34/39] megaraid_sas: Use synchronize_irq to wait for IRQs to complete

2017-02-08 Thread Shivasharan S
FIX - Do not use random delay to synchronize with IRQ. Use kernel API.

Signed-off-by: Kashyap Desai 
Signed-off-by: Shivasharan S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 20 ++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index b69200b..a9a6e5d 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -3145,6 +3145,22 @@ complete_cmd_fusion(struct megasas_instance *instance, 
u32 MSIxIndex)
 }
 
 /**
+ * megasas_sync_irqs - Synchronizes all IRQs owned by adapter
+ * @instance:  Adapter soft state
+ */
+void megasas_sync_irqs(unsigned long instance_addr)
+{
+   u32 count, i;
+   struct megasas_instance *instance =
+   (struct megasas_instance *)instance_addr;
+
+   count = instance->msix_vectors > 0 ? instance->msix_vectors : 1;
+
+   for (i = 0; i < count; i++)
+   synchronize_irq(pci_irq_vector(instance->pdev, i));
+}
+
+/**
  * megasas_complete_cmd_dpc_fusion -   Completes command
  * @instance:  Adapter soft state
  *
@@ -3820,7 +3836,7 @@ megasas_issue_tm(struct megasas_instance *instance, u16 
device_handle,
break;
else {
instance->instancet->disable_intr(instance);
-   msleep(1000);
+   megasas_sync_irqs((unsigned long)instance);
megasas_complete_cmd_dpc_fusion
((unsigned long)instance);
instance->instancet->enable_intr(instance);
@@ -4174,7 +4190,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int 
reason)
set_bit(MEGASAS_FUSION_IN_RESET, >reset_flags);
atomic_set(>adprecovery, MEGASAS_ADPRESET_SM_POLLING);
instance->instancet->disable_intr(instance);
-   msleep(1000);
+   megasas_sync_irqs((unsigned long)instance);
 
/* First try waiting for commands to complete */
if (megasas_wait_for_outstanding_fusion(instance, reason,
-- 
2.8.3



[PATCH v2 36/39] megaraid_sas: Cleanup VD_EXT_DEBUG and SPAN_DEBUG related debug prints

2017-02-08 Thread Shivasharan S
Signed-off-by: Kashyap Desai 
Signed-off-by: Shivasharan S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas.h|   2 -
 drivers/scsi/megaraid/megaraid_sas_base.c   |  15 --
 drivers/scsi/megaraid/megaraid_sas_fp.c | 266 +---
 drivers/scsi/megaraid/megaraid_sas_fusion.c |   5 -
 4 files changed, 2 insertions(+), 286 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 42c0e1f..dc331e8 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1403,8 +1403,6 @@ struct megasas_ctrl_info {
 
 #define MEGASAS_FW_BUSY1
 
-#define VD_EXT_DEBUG 0
-
 /* Driver's internal Logging levels*/
 #define OCR_LOGS(1 << 0)
 
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 0e7121d..5e0dea1 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4601,17 +4601,6 @@ static void megasas_update_ext_vd_details(struct 
megasas_instance *instance)
}
/* irrespective of FW raid maps, driver raid map is constant */
fusion->drv_map_sz = sizeof(struct MR_DRV_RAID_MAP_ALL);
-
-#if VD_EXT_DEBUG
-   dev_info(>pdev->dev, "instance->max_raid_mapsize 0x%x\n ",
-   instance->max_raid_mapsize);
-   dev_info(>pdev->dev, "new_map_sz = 0x%x, old_map_sz = 0x%x\n",
-   fusion->new_map_sz, fusion->old_map_sz);
-   dev_info(>pdev->dev, "ventura_map_sz = 0x%x, current_map_sz = 
0x%x\n",
-   ventura_map_sz, fusion->current_map_sz);
-   dev_info(>pdev->dev, "fusion->drv_map_sz =0x%x, size of 
driver raid map 0x%lx\n",
-   fusion->drv_map_sz, sizeof(struct MR_DRV_RAID_MAP_ALL));
-#endif
 }
 
 /**
@@ -5215,10 +5204,6 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
if (instance->is_ventura) {
scratch_pad_3 =
readl(>reg_set->outbound_scratch_pad_3);
-#if VD_EXT_DEBUG
-   dev_info(>pdev->dev, "scratch_pad3 0x%x\n",
-   scratch_pad_3);
-#endif
instance->max_raid_mapsize = ((scratch_pad_3 >>
MR_MAX_RAID_MAP_SIZE_OFFSET_SHIFT) &
MR_MAX_RAID_MAP_SIZE_MASK);
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c 
b/drivers/scsi/megaraid/megaraid_sas_fp.c
index a5517e7..7dc7708 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -77,7 +77,6 @@ MODULE_PARM_DESC(lb_pending_cmds, "Change raid-1 load 
balancing outstanding "
 #endif
 #define TRUE 1
 
-#define SPAN_DEBUG 0
 #define SPAN_ROW_SIZE(map, ld, index_) (MR_LdSpanPtrGet(ld, index_, 
map)->spanRowSize)
 #define SPAN_ROW_DATA_SIZE(map_, ld, index_)   (MR_LdSpanPtrGet(ld, index_, 
map)->spanRowDataSize)
 #define SPAN_INVALID  0xff
@@ -202,16 +201,6 @@ void MR_PopulateDrvRaidMap(struct megasas_instance 
*instance)
 
if (instance->max_raid_mapsize) {
fw_map_dyn = fusion->ld_map[(instance->map_id & 1)];
-#if VD_EXT_DEBUG
-   dev_dbg(>pdev->dev, "raidMapSize 0x%x 
fw_map_dyn->descTableOffset 0x%x\n",
-   le32_to_cpu(fw_map_dyn->raid_map_size),
-   le32_to_cpu(fw_map_dyn->desc_table_offset));
-   dev_dbg(>pdev->dev, "descTableSize 0x%x 
descTableNumElements 0x%x\n",
-   le32_to_cpu(fw_map_dyn->desc_table_size),
-   le32_to_cpu(fw_map_dyn->desc_table_num_elements));
-   dev_dbg(>pdev->dev, "drv map %p ldCount %d\n",
-   drv_map, le16_to_cpu(fw_map_dyn->ld_count));
-#endif
desc_table =
(struct MR_RAID_MAP_DESC_TABLE *)((void *)fw_map_dyn + 
le32_to_cpu(fw_map_dyn->desc_table_offset));
if (desc_table != fw_map_dyn->raid_map_desc_table)
@@ -230,25 +219,10 @@ void MR_PopulateDrvRaidMap(struct megasas_instance 
*instance)
le32_to_cpu(fw_map_dyn->desc_table_size);
 
for (i = 0; i < 
le32_to_cpu(fw_map_dyn->desc_table_num_elements); ++i) {
-
-#if VD_EXT_DEBUG
-   dev_dbg(>pdev->dev, "desc table %p\n",
-   desc_table);
-   dev_dbg(>pdev->dev, "raidmap type %d, 
raidmapOffset 0x%x\n",
-   le32_to_cpu(desc_table->raid_map_desc_type),
-   le32_to_cpu(desc_table->raid_map_desc_offset));
-   dev_dbg(>pdev->dev, "raid map number of 
elements 0%x, raidmapsize 0x%x\n",
-   le32_to_cpu(desc_table->raid_map_desc_elements),
-   
le32_to_cpu(desc_table->raid_map_desc_buffer_size));
-#endif
   

[PATCH v2 05/39] megaraid_sas: Refactor MEGASAS_IS_LOGICAL macro using sdev

2017-02-08 Thread Shivasharan S
Signed-off-by: Shivasharan S 
Signed-off-by: Kashyap Desai 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas.h|  4 ++--
 drivers/scsi/megaraid/megaraid_sas_base.c   | 20 ++--
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 12 ++--
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index f5c4742..dff877f 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -2301,8 +2301,8 @@ struct megasas_instance_template {
struct megasas_cmd *cmd);
 };
 
-#define MEGASAS_IS_LOGICAL(scp)
\
-   ((scp->device->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1)
+#define MEGASAS_IS_LOGICAL(sdev)   \
+   ((sdev->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1)
 
 #define MEGASAS_DEV_INDEX(scp) \
(((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) +   \
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 3ed876a..6ca49ef 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1279,7 +1279,7 @@ megasas_build_dcdb(struct megasas_instance *instance, 
struct scsi_cmnd *scp,
u16 flags = 0;
struct megasas_pthru_frame *pthru;
 
-   is_logical = MEGASAS_IS_LOGICAL(scp);
+   is_logical = MEGASAS_IS_LOGICAL(scp->device);
device_id = MEGASAS_DEV_INDEX(scp);
pthru = (struct megasas_pthru_frame *)cmd->frame;
 
@@ -1519,11 +1519,11 @@ inline int megasas_cmd_type(struct scsi_cmnd *cmd)
case WRITE_6:
case READ_16:
case WRITE_16:
-   ret = (MEGASAS_IS_LOGICAL(cmd)) ?
+   ret = (MEGASAS_IS_LOGICAL(cmd->device)) ?
READ_WRITE_LDIO : READ_WRITE_SYSPDIO;
break;
default:
-   ret = (MEGASAS_IS_LOGICAL(cmd)) ?
+   ret = (MEGASAS_IS_LOGICAL(cmd->device)) ?
NON_READ_WRITE_LDIO : NON_READ_WRITE_SYSPDIO;
}
return ret;
@@ -1699,15 +1699,16 @@ megasas_queue_command(struct Scsi_Host *shost, struct 
scsi_cmnd *scmd)
 
scmd->result = 0;
 
-   if (MEGASAS_IS_LOGICAL(scmd) &&
+   if (MEGASAS_IS_LOGICAL(scmd->device) &&
(scmd->device->id >= instance->fw_supported_vd_count ||
scmd->device->lun)) {
scmd->result = DID_BAD_TARGET << 16;
goto out_done;
}
 
-   if ((scmd->cmnd[0] == SYNCHRONIZE_CACHE) && MEGASAS_IS_LOGICAL(scmd) &&
-   (!instance->fw_sync_cache_support)) {
+   if ((scmd->cmnd[0] == SYNCHRONIZE_CACHE) &&
+   MEGASAS_IS_LOGICAL(scmd->device) &&
+   (!instance->fw_sync_cache_support)) {
scmd->result = DID_OK << 16;
goto out_done;
}
@@ -1758,7 +1759,7 @@ void megasas_update_sdev_properties(struct scsi_device 
*sdev)
if (!fusion)
return;
 
-   if (sdev->channel < MEGASAS_MAX_PD_CHANNELS &&
+   if (!MEGASAS_IS_LOGICAL(sdev) &&
instance->use_seqnum_jbod_fp) {
pd_index = (sdev->channel * MEGASAS_MAX_DEV_PER_CHANNEL) +
sdev->id;
@@ -1826,8 +1827,7 @@ static int megasas_slave_configure(struct scsi_device 
*sdev)
 
instance = megasas_lookup_instance(sdev->host->host_no);
if (instance->pd_list_not_supported) {
-   if (sdev->channel < MEGASAS_MAX_PD_CHANNELS &&
-   sdev->type == TYPE_DISK) {
+   if (!MEGASAS_IS_LOGICAL(sdev) && sdev->type == TYPE_DISK) {
pd_index = (sdev->channel * 
MEGASAS_MAX_DEV_PER_CHANNEL) +
sdev->id;
if (instance->pd_list[pd_index].driveState !=
@@ -1854,7 +1854,7 @@ static int megasas_slave_alloc(struct scsi_device *sdev)
struct MR_PRIV_DEVICE *mr_device_priv_data;
 
instance = megasas_lookup_instance(sdev->host->host_no);
-   if (sdev->channel < MEGASAS_MAX_PD_CHANNELS) {
+   if (!MEGASAS_IS_LOGICAL(sdev)) {
/*
 * Open the OS scan to the SYSTEM PD
 */
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 24b72c5..675afc9 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -3581,13 +3581,13 @@ static u16 megasas_get_tm_devhandle(struct scsi_device 
*sdev)
instance = (struct megasas_instance *)sdev->host->hostdata;
fusion = instance->ctrl_context;
 
-   if (sdev->channel < 

[PATCH v2 31/39] megaraid_sas: During OCR, if get_ctrl_info fails do not continue with OCR

2017-02-08 Thread Shivasharan S
Error handling: If controller reset is not able to
recover, kill HBA and quit immediately.

Signed-off-by: Kashyap Desai 
Signed-off-by: Shivasharan S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 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 207df1e..00e52a3 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -4285,6 +4285,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int 
reason)
__func__, __LINE__);
megaraid_sas_kill_hba(instance);
retval = FAILED;
+   goto out;
}
/* Reset load balance info */
if (fusion->load_balance_info)
-- 
2.8.3



[PATCH v2 18/39] megaraid_sas: In validate raid map, raid capability is not converted to cpu format for all lds

2017-02-08 Thread Shivasharan S
On a host, if an ld is deleted there is a hole in the ld array returned
by the FW. But in MR_ValidateMapInfo we are not accounting for holes in
the ld array and traverse only upto index num_lds.
This patch takes care of converting the capability field of all the
valid lds in the ld raid map.

Signed-off-by: Shivasharan S 
Signed-off-by: Kashyap Desai 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_fp.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c 
b/drivers/scsi/megaraid/megaraid_sas_fp.c
index d9b0f28..a0b0e68 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -452,7 +452,7 @@ u8 MR_ValidateMapInfo(struct megasas_instance *instance)
struct LD_LOAD_BALANCE_INFO *lbInfo;
PLD_SPAN_INFO ldSpanInfo;
struct MR_LD_RAID *raid;
-   u16 ldCount, num_lds;
+   u16 num_lds, i;
u16 ld;
u32 expected_size;
 
@@ -495,10 +495,17 @@ u8 MR_ValidateMapInfo(struct megasas_instance *instance)
num_lds = le16_to_cpu(drv_map->raidMap.ldCount);
 
/*Convert Raid capability values to CPU arch */
-   for (ldCount = 0; ldCount < num_lds; ldCount++) {
-   ld = MR_TargetIdToLdGet(ldCount, drv_map);
+   for (i = 0; (num_lds > 0) && (i < MAX_LOGICAL_DRIVES_EXT); i++) {
+   ld = MR_TargetIdToLdGet(i, drv_map);
+
+   /* For non existing VDs, iterate to next VD*/
+   if (ld >= (MAX_LOGICAL_DRIVES_EXT - 1))
+   continue;
+
raid = MR_LdRaidGet(ld, drv_map);
le32_to_cpus((u32 *)>capability);
+
+   num_lds--;
}
 
return 1;
-- 
2.8.3



[PATCH v2 23/39] megaraid_sas: latest controller OCR capability from FW before sending shutdown DCMD

2017-02-08 Thread Shivasharan S
Fetch the latest controller OCR capability from FW before
sending MR_DCMD_CTRL_SHUTDOWN
When application sends a shutdown DCMD (MR_DCMD_CTRL_SHUTDOWN),
driver will fetch latest controller information from firmware.
This is to ensure that driver always has latest OCR capability
of controller before sending the DCMD.

Signed-off-by: Kashyap Desai 
Signed-off-by: Shivasharan S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 5d7aa05..cd9d223 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -6900,6 +6900,13 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance,
   MFI_FRAME_SGL64 |
   MFI_FRAME_SENSE64));
 
+   if (cmd->frame->dcmd.opcode == MR_DCMD_CTRL_SHUTDOWN) {
+   if (megasas_get_ctrl_info(instance) != DCMD_SUCCESS) {
+   megasas_return_cmd(instance, cmd);
+   return -1;
+   }
+   }
+
if (cmd->frame->dcmd.opcode == MR_DRIVER_SET_APP_CRASHDUMP_MODE) {
error = megasas_set_crash_dump_params_ioctl(cmd);
megasas_return_cmd(instance, cmd);
-- 
2.8.3



[PATCH v2 22/39] megaraid_sas: avoid unaligned access in ioctl path

2017-02-08 Thread Shivasharan S
Fix kernel warning for accessing unaligned memory access in driver.

Signed-off-by: Shivasharan S 
Signed-off-by: Kashyap Desai 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index b2da257..5d7aa05 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -43,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -7007,7 +7008,8 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance,
sense_ptr = (unsigned long *) ((unsigned long)ioc->frame.raw +
ioc->sense_off);
 
-   if (copy_to_user((void __user *)((unsigned long)(*sense_ptr)),
+   if (copy_to_user((void __user *)((unsigned long)
+get_unaligned((unsigned long *)sense_ptr)),
 sense, ioc->sense_len)) {
dev_err(>pdev->dev, "Failed to copy out to 
user "
"sense data\n");
-- 
2.8.3



[PATCH v2 15/39] megaraid_sas: enhance debug logs in OCR context

2017-02-08 Thread Shivasharan S
Add additional logging from driver in OCR context.
Add debug logs for partial completion of IOs is iodone context.

Signed-off-by: Shivasharan S 
Signed-off-by: Kashyap Desai 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas.h|  3 +++
 drivers/scsi/megaraid/megaraid_sas_base.c   | 38 ++---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 35 +-
 3 files changed, 72 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index bed8a37..93da6dc 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1405,6 +1405,9 @@ struct megasas_ctrl_info {
 
 #define VD_EXT_DEBUG 0
 
+/* Driver's internal Logging levels*/
+#define OCR_LOGS(1 << 0)
+
 #define SCAN_PD_CHANNEL0x1
 #define SCAN_VD_CHANNEL0x2
 
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 51b35a6..b41bbea 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -2742,6 +2742,24 @@ blk_eh_timer_return megasas_reset_timer(struct scsi_cmnd 
*scmd)
 }
 
 /**
+ * megasas_dump_frame -This function will dump MPT/MFI frame
+ */
+static inline void
+megasas_dump_frame(void *mpi_request, int sz)
+{
+   int i;
+   __le32 *mfp = (__le32 *)mpi_request;
+
+   printk(KERN_INFO "IO request frame:\n\t");
+   for (i = 0; i < sz; i++) {
+   if (i && ((i % 8) == 0))
+   printk("\n\t");
+   printk("%08x ", le32_to_cpu(mfp[i]));
+   }
+   printk("\n");
+}
+
+/**
  * megasas_reset_bus_host -Bus & host reset handler entry point
  */
 static int megasas_reset_bus_host(struct scsi_cmnd *scmd)
@@ -2751,12 +2769,26 @@ static int megasas_reset_bus_host(struct scsi_cmnd 
*scmd)
 
instance = (struct megasas_instance *)scmd->device->host->hostdata;
 
+   scmd_printk(KERN_INFO, scmd,
+   "Controller reset is requested due to IO timeout\n"
+   "SCSI command pointer: (%p)\t SCSI host state: %d\t"
+   " SCSI host busy: %d\t FW outstanding: %d\n",
+   scmd, scmd->device->host->shost_state,
+   atomic_read((atomic_t *)>device->host->host_busy),
+   atomic_read(>fw_outstanding));
+
/*
 * First wait for all commands to complete
 */
-   if (instance->ctrl_context)
-   ret = megasas_reset_fusion(scmd->device->host, 1);
-   else
+   if (instance->ctrl_context) {
+   struct megasas_cmd_fusion *cmd;
+   cmd = (struct megasas_cmd_fusion *)scmd->SCp.ptr;
+   if (cmd)
+   megasas_dump_frame(cmd->io_request,
+   sizeof(struct MPI2_RAID_SCSI_IO_REQUEST));
+   ret = megasas_reset_fusion(scmd->device->host,
+   SCSIIO_TIMEOUT_OCR);
+   } else
ret = megasas_generic_reset(scmd);
 
return ret;
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 4628671..1252a3c 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -1445,8 +1445,10 @@ map_cmd_status(struct fusion_context *fusion,
struct scsi_cmnd *scmd, u8 status, u8 ext_status,
u32 data_length, u8 *sense)
 {
+   u8 cmd_type;
int resid;
 
+   cmd_type = megasas_cmd_type(scmd);
switch (status) {
 
case MFI_STAT_OK:
@@ -1477,6 +1479,13 @@ map_cmd_status(struct fusion_context *fusion,
 */
resid = (scsi_bufflen(scmd) - data_length);
scsi_set_resid(scmd, resid);
+
+   if (resid &&
+   ((cmd_type == READ_WRITE_LDIO) ||
+   (cmd_type == READ_WRITE_SYSPDIO)))
+   scmd_printk(KERN_INFO, scmd, "BRCM Debug mfi stat 0x%x, 
data len"
+   " requested/completed 0x%x/0x%x\n",
+   status, scsi_bufflen(scmd), data_length);
break;
 
case MFI_STAT_LD_OFFLINE:
@@ -3477,6 +3486,14 @@ int megasas_wait_for_outstanding_fusion(struct 
megasas_instance *instance,
   " will reset adapter scsi%d.\n",
instance->host->host_no);
megasas_complete_cmd_dpc_fusion((unsigned 
long)instance);
+   if (instance->requestorId && reason) {
+   dev_warn(>pdev->dev, "SR-IOV Found FW 
in FAULT"
+   " state while polling during"
+   " I/O timeout handling for %d\n",

[PATCH v2 30/39] megaraid_sas: Do not set fp_possible if TM capable for non-RW syspdIO, change fp_possible to bool

2017-02-08 Thread Shivasharan S
FIX - firmware wants non-RW SYS PD IOs to avoid FastPath for
better tracking and other functionalities if the device
is task management capable.

Signed-off-by: Kashyap Desai 
Signed-off-by: Shivasharan S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 04a4c43..207df1e 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -2566,7 +2566,8 @@ static void megasas_build_ld_nonrw_fusion(struct 
megasas_instance *instance,
  */
 static void
 megasas_build_syspd_fusion(struct megasas_instance *instance,
-   struct scsi_cmnd *scmd, struct megasas_cmd_fusion *cmd, u8 fp_possible)
+   struct scsi_cmnd *scmd, struct megasas_cmd_fusion *cmd,
+   bool fp_possible)
 {
u32 device_id;
struct MPI2_RAID_SCSI_IO_REQUEST *io_request;
@@ -2687,6 +2688,8 @@ megasas_build_io_fusion(struct megasas_instance *instance,
int sge_count;
u8  cmd_type;
struct MPI2_RAID_SCSI_IO_REQUEST *io_request = cmd->io_request;
+   struct MR_PRIV_DEVICE *mr_device_priv_data;
+   mr_device_priv_data = scp->device->hostdata;
 
/* Zero out some fields so they don't get reused */
memset(io_request->LUN, 0x0, 8);
@@ -2715,12 +2718,14 @@ megasas_build_io_fusion(struct megasas_instance 
*instance,
megasas_build_ld_nonrw_fusion(instance, scp, cmd);
break;
case READ_WRITE_SYSPDIO:
+   megasas_build_syspd_fusion(instance, scp, cmd, true);
+   break;
case NON_READ_WRITE_SYSPDIO:
-   if (instance->secure_jbod_support &&
-   (cmd_type == NON_READ_WRITE_SYSPDIO))
-   megasas_build_syspd_fusion(instance, scp, cmd, 0);
+   if (instance->secure_jbod_support ||
+   mr_device_priv_data->is_tm_capable)
+   megasas_build_syspd_fusion(instance, scp, cmd, false);
else
-   megasas_build_syspd_fusion(instance, scp, cmd, 1);
+   megasas_build_syspd_fusion(instance, scp, cmd, true);
break;
default:
break;
-- 
2.8.3



[PATCH v2 29/39] megaraid_sas: Remove unused pd_index from megasas_build_ld_nonrw_fusion

2017-02-08 Thread Shivasharan S
Signed-off-by: Kashyap Desai 
Signed-off-by: Shivasharan S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 9e2a289..04a4c43 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -2480,7 +2480,7 @@ static void megasas_build_ld_nonrw_fusion(struct 
megasas_instance *instance,
 {
u32 device_id;
struct MPI2_RAID_SCSI_IO_REQUEST *io_request;
-   u16 pd_index = 0, ld;
+   u16 ld;
struct MR_DRV_RAID_MAP_ALL *local_map_ptr;
struct fusion_context *fusion = instance->ctrl_context;
u8  span, physArm;
@@ -2492,7 +2492,6 @@ static void megasas_build_ld_nonrw_fusion(struct 
megasas_instance *instance,
 
io_request = cmd->io_request;
device_id = MEGASAS_DEV_INDEX(scmd);
-   pd_index = MEGASAS_PD_INDEX(scmd);
local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)];
io_request->DataLength = cpu_to_le32(scsi_bufflen(scmd));
/* get RAID_Context pointer */
-- 
2.8.3



[PATCH v2 17/39] megaraid_sas: reduce size of fusion_context and use vmalloc if kmalloc fails

2017-02-08 Thread Shivasharan S
Currently fusion context has fixed array load_balance_info. Use dynamic 
allocation.
In few places, driver do not want physically contigious memory.
Attempt to use vmalloc if physical contiguous memory is not available.

Signed-off-by: Shivasharan S 
Signed-off-by: Kashyap Desai 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas.h|  2 +
 drivers/scsi/megaraid/megaraid_sas_base.c   | 15 ++
 drivers/scsi/megaraid/megaraid_sas_fp.c |  3 +-
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 71 +++--
 drivers/scsi/megaraid/megaraid_sas_fusion.h |  3 +-
 5 files changed, 76 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 93da6dc..0a20fff 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -2488,4 +2488,6 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int 
reason);
 int megasas_task_abort_fusion(struct scsi_cmnd *scmd);
 int megasas_reset_target_fusion(struct scsi_cmnd *scmd);
 u32 mega_mod64(u64 dividend, u32 divisor);
+int megasas_alloc_fusion_context(struct megasas_instance *instance);
+void megasas_free_fusion_context(struct megasas_instance *instance);
 #endif /*LSI_MEGARAID_SAS_H */
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index c8fa480..b2da257 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -6029,18 +6029,12 @@ static int megasas_probe_one(struct pci_dev *pdev,
case PCI_DEVICE_ID_LSI_CUTLASS_52:
case PCI_DEVICE_ID_LSI_CUTLASS_53:
{
-   instance->ctrl_context_pages =
-   get_order(sizeof(struct fusion_context));
-   instance->ctrl_context = (void *)__get_free_pages(GFP_KERNEL,
-   instance->ctrl_context_pages);
-   if (!instance->ctrl_context) {
-   dev_printk(KERN_DEBUG, >dev, "Failed to allocate "
-  "memory for Fusion context info\n");
+   if (megasas_alloc_fusion_context(instance)) {
+   megasas_free_fusion_context(instance);
goto fail_alloc_dma_buf;
}
fusion = instance->ctrl_context;
-   memset(fusion, 0,
-   ((1 << PAGE_SHIFT) << instance->ctrl_context_pages));
+
if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) ||
(instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA))
fusion->adapter_type = THUNDERBOLT_SERIES;
@@ -6683,8 +6677,7 @@ static void megasas_detach_one(struct pci_dev *pdev)
fusion->pd_seq_sync[i],
fusion->pd_seq_phys[i]);
}
-   free_pages((ulong)instance->ctrl_context,
-   instance->ctrl_context_pages);
+   megasas_free_fusion_context(instance);
} else {
megasas_release_mfi(instance);
pci_free_consistent(pdev, sizeof(u32),
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c 
b/drivers/scsi/megaraid/megaraid_sas_fp.c
index c3ef82d..d9b0f28 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -489,7 +489,8 @@ u8 MR_ValidateMapInfo(struct megasas_instance *instance)
if (instance->UnevenSpanSupport)
mr_update_span_set(drv_map, ldSpanInfo);
 
-   mr_update_load_balance_params(drv_map, lbInfo);
+   if (lbInfo)
+   mr_update_load_balance_params(drv_map, lbInfo);
 
num_lds = le16_to_cpu(drv_map->raidMap.ldCount);
 
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 1252a3c..9019b82 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -2397,8 +2398,9 @@ megasas_build_ldio_fusion(struct megasas_instance 
*instance,
io_request->IoFlags |=
cpu_to_le16(MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH);
}
-   if ((fusion->load_balance_info[device_id].loadBalanceFlag) &&
-   (io_info.isRead)) {
+   if (fusion->load_balance_info &&
+   (fusion->load_balance_info[device_id].loadBalanceFlag) 
&&
+   (io_info.isRead)) {
io_info.devHandle =
get_updated_dev_handle(instance,
>load_balance_info[device_id],
@@ -4270,9 

[PATCH v2 20/39] megaraid_sas: Big endian RDPQ mode fix

2017-02-08 Thread Shivasharan S
Fix if RDPQ mode enabled MR FW is deployed on big endian host machine,
driver does not setup reply address correctly.

Signed-off-by: Shivasharan S 
Signed-off-by: Kashyap Desai 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 4aaf307..b26ee85 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -580,7 +580,7 @@ megasas_alloc_rdpq_fusion(struct megasas_instance *instance)
}
 
fusion->rdpq_virt[i].RDPQBaseAddress =
-   fusion->reply_frames_desc_phys[i];
+   cpu_to_le64(fusion->reply_frames_desc_phys[i]);
 
reply_desc = fusion->reply_frames_desc[i];
for (j = 0; j < fusion->reply_q_depth; j++, reply_desc++)
-- 
2.8.3



[PATCH v2 19/39] megaraid_sas: MR_TargetIdToLdGet u8 to u16 and avoid invalid raid-map access

2017-02-08 Thread Shivasharan S
fix in v2 - updated description content.
Change MR_TargetIdToLdGet return type from u8 to u16.

ld id range check is added at two places in this patch - 
@megasas_build_ldio_fusion and @megasas_build_ld_nonrw_fusion.
Previous driver code used different data type for lds TargetId returned from 
MR_TargetIdToLdGet.
Prior to this change, above two functions was safeguarded due to function 
always return u8
and maximum value of ld id returned was 255.

In below check, fw_supported_vd_count as of today is 64 or 256 and
valid range  to support is either 0-63 or 0-255. Ideally want to filter 
accessing
raid map for ld ids which are not valid. With the u16 change, invalid ld id 
value
is 0x and we will see kernel panic due to random memory access in 
MR_LdRaidGet.
The changes will ensure we do not call MR_LdRaidGet if ld id is beyond size of 
ldSpanMap array.

   if (ld < instance->fw_supported_vd_count)

>From firmware perspective,ld id 0xFF is invalid and even though current driver
code forward such command, firmware fails with target not available.

ld target id issue occurs mainly whenever driver loops to populate raid map 
(ea. MR_ValidateMapInfo).
These are the only two places where we may see out of range target ids and 
wants to
protect raid map access based on range provided by Firmware API.


Signed-off-by: Shivasharan S 
Signed-off-by: Kashyap Desai 
---
 drivers/scsi/megaraid/megaraid_sas.h|  2 +-
 drivers/scsi/megaraid/megaraid_sas_fp.c |  5 +++--
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 25 ++---
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 0a20fff..efc01a3 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -2448,7 +2448,7 @@ MR_BuildRaidContext(struct megasas_instance *instance,
struct IO_REQUEST_INFO *io_info,
struct RAID_CONTEXT *pRAID_Context,
struct MR_DRV_RAID_MAP_ALL *map, u8 **raidLUN);
-u8 MR_TargetIdToLdGet(u32 ldTgtId, struct MR_DRV_RAID_MAP_ALL *map);
+u16 MR_TargetIdToLdGet(u32 ldTgtId, struct MR_DRV_RAID_MAP_ALL *map);
 struct MR_LD_RAID *MR_LdRaidGet(u32 ld, struct MR_DRV_RAID_MAP_ALL *map);
 u16 MR_ArPdGet(u32 ar, u32 arm, struct MR_DRV_RAID_MAP_ALL *map);
 u16 MR_LdSpanArrayGet(u32 ld, u32 span, struct MR_DRV_RAID_MAP_ALL *map);
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c 
b/drivers/scsi/megaraid/megaraid_sas_fp.c
index a0b0e68..9d5d485 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -165,7 +165,7 @@ u16 MR_GetLDTgtId(u32 ld, struct MR_DRV_RAID_MAP_ALL *map)
return le16_to_cpu(map->raidMap.ldSpanMap[ld].ldRaid.targetId);
 }
 
-u8 MR_TargetIdToLdGet(u32 ldTgtId, struct MR_DRV_RAID_MAP_ALL *map)
+u16 MR_TargetIdToLdGet(u32 ldTgtId, struct MR_DRV_RAID_MAP_ALL *map)
 {
return map->raidMap.ldTgtIdToLd[ldTgtId];
 }
@@ -1151,7 +1151,7 @@ MR_BuildRaidContext(struct megasas_instance *instance,
 {
struct fusion_context *fusion;
struct MR_LD_RAID  *raid;
-   u32 ld, stripSize, stripe_mask;
+   u32 stripSize, stripe_mask;
u64 endLba, endStrip, endRow, start_row, start_strip;
u64 regStart;
u32 regSize;
@@ -1163,6 +1163,7 @@ MR_BuildRaidContext(struct megasas_instance *instance,
u8  retval = 0;
u8  startlba_span = SPAN_INVALID;
u64 *pdBlock = _info->pdBlock;
+   u16 ld;
 
ldStartBlock = io_info->ldStartBlock;
numBlocks = io_info->numBlocks;
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 9019b82..4aaf307 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -1121,7 +1121,8 @@ megasas_sync_map_info(struct megasas_instance *instance)
int i;
struct megasas_cmd *cmd;
struct megasas_dcmd_frame *dcmd;
-   u32 size_sync_info, num_lds;
+   u16 num_lds;
+   u32 size_sync_info;
struct fusion_context *fusion;
struct MR_LD_TARGET_SYNC *ci = NULL;
struct MR_DRV_RAID_MAP_ALL *map;
@@ -1870,7 +1871,7 @@ megasas_set_pd_lba(struct MPI2_RAID_SCSI_IO_REQUEST 
*io_request, u8 cdb_len,
   struct MR_DRV_RAID_MAP_ALL *local_map_ptr, u32 ref_tag)
 {
struct MR_LD_RAID *raid;
-   u32 ld;
+   u16 ld;
u64 start_blk = io_info->pdBlock;
u8 *cdb = io_request->CDB.CDB32;
u32 num_blocks = io_info->numBlocks;
@@ -2303,10 +2304,11 @@ megasas_build_ldio_fusion(struct megasas_instance 
*instance,
 
local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)];
ld = MR_TargetIdToLdGet(device_id, local_map_ptr);
-   raid = 

[PATCH v2 13/39] megaraid_sas: raid 1 write performance for large io

2017-02-08 Thread Shivasharan S
Avoid Host side PCI bandwidth bottleneck and hint FW to do Write buffering using
RaidFlag MR_RAID_FLAGS_IO_SUB_TYPE_LDIO_BW_LIMIT.
Once IO is landed in FW with MR_RAID_FLAGS_IO_SUB_TYPE_LDIO_BW_LIMIT,
it will do single DMA from host and buffer the Write operation. On back end,
FW will DMA same buffer to the Mirror and Data Arm.
This will improve large block IO performance which bottleneck due to Host side 
PCI bandwidth limitation.

Consistent ~4000MB T.P for 256K Block size is expected performance numbers.
IOPS for small Block size should be on par with Disk performance.
(E.g 42 SAS Disk in JBOD mode gives 3700MB T.P.
Same Drive used in R1 WT mode, should give ~1800MB T.P)

Using this patch 24 R1 VDs (HDD) gives below performance for Sequential Write.
Without this patch, we cannot reach above 3200MB (Throughput is in MB. )

Block Size  50% 256K and 50% 4K  100% 256K
4K 31002030
8K 31402740
16K31403140
32K34003240
64K35003700
128K   38703870
256K   39203920

Signed-off-by: Shivasharan S 
Signed-off-by: Kashyap Desai 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas.h|  5 +
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 32 +++--
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 075e2e9..bed8a37 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1409,6 +1409,8 @@ struct megasas_ctrl_info {
 #define SCAN_VD_CHANNEL0x2
 
 #define MEGASAS_KDUMP_QUEUE_DEPTH   100
+#define MR_LARGE_IO_MIN_SIZE   (32 * 1024)
+#define MR_R1_LDIO_PIGGYBACK_DEFAULT   4
 
 enum MR_SCSI_CMD_TYPE {
READ_WRITE_LDIO = 0,
@@ -1875,6 +1877,7 @@ union megasas_frame {
 struct MR_PRIV_DEVICE {
bool is_tm_capable;
bool tm_busy;
+   atomic_t r1_ldio_hint;
u8   interface_type;
 };
 struct megasas_cmd;
@@ -2235,6 +2238,8 @@ struct megasas_instance {
bool is_ventura;
bool msix_combined;
u16 max_raid_mapsize;
+   /* preffered count to send as LDIO irrspective of FP capable.*/
+   u8  r1_ldio_hint_default;
u32 nvme_page_size;
 };
 struct MR_LD_VF_MAP {
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 379c723..edbecc5 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -1383,6 +1383,7 @@ megasas_init_adapter_fusion(struct megasas_instance 
*instance)
}
 
instance->flag_ieee = 1;
+   instance->r1_ldio_hint_default =  MR_R1_LDIO_PIGGYBACK_DEFAULT;
fusion->fast_path_io = 0;
 
fusion->drv_map_pages = get_order(fusion->drv_map_sz);
@@ -2110,7 +2111,7 @@ static void megasas_stream_detect(struct megasas_instance 
*instance,
 static void
 megasas_set_raidflag_cpu_affinity(union RAID_CONTEXT_UNION *praid_context,
  struct MR_LD_RAID *raid, bool fp_possible,
- u8 is_read)
+ u8 is_read, u32 scsi_buff_len)
 {
u8 cpu_sel = MR_RAID_CTX_CPUSEL_0;
struct RAID_CONTEXT_G35 *rctx_g35;
@@ -2161,6 +2162,17 @@ megasas_set_raidflag_cpu_affinity(union 
RAID_CONTEXT_UNION *praid_context,
}
 
rctx_g35->routing_flags.bits.cpu_sel = cpu_sel;
+
+   /* Always give priority to MR_RAID_FLAGS_IO_SUB_TYPE_LDIO_BW_LIMIT
+* vs MR_RAID_FLAGS_IO_SUB_TYPE_CACHE_BYPASS.
+* IO Subtype is not bitmap.
+*/
+   if ((raid->level == 1) && (!is_read)) {
+   if (scsi_buff_len > MR_LARGE_IO_MIN_SIZE)
+   praid_context->raid_context_g35.raid_flags =
+   (MR_RAID_FLAGS_IO_SUB_TYPE_LDIO_BW_LIMIT
+   << MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT);
+   }
 }
 
 /**
@@ -2303,6 +2315,14 @@ megasas_build_ldio_fusion(struct megasas_instance 
*instance,
io_info.isRead && io_info.ra_capable)
fp_possible = false;
 
+   /* FP for Optimal raid level 1.
+* All large RAID-1 writes (> 32 KiB, both WT and WB modes)
+* are built by the driver as LD I/Os.
+* All small RAID-1 WT writes (<= 32 KiB) are built as FP I/Os
+* (there is never a reason to process these as buffered writes)
+* All small RAID-1 WB writes (<= 32 KiB) are built as FP I/Os
+* with the 

  1   2   >