Re: kernel BUG at block/bio.c:1787! while initializing scsi_debug on ppc64 host

2015-12-15 Thread Eryu Guan
On Tue, Dec 15, 2015 at 01:29:59PM -0500, Martin K. Petersen wrote:
> > "Eryu" == Eryu Guan  writes:
> 
> Eryu,
> 
> Does the patch below fix the issue?

Unfortunately no, still BUG_ON.

Thanks,
Eryu

> 
> -- 
> Martin K. PetersenOracle Linux Engineering
> 
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 3d22fc3e3c1a..d1eb7aa78b8d 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -2667,8 +2667,9 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
>  
>   if (buffer[3] == 0x3c) {
>   unsigned int lba_count, desc_count;
> + u64 max_ws = get_unaligned_be64(&buffer[36]);
>  
> - sdkp->max_ws_blocks = (u32)get_unaligned_be64(&buffer[36]);
> + sdkp->max_ws_blocks = (u32)max_ws;
>  
>   if (!sdkp->lbpme)
>   goto out;
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/15] copy offload patches

2015-12-15 Thread Martin K. Petersen
> "Mikulas" == Mikulas Patocka  writes:

Mikulas> Is there some software iSCSI implementation that supports
Mikulas> token-based copy? So that I could try to make support for it.

I did write support for token-based copy but it's in a different branch
from the xcopy stuff. I will have to reconcile those two branches and
then layer your stuff on top.

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


Re: kernel BUG at block/bio.c:1787! while initializing scsi_debug on ppc64 host

2015-12-15 Thread Martin K. Petersen
> "Ming" == Ming Lei  writes:

Ming> I think it is wrong to set max sectors from OPTIMAL TRANSFER
Ming> LENGTH.

OTL is the preferred size for REQ_TYPE_FS requests as reported by the
device. The intent is to honor that. Your patch clamps the rw_size to
BLK_DEF_MAX_SECTORS which is not correct.

Ming> Also it is ugly to set limits->max_sectors from drivers directly,
Ming> and drivers should have called block helpers to do that.

We're trying to avoid unnecessary accessor functions for the queue
limits. But I will add a sanity check for the page size. And fix up
scsi_debug.

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


Re: kernel BUG at block/bio.c:1787! while initializing scsi_debug on ppc64 host

2015-12-15 Thread Martin K. Petersen
> "Ming" == Ming Lei  writes:

Ming,

Ming> No, it can't.

Well, it fixes a problem on one of my test systems where max_ws_blocks,
by virtue of being 64 bits, clobbers opt_xfer_blocks causing rw_len and
thus max_sectors to be set incorrectly.

We haven't run into that issue on real hardware. Probably because
scsi_debug is the only driver reporting $LUDICROUS_NUMBER as the max hw
transfer.

Ming> As the debug log shows, it is because you use 'OPTIMAL TRANSFER
Ming> LENGTH' to set queue's max_sectors.

But that is intentional.

I agree that the value chosen by scsi_debug in this case is very low and
we should fix that.

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


Re: kernel BUG at block/bio.c:1787! while initializing scsi_debug on ppc64 host

2015-12-15 Thread Ming Lei
On Wed, Dec 16, 2015 at 2:29 AM, Martin K. Petersen
 wrote:
>> "Eryu" == Eryu Guan  writes:
>
> Eryu,
>
> Does the patch below fix the issue?

No, it can't.

As the debug log shows, it is because you use 'OPTIMAL
TRANSFER LENGTH' to set queue's max_sectors.

Thanks,

>
> --
> Martin K. Petersen  Oracle Linux Engineering
>
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 3d22fc3e3c1a..d1eb7aa78b8d 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -2667,8 +2667,9 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
>
> if (buffer[3] == 0x3c) {
> unsigned int lba_count, desc_count;
> +   u64 max_ws = get_unaligned_be64(&buffer[36]);
>
> -   sdkp->max_ws_blocks = (u32)get_unaligned_be64(&buffer[36]);
> +   sdkp->max_ws_blocks = (u32)max_ws;
>
> if (!sdkp->lbpme)
> goto out;



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


Re: kernel BUG at block/bio.c:1787! while initializing scsi_debug on ppc64 host

2015-12-15 Thread Ming Lei
On Wed, Dec 16, 2015 at 12:56 AM, Eryu Guan  wrote:
> On Tue, Dec 15, 2015 at 09:27:14PM +0800, Ming Lei wrote:
>> On Tue, Dec 15, 2015 at 9:06 PM, Eryu Guan  wrote:
>> > On Tue, Dec 15, 2015 at 08:06:47PM +0800, Ming Lei wrote:
>> >> On Tue, Dec 15, 2015 at 7:20 PM, Eryu Guan  wrote:
>> >> > On Fri, Dec 11, 2015 at 07:53:40PM +0800, Eryu Guan wrote:
>> >> >> Hi,
>> >> >>
>> >> >> I saw this kernel BUG_ON on 4.4-rc4 kernel, and this can be reproduced
>> >> >> easily on ppc64 host by:
>> >> >
>> >> > This is still reproducible with 4.4-rc5 kernel.
>> >>
>> >> Could you capture the debug log after appyling the attached patch and
>> >> the reproduction?
>> >
>> > Thanks for looking into this! dmesg shows:
>> >
>> > [  686.217682] bio_split: sectors 0, bio_sectors 128, bi_rw 0
>>
>> Then I guess queue_max_sectors(q) is bad, could you apply the
>> attached patch(and the last patch) and post the log?
>
> [  301.279018] blk_bio_segment_split: nseg 0, max_secs 64, max segs 2048
> [  301.279023]   bv.len 65536, bv.offset 0
> [  301.279026] bio_split: sectors 0, bio_sectors 128, bi_rw 0

Now, the issue is quite obvious, and page size is 64K on your platform,
but max_sectors is set as 64 by commit ca369d51b3e164, and I think
it is wrong to set max sectors from OPTIMAL TRANSFER LENGTH.

Also it is ugly to set limits->max_sectors from drivers directly, and drivers
should have called block helpers to do that.

> If full call trace is needed please let me know.

Thanks for your test, and the above log is absolutely enough, :-)

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


RE: qla2xxx: ISP27xx add tests for incomplete template.

2015-12-15 Thread Joe Carnuccio
Hi Dan,



Thanks for reading the code...



That loop would normally exit via the break at line 775;

if there were exactly count entries, that break avoids count being decremented 
to -1, so count remains zero.



if the loop is ever terminated by the while, then either/or:

- if there were more than count entries, then count is a relatively small 
positive number;

- if the END entry was missing, then count wraps to -1 (~0), and line 780/781 
prints all F's.



i.e. if count is not zero at line 779, then the template was wrong (too many 
entries, or no END entry).



( btw: yes, the redundant test for missing END entry at line 783 was added 
later than the while loop )



Regards

Joe





-Original Message-
From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
Sent: Tuesday, December 15, 2015 12:05 PM
To: Joe Carnuccio 
Cc: linux-scsi 
Subject: re: qla2xxx: ISP27xx add tests for incomplete template.



Hello Joe Carnuccio,



The patch 299f5e27ac5f: "qla2xxx: ISP27xx add tests for incomplete template." 
from Sep 25, 2014, leads to the following static checker

warning:



   drivers/scsi/qla2xxx/qla_tmpl.c:779 qla27xx_walk_template()

   warn: should this be 'count == -1'



drivers/scsi/qla2xxx/qla_tmpl.c

   764  static void

   765  qla27xx_walk_template(struct scsi_qla_host *vha,

   766  struct qla27xx_fwdt_template *tmp, void *buf, ulong *len)

   767  {

   768  struct qla27xx_fwdt_entry *ent = (void *)tmp + 
tmp->entry_offset;

   769  ulong count = tmp->entry_count;

   770

   771  ql_dbg(ql_dbg_misc, vha, 0xd01a,

   772  "%s: entry count %lx\n", __func__, count);

   773  while (count--) {

   774  if (qla27xx_find_entry(ent->hdr.entry_type)(vha, ent, 
buf, len))

   775  break;

   776  ent = qla27xx_next_entry(ent);

   777  }

   778

   779  if (count)

   780  ql_dbg(ql_dbg_misc, vha, 0xd018,

   781  "%s: residual count (%lx)\n", __func__, count);



The static checker assumes that we are testing to see if the loop ended with a 
break or not.  These are normally bugs because if we did not break the count is 
set to (ulong)-1.



This code is sort of weird.  It's just debugging so I guess it doesn't matter.  
Are we expecting -1?



   782

   783  if (ent->hdr.entry_type != ENTRY_TYPE_TMP_END)

   784  ql_dbg(ql_dbg_misc, vha, 0xd019,

   785  "%s: missing end (%lx)\n", __func__, count);

   786

   787  ql_dbg(ql_dbg_misc, vha, 0xd01b,

   788  "%s: len=%lx\n", __func__, *len);

   789

   790  if (buf) {

   791  ql_log(ql_log_warn, vha, 0xd015,

   792  "Firmware dump saved to temp buffer (%ld/%p)\n",

   793  vha->host_no, vha->hw->fw_dump);

   794  qla2x00_post_uevent_work(vha, QLA_UEVENT_CODE_FW_DUMP);

   795  }

   796  }



regards,

dan carpenter
<>

Re: [PATCH v2 3/6] cxlflash: Removed driver date print

2015-12-15 Thread Manoj Kumar

On 12/14/2015 3:06 PM, Uma Krishnan wrote:

Having a date for the driver requires it to be updated quite
often. Removing the date which is not necessary. Also made
use of the existing symbol to print the driver name.

Signed-off-by: Uma Krishnan 
---


Acked-by: Manoj N. Kumar 

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


re: qla2xxx: ISP27xx add tests for incomplete template.

2015-12-15 Thread Dan Carpenter
Hello Joe Carnuccio,

The patch 299f5e27ac5f: "qla2xxx: ISP27xx add tests for incomplete
template." from Sep 25, 2014, leads to the following static checker
warning:

drivers/scsi/qla2xxx/qla_tmpl.c:779 qla27xx_walk_template()
warn: should this be 'count == -1'

drivers/scsi/qla2xxx/qla_tmpl.c
   764  static void
   765  qla27xx_walk_template(struct scsi_qla_host *vha,
   766  struct qla27xx_fwdt_template *tmp, void *buf, ulong *len)
   767  {
   768  struct qla27xx_fwdt_entry *ent = (void *)tmp + 
tmp->entry_offset;
   769  ulong count = tmp->entry_count;
   770  
   771  ql_dbg(ql_dbg_misc, vha, 0xd01a,
   772  "%s: entry count %lx\n", __func__, count);
   773  while (count--) {
   774  if (qla27xx_find_entry(ent->hdr.entry_type)(vha, ent, 
buf, len))
   775  break;
   776  ent = qla27xx_next_entry(ent);
   777  }
   778  
   779  if (count)
   780  ql_dbg(ql_dbg_misc, vha, 0xd018,
   781  "%s: residual count (%lx)\n", __func__, count);

The static checker assumes that we are testing to see if the loop ended
with a break or not.  These are normally bugs because if we did not
break the count is set to (ulong)-1.

This code is sort of weird.  It's just debugging so I guess it doesn't
matter.  Are we expecting -1?

   782  
   783  if (ent->hdr.entry_type != ENTRY_TYPE_TMP_END)
   784  ql_dbg(ql_dbg_misc, vha, 0xd019,
   785  "%s: missing end (%lx)\n", __func__, count);
   786  
   787  ql_dbg(ql_dbg_misc, vha, 0xd01b,
   788  "%s: len=%lx\n", __func__, *len);
   789  
   790  if (buf) {
   791  ql_log(ql_log_warn, vha, 0xd015,
   792  "Firmware dump saved to temp buffer (%ld/%p)\n",
   793  vha->host_no, vha->hw->fw_dump);
   794  qla2x00_post_uevent_work(vha, QLA_UEVENT_CODE_FW_DUMP);
   795  }
   796  }

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


RE: [PATCH] bnx2fc:Add proper locking protection in bnx2fc_ctrlr_enabled

2015-12-15 Thread Joe Carnuccio
Also, the patch fails to do what it's message describes, i.e. the calls 
_bnx2fc_enable() and _bnx2fc_disable() are outside the lock/unlock.


-Original Message-
From: Chad Dupuis 
Sent: Tuesday, December 15, 2015 8:43 AM
To: Nicholas Krause 
Cc: Dept-Eng QLogic Storage Upstream ; 
jbottom...@odin.com; martin.peter...@oracle.com; linux-scsi 
; linux-kernel 
Subject: Re: [PATCH] bnx2fc:Add proper locking protection in 
bnx2fc_ctrlr_enabled


On Sat, 12 Dec 2015, Nicholas Krause wrote:

> This adds proper locking protection in bnx2fc_ctrl_enabled around the 
> calls to the functions, _bnx2fc_enable and _bnx2fc_disable in order to 
> avoid concurrent access on these functions accessing global referenced 
> data structures in their internal intended work.
>
> Signed-off-by: Nicholas Krause 
> ---
> drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 8 
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
> b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> index 67405c6..e43648f 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> @@ -2177,13 +2177,21 @@ static int bnx2fc_ctlr_enabled(struct 
> fcoe_ctlr_device *cdev) {
>   struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(cdev);
>
> + rtnl_lock();
> + mutex_lock(&bnx2fc_dev_lock);
>   switch (cdev->enabled) {
>   case FCOE_CTLR_ENABLED:
> + rtnl_unlock();
> + mutex_unlock(&bnx2fc_dev_lock);
>   return __bnx2fc_enable(ctlr);
>   case FCOE_CTLR_DISABLED:
> + rtnl_unlock();
> + mutex_unlock(&bnx2fc_dev_lock);
>   return __bnx2fc_disable(ctlr);
>   case FCOE_CTLR_UNUSED:
>   default:
> + rtnl_unlock();
> + mutex_unlock(&bnx2fc_dev_lock);
>   return -ENOTSUPP;
>   };
> }
>

Nack.  All we end up protecting is the check of cdev->enabled and I do not 
believe taking two mutexes is required for that.
<>

RE: [PATCH v2 3/9] aacraid: Added EEH support

2015-12-15 Thread Raghava Aditya Renukunta
Hello All,

It looks like the build robot did not   merge the previous aacraid patches
which contained the functions aac_release_resources and aac_acquire_resources,
 before applying and building this set of patches.

As is evident from the commit messages here

https://github.com/0day-ci/linux/tree/master/drivers/scsi/aacraid

This kbuild test robot can be safely ignored.


Regards,
Raghava Aditya

> -Original Message-
> From: kbuild test robot [mailto:l...@intel.com]
> Sent: Saturday, December 12, 2015 4:28 PM
> To: Raghava Aditya Renukunta
> Cc: kbuild-...@01.org; jbottom...@parallels.com; linux-scsi@vger.kernel.org;
> Mahesh Rajashekhara; Murthy Bhat; Santosh Akula; Gana Sridaran;
> aacr...@pmc-sierra.com; Scott Benesh; Raghava Aditya Renukunta
> Subject: Re: [PATCH v2 3/9] aacraid: Added EEH support
> 
> Hi Raghava,
> 
> [auto build test ERROR on scsi/for-next]
> [also build test ERROR on v4.4-rc4 next-20151211]
> 
> url:https://github.com/0day-ci/linux/commits/Raghava-Aditya-
> Renukunta/aacraid-Patchset-for-aacraid-driver-version-41052/20151211-
> 094405
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
> config: x86_64-randconfig-r0-12130550 (attached as .config)
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=x86_64
> 
> All errors (new ones prefixed by >>):
> 
>drivers/scsi/aacraid/linit.c: In function 'aac_pci_error_detected':
> >> drivers/scsi/aacraid/linit.c:1546:3: error: implicit declaration of 
> >> function
> 'aac_release_resources' [-Werror=implicit-function-declaration]
>   aac_release_resources(aac);
>   ^
>drivers/scsi/aacraid/linit.c: In function 'aac_pci_resume':
> >> drivers/scsi/aacraid/linit.c:1617:2: error: implicit declaration of 
> >> function
> 'aac_acquire_resources' [-Werror=implicit-function-declaration]
>  aac_acquire_resources(aac);
>  ^
>cc1: some warnings being treated as errors
> 
> vim +/aac_release_resources +1546 drivers/scsi/aacraid/linit.c
> 
>   1540
>   1541aac->handle_pci_error = 1;
>   1542aac->adapter_shutdown = 1;
>   1543
>   1544scsi_block_requests(aac->scsi_host_ptr);
>   1545aac_flush_ios(aac);
> > 1546aac_release_resources(aac);
>   1547
>   1548pci_disable_pcie_error_reporting(pdev);
>   1549aac_adapter_ioremap(aac, 0);
>   1550
>   1551return PCI_ERS_RESULT_NEED_RESET;
>   1552case pci_channel_io_perm_failure:
>   1553aac->handle_pci_error = 1;
>   1554aac->adapter_shutdown = 1;
>   1555
>   1556aac_flush_ios(aac);
>   1557return PCI_ERS_RESULT_DISCONNECT;
>   1558}
>   1559
>   1560return PCI_ERS_RESULT_NEED_RESET;
>   1561}
>   1562
>   1563static pci_ers_result_t aac_pci_mmio_enabled(struct pci_dev 
> *pdev)
>   1564{
>   1565dev_err(&pdev->dev, "aacraid: PCI error - mmio
> enabled\n");
>   1566return PCI_ERS_RESULT_NEED_RESET;
>   1567}
>   1568
>   1569static pci_ers_result_t aac_pci_slot_reset(struct pci_dev *pdev)
>   1570{
>   1571dev_err(&pdev->dev, "aacraid: PCI error - slot 
> reset\n");
>   1572pci_restore_state(pdev);
>   1573if (pci_enable_device(pdev)) {
>   1574dev_warn(&pdev->dev,
>   1575"aacraid: failed to enable slave\n");
>   1576goto fail_device;
>   1577}
>   1578
>   1579pci_set_master(pdev);
>   1580
>   1581if (pci_enable_device_mem(pdev)) {
>   1582dev_err(&pdev->dev, "pci_enable_device_mem
> failed\n");
>   1583goto fail_device;
>   1584}
>   1585
>   1586return PCI_ERS_RESULT_RECOVERED;
>   1587
>   1588fail_device:
>   1589dev_err(&pdev->dev, "aacraid: PCI error - slot reset
> failed\n");
>   1590return PCI_ERS_RESULT_DISCONNECT;
>   1591}
>   1592
>   1593
>   1594static void aac_pci_resume(struct pci_dev *pdev)
>   1595{
>   1596struct Scsi_Host *shost = pci_get_drvdata(pdev);
>   1597struct scsi_device *sdev = NULL;
>   1598struct aac_dev *aac = (struct aac_dev 
> *)shost_priv(shost);
>   1599
>   1600pci_cleanup_aer_uncorrect_error_status(pdev);
>   1601
>   1602if (aac_adapter_ioremap(aac, aac->base_size)) {
>   1603
>   1604dev_err(&pdev->dev, "aacraid: ioremap 
> failed\n");
>   1605/* remap failed, go back ... */
>   1606aac->comm_

Re: kernel BUG at block/bio.c:1787! while initializing scsi_debug on ppc64 host

2015-12-15 Thread Martin K. Petersen
> "Eryu" == Eryu Guan  writes:

Eryu,

Does the patch below fix the issue?

-- 
Martin K. Petersen  Oracle Linux Engineering

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 3d22fc3e3c1a..d1eb7aa78b8d 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2667,8 +2667,9 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
 
if (buffer[3] == 0x3c) {
unsigned int lba_count, desc_count;
+   u64 max_ws = get_unaligned_be64(&buffer[36]);
 
-   sdkp->max_ws_blocks = (u32)get_unaligned_be64(&buffer[36]);
+   sdkp->max_ws_blocks = (u32)max_ws;
 
if (!sdkp->lbpme)
goto out;
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: kernel BUG at block/bio.c:1787! while initializing scsi_debug on ppc64 host

2015-12-15 Thread Eryu Guan
On Tue, Dec 15, 2015 at 11:38:41PM +0800, Ming Lei wrote:
> On Tue, 15 Dec 2015 21:06:31 +0800
> Eryu Guan  wrote:
> 
> > On Tue, Dec 15, 2015 at 08:06:47PM +0800, Ming Lei wrote:
> > > On Tue, Dec 15, 2015 at 7:20 PM, Eryu Guan  wrote:
> > > > On Fri, Dec 11, 2015 at 07:53:40PM +0800, Eryu Guan wrote:
> > > >> Hi,
> > > >>
> > > >> I saw this kernel BUG_ON on 4.4-rc4 kernel, and this can be reproduced
> > > >> easily on ppc64 host by:
> > > >
> > > > This is still reproducible with 4.4-rc5 kernel.
> > > 
> > > Could you capture the debug log after appyling the attached patch and
> > > the reproduction?
> > 
> > Thanks for looking into this! dmesg shows:
> > 
> > [  686.217682] bio_split: sectors 0, bio_sectors 128, bi_rw 0
> 
> I guess the following patch should fix the issue, and ca369d51b3
> uses OPTIMAL TRANSFER LENGTH to set limits->max_sectors, which
> may be less than one page size.
> 
> I don't understand the idea behind this change, Martin, could
> you explain it a bit?
> 
> ---
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 3d22fc3..d66d362 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -2889,10 +2889,11 @@ static int sd_revalidate_disk(struct gendisk *disk)
>*/
>   if (sdkp->opt_xfer_blocks && sdkp->opt_xfer_blocks <= dev_max &&
>   sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS)
> - rw_max = q->limits.io_opt =
> + q->limits.io_opt =
>   logical_to_sectors(sdp, sdkp->opt_xfer_blocks);
> - else
> - rw_max = BLK_DEF_MAX_SECTORS;
> +
> + rw_max = min_t(unsigned, BLK_DEF_MAX_SECTORS,
> +q->limits.max_dev_sectors);
>  
>   /* Combine with controller limits */
>   q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q));

I tested this patch and no BUG_ON this time, the debug messages are not
triggered either.

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


Re: kernel BUG at block/bio.c:1787! while initializing scsi_debug on ppc64 host

2015-12-15 Thread Eryu Guan
On Tue, Dec 15, 2015 at 09:27:14PM +0800, Ming Lei wrote:
> On Tue, Dec 15, 2015 at 9:06 PM, Eryu Guan  wrote:
> > On Tue, Dec 15, 2015 at 08:06:47PM +0800, Ming Lei wrote:
> >> On Tue, Dec 15, 2015 at 7:20 PM, Eryu Guan  wrote:
> >> > On Fri, Dec 11, 2015 at 07:53:40PM +0800, Eryu Guan wrote:
> >> >> Hi,
> >> >>
> >> >> I saw this kernel BUG_ON on 4.4-rc4 kernel, and this can be reproduced
> >> >> easily on ppc64 host by:
> >> >
> >> > This is still reproducible with 4.4-rc5 kernel.
> >>
> >> Could you capture the debug log after appyling the attached patch and
> >> the reproduction?
> >
> > Thanks for looking into this! dmesg shows:
> >
> > [  686.217682] bio_split: sectors 0, bio_sectors 128, bi_rw 0
> 
> Then I guess queue_max_sectors(q) is bad, could you apply the
> attached patch(and the last patch) and post the log?

[  301.279018] blk_bio_segment_split: nseg 0, max_secs 64, max segs 2048
[  301.279023]   bv.len 65536, bv.offset 0
[  301.279026] bio_split: sectors 0, bio_sectors 128, bi_rw 0

If full call trace is needed please let me know.

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


Re: [PATCH] bnx2fc:Add proper locking protection in bnx2fc_ctrlr_enabled

2015-12-15 Thread Chad Dupuis


On Sat, 12 Dec 2015, Nicholas Krause wrote:


This adds proper locking protection in bnx2fc_ctrl_enabled around
the calls to the functions, _bnx2fc_enable and _bnx2fc_disable in
order to avoid concurrent access on these functions accessing global
referenced data structures in their internal intended work.

Signed-off-by: Nicholas Krause 
---
drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 8 
1 file changed, 8 insertions(+)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 67405c6..e43648f 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -2177,13 +2177,21 @@ static int bnx2fc_ctlr_enabled(struct fcoe_ctlr_device 
*cdev)
{
struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(cdev);

+   rtnl_lock();
+   mutex_lock(&bnx2fc_dev_lock);
switch (cdev->enabled) {
case FCOE_CTLR_ENABLED:
+   rtnl_unlock();
+   mutex_unlock(&bnx2fc_dev_lock);
return __bnx2fc_enable(ctlr);
case FCOE_CTLR_DISABLED:
+   rtnl_unlock();
+   mutex_unlock(&bnx2fc_dev_lock);
return __bnx2fc_disable(ctlr);
case FCOE_CTLR_UNUSED:
default:
+   rtnl_unlock();
+   mutex_unlock(&bnx2fc_dev_lock);
return -ENOTSUPP;
};
}



Nack.  All we end up protecting is the check of cdev->enabled and I do not 
believe taking two mutexes is required for that.

--
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 12/15] be2iscsi: Fix IOPOLL implementation

2015-12-15 Thread Jitendra Bhivare
From: Jitendra 

OS not responding when running 2 port traffic on 72 CPUs system.

be2iscsi IRQs gets affined to CPU0 when irqbalancer is disabled.
be_iopoll processing completions in BLOCK_IOPOLL_SOFTIRQ hogged CPU0.

1. Use budget to exit the polling loop. beiscsi_process_cq didn't honour it.
2. Rearming of EQ is done only after iopoll completes.

Signed-off-by: Jitendra 
---
 drivers/scsi/be2iscsi/be_cmds.c  |2 +-
 drivers/scsi/be2iscsi/be_iscsi.c |2 +-
 drivers/scsi/be2iscsi/be_main.c  |   91 +-
 drivers/scsi/be2iscsi/be_main.h  |5 +-
 4 files changed, 56 insertions(+), 44 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index eced82b..3dbf6af 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -543,7 +543,7 @@ int beiscsi_process_mcc(struct beiscsi_hba *phba)
}
 
if (num)
-   hwi_ring_cq_db(phba, phba->ctrl.mcc_obj.cq.id, num, 1, 0);
+   hwi_ring_cq_db(phba, phba->ctrl.mcc_obj.cq.id, num, 1);
 
spin_unlock_bh(&phba->ctrl.mcc_cq_lock);
return status;
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index c89a025..3545721 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -1298,7 +1298,7 @@ static void beiscsi_flush_cq(struct beiscsi_hba *phba)
for (i = 0; i < phba->num_cpus; i++) {
pbe_eq = &phwi_context->be_eq[i];
blk_iopoll_disable(&pbe_eq->iopoll);
-   beiscsi_process_cq(pbe_eq);
+   beiscsi_process_cq(pbe_eq, BE2_MAX_NUM_CQ_PROC);
blk_iopoll_enable(&pbe_eq->iopoll);
}
 }
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index a665e6a..9a86044 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -895,32 +895,21 @@ static irqreturn_t be_isr_mcc(int irq, void *dev_id)
 static irqreturn_t be_isr_msix(int irq, void *dev_id)
 {
struct beiscsi_hba *phba;
-   struct be_eq_entry *eqe = NULL;
struct be_queue_info *eq;
-   struct be_queue_info *cq;
-   unsigned int num_eq_processed;
struct be_eq_obj *pbe_eq;
 
pbe_eq = dev_id;
eq = &pbe_eq->q;
-   cq = pbe_eq->cq;
-   eqe = queue_tail_node(eq);
 
phba = pbe_eq->phba;
-   num_eq_processed = 0;
-   while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32]
-   & EQE_VALID_MASK) {
-   if (!blk_iopoll_sched_prep(&pbe_eq->iopoll))
-   blk_iopoll_sched(&pbe_eq->iopoll);
-
-   AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0);
-   queue_tail_inc(eq);
-   eqe = queue_tail_node(eq);
-   num_eq_processed++;
-   }
-
-   if (num_eq_processed)
-   hwi_ring_eq_db(phba, eq->id, 1, num_eq_processed, 0, 1);
+   /* disable interrupt till iopoll completes */
+   hwi_ring_eq_db(phba, eq->id, 1, 0, 0, 1);
+   if (!blk_iopoll_sched_prep(&pbe_eq->iopoll))
+   blk_iopoll_sched(&pbe_eq->iopoll);
+   else
+   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_IO,
+   "BM_%d: received event while polling eq %d cq %d\n",
+   eq->id, pbe_eq->cq->id);
 
return IRQ_HANDLED;
 }
@@ -998,6 +987,7 @@ static irqreturn_t be_isr(int irq, void *dev_id)
return IRQ_NONE;
 }
 
+
 static int beiscsi_init_irqs(struct beiscsi_hba *phba)
 {
struct pci_dev *pcidev = phba->pcidev;
@@ -1072,7 +1062,7 @@ free_msix_irqs:
 
 void hwi_ring_cq_db(struct beiscsi_hba *phba,
   unsigned int id, unsigned int num_processed,
-  unsigned char rearm, unsigned char event)
+  unsigned char rearm)
 {
u32 val = 0;
 
@@ -2044,7 +2034,7 @@ static void  beiscsi_process_mcc_isr(struct beiscsi_hba 
*phba)
 
if (num_processed >= 32) {
hwi_ring_cq_db(phba, mcc_cq->id,
-   num_processed, 0, 0);
+   num_processed, 0);
num_processed = 0;
}
if (mcc_compl->flags & CQE_FLAGS_ASYNC_MASK) {
@@ -2062,24 +2052,25 @@ static void  beiscsi_process_mcc_isr(struct beiscsi_hba 
*phba)
}
 
if (num_processed > 0)
-   hwi_ring_cq_db(phba, mcc_cq->id, num_processed, 1, 0);
+   hwi_ring_cq_db(phba, mcc_cq->id, num_processed, 1);
 
 }
 
 /**
  * beiscsi_process_cq()- Process the Completion Queue
  * @pbe_eq: Event Q on which the Completion has come
+ * @budget: Max number of events to processed
  *
  * return
  * Number of Completion Entries processed.
  **/
-unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq)
+unsigned int beiscsi_process_cq(struct be_eq_obj

[PATCH v1 3/3] hpsa: add box and bay information for enclosure devices

2015-12-15 Thread Don Brace
Adding a new method to display enclosure device information.

Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Scott Teel 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |  108 ---
 drivers/scsi/hpsa_cmd.h |   13 ++
 2 files changed, 114 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index f8370b8..6f84ec7 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -750,7 +750,6 @@ static ssize_t host_show_hp_ssd_smart_path_enabled(struct 
device *dev,
 }
 
 #define MAX_PATHS 8
-
 static ssize_t path_info_show(struct device *dev,
 struct device_attribute *attr, char *buf)
 {
@@ -792,9 +791,7 @@ static ssize_t path_info_show(struct device *dev,
hdev->bus, hdev->target, hdev->lun,
scsi_device_type(hdev->devtype));
 
-   if (hdev->external ||
-   hdev->devtype == TYPE_RAID ||
-   is_logical_device(hdev)) {
+   if (hdev->devtype == TYPE_RAID || is_logical_device(hdev)) {
output_len += scnprintf(buf + output_len,
PAGE_SIZE - output_len,
"%s\n", active);
@@ -808,8 +805,7 @@ static ssize_t path_info_show(struct device *dev,
phys_connector[0] = '0';
if (phys_connector[1] < '0')
phys_connector[1] = '0';
-   if (hdev->phys_connector[i] > 0)
-   output_len += scnprintf(buf + output_len,
+   output_len += scnprintf(buf + output_len,
PAGE_SIZE - output_len,
"PORT: %.2s ",
phys_connector);
@@ -3191,6 +3187,90 @@ out:
return rc;
 }
 
+/*
+ * get enclosure information
+ * struct ReportExtendedLUNdata *rlep - Used for BMIC drive number
+ * struct hpsa_scsi_dev_t *encl_dev - device entry for enclosure
+ * Uses id_physical_device to determine the box_index.
+ */
+static int hpsa_get_enclosure_info(struct ctlr_info *h,
+   unsigned char *scsi3addr,
+   struct ReportExtendedLUNdata *rlep, int rle_index,
+   struct hpsa_scsi_dev_t *encl_dev)
+{
+   int rc = -1;
+   struct CommandList *c = NULL;
+   struct ErrorInfo *ei = NULL;
+   struct bmic_sense_storage_box_params *bssbp = NULL;
+   struct bmic_identify_physical_device *id_phys = NULL;
+   struct ext_report_lun_entry *rle = &rlep->LUN[rle_index];
+   u16 bmic_device_index = 0;
+
+
+   bssbp = kzalloc(sizeof(*bssbp), GFP_KERNEL);
+   if (!bssbp)
+   goto out;
+
+   id_phys = kzalloc(sizeof(*id_phys), GFP_KERNEL);
+   if (!id_phys)
+   goto out;
+
+   bmic_device_index = GET_BMIC_DRIVE_NUMBER(&rle->lunid[0]);
+
+   if (bmic_device_index == 0xFF00)
+   goto out;
+
+   memset(id_phys, 0, sizeof(*id_phys));
+   rc = hpsa_bmic_id_physical_device(h, scsi3addr, bmic_device_index,
+   id_phys, sizeof(*id_phys));
+   if (rc) {
+   dev_warn(&h->pdev->dev, "%s: id_phys failed %d bdi[0x%x]\n",
+   __func__, encl_dev->external, bmic_device_index);
+   goto out;
+   }
+
+   c = cmd_alloc(h);
+
+   rc = fill_cmd(c, BMIC_SENSE_STORAGE_BOX_PARAMS, h, bssbp,
+   sizeof(*bssbp), 0, RAID_CTLR_LUNID, TYPE_CMD);
+
+   if (rc)
+   goto out;
+
+   if (id_phys->phys_connector[1] == 'E')
+   c->Request.CDB[5] = id_phys->box_index;
+   else
+   c->Request.CDB[5] = 0;
+
+   rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, PCI_DMA_FROMDEVICE,
+   NO_TIMEOUT);
+   if (rc)
+   goto out;
+
+   ei = c->err_info;
+   if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) {
+   rc = -1;
+   goto out;
+   }
+
+   encl_dev->box[id_phys->active_path_number] = bssbp->phys_box_on_port;
+   memcpy(&encl_dev->phys_connector[id_phys->active_path_number],
+   bssbp->phys_connector, sizeof(bssbp->phys_connector));
+
+   rc = IO_OK;
+out:
+   kfree(bssbp);
+   kfree(id_phys);
+
+   if (c)
+   cmd_free(h, c);
+
+   if (rc != IO_OK)
+   hpsa_show_dev_msg(KERN_INFO, h, encl_dev,
+   "Error, could not get enclosure information\n");
+   return rc;
+}
+
 static u64 hpsa_get_sas_address_from_report_physical(struct ctlr_info *h,
unsigned char *scsi3addr)
 {
@@ -4032,7 +4112,8 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
 
/* skip masked non-disk devices 

[PATCH v1 1/3] hpsa: fix path_info_show

2015-12-15 Thread Don Brace
left off some changes from Rasmus Villemoes where he changed
snprintf to scnprintf

Suggested-by: Rasmus Villemoes 
Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Scott Teel 
Reviewed-by: Rasmus Villemoes 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index a386036..f8370b8 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -795,7 +795,7 @@ static ssize_t path_info_show(struct device *dev,
if (hdev->external ||
hdev->devtype == TYPE_RAID ||
is_logical_device(hdev)) {
-   output_len += snprintf(buf + output_len,
+   output_len += scnprintf(buf + output_len,
PAGE_SIZE - output_len,
"%s\n", active);
continue;
@@ -809,28 +809,28 @@ static ssize_t path_info_show(struct device *dev,
if (phys_connector[1] < '0')
phys_connector[1] = '0';
if (hdev->phys_connector[i] > 0)
-   output_len += snprintf(buf + output_len,
+   output_len += scnprintf(buf + output_len,
PAGE_SIZE - output_len,
"PORT: %.2s ",
phys_connector);
if (hdev->devtype == TYPE_DISK && hdev->expose_device) {
if (box == 0 || box == 0xFF) {
-   output_len += snprintf(buf + output_len,
+   output_len += scnprintf(buf + output_len,
PAGE_SIZE - output_len,
"BAY: %hhu %s\n",
bay, active);
} else {
-   output_len += snprintf(buf + output_len,
+   output_len += scnprintf(buf + output_len,
PAGE_SIZE - output_len,
"BOX: %hhu BAY: %hhu %s\n",
box, bay, active);
}
} else if (box != 0 && box != 0xFF) {
-   output_len += snprintf(buf + output_len,
+   output_len += scnprintf(buf + output_len,
PAGE_SIZE - output_len, "BOX: %hhu %s\n",
box, active);
} else
-   output_len += snprintf(buf + output_len,
+   output_len += scnprintf(buf + output_len,
PAGE_SIZE - output_len, "%s\n", active);
}
 

--
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 v1 2/3] hpsa: change SAS transport devices to bus 0.

2015-12-15 Thread Don Brace
sas transport places devices on bus 0 but driver was setting
the bus to 3.

Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Scott Teel 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index ae5beda..fdd39fc 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -400,7 +400,7 @@ struct offline_device_entry {
 #define HPSA_PHYSICAL_DEVICE_BUS   0
 #define HPSA_RAID_VOLUME_BUS   1
 #define HPSA_EXTERNAL_RAID_VOLUME_BUS  2
-#define HPSA_HBA_BUS   3
+#define HPSA_HBA_BUS   0
 
 /*
Send the command to the hardware

--
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 v1 0/3] hpsa update

2015-12-15 Thread Don Brace
These patches are based on Linus's tree

The changes are:
 - correct missing changes from snprintf to scnprintf
   in path_info_show by Rasmus Villemoes
 - fix reported bus for SAS transport devices
 - add in enclosure information

Changes from initial upload
 - added short patch description for patch
   hpsa-add-enclosure-connection-box-bay-information
 - kept hpsa-change-hba-controller-to-bus-0 the same to
   minimize changes.
---

Don Brace (3):
  hpsa: fix path_info_show
  hpsa: change SAS transport devices to bus 0.
  hpsa: add box and bay information for enclosure devices


 drivers/scsi/hpsa.c |  118 ++-
 drivers/scsi/hpsa.h |2 -
 drivers/scsi/hpsa_cmd.h |   13 +
 3 files changed, 120 insertions(+), 13 deletions(-)

--
Signature
--
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 15/15] be2iscsi: Update the driver version

2015-12-15 Thread Jitendra Bhivare
From: Jitendra 

Driver version: 11.0.0.0

Signed-off-by: Jitendra 
---
 drivers/scsi/be2iscsi/be_main.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 41c708c..16a6fd0 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -36,7 +36,7 @@
 #include 
 
 #define DRV_NAME   "be2iscsi"
-#define BUILD_STR  "10.6.0.1"
+#define BUILD_STR  "11.0.0.0"
 #define BE_NAME"Emulex OneConnect" \
"Open-iSCSI Driver version" BUILD_STR
 #define DRV_DESC   BE_NAME " " "Driver"
-- 
1.7.1

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


[PATCH 14/15] be2iscsi: Fix WRB leak in login/logout path

2015-12-15 Thread Jitendra Bhivare
From: Jitendra 

Login/Logout loop was hanging after few hours. /var/log/message showed
that alloc_wrb_handle() function was not able to allocate any new WRB.

Sep 11 11:25:22 Jhelum10 kernel: connection32513:0: Could not send nopout
Sep 11 11:25:22 Jhelum10 kernel: scsi host10: BM_4989 : Alloc of WRB_HANDLE
Failedfor the CID : 384
Sep 11 11:25:22 Jhelum10 kernel: connection32513:0: Could not allocate pdu for
mgmt task.

Driver allocates WRB to pass login negotiated parameters information to FW
in beiscsi_offload_connection(). This allocated WRB was not freed so there
was WRB_Leak happening.

Put WRB used for posting the login-negotiated parameters back in pool.

Signed-off-by: Jitendra 
---
 drivers/scsi/be2iscsi/be_main.c |   72 ++
 1 files changed, 49 insertions(+), 23 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 9a86044..d8cdb4e 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1184,6 +1184,22 @@ free_io_sgl_handle(struct beiscsi_hba *phba, struct 
sgl_handle *psgl_handle)
phba->io_sgl_free_index++;
 }
 
+static inline struct wrb_handle *
+beiscsi_get_wrb_handle(struct hwi_wrb_context *pwrb_context,
+  unsigned int wrbs_per_cxn)
+{
+   struct wrb_handle *pwrb_handle;
+
+   pwrb_handle = pwrb_context->pwrb_handle_base[pwrb_context->alloc_index];
+   pwrb_context->wrb_handles_available--;
+   if (pwrb_context->alloc_index == (wrbs_per_cxn - 1))
+   pwrb_context->alloc_index = 0;
+   else
+   pwrb_context->alloc_index++;
+
+   return pwrb_handle;
+}
+
 /**
  * alloc_wrb_handle - To allocate a wrb handle
  * @phba: The hba pointer
@@ -1193,30 +1209,30 @@ free_io_sgl_handle(struct beiscsi_hba *phba, struct 
sgl_handle *psgl_handle)
  * This happens under session_lock until submission to chip
  */
 struct wrb_handle *alloc_wrb_handle(struct beiscsi_hba *phba, unsigned int cid,
-struct hwi_wrb_context **pcontext)
+   struct hwi_wrb_context **pcontext)
 {
struct hwi_wrb_context *pwrb_context;
struct hwi_controller *phwi_ctrlr;
-   struct wrb_handle *pwrb_handle;
uint16_t cri_index = BE_GET_CRI_FROM_CID(cid);
 
phwi_ctrlr = phba->phwi_ctrlr;
pwrb_context = &phwi_ctrlr->wrb_context[cri_index];
-   if (pwrb_context->wrb_handles_available >= 2) {
-   pwrb_handle = pwrb_context->pwrb_handle_base[
-   pwrb_context->alloc_index];
-   pwrb_context->wrb_handles_available--;
-   if (pwrb_context->alloc_index ==
-   (phba->params.wrbs_per_cxn - 1))
-   pwrb_context->alloc_index = 0;
-   else
-   pwrb_context->alloc_index++;
+   /* return the context address */
+   *pcontext = pwrb_context;
+   return beiscsi_get_wrb_handle(pwrb_context, phba->params.wrbs_per_cxn);
+}
 
-   /* Return the context address */
-   *pcontext = pwrb_context;
-   } else
-   pwrb_handle = NULL;
-   return pwrb_handle;
+static inline void
+beiscsi_put_wrb_handle(struct hwi_wrb_context *pwrb_context,
+  struct wrb_handle *pwrb_handle,
+  unsigned int wrbs_per_cxn)
+{
+   pwrb_context->pwrb_handle_base[pwrb_context->free_index] = pwrb_handle;
+   pwrb_context->wrb_handles_available++;
+   if (pwrb_context->free_index == (wrbs_per_cxn - 1))
+   pwrb_context->free_index = 0;
+   else
+   pwrb_context->free_index++;
 }
 
 /**
@@ -1231,13 +1247,9 @@ static void
 free_wrb_handle(struct beiscsi_hba *phba, struct hwi_wrb_context *pwrb_context,
struct wrb_handle *pwrb_handle)
 {
-   pwrb_context->pwrb_handle_base[pwrb_context->free_index] = pwrb_handle;
-   pwrb_context->wrb_handles_available++;
-   if (pwrb_context->free_index == (phba->params.wrbs_per_cxn - 1))
-   pwrb_context->free_index = 0;
-   else
-   pwrb_context->free_index++;
-
+   beiscsi_put_wrb_handle(pwrb_context,
+  pwrb_handle,
+  phba->params.wrbs_per_cxn);
beiscsi_log(phba, KERN_INFO,
BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG,
"BM_%d : FREE WRB: pwrb_handle=%p free_index=0x%x"
@@ -4715,6 +4727,20 @@ beiscsi_offload_connection(struct beiscsi_conn 
*beiscsi_conn,
doorbell |= 1 << DB_DEF_PDU_NUM_POSTED_SHIFT;
iowrite32(doorbell, phba->db_va +
  beiscsi_conn->doorbell_offset);
+
+   /*
+* There is no completion for CONTEXT_UPDATE. The completion of next
+* WRB posted guarantees FW's processing and DMA'ing of it.
+* Use beiscsi_put_wrb_handle to put it back

[PATCH 13/15] be2iscsi: Fix to process 25G link speed info from FW

2015-12-15 Thread Jitendra Bhivare
From: Jitendra 

Async link event provides port_speed info. Use the same to report in
ISCSI_HOST_PARAM_PORT_SPEED query. Removed link status query IOCTL used
to do the same.

25G and 40G are defined in kernel enum iscsi_port_speed.

Fixed get_nic_conf structure definition. Removed rsvd[23] field in
be_cmd_get_nic_conf_resp.

Signed-off-by: Jitendra 
---
 drivers/scsi/be2iscsi/be_cmds.c |   47 -
 drivers/scsi/be2iscsi/be_cmds.h |   65 ++
 drivers/scsi/be2iscsi/be_iscsi.c|   41 +
 drivers/scsi/be2iscsi/be_main.h |1 +
 drivers/scsi/be2iscsi/be_mgmt.c |   28 ---
 drivers/scsi/scsi_transport_iscsi.c |2 +
 include/scsi/iscsi_if.h |2 +
 7 files changed, 57 insertions(+), 129 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 3dbf6af..498eba2 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -402,31 +402,31 @@ void beiscsi_fail_session(struct iscsi_cls_session 
*cls_session)
iscsi_session_failure(cls_session->dd_data, ISCSI_ERR_CONN_FAILED);
 }
 
-static void beiscsi_async_link_state_process(struct beiscsi_hba *phba,
-   struct be_async_event_link_state *evt)
+static void beiscsi_process_async_link(struct beiscsi_hba *phba,
+  struct be_mcc_compl *compl)
 {
-   if ((evt->port_link_status == ASYNC_EVENT_LINK_DOWN) ||
-   ((evt->port_link_status & ASYNC_EVENT_LOGICAL) &&
-(evt->port_fault != BEISCSI_PHY_LINK_FAULT_NONE))) {
-   phba->state = BE_ADAPTER_LINK_DOWN;
+   struct be_async_event_link_state *evt;
 
-   beiscsi_log(phba, KERN_ERR,
-   BEISCSI_LOG_CONFIG | BEISCSI_LOG_INIT,
-   "BC_%d : Link Down on Port %d\n",
-   evt->physical_port);
+   evt = (struct be_async_event_link_state *)compl;
 
-   iscsi_host_for_each_session(phba->shost,
-   beiscsi_fail_session);
-   } else if ((evt->port_link_status & ASYNC_EVENT_LINK_UP) ||
-   ((evt->port_link_status & ASYNC_EVENT_LOGICAL) &&
-(evt->port_fault == BEISCSI_PHY_LINK_FAULT_NONE))) {
+   phba->port_speed = evt->port_speed;
+   /**
+* Check logical link status in ASYNC event.
+* This has been newly introduced in SKH-R Firmware 10.0.338.45.
+**/
+   if (evt->port_link_status & BE_ASYNC_LINK_UP_MASK) {
phba->state = BE_ADAPTER_LINK_UP | BE_ADAPTER_CHECK_BOOT;
phba->get_boot = BE_GET_BOOT_RETRIES;
-
-   beiscsi_log(phba, KERN_ERR,
-   BEISCSI_LOG_CONFIG | BEISCSI_LOG_INIT,
-   "BC_%d : Link UP on Port %d\n",
-   evt->physical_port);
+   __beiscsi_log(phba, KERN_ERR,
+ "BC_%d : Link Up on Port %d tag 0x%x\n",
+ evt->physical_port, evt->event_tag);
+   } else {
+   phba->state = BE_ADAPTER_LINK_DOWN;
+   __beiscsi_log(phba, KERN_ERR,
+ "BC_%d : Link Down on Port %d tag 0x%x\n",
+ evt->physical_port, evt->event_tag);
+   iscsi_host_for_each_session(phba->shost,
+   beiscsi_fail_session);
}
 }
 
@@ -503,8 +503,7 @@ void beiscsi_process_async_event(struct beiscsi_hba *phba,
evt_code &= ASYNC_TRAILER_EVENT_CODE_MASK;
switch (evt_code) {
case ASYNC_EVENT_CODE_LINK_STATE:
-   beiscsi_async_link_state_process(phba,
-   (struct be_async_event_link_state *)compl);
+   beiscsi_process_async_link(phba, compl);
break;
case ASYNC_EVENT_CODE_ISCSI:
phba->state |= BE_ADAPTER_CHECK_BOOT;
@@ -520,8 +519,8 @@ void beiscsi_process_async_event(struct beiscsi_hba *phba,
}
 
beiscsi_log(phba, sev, BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
-   "BC_%d : ASYNC Event: status 0x%08x flags 0x%08x\n",
-   compl->status, compl->flags);
+   "BC_%d : ASYNC Event %x: status 0x%08x flags 0x%08x\n",
+   evt_code, compl->status, compl->flags);
 }
 
 int beiscsi_process_mcc(struct beiscsi_hba *phba)
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 6411f7b..3b9bc2e 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -142,7 +142,6 @@ struct be_async_event_trailer {
 enum {
ASYNC_EVENT_LINK_DOWN = 0x0,
ASYNC_EVENT_LINK_UP = 0x1,
-   ASYNC_EVENT_LOGICAL = 0x2
 };
 
 /**
@@ -152,13 +151,26 @@ enum {
 struct be_async_event_link_state {
u8 physical_port;
u8 port_link_status;
+/**

[PATCH 04/15] be2iscsi: Fix to synchronize tag allocation using spin_lock

2015-12-15 Thread Jitendra Bhivare
From: Jitendra 

alloc_mcc_tag/free_mcc_tag is now done under mcc_lock spin_lock

Signed-off-by: Jitendra 
---
 drivers/scsi/be2iscsi/be_cmds.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 21c806f..6f58063 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -118,6 +118,7 @@ unsigned int alloc_mcc_tag(struct beiscsi_hba *phba)
 {
unsigned int tag = 0;
 
+   spin_lock(&phba->ctrl.mcc_lock);
if (phba->ctrl.mcc_tag_available) {
tag = phba->ctrl.mcc_tag[phba->ctrl.mcc_alloc_index];
phba->ctrl.mcc_tag[phba->ctrl.mcc_alloc_index] = 0;
@@ -130,6 +131,7 @@ unsigned int alloc_mcc_tag(struct beiscsi_hba *phba)
else
phba->ctrl.mcc_alloc_index++;
}
+   spin_unlock(&phba->ctrl.mcc_lock);
return tag;
 }
 
@@ -254,7 +256,7 @@ release_mcc_tag:
 
 void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag)
 {
-   spin_lock(&ctrl->mbox_lock);
+   spin_lock(&ctrl->mcc_lock);
tag = tag & 0x00FF;
ctrl->mcc_tag[ctrl->mcc_free_index] = tag;
if (ctrl->mcc_free_index == (MAX_MCC_CMD - 1))
@@ -262,7 +264,7 @@ void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int 
tag)
else
ctrl->mcc_free_index++;
ctrl->mcc_tag_available++;
-   spin_unlock(&ctrl->mbox_lock);
+   spin_unlock(&ctrl->mcc_lock);
 }
 
 bool is_link_state_evt(u32 trailer)
-- 
1.7.1

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


[PATCH 01/15] be2iscsi: Fix soft lockup in mgmt_get_all_if_id path using bmbx

2015-12-15 Thread Jitendra Bhivare
From: Jitendra 

We are taking mbox_lock spinlock which disables pre-emption before we poll
for mbox completion. Waiting there with spinlock held in excess of 20s will
cause soft lockup.

Actual fix is to change mbox_lock to mutex.
The changes are done in phases. This is the first part.
1. Changed mgmt_get_all_if_id to use MCC where after posting lock is released.
2. Changed be_mbox_db_ready_wait to busy wait for 12s max and removed
wait_event_timeout. Added error handling code for IO reads.
OPCODE_COMMON_QUERY_FIRMWARE_CONFIG mbox command takes 8s time when unreachable
boot targets configured.

Signed-off-by: Jitendra 
---
 drivers/scsi/be2iscsi/be_cmds.c |   60 +++
 drivers/scsi/be2iscsi/be_mgmt.c |   32 ++--
 2 files changed, 51 insertions(+), 41 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 2778089..cd50e3c 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -587,47 +587,42 @@ int be_mcc_notify_wait(struct beiscsi_hba *phba)
  **/
 static int be_mbox_db_ready_wait(struct be_ctrl_info *ctrl)
 {
-#define BEISCSI_MBX_RDY_BIT_TIMEOUT4000/* 4sec */
+#define BEISCSI_MBX_RDY_BIT_TIMEOUT12000   /* 12sec */
void __iomem *db = ctrl->db + MPU_MAILBOX_DB_OFFSET;
struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev);
unsigned long timeout;
-   bool read_flag = false;
-   int ret = 0, i;
u32 ready;
-   DECLARE_WAIT_QUEUE_HEAD_ONSTACK(rdybit_check_q);
 
-   if (beiscsi_error(phba))
-   return -EIO;
+   /*
+* This BMBX busy wait path is used during init only.
+* For the commands executed during init, 5s should suffice.
+*/
+   timeout = jiffies + msecs_to_jiffies(BEISCSI_MBX_RDY_BIT_TIMEOUT);
+   do {
+   if (beiscsi_error(phba))
+   return -EIO;
 
-   timeout = jiffies + (HZ * 110);
+   ready = ioread32(db);
+   if (ready == 0x)
+   return -EIO;
 
-   do {
-   for (i = 0; i < BEISCSI_MBX_RDY_BIT_TIMEOUT; i++) {
-   ready = ioread32(db) & MPU_MAILBOX_DB_RDY_MASK;
-   if (ready) {
-   read_flag = true;
-   break;
-   }
-   mdelay(1);
-   }
+   ready &= MPU_MAILBOX_DB_RDY_MASK;
+   if (ready)
+   return 0;
 
-   if (!read_flag) {
-   wait_event_timeout(rdybit_check_q,
- (read_flag != true),
-  HZ * 5);
-   }
-   } while ((time_before(jiffies, timeout)) && !read_flag);
+   if (time_after(jiffies, timeout))
+   break;
+   mdelay(1);
+   } while (!ready);
 
-   if (!read_flag) {
-   beiscsi_log(phba, KERN_ERR,
-   BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
-   "BC_%d : FW Timed Out\n");
-   phba->fw_timeout = true;
-   beiscsi_ue_detect(phba);
-   ret = -EBUSY;
-   }
+   beiscsi_log(phba, KERN_ERR,
+   BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
+   "BC_%d : FW Timed Out\n");
 
-   return ret;
+   phba->fw_timeout = true;
+   beiscsi_ue_detect(phba);
+
+   return -EBUSY;
 }
 
 /*
@@ -674,6 +669,9 @@ int be_mbox_notify(struct be_ctrl_info *ctrl)
if (status)
return status;
 
+   /* RDY is set; small delay before CQE read. */
+   udelay(1);
+
if (be_mcc_compl_is_new(compl)) {
status = be_mcc_compl_process(ctrl, &mbox->compl);
be_mcc_compl_use(compl);
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index aea3e6b..7b54b23 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -809,27 +809,39 @@ int mgmt_open_connection(struct beiscsi_hba *phba,
 unsigned int mgmt_get_all_if_id(struct beiscsi_hba *phba)
 {
struct be_ctrl_info *ctrl = &phba->ctrl;
-   struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);
-   struct be_cmd_get_all_if_id_req *req = embedded_payload(wrb);
-   struct be_cmd_get_all_if_id_req *pbe_allid = req;
+   struct be_mcc_wrb *wrb;
+   struct be_cmd_get_all_if_id_req *req;
+   struct be_cmd_get_all_if_id_req *pbe_allid;
+   unsigned int tag;
int status = 0;
 
-   memset(wrb, 0, sizeof(*wrb));
-
spin_lock(&ctrl->mbox_lock);
+   tag = alloc_mcc_tag(phba);
+   if (!tag) {
+   spin_unlock(&ctrl->mbox_lock);
+   return -ENOMEM;
+   }
+
+   wrb = wrb_from_mccq(phba);
+   req = embedded_payload(wrb);
+   

[PATCH 06/15] be2iscsi: Added return value check for mgmt_get_all_if_id

2015-12-15 Thread Jitendra Bhivare
From: Jitendra 

Use of mutex_lock_interruptible can return -EINTR, handle and log
the error.

Signed-off-by: Jitendra 
---
 drivers/scsi/be2iscsi/be_iscsi.c |7 ---
 drivers/scsi/be2iscsi/be_mgmt.c  |   10 ++
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index b7087ba..188d83f 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -367,13 +367,14 @@ beiscsi_set_vlan_tag(struct Scsi_Host *shost,
  struct iscsi_iface_param_info *iface_param)
 {
struct beiscsi_hba *phba = iscsi_host_priv(shost);
-   int ret = 0;
+   int ret;
 
/* Get the Interface Handle */
-   if (mgmt_get_all_if_id(phba)) {
+   ret = mgmt_get_all_if_id(phba);
+   if (ret) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BS_%d : Getting Interface Handle Failed\n");
-   return -EIO;
+   return ret;
}
 
switch (iface_param->param) {
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index a41013e..a8a1670 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1018,8 +1018,9 @@ int mgmt_set_ip(struct beiscsi_hba *phba,
uint32_t ip_type;
int rc;
 
-   if (mgmt_get_all_if_id(phba))
-   return -EIO;
+   rc = mgmt_get_all_if_id(phba);
+   if (rc)
+   return rc;
 
ip_type = (ip_param->param == ISCSI_NET_PARAM_IPV6_ADDR) ?
BE2_IPV6 : BE2_IPV4 ;
@@ -1188,8 +1189,9 @@ int mgmt_get_if_info(struct beiscsi_hba *phba, int 
ip_type,
uint32_t ioctl_size = sizeof(struct be_cmd_get_if_info_resp);
int rc;
 
-   if (mgmt_get_all_if_id(phba))
-   return -EIO;
+   rc = mgmt_get_all_if_id(phba);
+   if (rc)
+   return rc;
 
do {
rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
-- 
1.7.1

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


[PATCH 02/15] be2iscsi: Fix mbox synchronization replacing spinlock with mutex

2015-12-15 Thread Jitendra Bhivare
From: Jitendra 

This is second part of actual fix for soft lockup.

All mbox cmds issued using BMBX and MCC are synchronized using mutex
mbox_lock instead of spin_lock. Used mutex_lock_interruptible where
ever possible.

Signed-off-by: Jitendra 
---
 drivers/scsi/be2iscsi/be.h  |2 +-
 drivers/scsi/be2iscsi/be_cmds.c |   73 ++-
 drivers/scsi/be2iscsi/be_main.c |2 +-
 drivers/scsi/be2iscsi/be_mgmt.c |  105 --
 4 files changed, 94 insertions(+), 88 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index 77f992e..cf19bce 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -124,7 +124,7 @@ struct be_ctrl_info {
struct pci_dev *pdev;
 
/* Mbox used for cmd request/response */
-   spinlock_t mbox_lock;   /* For serializing mbox cmds to BE card */
+   struct mutex mbox_lock; /* For serializing mbox cmds to BE card */
struct be_dma_mem mbox_mem;
/* Mbox mem is adjusted to align to 16 bytes. The allocated addr
 * is stored for freeing purpose */
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index cd50e3c..6fabded 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -164,9 +164,9 @@ int beiscsi_mccq_compl(struct beiscsi_hba *phba,
}
 
/* Set MBX Tag state to Active */
-   spin_lock(&phba->ctrl.mbox_lock);
+   mutex_lock(&phba->ctrl.mbox_lock);
phba->ctrl.ptag_state[tag].tag_state = MCC_TAG_STATE_RUNNING;
-   spin_unlock(&phba->ctrl.mbox_lock);
+   mutex_unlock(&phba->ctrl.mbox_lock);
 
/* wait for the mccq completion */
rc = wait_event_interruptible_timeout(
@@ -178,9 +178,9 @@ int beiscsi_mccq_compl(struct beiscsi_hba *phba,
if (rc <= 0) {
struct be_dma_mem *tag_mem;
/* Set MBX Tag state to timeout */
-   spin_lock(&phba->ctrl.mbox_lock);
+   mutex_lock(&phba->ctrl.mbox_lock);
phba->ctrl.ptag_state[tag].tag_state = MCC_TAG_STATE_TIMEOUT;
-   spin_unlock(&phba->ctrl.mbox_lock);
+   mutex_unlock(&phba->ctrl.mbox_lock);
 
/* Store resource addr to be freed later */
tag_mem = &phba->ctrl.ptag_state[tag].tag_mem_state;
@@ -199,9 +199,9 @@ int beiscsi_mccq_compl(struct beiscsi_hba *phba,
} else {
rc = 0;
/* Set MBX Tag state to completed */
-   spin_lock(&phba->ctrl.mbox_lock);
+   mutex_lock(&phba->ctrl.mbox_lock);
phba->ctrl.ptag_state[tag].tag_state = MCC_TAG_STATE_COMPLETED;
-   spin_unlock(&phba->ctrl.mbox_lock);
+   mutex_unlock(&phba->ctrl.mbox_lock);
}
 
mcc_tag_response = phba->ctrl.mcc_numtag[tag];
@@ -390,9 +390,9 @@ int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
tag_mem->va, tag_mem->dma);
 
/* Change tag state */
-   spin_lock(&phba->ctrl.mbox_lock);
+   mutex_lock(&phba->ctrl.mbox_lock);
ctrl->ptag_state[tag].tag_state = MCC_TAG_STATE_COMPLETED;
-   spin_unlock(&phba->ctrl.mbox_lock);
+   mutex_unlock(&phba->ctrl.mbox_lock);
 
/* Free MCC Tag */
free_mcc_tag(ctrl, tag);
@@ -831,7 +831,7 @@ int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
struct be_dma_mem *q_mem = &eq->dma_mem;
int status;
 
-   spin_lock(&ctrl->mbox_lock);
+   mutex_lock(&ctrl->mbox_lock);
memset(wrb, 0, sizeof(*wrb));
 
be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
@@ -858,7 +858,7 @@ int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
eq->id = le16_to_cpu(resp->eq_id);
eq->created = true;
}
-   spin_unlock(&ctrl->mbox_lock);
+   mutex_unlock(&ctrl->mbox_lock);
return status;
 }
 
@@ -879,7 +879,7 @@ int be_cmd_fw_initialize(struct be_ctrl_info *ctrl)
int status;
u8 *endian_check;
 
-   spin_lock(&ctrl->mbox_lock);
+   mutex_lock(&ctrl->mbox_lock);
memset(wrb, 0, sizeof(*wrb));
 
endian_check = (u8 *) wrb;
@@ -898,7 +898,7 @@ int be_cmd_fw_initialize(struct be_ctrl_info *ctrl)
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
"BC_%d : be_cmd_fw_initialize Failed\n");
 
-   spin_unlock(&ctrl->mbox_lock);
+   mutex_unlock(&ctrl->mbox_lock);
return status;
 }
 
@@ -919,7 +919,7 @@ int be_cmd_fw_uninit(struct be_ctrl_info *ctrl)
int status;
u8 *endian_check;
 
-   spin_lock(&ctrl->mbox_lock);
+   mutex_lock(&ctrl->mbox_lock);
memset(wrb, 0, sizeof(*wrb));
 
endian_check = (u8 *) wrb;
@@ -939,7 +939,7 @@ int be_cmd_fw_uninit(struct be_ctrl_info *ctrl)
beiscsi_log(phba, KERN_ERR, BEISCSI_

[PATCH 03/15] be2iscsi: Fix to use atomic operations for tag_state

2015-12-15 Thread Jitendra Bhivare
From: Jitendra 

Replace lock based tag_state manipulations with atomic operations.

Signed-off-by: Jitendra 
---
 drivers/scsi/be2iscsi/be.h  |2 +-
 drivers/scsi/be2iscsi/be_cmds.c |   26 --
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index cf19bce..419b53f 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -113,7 +113,7 @@ struct beiscsi_mcc_tag_state {
 #define MCC_TAG_STATE_COMPLETED 0x00
 #define MCC_TAG_STATE_RUNNING   0x01
 #define MCC_TAG_STATE_TIMEOUT   0x02
-   uint8_t tag_state;
+   atomic_t tag_state;
struct be_dma_mem tag_mem_state;
 };
 
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 6fabded..21c806f 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -164,9 +164,8 @@ int beiscsi_mccq_compl(struct beiscsi_hba *phba,
}
 
/* Set MBX Tag state to Active */
-   mutex_lock(&phba->ctrl.mbox_lock);
-   phba->ctrl.ptag_state[tag].tag_state = MCC_TAG_STATE_RUNNING;
-   mutex_unlock(&phba->ctrl.mbox_lock);
+   atomic_set(&phba->ctrl.ptag_state[tag].tag_state,
+   MCC_TAG_STATE_RUNNING);
 
/* wait for the mccq completion */
rc = wait_event_interruptible_timeout(
@@ -178,9 +177,8 @@ int beiscsi_mccq_compl(struct beiscsi_hba *phba,
if (rc <= 0) {
struct be_dma_mem *tag_mem;
/* Set MBX Tag state to timeout */
-   mutex_lock(&phba->ctrl.mbox_lock);
-   phba->ctrl.ptag_state[tag].tag_state = MCC_TAG_STATE_TIMEOUT;
-   mutex_unlock(&phba->ctrl.mbox_lock);
+   atomic_set(&phba->ctrl.ptag_state[tag].tag_state,
+   MCC_TAG_STATE_TIMEOUT);
 
/* Store resource addr to be freed later */
tag_mem = &phba->ctrl.ptag_state[tag].tag_mem_state;
@@ -199,9 +197,8 @@ int beiscsi_mccq_compl(struct beiscsi_hba *phba,
} else {
rc = 0;
/* Set MBX Tag state to completed */
-   mutex_lock(&phba->ctrl.mbox_lock);
-   phba->ctrl.ptag_state[tag].tag_state = MCC_TAG_STATE_COMPLETED;
-   mutex_unlock(&phba->ctrl.mbox_lock);
+   atomic_set(&phba->ctrl.ptag_state[tag].tag_state,
+   MCC_TAG_STATE_COMPLETED);
}
 
mcc_tag_response = phba->ctrl.mcc_numtag[tag];
@@ -373,9 +370,11 @@ int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
ctrl->mcc_numtag[tag] |= (extd_status & 0x00FF) << 8;
ctrl->mcc_numtag[tag] |= (compl_status & 0x00FF);
 
-   if (ctrl->ptag_state[tag].tag_state == MCC_TAG_STATE_RUNNING) {
+   if (atomic_read(&ctrl->ptag_state[tag].tag_state) ==
+   MCC_TAG_STATE_RUNNING) {
wake_up_interruptible(&ctrl->mcc_wait[tag]);
-   } else if (ctrl->ptag_state[tag].tag_state == MCC_TAG_STATE_TIMEOUT) {
+   } else if (atomic_read(&ctrl->ptag_state[tag].tag_state) ==
+   MCC_TAG_STATE_TIMEOUT) {
struct be_dma_mem *tag_mem;
tag_mem = &ctrl->ptag_state[tag].tag_mem_state;
 
@@ -390,9 +389,8 @@ int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
tag_mem->va, tag_mem->dma);
 
/* Change tag state */
-   mutex_lock(&phba->ctrl.mbox_lock);
-   ctrl->ptag_state[tag].tag_state = MCC_TAG_STATE_COMPLETED;
-   mutex_unlock(&phba->ctrl.mbox_lock);
+   atomic_set(&ctrl->ptag_state[tag].tag_state,
+   MCC_TAG_STATE_COMPLETED);
 
/* Free MCC Tag */
free_mcc_tag(ctrl, tag);
-- 
1.7.1

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


[PATCH 07/15] be2iscsi: Fix to remove shutdown entry point

2015-12-15 Thread Jitendra Bhivare
From: Jitendra 

Null pointer dereference in shutdown path after taking dump.

Shutdown path is not needed as FW comes up clean every time during probe
after issuing FUNCTION reset MBOX command.

Signed-off-by: Jitendra 
---
 drivers/scsi/be2iscsi/be_cmds.c |   17 +++--
 drivers/scsi/be2iscsi/be_cmds.h |2 +-
 drivers/scsi/be2iscsi/be_main.c |   24 
 drivers/scsi/be2iscsi/be_main.h |3 +--
 4 files changed, 9 insertions(+), 37 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 1e70053..e4cc98f 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -414,22 +414,11 @@ static struct be_mcc_compl *be_mcc_compl_get(struct 
beiscsi_hba *phba)
 }
 
 /**
- * be2iscsi_fail_session(): Closing session with appropriate error
+ * beiscsi_fail_session(): Closing session with appropriate error
  * @cls_session: ptr to session
- *
- * Depending on adapter state appropriate error flag is passed.
  **/
-void be2iscsi_fail_session(struct iscsi_cls_session *cls_session)
+void beiscsi_fail_session(struct iscsi_cls_session *cls_session)
 {
-   struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
-   struct beiscsi_hba *phba = iscsi_host_priv(shost);
-   uint32_t iscsi_err_flag;
-
-   if (phba->state & BE_ADAPTER_STATE_SHUTDOWN)
-   iscsi_err_flag = ISCSI_ERR_INVALID_HOST;
-   else
-   iscsi_err_flag = ISCSI_ERR_CONN_FAILED;
-
iscsi_session_failure(cls_session->dd_data, ISCSI_ERR_CONN_FAILED);
 }
 
@@ -447,7 +436,7 @@ void beiscsi_async_link_state_process(struct beiscsi_hba 
*phba,
evt->physical_port);
 
iscsi_host_for_each_session(phba->shost,
-   be2iscsi_fail_session);
+   beiscsi_fail_session);
} else if ((evt->port_link_status & ASYNC_EVENT_LINK_UP) ||
((evt->port_link_status & ASYNC_EVENT_LOGICAL) &&
 (evt->port_fault == BEISCSI_PHY_LINK_FAULT_NONE))) {
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 4bfca35..5d165ee 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -1367,5 +1367,5 @@ void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int 
payload_len,
 void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
u8 subsystem, u8 opcode, int cmd_len);
 
-void be2iscsi_fail_session(struct iscsi_cls_session *cls_session);
+void beiscsi_fail_session(struct iscsi_cls_session *cls_session);
 #endif /* !BEISCSI_CMDS_H */
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 61ce86b..2f3e118 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -5315,7 +5315,6 @@ static void beiscsi_quiesce(struct beiscsi_hba *phba,
 
 static void beiscsi_remove(struct pci_dev *pcidev)
 {
-
struct beiscsi_hba *phba = NULL;
 
phba = pci_get_drvdata(pcidev);
@@ -5325,9 +5324,9 @@ static void beiscsi_remove(struct pci_dev *pcidev)
}
 
beiscsi_destroy_def_ifaces(phba);
-   beiscsi_quiesce(phba, BEISCSI_CLEAN_UNLOAD);
iscsi_boot_destroy_kset(phba->boot_kset);
iscsi_host_remove(phba->shost);
+   beiscsi_quiesce(phba, BEISCSI_CLEAN_UNLOAD);
pci_dev_put(phba->pcidev);
iscsi_host_free(phba->shost);
pci_disable_pcie_error_reporting(pcidev);
@@ -5336,23 +5335,6 @@ static void beiscsi_remove(struct pci_dev *pcidev)
pci_disable_device(pcidev);
 }
 
-static void beiscsi_shutdown(struct pci_dev *pcidev)
-{
-
-   struct beiscsi_hba *phba = NULL;
-
-   phba = (struct beiscsi_hba *)pci_get_drvdata(pcidev);
-   if (!phba) {
-   dev_err(&pcidev->dev, "beiscsi_shutdown called with no phba\n");
-   return;
-   }
-
-   phba->state = BE_ADAPTER_STATE_SHUTDOWN;
-   iscsi_host_for_each_session(phba->shost, be2iscsi_fail_session);
-   beiscsi_quiesce(phba, BEISCSI_CLEAN_UNLOAD);
-   pci_disable_device(pcidev);
-}
-
 static void beiscsi_msix_enable(struct beiscsi_hba *phba)
 {
int i, status;
@@ -5673,6 +5655,9 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
goto hba_free;
}
 
+   /*
+* FUNCTION_RESET should clean up any stale info in FW for this fn
+*/
ret = beiscsi_cmd_reset_function(phba);
if (ret) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
@@ -5861,7 +5846,6 @@ static struct pci_driver beiscsi_pci_driver = {
.name = DRV_NAME,
.probe = beiscsi_dev_probe,
.remove = beiscsi_remove,
-   .shutdown = beiscsi_shutdown,
.id_table = beiscsi_pci_id_table,
.err_handler = &beiscsi_eeh_handlers
 };
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 5c67c07..bd9d1e1 100644
-

[PATCH 00/15] be2iscsi: driver update 11.0.0.0

2015-12-15 Thread Jitendra Bhivare
From: Jitendra 

This patch is generated against for-next branch.

Jitendra (15):
  be2iscsi: Fix soft lockup in mgmt_get_all_if_id path using bmbx
  be2iscsi: Fix mbox synchronization replacing spinlock with mutex
  be2iscsi: Fix to use atomic operations for tag_state
  be2iscsi: Fix to synchronize tag allocation using spin_lock
  be2iscsi: Set mbox timeout to 30s
  be2iscsi: Added return value check for mgmt_get_all_if_id
  be2iscsi: Fix to remove shutdown entry point
  be2iscsi: Fix VLAN support for IPv6 network
  be2iscsi: Fix to handle misconfigured optics events
  be2iscsi: Add FW config validation
  be2iscsi: Fix return value for MCC completion
  be2iscsi: Fix IOPOLL implementation
  be2iscsi: Fix to process 25G link speed info from FW
  be2iscsi: Fix WRB leak in login/logout path
  be2iscsi: Update the driver version

 drivers/scsi/be2iscsi/be.h  |4 +-
 drivers/scsi/be2iscsi/be_cmds.c |  368 ++---
 drivers/scsi/be2iscsi/be_cmds.h |  114 ++-
 drivers/scsi/be2iscsi/be_iscsi.c|   54 ++---
 drivers/scsi/be2iscsi/be_main.c |  210 ++-
 drivers/scsi/be2iscsi/be_main.h |   23 ++-
 drivers/scsi/be2iscsi/be_mgmt.c |  387 +--
 drivers/scsi/be2iscsi/be_mgmt.h |2 +
 drivers/scsi/scsi_transport_iscsi.c |2 +
 include/scsi/iscsi_if.h |2 +
 10 files changed, 648 insertions(+), 518 deletions(-)

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


[PATCH 09/15] be2iscsi: Fix to handle misconfigured optics events

2015-12-15 Thread Jitendra Bhivare
From: Jitendra 

Log messages for misconfigured transceivers reported by FW.

Register async events that driver handles using MCC_CREATE_EXT ioctl.
Errors messages for faulted/uncertified/unqualified optics are logged.
Added IOCTL to get port_name to be displayed in error message.

Signed-off-by: Jitendra 
---
 drivers/scsi/be2iscsi/be_cmds.c |  164 --
 drivers/scsi/be2iscsi/be_cmds.h |   47 ++--
 drivers/scsi/be2iscsi/be_main.c |   19 +
 drivers/scsi/be2iscsi/be_main.h |   10 ++-
 drivers/scsi/be2iscsi/be_mgmt.c |   42 ++
 drivers/scsi/be2iscsi/be_mgmt.h |2 +
 6 files changed, 199 insertions(+), 85 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index e4cc98f..9bb5905 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -267,26 +267,6 @@ void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int 
tag)
spin_unlock(&ctrl->mcc_lock);
 }
 
-bool is_link_state_evt(u32 trailer)
-{
-   return (((trailer >> ASYNC_TRAILER_EVENT_CODE_SHIFT) &
- ASYNC_TRAILER_EVENT_CODE_MASK) ==
- ASYNC_EVENT_CODE_LINK_STATE);
-}
-
-static bool is_iscsi_evt(u32 trailer)
-{
-   return ((trailer >> ASYNC_TRAILER_EVENT_CODE_SHIFT) &
- ASYNC_TRAILER_EVENT_CODE_MASK) ==
- ASYNC_EVENT_CODE_ISCSI;
-}
-
-static int iscsi_evt_type(u32 trailer)
-{
-   return (trailer >> ASYNC_TRAILER_EVENT_TYPE_SHIFT) &
-ASYNC_TRAILER_EVENT_TYPE_MASK;
-}
-
 static inline bool be_mcc_compl_is_new(struct be_mcc_compl *compl)
 {
if (compl->flags != 0) {
@@ -422,7 +402,7 @@ void beiscsi_fail_session(struct iscsi_cls_session 
*cls_session)
iscsi_session_failure(cls_session->dd_data, ISCSI_ERR_CONN_FAILED);
 }
 
-void beiscsi_async_link_state_process(struct beiscsi_hba *phba,
+static void beiscsi_async_link_state_process(struct beiscsi_hba *phba,
struct be_async_event_link_state *evt)
 {
if ((evt->port_link_status == ASYNC_EVENT_LINK_DOWN) ||
@@ -450,6 +430,100 @@ void beiscsi_async_link_state_process(struct beiscsi_hba 
*phba,
}
 }
 
+static char *beiscsi_port_misconf_event_msg[] = {
+   "Physical Link is functional.",
+   "Optics faulted/incorrectly installed/not installed - Reseat optics, if 
issue not resolved, replace.",
+   "Optics of two types installed - Remove one optic or install matching 
pair of optics.",
+   "Incompatible optics - Replace with compatible optics for card to 
function.",
+   "Unqualified optics - Replace with Avago optics for Warranty and 
Technical Support.",
+   "Uncertified optics - Replace with Avago Certified optics to enable 
link operation."
+};
+
+static void beiscsi_process_async_sli(struct beiscsi_hba *phba,
+ struct be_mcc_compl *compl)
+{
+   struct be_async_event_sli *async_sli;
+   u8 evt_type, state, old_state, le;
+   char *sev = KERN_WARNING;
+   char *msg = NULL;
+
+   evt_type = compl->flags >> ASYNC_TRAILER_EVENT_TYPE_SHIFT;
+   evt_type &= ASYNC_TRAILER_EVENT_TYPE_MASK;
+
+   /* processing only MISCONFIGURED physical port event */
+   if (evt_type != ASYNC_SLI_EVENT_TYPE_MISCONFIGURED)
+   return;
+
+   async_sli = (struct be_async_event_sli *)compl;
+   state = async_sli->event_data1 >>
+(phba->fw_config.phys_port * 8) & 0xff;
+   le = async_sli->event_data2 >>
+(phba->fw_config.phys_port * 8) & 0xff;
+
+   old_state = phba->optic_state;
+   phba->optic_state = state;
+
+   if (state >= ARRAY_SIZE(beiscsi_port_misconf_event_msg)) {
+   /* fw is reporting a state we don't know, log and return */
+   __beiscsi_log(phba, KERN_ERR,
+   "BC_%d : Port %c: Unrecognized optic state 0x%x\n",
+   phba->port_name, async_sli->event_data1);
+   return;
+   }
+
+   if (ASYNC_SLI_LINK_EFFECT_VALID(le)) {
+   /* log link effect for unqualified-4, uncertified-5 optics */
+   if (state > 3)
+   msg = (ASYNC_SLI_LINK_EFFECT_STATE(le)) ?
+   " Link is non-operational." :
+   " Link is operational.";
+   /* 1 - info */
+   if (ASYNC_SLI_LINK_EFFECT_SEV(le) == 1)
+   sev = KERN_INFO;
+   /* 2 - error */
+   if (ASYNC_SLI_LINK_EFFECT_SEV(le) == 2)
+   sev = KERN_ERR;
+   }
+
+   if (old_state != phba->optic_state)
+   __beiscsi_log(phba, sev, "BC_%d : Port %c: %s%s\n",
+ phba->port_name,
+ beiscsi_port_misconf_event_msg[state],
+ !msg ? "" : msg);
+}
+
+void beiscsi_process_async_event(struct beiscsi_hba *phba,
+ 

[PATCH 05/15] be2iscsi: Set mbox timeout to 30s

2015-12-15 Thread Jitendra Bhivare
From: Jitendra 

FW recommended timeout for all mbox command is 30s.
Use msleep instead mdelay to relinquish CPU when polling for
mbox completion.

Signed-off-by: Jitendra 
---
 drivers/scsi/be2iscsi/be_cmds.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 6f58063..1e70053 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -587,7 +587,8 @@ int be_mcc_notify_wait(struct beiscsi_hba *phba)
  **/
 static int be_mbox_db_ready_wait(struct be_ctrl_info *ctrl)
 {
-#define BEISCSI_MBX_RDY_BIT_TIMEOUT12000   /* 12sec */
+   /* wait 30s for generic non-flash MBOX operation */
+#define BEISCSI_MBX_RDY_BIT_TIMEOUT3
void __iomem *db = ctrl->db + MPU_MAILBOX_DB_OFFSET;
struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev);
unsigned long timeout;
@@ -612,7 +613,7 @@ static int be_mbox_db_ready_wait(struct be_ctrl_info *ctrl)
 
if (time_after(jiffies, timeout))
break;
-   mdelay(1);
+   msleep(20);
} while (!ready);
 
beiscsi_log(phba, KERN_ERR,
-- 
1.7.1

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


[PATCH 10/15] be2iscsi: Add FW config validation

2015-12-15 Thread Jitendra Bhivare
From: Jitendra 

System crash in I+T card personality

Fix to add validation for ULP in initiator mode, physical port number,
and supported queue, icd, cid counts.

Signed-off-by: Jitendra 
---
 drivers/scsi/be2iscsi/be_main.c |2 +-
 drivers/scsi/be2iscsi/be_main.h |2 +
 drivers/scsi/be2iscsi/be_mgmt.c |  188 +--
 3 files changed, 123 insertions(+), 69 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 8967e05..a665e6a 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -5670,6 +5670,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
goto free_port;
}
mgmt_get_port_name(&phba->ctrl, phba);
+   beiscsi_get_params(phba);
 
if (enable_msix)
find_num_cpus(phba);
@@ -5687,7 +5688,6 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
}
 
phba->shost->max_id = phba->params.cxns_per_ctrl;
-   beiscsi_get_params(phba);
phba->shost->can_queue = phba->params.ios_per_ctrl;
ret = beiscsi_init_port(phba);
if (ret < 0) {
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index c09082a..f89861b 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -397,7 +397,9 @@ struct beiscsi_hba {
 * group together since they are used most frequently
 * for cid to cri conversion
 */
+#define BEISCSI_PHYS_PORT_MAX  4
unsigned int phys_port;
+   /* valid values of phys_port id are 0, 1, 2, 3 */
unsigned int eqid_count;
unsigned int cqid_count;
unsigned int iscsi_cid_start[BEISCSI_ULP_COUNT];
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index ad7aa75..15f7ad7 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -373,90 +373,142 @@ int mgmt_get_fw_config(struct be_ctrl_info *ctrl,
struct beiscsi_hba *phba)
 {
struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);
-   struct be_fw_cfg *req = embedded_payload(wrb);
-   int status = 0;
+   struct be_fw_cfg *pfw_cfg = embedded_payload(wrb);
+   uint32_t cid_count, icd_count;
+   int status = -EINVAL;
+   uint8_t ulp_num = 0;
 
mutex_lock(&ctrl->mbox_lock);
memset(wrb, 0, sizeof(*wrb));
+   be_wrb_hdr_prepare(wrb, sizeof(*pfw_cfg), true, 0);
 
-   be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
-
-   be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
+   be_cmd_hdr_prepare(&pfw_cfg->hdr, CMD_SUBSYSTEM_COMMON,
   OPCODE_COMMON_QUERY_FIRMWARE_CONFIG,
   EMBED_MBX_MAX_PAYLOAD_SIZE);
-   status = be_mbox_notify(ctrl);
-   if (!status) {
-   uint8_t ulp_num = 0;
-   struct be_fw_cfg *pfw_cfg;
-   pfw_cfg = req;
 
-   if (!is_chip_be2_be3r(phba)) {
-   phba->fw_config.eqid_count = pfw_cfg->eqid_count;
-   phba->fw_config.cqid_count = pfw_cfg->cqid_count;
+   if (be_mbox_notify(ctrl)) {
+   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
+   "BG_%d : Failed in mgmt_get_fw_config\n");
+   goto fail_init;
+   }
 
-   beiscsi_log(phba, KERN_INFO,
-   BEISCSI_LOG_INIT,
-   "BG_%d : EQ_Count : %d CQ_Count : %d\n",
-   phba->fw_config.eqid_count,
+   /* FW response formats depend on port id */
+   phba->fw_config.phys_port = pfw_cfg->phys_port;
+   if (phba->fw_config.phys_port >= BEISCSI_PHYS_PORT_MAX) {
+   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
+   "BG_%d : invalid physical port id %d\n",
+   phba->fw_config.phys_port);
+   goto fail_init;
+   }
+
+   /* populate and check FW config against min and max values */
+   if (!is_chip_be2_be3r(phba)) {
+   phba->fw_config.eqid_count = pfw_cfg->eqid_count;
+   phba->fw_config.cqid_count = pfw_cfg->cqid_count;
+   if (phba->fw_config.eqid_count == 0 ||
+   phba->fw_config.eqid_count > 2048) {
+   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
+   "BG_%d : invalid EQ count %d\n",
+   phba->fw_config.eqid_count);
+   goto fail_init;
+   }
+   if (phba->fw_config.cqid_count == 0 ||
+   phba->fw_config.cqid_count > 4096) {
+   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
+   "BG_%d : invalid CQ count %d\n",
  

[PATCH 08/15] be2iscsi: Fix VLAN support for IPv6 network

2015-12-15 Thread Jitendra Bhivare
From: Jitendra 

Configuring VLAN parameters through IPv6 interface was not supported in driver.

Signed-off-by: Jitendra 
---
 drivers/scsi/be2iscsi/be_iscsi.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 188d83f..c89a025 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -466,6 +466,10 @@ beiscsi_set_ipv6(struct Scsi_Host *shost,
ret = mgmt_set_ip(phba, iface_param, NULL,
  ISCSI_BOOTPROTO_STATIC);
break;
+   case ISCSI_NET_PARAM_VLAN_ENABLED:
+   case ISCSI_NET_PARAM_VLAN_TAG:
+   ret = beiscsi_set_vlan_tag(shost, iface_param);
+   break;
default:
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BS_%d : Param %d not supported\n",
-- 
1.7.1

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


[PATCH 11/15] be2iscsi: Fix return value for MCC completion

2015-12-15 Thread Jitendra Bhivare
From: Jitendra 

Change return value of completed MCC EBUSY to EINVAL.

Signed-off-by: Jitendra 
---
 drivers/scsi/be2iscsi/be_cmds.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 9bb5905..eced82b 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -323,7 +323,7 @@ static int be_mcc_compl_process(struct be_ctrl_info *ctrl,
if (resp_hdr->response_length)
return 0;
}
-   return -EBUSY;
+   return -EINVAL;
}
return 0;
 }
-- 
1.7.1

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


Re: kernel BUG at block/bio.c:1787! while initializing scsi_debug on ppc64 host

2015-12-15 Thread Martin K. Petersen
> "Eryu" == Eryu Guan  writes:

Eryu,

Eryu> This is still reproducible with 4.4-rc5 kernel.

Sorry about the delay. I've been busy with a lab move and most of my
machines have been disconnected since last week. Almost done getting my
equipment back online.

However, I think I have found the smoking gun. More in a bit...

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


Re: kernel BUG at block/bio.c:1787! while initializing scsi_debug on ppc64 host

2015-12-15 Thread Ming Lei
On Tue, 15 Dec 2015 21:06:31 +0800
Eryu Guan  wrote:

> On Tue, Dec 15, 2015 at 08:06:47PM +0800, Ming Lei wrote:
> > On Tue, Dec 15, 2015 at 7:20 PM, Eryu Guan  wrote:
> > > On Fri, Dec 11, 2015 at 07:53:40PM +0800, Eryu Guan wrote:
> > >> Hi,
> > >>
> > >> I saw this kernel BUG_ON on 4.4-rc4 kernel, and this can be reproduced
> > >> easily on ppc64 host by:
> > >
> > > This is still reproducible with 4.4-rc5 kernel.
> > 
> > Could you capture the debug log after appyling the attached patch and
> > the reproduction?
> 
> Thanks for looking into this! dmesg shows:
> 
> [  686.217682] bio_split: sectors 0, bio_sectors 128, bi_rw 0

I guess the following patch should fix the issue, and ca369d51b3
uses OPTIMAL TRANSFER LENGTH to set limits->max_sectors, which
may be less than one page size.

I don't understand the idea behind this change, Martin, could
you explain it a bit?

---
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 3d22fc3..d66d362 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2889,10 +2889,11 @@ static int sd_revalidate_disk(struct gendisk *disk)
 */
if (sdkp->opt_xfer_blocks && sdkp->opt_xfer_blocks <= dev_max &&
sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS)
-   rw_max = q->limits.io_opt =
+   q->limits.io_opt =
logical_to_sectors(sdp, sdkp->opt_xfer_blocks);
-   else
-   rw_max = BLK_DEF_MAX_SECTORS;
+
+   rw_max = min_t(unsigned, BLK_DEF_MAX_SECTORS,
+  q->limits.max_dev_sectors);
 
/* Combine with controller limits */
q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q));
-- 
1.9.1





> 
> Thanks,
> Eryu
> 
> P.S. full call trace
> 
> [  686.065692] scsi_debug:sdebug_driver_probe: host protection
> [  686.065710] scsi host1: scsi_debug, version 1.85 [20141022], 
> dev_size_mb=256, opts=0x0
> [  686.065981] scsi 1:0:0:0: Direct-Access Linuxscsi_debug   0184 
> PQ: 0 ANSI: 6
> [  686.066873] sd 1:0:0:0: Attached scsi generic sg1 type 0
> [  686.077683] sd 1:0:0:0: [sdb] 524288 512-byte logical blocks: (268 MB/256 
> MiB)
> [  686.077694] sd 1:0:0:0: [sdb] 4096-byte physical blocks
> [  686.087670] sd 1:0:0:0: [sdb] Write Protect is off
> [  686.107671] sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, 
> supports DPO and FUA
> [  686.217682] bio_split: sectors 0, bio_sectors 128, bi_rw 0
> [  686.217695] [ cut here ]
> [  686.217698] kernel BUG at block/bio.c:1793!
> [  686.217702] Oops: Exception in kernel mode, sig: 5 [#1]
> [  686.217704] SMP NR_CPUS=2048 NUMA pSeries
> [  686.217707] Modules linked in: scsi_debug sg pseries_rng nfsd auth_rpcgss 
> nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c sd_mod ibmvscsi ibmveth 
> scsi_transport_srp
> [  686.217727] CPU: 8 PID: 9515 Comm: kworker/u32:0 Not tainted 4.4.0-rc5+ #33
> [  686.217733] Workqueue: events_unbound async_run_entry_fn
> [  686.217737] task: c005edb23cc0 ti: c005f016c000 task.ti: 
> c005f016c000
> [  686.217740] NIP: c03c45c4 LR: c03c46b8 CTR: 
> 013abb8c
> [  686.217743] REGS: c005f016ea20 TRAP: 0700   Not tainted  (4.4.0-rc5+)
> [  686.217746] MSR: 800100029033   CR: 22bb2322  
> XER: 000f
> [  686.217756] CFAR: c03c46cc SOFTE: 1 
> GPR00: c03c46b8 c005f016eca0 c1068300 002e 
> GPR04: c005ffd09c50 c005ffd1b4a0 0001  
> GPR08: 0001 c0bab284 0005ff16 0130 
> GPR12: 3f30 ce7e4c00  f15d0e40 
> GPR16: c005f3c3b7a0 c0057439 0001  
> GPR20:  0080  c005f5093200 
> GPR24: c005edb0efa0 c005f016ee60 c005f5093288  
> GPR28: 0240 c005f5093200  c005efd67600 
> [  686.217797] NIP [c03c45c4] bio_split+0x54/0x160
> [  686.217800] LR [c03c46b8] bio_split+0x148/0x160
> [  686.217803] Call Trace:
> [  686.217805] [c005f016eca0] [c03c46b8] bio_split+0x148/0x160 
> (unreliable)
> [  686.217810] [c005f016ed30] [c03d75e0] 
> blk_queue_split+0x3c0/0x570
> [  686.217814] [c005f016ee30] [c03d10a8] blk_queue_bio+0x48/0x440
> [  686.217818] [c005f016ee90] [c03cec9c] 
> generic_make_request+0x15c/0x220
> [  686.217822] [c005f016eef0] [c03cee24] submit_bio+0xc4/0x1d0
> [  686.217826] [c005f016efa0] [c02db204] submit_bh_wbc+0x1a4/0x200
> [  686.217830] [c005f016eff0] [c02db6f0] 
> block_read_full_page+0x320/0x420
> [  686.217835] [c005f016f4a0] [c02dedb4] blkdev_readpage+0x24/0x40
> [  686.217839] [c005f016f4c0] [c01f06fc] 
> do_read_cache_page+0xbc/0x290
> [  686.217844] [c005f016f530] [c03e8e00] read_dev_sector+0x40/0xc0
> [  686.217848] [c005f016f560] [c0

Re: [PATCH 2/3] hpsa: change SAS transport devices to bus 0.

2015-12-15 Thread Don Brace

On 12/09/2015 05:21 PM, Matthew R. Ochs wrote:

On Dec 9, 2015, at 3:18 PM, Don Brace  wrote:

sas transport places devices on bus 0 but driver was setting
the bus to 3.

Reviewed-by: Justin Lindley 
Reviewed-by: Kevin Barnett 
Reviewed-by: Scott Teel 
Signed-off-by: Don Brace 
---
drivers/scsi/hpsa.h |2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index ae5beda..fdd39fc 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -400,7 +400,7 @@ struct offline_device_entry {
#define HPSA_PHYSICAL_DEVICE_BUS0
#define HPSA_RAID_VOLUME_BUS1
#define HPSA_EXTERNAL_RAID_VOLUME_BUS   2
-#define HPSA_HBA_BUS   3
+#define HPSA_HBA_BUS   0

Is this not the same as using HPSA_PHYSICAL_DEVICE_BUS?

I was just trying to minimize the changes. I can update the driver
is necessary.

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


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


Re: [PATCH] USB: storage: add "no SYNCHRONIZE CACHE" quirk

2015-12-15 Thread Alan Stern
On Tue, 15 Dec 2015, Oliver Neukum wrote:

> On Thu, 2015-12-03 at 13:36 -0500, Alan Stern wrote:
> > This is an old problem, but it was never resolved and it still affects
> > people (Bugzilla #89511).  In short, there are USB-(S)ATA bridges that
> > claim to be write-back but don't support the SYNCHRONIZE CACHE
> > command.  
> > This causes errors when filesystems try to flush data out to the disk.
> 
> OK, maybe this is a stupid idea, but could we test the command as we
> enumerate the slave and store the result?

Maybe, although doing so within usb-storage would be kind of difficult
-- that driver is set up to forward requests from the SCSI layer, not
to generate requests of its own.  Besides, usb-storage doesn't know 
anything about write-back vs. write-through; only sd does.  I suppose 
sd could perform that test.

Alan Stern

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


Re: kernel BUG at block/bio.c:1787! while initializing scsi_debug on ppc64 host

2015-12-15 Thread Ming Lei
On Tue, Dec 15, 2015 at 9:06 PM, Eryu Guan  wrote:
> On Tue, Dec 15, 2015 at 08:06:47PM +0800, Ming Lei wrote:
>> On Tue, Dec 15, 2015 at 7:20 PM, Eryu Guan  wrote:
>> > On Fri, Dec 11, 2015 at 07:53:40PM +0800, Eryu Guan wrote:
>> >> Hi,
>> >>
>> >> I saw this kernel BUG_ON on 4.4-rc4 kernel, and this can be reproduced
>> >> easily on ppc64 host by:
>> >
>> > This is still reproducible with 4.4-rc5 kernel.
>>
>> Could you capture the debug log after appyling the attached patch and
>> the reproduction?
>
> Thanks for looking into this! dmesg shows:
>
> [  686.217682] bio_split: sectors 0, bio_sectors 128, bi_rw 0

Then I guess queue_max_sectors(q) is bad, could you apply the
attached patch(and the last patch) and post the log?


>
> Thanks,
> Eryu
>
> P.S. full call trace
>
> [  686.065692] scsi_debug:sdebug_driver_probe: host protection
> [  686.065710] scsi host1: scsi_debug, version 1.85 [20141022], 
> dev_size_mb=256, opts=0x0
> [  686.065981] scsi 1:0:0:0: Direct-Access Linuxscsi_debug   0184 
> PQ: 0 ANSI: 6
> [  686.066873] sd 1:0:0:0: Attached scsi generic sg1 type 0
> [  686.077683] sd 1:0:0:0: [sdb] 524288 512-byte logical blocks: (268 MB/256 
> MiB)
> [  686.077694] sd 1:0:0:0: [sdb] 4096-byte physical blocks
> [  686.087670] sd 1:0:0:0: [sdb] Write Protect is off
> [  686.107671] sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, 
> supports DPO and FUA
> [  686.217682] bio_split: sectors 0, bio_sectors 128, bi_rw 0
> [  686.217695] [ cut here ]
> [  686.217698] kernel BUG at block/bio.c:1793!
> [  686.217702] Oops: Exception in kernel mode, sig: 5 [#1]
> [  686.217704] SMP NR_CPUS=2048 NUMA pSeries
> [  686.217707] Modules linked in: scsi_debug sg pseries_rng nfsd auth_rpcgss 
> nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c sd_mod ibmvscsi ibmveth 
> scsi_transport_srp
> [  686.217727] CPU: 8 PID: 9515 Comm: kworker/u32:0 Not tainted 4.4.0-rc5+ #33
> [  686.217733] Workqueue: events_unbound async_run_entry_fn
> [  686.217737] task: c005edb23cc0 ti: c005f016c000 task.ti: 
> c005f016c000
> [  686.217740] NIP: c03c45c4 LR: c03c46b8 CTR: 
> 013abb8c
> [  686.217743] REGS: c005f016ea20 TRAP: 0700   Not tainted  (4.4.0-rc5+)
> [  686.217746] MSR: 800100029033   CR: 22bb2322  
> XER: 000f
> [  686.217756] CFAR: c03c46cc SOFTE: 1
> GPR00: c03c46b8 c005f016eca0 c1068300 002e
> GPR04: c005ffd09c50 c005ffd1b4a0 0001 
> GPR08: 0001 c0bab284 0005ff16 0130
> GPR12: 3f30 ce7e4c00  f15d0e40
> GPR16: c005f3c3b7a0 c0057439 0001 
> GPR20:  0080  c005f5093200
> GPR24: c005edb0efa0 c005f016ee60 c005f5093288 
> GPR28: 0240 c005f5093200  c005efd67600
> [  686.217797] NIP [c03c45c4] bio_split+0x54/0x160
> [  686.217800] LR [c03c46b8] bio_split+0x148/0x160
> [  686.217803] Call Trace:
> [  686.217805] [c005f016eca0] [c03c46b8] bio_split+0x148/0x160 
> (unreliable)
> [  686.217810] [c005f016ed30] [c03d75e0] 
> blk_queue_split+0x3c0/0x570
> [  686.217814] [c005f016ee30] [c03d10a8] blk_queue_bio+0x48/0x440
> [  686.217818] [c005f016ee90] [c03cec9c] 
> generic_make_request+0x15c/0x220
> [  686.217822] [c005f016eef0] [c03cee24] submit_bio+0xc4/0x1d0
> [  686.217826] [c005f016efa0] [c02db204] submit_bh_wbc+0x1a4/0x200
> [  686.217830] [c005f016eff0] [c02db6f0] 
> block_read_full_page+0x320/0x420
> [  686.217835] [c005f016f4a0] [c02dedb4] blkdev_readpage+0x24/0x40
> [  686.217839] [c005f016f4c0] [c01f06fc] 
> do_read_cache_page+0xbc/0x290
> [  686.217844] [c005f016f530] [c03e8e00] read_dev_sector+0x40/0xc0
> [  686.217848] [c005f016f560] [c03ec6bc] read_lba+0xdc/0x200
> [  686.217851] [c005f016f5c0] [c03ece4c] find_valid_gpt+0xec/0x740
> [  686.217855] [c005f016f6a0] [c03ed894] efi_partition+0x3f4/0x450
> [  686.217859] [c005f016f820] [c03ea428] 
> check_partition+0x158/0x2f0
> [  686.217863] [c005f016f8a0] [c03e9694] 
> rescan_partitions+0xd4/0x390
> [  686.217867] [c005f016f970] [c02e0938] __blkdev_get+0x3a8/0x4d0
> [  686.217871] [c005f016f9e0] [c02e0c90] blkdev_get+0x230/0x4a0
> [  686.217875] [c005f016fa90] [c03e65b8] add_disk+0x478/0x500
> [  686.217880] [c005f016fb40] [d3fa66a8] 
> sd_probe_async+0xf8/0x240 [sd_mod]
> [  686.217884] [c005f016fbc0] [c00d7db8] 
> async_run_entry_fn+0x98/0x1f0
> [  686.217888] [c005f016fc50] [c00cc1a0] 
> process_one_work+0x190/0x470
> [  686.217892] [c005f016fce0] [c00cc5fc] worker_thread+0x17c/0x5a0
> [  686

RE: [PATCH 5/9] be2iscsi: Fix to handle misconfigured optics events

2015-12-15 Thread Jitendra Bhivare
> So please add defines for the individual messages and use a key-value
map to lookup the messages.
FW events are in sequence 0...5 so key is implied and value is being
stored in array of strings.
BEISCSI_PORT_MISCONF_EVENT_MAX (replaced with ARRAY_SIZE) is just to
verify the event number.
Not so sure what you are suggesting.

port_name IOCTL is needed to display the error message.

Will split FW config validation.

Thanks,

JB

-Original Message-
From: Hannes Reinecke [mailto:h...@suse.de]
Sent: Monday, December 14, 2015 8:49 PM
To: Jitendra Bhivare; linux-scsi@vger.kernel.org; micha...@cs.wisc.edu
Subject: Re: [PATCH 5/9] be2iscsi: Fix to handle misconfigured optics
events

On 12/14/2015 07:11 AM, Jitendra Bhivare wrote:
> From: Jitendra 
>
> Log messages for misconfigured transceivers reported by FW.
>
> Register async events that driver handles using MCC_CREATE_EXT ioctl.
> Errors messages for faulted/uncertified/unqualified optics are logged.
> Added FW config validation.
>
> Signed-off-by: Jitendra 
> ---
>   drivers/scsi/be2iscsi/be_cmds.c |  169 ++---
>   drivers/scsi/be2iscsi/be_cmds.h |   47 +++-
>   drivers/scsi/be2iscsi/be_main.c |   22 +---
>   drivers/scsi/be2iscsi/be_main.h |   12 ++-
>   drivers/scsi/be2iscsi/be_mgmt.c |  230
+++
>   drivers/scsi/be2iscsi/be_mgmt.h |2 +
>   6 files changed, 327 insertions(+), 155 deletions(-)
>
> diff --git a/drivers/scsi/be2iscsi/be_cmds.c
> b/drivers/scsi/be2iscsi/be_cmds.c index e4cc98f..58a9fda 100644
> --- a/drivers/scsi/be2iscsi/be_cmds.c
> +++ b/drivers/scsi/be2iscsi/be_cmds.c
> @@ -267,26 +267,6 @@ void free_mcc_tag(struct be_ctrl_info *ctrl,
unsigned int tag)
>   spin_unlock(&ctrl->mcc_lock);
>   }
>
> -bool is_link_state_evt(u32 trailer)
> -{
> - return (((trailer >> ASYNC_TRAILER_EVENT_CODE_SHIFT) &
> -   ASYNC_TRAILER_EVENT_CODE_MASK) ==
> -   ASYNC_EVENT_CODE_LINK_STATE);
> -}
> -
> -static bool is_iscsi_evt(u32 trailer) -{
> - return ((trailer >> ASYNC_TRAILER_EVENT_CODE_SHIFT) &
> -   ASYNC_TRAILER_EVENT_CODE_MASK) ==
> -   ASYNC_EVENT_CODE_ISCSI;
> -}
> -
> -static int iscsi_evt_type(u32 trailer) -{
> - return (trailer >> ASYNC_TRAILER_EVENT_TYPE_SHIFT) &
> -  ASYNC_TRAILER_EVENT_TYPE_MASK;
> -}
> -
>   static inline bool be_mcc_compl_is_new(struct be_mcc_compl *compl)
>   {
>   if (compl->flags != 0) {
> @@ -343,7 +323,7 @@ static int be_mcc_compl_process(struct be_ctrl_info
*ctrl,
>   if (resp_hdr->response_length)
>   return 0;
>   }
> - return -EBUSY;
> + return -EINVAL;
>   }
>   return 0;
>   }
How is this related to the above description?
Shouldn't it be moved to a different patch?

> @@ -422,7 +402,7 @@ void beiscsi_fail_session(struct iscsi_cls_session
*cls_session)
>   iscsi_session_failure(cls_session->dd_data,
ISCSI_ERR_CONN_FAILED);
>   }
>
> -void beiscsi_async_link_state_process(struct beiscsi_hba *phba,
> +static void beiscsi_async_link_state_process(struct beiscsi_hba
> +*phba,
>   struct be_async_event_link_state *evt)
>   {
>   if ((evt->port_link_status == ASYNC_EVENT_LINK_DOWN) || @@ -450,6
> +430,103 @@ void beiscsi_async_link_state_process(struct beiscsi_hba
*phba,
>   }
>   }
>
> +static char *beiscsi_port_misconf_event_msg[] = {
> + "Physical Link is functional.",
> + "Optics faulted/incorrectly installed/not installed - Reseat
optics, if issue not resolved, replace.",
> + "Optics of two types installed - Remove one optic or install
matching pair of optics.",
> + "Incompatible optics - Replace with compatible optics for card to
function.",
> + "Unqualified optics - Replace with Avago optics for Warranty and
Technical Support.",
> + "Uncertified optics - Replace with Avago Certified optics to
enable link operation."
> +};
> +#define BEISCSI_PORT_MISCONF_EVENT_MAX \
> + (sizeof(beiscsi_port_misconf_event_msg) / \
> +  sizeof(beiscsi_port_misconf_event_msg[0]))
> +
Please don't. The above list is tied with event numbers from firmware, and
by no means arbitrary.
So please add defines for the individual messages and use a key-value map
to lookup the messages.

> +static void beiscsi_process_async_sli(struct beiscsi_hba *phba,
> +   struct be_mcc_compl *compl) {
> + struct be_async_event_sli *async_sli;
> + u8 evt_type, state, old_state, le;
> + char *sev = KERN_WARNING;
> + char *msg = NULL;
> +
> + evt_type = compl->flags >> ASYNC_TRAILER_EVENT_TYPE_SHIFT;
> + evt_type &= ASYNC_TRAILER_EVENT_TYPE_MASK;
> +
> + /* processing only MISCONFIGURED physical port event */
> + if (evt_type != ASYNC_SLI_EVENT_TYPE_MISCONFIGURED)
> + return;
> +
> + async_sli = (struct be_async_event_sli *)compl;
> + state = async_sli->event_data1 >>
> + 

Re: kernel BUG at block/bio.c:1787! while initializing scsi_debug on ppc64 host

2015-12-15 Thread Eryu Guan
On Tue, Dec 15, 2015 at 08:06:47PM +0800, Ming Lei wrote:
> On Tue, Dec 15, 2015 at 7:20 PM, Eryu Guan  wrote:
> > On Fri, Dec 11, 2015 at 07:53:40PM +0800, Eryu Guan wrote:
> >> Hi,
> >>
> >> I saw this kernel BUG_ON on 4.4-rc4 kernel, and this can be reproduced
> >> easily on ppc64 host by:
> >
> > This is still reproducible with 4.4-rc5 kernel.
> 
> Could you capture the debug log after appyling the attached patch and
> the reproduction?

Thanks for looking into this! dmesg shows:

[  686.217682] bio_split: sectors 0, bio_sectors 128, bi_rw 0

Thanks,
Eryu

P.S. full call trace

[  686.065692] scsi_debug:sdebug_driver_probe: host protection
[  686.065710] scsi host1: scsi_debug, version 1.85 [20141022], 
dev_size_mb=256, opts=0x0
[  686.065981] scsi 1:0:0:0: Direct-Access Linuxscsi_debug   0184 
PQ: 0 ANSI: 6
[  686.066873] sd 1:0:0:0: Attached scsi generic sg1 type 0
[  686.077683] sd 1:0:0:0: [sdb] 524288 512-byte logical blocks: (268 MB/256 
MiB)
[  686.077694] sd 1:0:0:0: [sdb] 4096-byte physical blocks
[  686.087670] sd 1:0:0:0: [sdb] Write Protect is off
[  686.107671] sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, 
supports DPO and FUA
[  686.217682] bio_split: sectors 0, bio_sectors 128, bi_rw 0
[  686.217695] [ cut here ]
[  686.217698] kernel BUG at block/bio.c:1793!
[  686.217702] Oops: Exception in kernel mode, sig: 5 [#1]
[  686.217704] SMP NR_CPUS=2048 NUMA pSeries
[  686.217707] Modules linked in: scsi_debug sg pseries_rng nfsd auth_rpcgss 
nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c sd_mod ibmvscsi ibmveth 
scsi_transport_srp
[  686.217727] CPU: 8 PID: 9515 Comm: kworker/u32:0 Not tainted 4.4.0-rc5+ #33
[  686.217733] Workqueue: events_unbound async_run_entry_fn
[  686.217737] task: c005edb23cc0 ti: c005f016c000 task.ti: 
c005f016c000
[  686.217740] NIP: c03c45c4 LR: c03c46b8 CTR: 013abb8c
[  686.217743] REGS: c005f016ea20 TRAP: 0700   Not tainted  (4.4.0-rc5+)
[  686.217746] MSR: 800100029033   CR: 22bb2322  XER: 
000f
[  686.217756] CFAR: c03c46cc SOFTE: 1 
GPR00: c03c46b8 c005f016eca0 c1068300 002e 
GPR04: c005ffd09c50 c005ffd1b4a0 0001  
GPR08: 0001 c0bab284 0005ff16 0130 
GPR12: 3f30 ce7e4c00  f15d0e40 
GPR16: c005f3c3b7a0 c0057439 0001  
GPR20:  0080  c005f5093200 
GPR24: c005edb0efa0 c005f016ee60 c005f5093288  
GPR28: 0240 c005f5093200  c005efd67600 
[  686.217797] NIP [c03c45c4] bio_split+0x54/0x160
[  686.217800] LR [c03c46b8] bio_split+0x148/0x160
[  686.217803] Call Trace:
[  686.217805] [c005f016eca0] [c03c46b8] bio_split+0x148/0x160 
(unreliable)
[  686.217810] [c005f016ed30] [c03d75e0] blk_queue_split+0x3c0/0x570
[  686.217814] [c005f016ee30] [c03d10a8] blk_queue_bio+0x48/0x440
[  686.217818] [c005f016ee90] [c03cec9c] 
generic_make_request+0x15c/0x220
[  686.217822] [c005f016eef0] [c03cee24] submit_bio+0xc4/0x1d0
[  686.217826] [c005f016efa0] [c02db204] submit_bh_wbc+0x1a4/0x200
[  686.217830] [c005f016eff0] [c02db6f0] 
block_read_full_page+0x320/0x420
[  686.217835] [c005f016f4a0] [c02dedb4] blkdev_readpage+0x24/0x40
[  686.217839] [c005f016f4c0] [c01f06fc] 
do_read_cache_page+0xbc/0x290
[  686.217844] [c005f016f530] [c03e8e00] read_dev_sector+0x40/0xc0
[  686.217848] [c005f016f560] [c03ec6bc] read_lba+0xdc/0x200
[  686.217851] [c005f016f5c0] [c03ece4c] find_valid_gpt+0xec/0x740
[  686.217855] [c005f016f6a0] [c03ed894] efi_partition+0x3f4/0x450
[  686.217859] [c005f016f820] [c03ea428] check_partition+0x158/0x2f0
[  686.217863] [c005f016f8a0] [c03e9694] 
rescan_partitions+0xd4/0x390
[  686.217867] [c005f016f970] [c02e0938] __blkdev_get+0x3a8/0x4d0
[  686.217871] [c005f016f9e0] [c02e0c90] blkdev_get+0x230/0x4a0
[  686.217875] [c005f016fa90] [c03e65b8] add_disk+0x478/0x500
[  686.217880] [c005f016fb40] [d3fa66a8] sd_probe_async+0xf8/0x240 
[sd_mod]
[  686.217884] [c005f016fbc0] [c00d7db8] 
async_run_entry_fn+0x98/0x1f0
[  686.217888] [c005f016fc50] [c00cc1a0] 
process_one_work+0x190/0x470
[  686.217892] [c005f016fce0] [c00cc5fc] worker_thread+0x17c/0x5a0
[  686.217896] [c005f016fd80] [c00d3da8] kthread+0x108/0x130
[  686.217901] [c005f016fe30] [c0009538] 
ret_from_kernel_thread+0x5c/0xa4
[  686.217904] Instruction dump:
[  686.217906] 7cdf3378 7c9e2378 7c7d1b78 f8010010 7cbc2b78 f821ff71 80c30028 
40dd00e8
[  686.217912] 54caba7e 3900 7f8a2040 40dd00d8 <0b08> 5

Re: kernel BUG at block/bio.c:1787! while initializing scsi_debug on ppc64 host

2015-12-15 Thread Ming Lei
On Tue, Dec 15, 2015 at 7:20 PM, Eryu Guan  wrote:
> On Fri, Dec 11, 2015 at 07:53:40PM +0800, Eryu Guan wrote:
>> Hi,
>>
>> I saw this kernel BUG_ON on 4.4-rc4 kernel, and this can be reproduced
>> easily on ppc64 host by:
>
> This is still reproducible with 4.4-rc5 kernel.

Could you capture the debug log after appyling the attached patch and
the reproduction?

Thanks,

>
> Thanks,
> Eryu
>
>>
>> modprobe scsi_debug sector_size=512 physblk_exp=3 dev_size_mb=256
>>
>> And I bisected to this commit
>>
>>   commit ca369d51b3e1649be4a72addd6d6a168cfb3f537
>>   Author: Martin K. Petersen 
>>   Date:   Fri Nov 13 16:46:48 2015 -0500
>>
>>   block/sd: Fix device-imposed transfer length limits
>>
>> I confirmed by reverting this commit on top of 4.4-rc4 kernel and test
>> passed.
>>
>> Thanks,
>> Eryu
>>
>> P.S. dmesg log
>> [  817.477557] scsi_debug:sdebug_driver_probe: host protection
>> [  817.477571] scsi host1: scsi_debug, version 1.85 [20141022], 
>> dev_size_mb=256, opts=0x0
>> [  817.478202] scsi 1:0:0:0: Direct-Access Linuxscsi_debug   
>> 0184 PQ: 0 ANSI: 6
>> [  817.478733] sd 1:0:0:0: Attached scsi generic sg1 type 0
>> [  817.496144] sd 1:0:0:0: [sdb] 524288 512-byte logical blocks: (268 MB/256 
>> MiB)
>> [  817.496155] sd 1:0:0:0: [sdb] 4096-byte physical blocks
>> [  817.506142] sd 1:0:0:0: [sdb] Write Protect is off
>> [  817.526134] sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, 
>> supports DPO and FUA
>> [  817.646163] [ cut here ]
>> [  817.646168] kernel BUG at block/bio.c:1787!
>> [  817.646172] Oops: Exception in kernel mode, sig: 5 [#1]
>> [  817.646174] SMP NR_CPUS=2048 NUMA pSeries
>> [  817.646178] Modules linked in: scsi_debug(E) nfsv3(E) rpcsec_gss_krb5(E) 
>> nfsv4(E) dns_resolver(E) nfs(E) fscache(E) dm_mod(E) loop(E) sg(E) 
>> pseries_rng(E) nfsd(E) auth_rpcgss(E) nfs_acl(E) lockd(E) sunrpc(E) grace(E) 
>> ip_tables(E) xfs(E) libcrc32c(E) sd_mod(E) ibmvscsi(E) ibmveth(E) 
>> scsi_transport_srp(E)
>> [  817.646205] CPU: 6 PID: 166 Comm: kworker/u321:1 Tainted: GE  
>>  4.4.0-rc4 #1
>> [  817.646211] Workqueue: events_unbound .async_run_entry_fn
>> [  817.646215] task: ca0c ti: ca18 task.ti: 
>> ca18
>> [  817.646218] NIP: c03b1d54 LR: c03c4780 CTR: 
>> c03be420
>> [  817.646222] REGS: ca1826c0 TRAP: 0700   Tainted: GE   
>>  (4.4.0-rc4)
>> [  817.646225] MSR: 800100029032   CR: 24732728  XER: 
>> 
>> [  817.646233] CFAR: c03c477c SOFTE: 1
>> GPR00: c03c4780 ca182940 c1325e00 c0016cebcf00
>> GPR04:  0240 c0013c5f4d80 0040
>> GPR08: f0436ac0 0001  
>> GPR12: 24732722 ce743900  f0436ac0
>> GPR16: c000f9e3eee0 c0010dab 0001 
>> GPR20:  0080  c0016cebcf00
>> GPR24: c000ff9b5a20 ca182bb8 c0016cebcf88 
>> GPR28:  c0016cebcf00  0001
>> [  817.646273] NIP [c03b1d54] .bio_split+0x34/0x110
>> [  817.646277] LR [c03c4780] .blk_queue_split+0x3b0/0x560
>> [  817.646280] Call Trace:
>> [  817.646282] [ca182940] [ca1829d0] 0xca1829d0 
>> (unreliable)
>> [  817.646287] [ca1829d0] [c03c4780] 
>> .blk_queue_split+0x3b0/0x560
>> [  817.646291] [ca182ae0] [c03be460] 
>> .blk_queue_bio+0x40/0x430
>> [  817.646295] [ca182b80] [c03bc0f0] 
>> .generic_make_request+0x150/0x210
>> [  817.646299] [ca182c30] [c03bc26c] .submit_bio+0xbc/0x1c0
>> [  817.646304] [ca182cf0] [c02cb64c] 
>> .submit_bh_wbc+0x19c/0x200
>> [  817.646308] [ca182d90] [c02cbb10] 
>> .block_read_full_page+0x310/0x410
>> [  817.646312] [ca183290] [c02cf11c] 
>> .blkdev_readpage+0x1c/0x30
>> [  817.646316] [ca183300] [c01e51a0] 
>> .do_read_cache_page+0xc0/0x290
>> [  817.646321] [ca1833c0] [c03d59f8] 
>> .read_dev_sector+0x38/0xb0
>> [  817.646325] [ca183440] [c03d977c] .read_lba+0xcc/0x1f0
>> [  817.646329] [ca1834f0] [c03da3b8] 
>> .efi_partition+0x118/0x780
>> [  817.646333] [ca183670] [c03d6fcc] 
>> .check_partition+0x14c/0x2e0
>> [  817.646337] [ca183700] [c03d6260] 
>> .rescan_partitions+0xd0/0x380
>> [  817.646341] [ca1837e0] [c02d0b88] 
>> .__blkdev_get+0x3d8/0x530
>> [  817.646345] [ca1838a0] [c02d0f10] .blkdev_get+0x230/0x4a0
>> [  817.646348] [ca1839a0] [c03d3288] .add_disk+0x468/0x4f0
>> [  817.646353] [ca183a60] [d2026450] 
>> .sd_probe_async+0xf0/0x230 [sd_mod]
>> [  817.646357] [ca183af0] [c00d23a8]

Re: [PATCH] USB: storage: add "no SYNCHRONIZE CACHE" quirk

2015-12-15 Thread Oliver Neukum
On Thu, 2015-12-03 at 13:36 -0500, Alan Stern wrote:
> This is an old problem, but it was never resolved and it still affects
> people (Bugzilla #89511).  In short, there are USB-(S)ATA bridges that
> claim to be write-back but don't support the SYNCHRONIZE CACHE
> command.  
> This causes errors when filesystems try to flush data out to the disk.

OK, maybe this is a stupid idea, but could we test the command as we
enumerate the slave and store the result?

Regards
Oliver


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


Re: [PATCH] ses: fix additional element traversal bug

2015-12-15 Thread Hannes Reinecke

On 12/11/2015 06:16 PM, James Bottomley wrote:

KASAN found that our additional element processing scripts drop off
the end of the VPD page into unallocated space.  The reason is that
not every element has additional information but our traversal
routines think they do, leading to them expecting far more additional
information than is present.  Fix this by adding a gate to the
traversal routine so that it only processes elements that are expected
to have additional information (list is in SES-2 section 6.1.13.1:
Additional Element Status diagnostic page overview)

Reported-by: Pavel Tikhomirov 
Tested-by: Pavel Tikhomirov 
Cc: sta...@vger.kernel.org
Signed-off-by: James Bottomley 

---

diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index 1736935..53ef1cb 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -561,7 +561,15 @@ static void ses_enclosure_data_process(struct 
enclosure_device *edev,
if (desc_ptr)
desc_ptr += len;

-   if (addl_desc_ptr)
+   if (addl_desc_ptr &&
+   /* only find additional descriptions for specific 
devices */
+   (type_ptr[0] == ENCLOSURE_COMPONENT_DEVICE ||
+type_ptr[0] == ENCLOSURE_COMPONENT_ARRAY_DEVICE ||
+type_ptr[0] == ENCLOSURE_COMPONENT_SAS_EXPANDER ||
+/* these elements are optional */
+type_ptr[0] == 
ENCLOSURE_COMPONENT_SCSI_TARGET_PORT ||
+type_ptr[0] == 
ENCLOSURE_COMPONENT_SCSI_INITIATOR_PORT ||
+type_ptr[0] == 
ENCLOSURE_COMPONENT_CONTROLLER_ELECTRONICS))
addl_desc_ptr += addl_desc_ptr[1] + 2;

}
diff --git a/include/linux/enclosure.h b/include/linux/enclosure.h
index 7be22da..a4cf57c 100644
--- a/include/linux/enclosure.h
+++ b/include/linux/enclosure.h
@@ -29,7 +29,11 @@
  /* A few generic types ... taken from ses-2 */
  enum enclosure_component_type {
ENCLOSURE_COMPONENT_DEVICE = 0x01,
+   ENCLOSURE_COMPONENT_CONTROLLER_ELECTRONICS = 0x07,
+   ENCLOSURE_COMPONENT_SCSI_TARGET_PORT = 0x14,
+   ENCLOSURE_COMPONENT_SCSI_INITIATOR_PORT = 0x15,
ENCLOSURE_COMPONENT_ARRAY_DEVICE = 0x17,
+   ENCLOSURE_COMPONENT_SAS_EXPANDER = 0x18,
  };

  /* ses-2 common element status */


Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: kernel BUG at block/bio.c:1787! while initializing scsi_debug on ppc64 host

2015-12-15 Thread Eryu Guan
On Fri, Dec 11, 2015 at 07:53:40PM +0800, Eryu Guan wrote:
> Hi,
> 
> I saw this kernel BUG_ON on 4.4-rc4 kernel, and this can be reproduced
> easily on ppc64 host by:

This is still reproducible with 4.4-rc5 kernel.

Thanks,
Eryu

> 
> modprobe scsi_debug sector_size=512 physblk_exp=3 dev_size_mb=256
> 
> And I bisected to this commit
> 
>   commit ca369d51b3e1649be4a72addd6d6a168cfb3f537
>   Author: Martin K. Petersen 
>   Date:   Fri Nov 13 16:46:48 2015 -0500
> 
>   block/sd: Fix device-imposed transfer length limits
> 
> I confirmed by reverting this commit on top of 4.4-rc4 kernel and test
> passed.
> 
> Thanks,
> Eryu
> 
> P.S. dmesg log
> [  817.477557] scsi_debug:sdebug_driver_probe: host protection 
> [  817.477571] scsi host1: scsi_debug, version 1.85 [20141022], 
> dev_size_mb=256, opts=0x0 
> [  817.478202] scsi 1:0:0:0: Direct-Access Linuxscsi_debug   0184 
> PQ: 0 ANSI: 6 
> [  817.478733] sd 1:0:0:0: Attached scsi generic sg1 type 0 
> [  817.496144] sd 1:0:0:0: [sdb] 524288 512-byte logical blocks: (268 MB/256 
> MiB) 
> [  817.496155] sd 1:0:0:0: [sdb] 4096-byte physical blocks 
> [  817.506142] sd 1:0:0:0: [sdb] Write Protect is off 
> [  817.526134] sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, 
> supports DPO and FUA 
> [  817.646163] [ cut here ] 
> [  817.646168] kernel BUG at block/bio.c:1787! 
> [  817.646172] Oops: Exception in kernel mode, sig: 5 [#1] 
> [  817.646174] SMP NR_CPUS=2048 NUMA pSeries 
> [  817.646178] Modules linked in: scsi_debug(E) nfsv3(E) rpcsec_gss_krb5(E) 
> nfsv4(E) dns_resolver(E) nfs(E) fscache(E) dm_mod(E) loop(E) sg(E) 
> pseries_rng(E) nfsd(E) auth_rpcgss(E) nfs_acl(E) lockd(E) sunrpc(E) grace(E) 
> ip_tables(E) xfs(E) libcrc32c(E) sd_mod(E) ibmvscsi(E) ibmveth(E) 
> scsi_transport_srp(E) 
> [  817.646205] CPU: 6 PID: 166 Comm: kworker/u321:1 Tainted: GE   
> 4.4.0-rc4 #1 
> [  817.646211] Workqueue: events_unbound .async_run_entry_fn 
> [  817.646215] task: ca0c ti: ca18 task.ti: 
> ca18 
> [  817.646218] NIP: c03b1d54 LR: c03c4780 CTR: 
> c03be420 
> [  817.646222] REGS: ca1826c0 TRAP: 0700   Tainted: GE
> (4.4.0-rc4) 
> [  817.646225] MSR: 800100029032   CR: 24732728  XER: 
>  
> [  817.646233] CFAR: c03c477c SOFTE: 1  
> GPR00: c03c4780 ca182940 c1325e00 c0016cebcf00  
> GPR04:  0240 c0013c5f4d80 0040  
> GPR08: f0436ac0 0001    
> GPR12: 24732722 ce743900  f0436ac0  
> GPR16: c000f9e3eee0 c0010dab 0001   
> GPR20:  0080  c0016cebcf00  
> GPR24: c000ff9b5a20 ca182bb8 c0016cebcf88   
> GPR28:  c0016cebcf00  0001  
> [  817.646273] NIP [c03b1d54] .bio_split+0x34/0x110 
> [  817.646277] LR [c03c4780] .blk_queue_split+0x3b0/0x560 
> [  817.646280] Call Trace: 
> [  817.646282] [ca182940] [ca1829d0] 0xca1829d0 
> (unreliable) 
> [  817.646287] [ca1829d0] [c03c4780] 
> .blk_queue_split+0x3b0/0x560 
> [  817.646291] [ca182ae0] [c03be460] 
> .blk_queue_bio+0x40/0x430 
> [  817.646295] [ca182b80] [c03bc0f0] 
> .generic_make_request+0x150/0x210 
> [  817.646299] [ca182c30] [c03bc26c] .submit_bio+0xbc/0x1c0 
> [  817.646304] [ca182cf0] [c02cb64c] 
> .submit_bh_wbc+0x19c/0x200 
> [  817.646308] [ca182d90] [c02cbb10] 
> .block_read_full_page+0x310/0x410 
> [  817.646312] [ca183290] [c02cf11c] 
> .blkdev_readpage+0x1c/0x30 
> [  817.646316] [ca183300] [c01e51a0] 
> .do_read_cache_page+0xc0/0x290 
> [  817.646321] [ca1833c0] [c03d59f8] 
> .read_dev_sector+0x38/0xb0 
> [  817.646325] [ca183440] [c03d977c] .read_lba+0xcc/0x1f0 
> [  817.646329] [ca1834f0] [c03da3b8] 
> .efi_partition+0x118/0x780 
> [  817.646333] [ca183670] [c03d6fcc] 
> .check_partition+0x14c/0x2e0 
> [  817.646337] [ca183700] [c03d6260] 
> .rescan_partitions+0xd0/0x380 
> [  817.646341] [ca1837e0] [c02d0b88] 
> .__blkdev_get+0x3d8/0x530 
> [  817.646345] [ca1838a0] [c02d0f10] .blkdev_get+0x230/0x4a0 
> [  817.646348] [ca1839a0] [c03d3288] .add_disk+0x468/0x4f0 
> [  817.646353] [ca183a60] [d2026450] 
> .sd_probe_async+0xf0/0x230 [sd_mod] 
> [  817.646357] [ca183af0] [c00d23a8] 
> .async_run_entry_fn+0x98/0x200 
> [  817.646362] [ca183ba0] [c00c6d74] 
> .process_one_work+0x1a4/0x490 
> [  817.646366] [ca183c40] [c00c71dc] 
> .worker_thr

Re: [PATCH v2 3/3] ses: fix discovery of SATA devices in SAS enclosures

2015-12-15 Thread Hannes Reinecke

On 12/09/2015 09:56 PM, James Bottomley wrote:

The current discovery routines use the VPD 0x83 inquiry page to find
the device SAS address and match it to the end point in the enclosure.
This doesn't work for SATA devices because expanders (or hosts) simply
make up an endpoint address for STP and thus the address returned by
the VPD page never matches.  Instead of doing this, for SAS attached
devices, match by the direct endpoint address instead.

Signed-off-by: James Bottomley 

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 5f692ae..2a1d20e 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -194,6 +194,7 @@ config CHR_DEV_SCH
  config SCSI_ENCLOSURE
tristate "SCSI Enclosure Support"
depends on SCSI && ENCLOSURE_SERVICES
+   depends on m || SCSI_SAS_ATTRS != m
help
  Enclosures are devices sitting on or in SCSI backplanes that
  manage devices.  If you have a disk cage, the chances are that
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index 7d9cec5..1736935 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -34,6 +34,8 @@
  #include 
  #include 

+#include 
+
  struct ses_device {
unsigned char *page1;
unsigned char *page1_types;
@@ -571,31 +573,15 @@ static void ses_enclosure_data_process(struct 
enclosure_device *edev,
  static void ses_match_to_enclosure(struct enclosure_device *edev,
   struct scsi_device *sdev)
  {
-   unsigned char *desc;
struct efd efd = {
.addr = 0,
};

ses_enclosure_data_process(edev, to_scsi_device(edev->edev.parent), 0);

-   if (!sdev->vpd_pg83_len)
-   return;
-
-   desc = sdev->vpd_pg83 + 4;
-   while (desc < sdev->vpd_pg83 + sdev->vpd_pg83_len) {
-   enum scsi_protocol proto = desc[0] >> 4;
-   u8 code_set = desc[0] & 0x0f;
-   u8 piv = desc[1] & 0x80;
-   u8 assoc = (desc[1] & 0x30) >> 4;
-   u8 type = desc[1] & 0x0f;
-   u8 len = desc[3];
-
-   if (piv && code_set == 1 && assoc == 1
-   && proto == SCSI_PROTOCOL_SAS && type == 3 && len == 8)
-   efd.addr = get_unaligned_be64(&desc[4]);
+   if (is_sas_attached(sdev))
+   efd.addr = sas_get_address(sdev);

-   desc += len + 4;
-   }
if (efd.addr) {
efd.dev = &sdev->sdev_gendev;




Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH 2/3] scsi_transport_sas: add function to get SAS endpoint address

2015-12-15 Thread Hannes Reinecke

On 12/09/2015 08:13 PM, James Bottomley wrote:

For a device known to be SAS connected, this will return the endpoint
address.  This is useful for getting the SAS address of SATA devices.

Signed-off-by: James Bottomley 
---
  drivers/scsi/scsi_transport_sas.c |   14 ++
  include/scsi/scsi_transport_sas.h |1 +
  2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/scsi_transport_sas.c 
b/drivers/scsi/scsi_transport_sas.c
index b17f763..80520e2 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -383,6 +383,20 @@ void sas_remove_host(struct Scsi_Host *shost)
  EXPORT_SYMBOL(sas_remove_host);

  /**
+ * sas_get_address - return the SAS address of the device
+ * @sdev: scsi device
+ *
+ * Returns the SAS address of the scsi device
+ */
+u64 sas_get_address(struct scsi_device *sdev)
+{
+   struct sas_end_device *rdev = sas_sdev_to_rdev(sdev);
+
+   return rdev->rphy.identify.sas_address;
+}
+EXPORT_SYMBOL(sas_get_address);
+
+/**
   * sas_tlr_supported - checking TLR bit in vpd 0x90
   * @sdev: scsi device struct
   *
diff --git a/include/scsi/scsi_transport_sas.h 
b/include/scsi/scsi_transport_sas.h
index a8fdd10..13c0b2b 100644
--- a/include/scsi/scsi_transport_sas.h
+++ b/include/scsi/scsi_transport_sas.h
@@ -189,6 +189,7 @@ extern int sas_phy_add(struct sas_phy *);
  extern void sas_phy_delete(struct sas_phy *);
  extern int scsi_is_sas_phy(const struct device *);

+u64 sas_get_address(struct scsi_device *);
  unsigned int sas_tlr_supported(struct scsi_device *);
  unsigned int sas_is_tlr_enabled(struct scsi_device *);
  void sas_disable_tlr(struct scsi_device *);


Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH 1/3] scsi_transport_sas: add is_sas_attached() function

2015-12-15 Thread Hannes Reinecke

On 12/09/2015 08:12 PM, James Bottomley wrote:

Adds a function designed to be callable any time (regardless of
whether the transport attributes are configured or not) which returns
true if the device is attached over a SAS transport.  The design of
this function is that transport specific functions can be embedded
within a

if (is_sas_attached(sdev)) {
...
}

which would be compiled out (and thus eliminate the symbols) if SAS is
not configured.

Signed-off-by: James Bottomley 
---
  drivers/scsi/scsi_transport_sas.c |   16 
  include/scsi/scsi_transport_sas.h |9 +
  2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/scsi_transport_sas.c 
b/drivers/scsi/scsi_transport_sas.c
index 30d26e3..b17f763 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -341,6 +341,22 @@ static int do_sas_phy_delete(struct device *dev, void 
*data)
  }

  /**
+ * is_sas_attached - check if device is SAS attached
+ * @sdev: scsi device to check
+ *
+ * returns true if the device is SAS attached
+ */
+int is_sas_attached(struct scsi_device *sdev)
+{
+   struct Scsi_Host *shost = sdev->host;
+
+   return shost->transportt->host_attrs.ac.class ==
+   &sas_host_class.class;
+}
+EXPORT_SYMBOL(is_sas_attached);
+
+
+/**
   * sas_remove_children  -  tear down a devices SAS data structures
   * @dev:  device belonging to the sas object
   *
diff --git a/include/scsi/scsi_transport_sas.h 
b/include/scsi/scsi_transport_sas.h
index 0bd71e2..a8fdd10 100644
--- a/include/scsi/scsi_transport_sas.h
+++ b/include/scsi/scsi_transport_sas.h
@@ -10,6 +10,15 @@ struct scsi_transport_template;
  struct sas_rphy;
  struct request;

+#if !IS_ENABLED(CONFIG_SCSI_SAS_ATTRS)
+static inline int is_sas_attached(struct scsi_device *sdev)
+{
+   return 0;
+}
+#else
+extern int is_sas_attached(struct scsi_device *sdev);
+#endif
+
  static inline int sas_protocol_ata(enum sas_protocol proto)
  {
return ((proto & SAS_PROTOCOL_SATA) ||


Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
--
Dr. Hannes ReineckezSeries & Storage
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)
--
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