[patch] [SCSI] bfa: Use GFP_ATOMIC under spin_lock

2013-03-08 Thread Dan Carpenter
This is always called with spinlocks held so it should use
GFP_ATOMIC.  The call tree is:

- bfad_drv_start()
   Takes spin_lock_irqsave(bfad-bfad_lock, flags);
   - bfa_fcs_pbc_vport_init()
  - bfa_fcb_pbc_vport_create()

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

diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index a5f7690..d144a06 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -491,7 +491,7 @@ bfa_fcb_pbc_vport_create(struct bfad_s *bfad, struct 
bfi_pbc_vport_s pbc_vport)
struct bfad_vport_s   *vport;
int rc;
 
-   vport = kzalloc(sizeof(struct bfad_vport_s), GFP_KERNEL);
+   vport = kzalloc(sizeof(struct bfad_vport_s), GFP_ATOMIC);
if (!vport) {
bfa_trc(bfad, 0);
return;
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch] [SCSI] scsi_transport_sas: check for allocation failure

2013-03-08 Thread Dan Carpenter
Static checkers complain that this allocation isn't checked.  We
should return zero if the allocation fails.

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

diff --git a/drivers/scsi/scsi_transport_sas.c 
b/drivers/scsi/scsi_transport_sas.c
index 1b68142..a022997 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -379,9 +379,12 @@ sas_tlr_supported(struct scsi_device *sdev)
 {
const int vpd_len = 32;
struct sas_end_device *rdev = sas_sdev_to_rdev(sdev);
-   char *buffer = kzalloc(vpd_len, GFP_KERNEL);
+   char *buffer;
int ret = 0;
 
+   buffer = kzalloc(vpd_len, GFP_KERNEL);
+   if (!buffer)
+   goto out;
if (scsi_get_vpd_page(sdev, 0x90, buffer, vpd_len))
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: [RFC 01/11] iscsi-target: Add iscsit_transport API template

2013-03-08 Thread Or Gerlitz
On Fri, Mar 8, 2013 at 6:14 AM, Roland Dreier rol...@kernel.org wrote:
 Nicholas A. Bellinger n...@linux-iscsi.org wrote:
  +EXPORT_SYMBOL(iscsit_get_transport);

 It's not clear to me why this needs to be exported.  Who would use it
 outside the core iscsi target module?

Yep, as Nic noted, we're adding here an iscsi transport concept e.g in
the same manner Mike did libiscsi back in 2005/6 when the iser
initiator was pushed. This allows for multiple iscsi flavours to use a
common code  for common functionality. In the initiator area initially
there were iscsi tcp and iser, later few iscsi HW offloads were merged
too. Same story here. I think that the point is whether or not these
APIs are needed, since once we agree on that, we need an header file
and exporting of functions. As libiscsi.h resided under include/ it
makes sense to me for this include to be located there too.

Or.

Or.
--
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: [RFC 01/11] iscsi-target: Add iscsit_transport API template

2013-03-08 Thread Roland Dreier
On Thu, Mar 7, 2013 at 10:02 PM, Nicholas A. Bellinger
n...@linux-iscsi.org wrote:
 Or and I discussed this point in the last status call, and given what
 the initiator did originally (eg: export iscsi_transport) he asked to
 keep it under drivers/infiniband/ulp/isert/ with the extra include bits.

 I'd have a slight preference to move iser-target code under
 drivers/target/iscsi/, and not put anything into include/target/iscsi/
 if there won't be another module that uses it..

 Do you have a preference here..?

It's not really something that matters to me.

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


Re: [patch] [SCSI] scsi_transport_sas: check for allocation failure

2013-03-08 Thread Douglas Gilbert

On 13-03-08 07:02 AM, Dan Carpenter wrote:

Static checkers complain that this allocation isn't checked.  We
should return zero if the allocation fails.

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

diff --git a/drivers/scsi/scsi_transport_sas.c 
b/drivers/scsi/scsi_transport_sas.c
index 1b68142..a022997 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -379,9 +379,12 @@ sas_tlr_supported(struct scsi_device *sdev)
  {
const int vpd_len = 32;
struct sas_end_device *rdev = sas_sdev_to_rdev(sdev);
-   char *buffer = kzalloc(vpd_len, GFP_KERNEL);
+   char *buffer;
int ret = 0;

+   buffer = kzalloc(vpd_len, GFP_KERNEL);
+   if (!buffer)
+   goto out;
if (scsi_get_vpd_page(sdev, 0x90, buffer, vpd_len))
goto out;



For 32 bytes, why not use the stack?

unsigned int
sas_tlr_supported(struct scsi_device *sdev)
{
unsigned char buffer[32];
struct sas_end_device *rdev = sas_sdev_to_rdev(sdev);
int ret = 0;

if (scsi_get_vpd_page(sdev, 0x90, buffer, sizeof(buffer)))
goto out;

/*
 * The VPD Protocol Specific Logical Unit page (0x90) for SAS
 * has a 4 byte header and then one descriptor per device port.
 * The TLR bit is at offset 8 on each port descriptor.
 * We take the TLR value in the first descriptor.
 */
ret = buffer[4 + 8]  0x01;

 out:
rdev-tlr_supported = ret;
return ret;
}


Note the comment is changed.

Doug Gilbert


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


Re: [patch] [SCSI] scsi_transport_sas: check for allocation failure

2013-03-08 Thread Dan Carpenter
On Fri, Mar 08, 2013 at 12:57:12PM -0500, Douglas Gilbert wrote:
 On 13-03-08 07:02 AM, Dan Carpenter wrote:
 
 For 32 bytes, why not use the stack?
 

It's a good point.  I'll resend on Monday.

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: [RFC 01/11] iscsi-target: Add iscsit_transport API template

2013-03-08 Thread Nicholas A. Bellinger
On Fri, 2013-03-08 at 14:36 +0200, Or Gerlitz wrote:
 On Fri, Mar 8, 2013 at 6:14 AM, Roland Dreier rol...@kernel.org wrote:
  Nicholas A. Bellinger n...@linux-iscsi.org wrote:
   +EXPORT_SYMBOL(iscsit_get_transport);
 
  It's not clear to me why this needs to be exported.  Who would use it
  outside the core iscsi target module?
 
 Yep, as Nic noted, we're adding here an iscsi transport concept e.g in
 the same manner Mike did libiscsi back in 2005/6 when the iser
 initiator was pushed. This allows for multiple iscsi flavours to use a
 common code  for common functionality. In the initiator area initially
 there were iscsi tcp and iser, later few iscsi HW offloads were merged
 too. Same story here. I think that the point is whether or not these
 APIs are needed, since once we agree on that, we need an header file
 and exporting of functions. As libiscsi.h resided under include/ it
 makes sense to me for this include to be located there too.

So my main concern with putting iscsit_transport definitions into
include/target/iscsi/ is the number of dependencies required from
iscsi_target_core.h.

Currently with iscsi_cmd embedded into isert_cmd, this will require most
existing iscsi_target_core.h definitions to be pushed out into
include/target/iscsi/.  This also includes some namespace conflicts
between libiscsi.h and iscsi_target_core.h, but those can be solved
easily enough.

I'm still leaning towards just keeping iscsi_transport.h definitions
local to drivers/target/iscsi, if there is really not going to be other
drivers aside from ib_isert that end up using it.  If there was interest
in traditional iscsi-target HW offloads using this interface then the
story would be different, but every HW offload that I've seen thus far
using LIO is based on out-of-tree NIC code to start.

--nab







 

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


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


[PATCH 3/5] bnx2fc: Fix race condition between IO completion and abort

2013-03-08 Thread Bhanu Prakash Gollapudi
When IO is successfully completed while an abort is pending, eh_abort
incorrectly assumes that abort failed and performes recovery by issuing
cleanup. Howerver, cleanup timesout as the firmware has no clue about
this IO. Fix this by checking if the IO has already completed.

Signed-off-by: Bhanu Prakash Gollapudi bprak...@broadcom.com
---
 drivers/scsi/bnx2fc/bnx2fc_io.c |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 60798e8..539b95b 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -1269,8 +1269,11 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd)
 
spin_lock_bh(tgt-tgt_lock);
io_req-wait_for_comp = 0;
-   if (!(test_and_set_bit(BNX2FC_FLAG_ABTS_DONE,
-   io_req-req_flags))) {
+   if (test_bit(BNX2FC_FLAG_IO_COMPL, io_req-req_flags)) {
+   BNX2FC_IO_DBG(io_req, IO completed in a different context\n);
+   rc = SUCCESS;
+   } else if (!(test_and_set_bit(BNX2FC_FLAG_ABTS_DONE,
+ io_req-req_flags))) {
/* Let the scsi-ml try to recover this command */
printk(KERN_ERR PFX abort failed, xid = 0x%x\n,
   io_req-xid);
-- 
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 5/5] bnx2fc: Bumped version to 1.0.14

2013-03-08 Thread Bhanu Prakash Gollapudi
Signed-off-by: Bhanu Prakash Gollapudi bprak...@broadcom.com
---
 drivers/scsi/bnx2fc/bnx2fc.h  |2 +-
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h
index 676dba3..1ece6e9 100644
--- a/drivers/scsi/bnx2fc/bnx2fc.h
+++ b/drivers/scsi/bnx2fc/bnx2fc.h
@@ -64,7 +64,7 @@
 #include bnx2fc_constants.h
 
 #define BNX2FC_NAMEbnx2fc
-#define BNX2FC_VERSION 1.0.13
+#define BNX2FC_VERSION 1.0.14
 
 #define PFXbnx2fc: 
 
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 1e852d6..9ab62da 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -22,7 +22,7 @@ DEFINE_PER_CPU(struct bnx2fc_percpu_s, bnx2fc_percpu);
 
 #define DRV_MODULE_NAMEbnx2fc
 #define DRV_MODULE_VERSION BNX2FC_VERSION
-#define DRV_MODULE_RELDATE Dec 21, 2012
+#define DRV_MODULE_RELDATE Mar 08, 2012
 
 
 static char version[] =
-- 
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 2/5] bnx2fc: Include chip number in the symbolic name

2013-03-08 Thread Bhanu Prakash Gollapudi
Signed-off-by: Bhanu Prakash Gollapudi bprak...@broadcom.com
---
 drivers/scsi/bnx2fc/bnx2fc.h  |   53 +
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c |   51 +++
 2 files changed, 98 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h
index 50fcd01..2f118e3 100644
--- a/drivers/scsi/bnx2fc/bnx2fc.h
+++ b/drivers/scsi/bnx2fc/bnx2fc.h
@@ -68,6 +68,57 @@
 
 #define PFXbnx2fc: 
 
+#define BCM_CHIP_LEN   16
+
+#ifndef PCI_DEVICE_ID_NX2_57710
+#define PCI_DEVICE_ID_NX2_577100x164e
+#endif
+#ifndef PCI_DEVICE_ID_NX2_57711
+#define PCI_DEVICE_ID_NX2_577110x164f
+#endif
+#ifndef PCI_DEVICE_ID_NX2_57712
+#define PCI_DEVICE_ID_NX2_577120x1662
+#endif
+#ifndef PCI_DEVICE_ID_NX2_57712_MF
+#define PCI_DEVICE_ID_NX2_57712_MF 0x1663
+#endif
+#ifndef PCI_DEVICE_ID_NX2_57712_VF
+#define PCI_DEVICE_ID_NX2_57712_VF 0x166f
+#endif
+#ifndef PCI_DEVICE_ID_NX2_57800
+#define PCI_DEVICE_ID_NX2_578000x168a
+#endif
+#ifndef PCI_DEVICE_ID_NX2_57800_MF
+#define PCI_DEVICE_ID_NX2_57800_MF 0x16a5
+#endif
+#ifndef PCI_DEVICE_ID_NX2_57800_VF
+#define PCI_DEVICE_ID_NX2_57800_VF 0x16a9
+#endif
+#ifndef PCI_DEVICE_ID_NX2_57810
+#define PCI_DEVICE_ID_NX2_578100x168e
+#endif
+#ifndef PCI_DEVICE_ID_NX2_57810_MF
+#define PCI_DEVICE_ID_NX2_57810_MF 0x16ae
+#endif
+#ifndef PCI_DEVICE_ID_NX2_57810_VF
+#define PCI_DEVICE_ID_NX2_57810_VF 0x16af
+#endif
+#ifndef PCI_DEVICE_ID_NX2_57840
+#define PCI_DEVICE_ID_NX2_578400x168d
+#endif
+#ifndef PCI_DEVICE_ID_NX2_57840_MF
+#define PCI_DEVICE_ID_NX2_57840_MF 0x16a4
+#endif
+#ifndef PCI_DEVICE_ID_NX2_57840_VF
+#define PCI_DEVICE_ID_NX2_57840_VF 0x16ad
+#endif
+#ifndef PCI_DEVICE_ID_NX2_57840_2_20
+#define PCI_DEVICE_ID_NX2_57840_2_20   0x16a2
+#endif
+#ifndef PCI_DEVICE_ID_NX2_57840_4_10
+#define PCI_DEVICE_ID_NX2_57840_4_10   0x16a1
+#endif
+
 #define BNX2X_DOORBELL_PCI_BAR 2
 
 #define BNX2FC_MAX_BD_LEN  0x
@@ -243,6 +294,8 @@ struct bnx2fc_hba {
int wait_for_link_down;
int num_ofld_sess;
struct list_head vports;
+
+   char chip_num[BCM_CHIP_LEN];
 };
 
 struct bnx2fc_interface {
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 2daf4b0..dd2c5c9 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -679,6 +679,7 @@ static int bnx2fc_shost_config(struct fc_lport *lport, 
struct device *dev)
 {
struct fcoe_port *port = lport_priv(lport);
struct bnx2fc_interface *interface = port-priv;
+   struct bnx2fc_hba *hba = interface-hba;
struct Scsi_Host *shost = lport-host;
int rc = 0;
 
@@ -699,8 +700,9 @@ static int bnx2fc_shost_config(struct fc_lport *lport, 
struct device *dev)
}
if (!lport-vport)
fc_host_max_npiv_vports(lport-host) = USHRT_MAX;
-   sprintf(fc_host_symbolic_name(lport-host), %s v%s over %s,
-   BNX2FC_NAME, BNX2FC_VERSION,
+   snprintf(fc_host_symbolic_name(lport-host), 256,
+%s (Broadcom %s) v%s over %s,
+   BNX2FC_NAME, hba-chip_num, BNX2FC_VERSION,
interface-netdev-name);
 
return 0;
@@ -1649,23 +1651,60 @@ mem_err:
 static int bnx2fc_bind_pcidev(struct bnx2fc_hba *hba)
 {
struct cnic_dev *cnic;
+   struct pci_dev *pdev;
 
if (!hba-cnic) {
printk(KERN_ERR PFX cnic is NULL\n);
return -ENODEV;
}
cnic = hba-cnic;
-   hba-pcidev = cnic-pcidev;
-   if (hba-pcidev)
-   pci_dev_get(hba-pcidev);
+   pdev = hba-pcidev = cnic-pcidev;
+   if (!hba-pcidev)
+   return -ENODEV;
 
+   switch (pdev-device) {
+   case PCI_DEVICE_ID_NX2_57710:
+   strncpy(hba-chip_num, BCM57710, BCM_CHIP_LEN);
+   break;
+   case PCI_DEVICE_ID_NX2_57711:
+   strncpy(hba-chip_num, BCM57711, BCM_CHIP_LEN);
+   break;
+   case PCI_DEVICE_ID_NX2_57712:
+   case PCI_DEVICE_ID_NX2_57712_MF:
+   case PCI_DEVICE_ID_NX2_57712_VF:
+   strncpy(hba-chip_num, BCM57712, BCM_CHIP_LEN);
+   break;
+   case PCI_DEVICE_ID_NX2_57800:
+   case PCI_DEVICE_ID_NX2_57800_MF:
+   case PCI_DEVICE_ID_NX2_57800_VF:
+   strncpy(hba-chip_num, BCM57800, BCM_CHIP_LEN);
+   break;
+   case PCI_DEVICE_ID_NX2_57810:
+   case PCI_DEVICE_ID_NX2_57810_MF:
+   case PCI_DEVICE_ID_NX2_57810_VF:
+   strncpy(hba-chip_num, BCM57810, BCM_CHIP_LEN);
+   break;
+   case PCI_DEVICE_ID_NX2_57840:
+   case PCI_DEVICE_ID_NX2_57840_MF:
+   case PCI_DEVICE_ID_NX2_57840_VF:
+   case PCI_DEVICE_ID_NX2_57840_2_20:
+   case PCI_DEVICE_ID_NX2_57840_4_10:
+

[PATCH 1/5] bnx2fc: Enable cached tasks to improve performance

2013-03-08 Thread Bhanu Prakash Gollapudi
Set perf_config to 3 during firmware initialization to enable both
cached connections as well as cached tasks.

Signed-off-by: Bhanu Prakash Gollapudi bprak...@broadcom.com
---
 drivers/scsi/bnx2fc/bnx2fc_hwi.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_hwi.c b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
index 85ea98a..c1fa69e 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_hwi.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
@@ -126,7 +126,11 @@ int bnx2fc_send_fw_fcoe_init_msg(struct bnx2fc_hba *hba)
fcoe_init3.error_bit_map_lo = 0x;
fcoe_init3.error_bit_map_hi = 0x;
 
-   fcoe_init3.perf_config = 1;
+   /*
+* enable both cached connection and cached tasks
+* 0 = none, 1 = cached connection, 2 = cached tasks, 3 = both
+*/
+   fcoe_init3.perf_config = 3;
 
kwqe_arr[0] = (struct kwqe *) fcoe_init1;
kwqe_arr[1] = (struct kwqe *) fcoe_init2;
-- 
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 0/5] bnx2fc version 1.0.14

2013-03-08 Thread Bhanu Prakash Gollapudi
Hi James,

Please consider including the following patches for 3.9+ merge window.

Thanks,
Bhanu

Bhanu Prakash Gollapudi (5):
  bnx2fc: Enable cached tasks to improve performance
  bnx2fc: Include chip number in the symbolic name
  bnx2fc: Fix race condition between IO completion and abort
  bnx2fc: Update copyright information
  bnx2fc: Bumped version to 1.0.14

 drivers/scsi/bnx2fc/bnx2fc.h  |   57 +++-
 drivers/scsi/bnx2fc/bnx2fc_els.c  |2 +-
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c |   55 ++-
 drivers/scsi/bnx2fc/bnx2fc_hwi.c  |8 -
 drivers/scsi/bnx2fc/bnx2fc_io.c   |9 --
 drivers/scsi/bnx2fc/bnx2fc_tgt.c  |2 +-
 6 files changed, 116 insertions(+), 17 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


Re: [patch] [SCSI] scsi_transport_sas: check for allocation failure

2013-03-08 Thread James Bottomley
On Fri, 2013-03-08 at 12:57 -0500, Douglas Gilbert wrote:
 On 13-03-08 07:02 AM, Dan Carpenter wrote:
  Static checkers complain that this allocation isn't checked.  We
  should return zero if the allocation fails.
 
  Signed-off-by: Dan Carpenter dan.carpen...@oracle.com
 
  diff --git a/drivers/scsi/scsi_transport_sas.c 
  b/drivers/scsi/scsi_transport_sas.c
  index 1b68142..a022997 100644
  --- a/drivers/scsi/scsi_transport_sas.c
  +++ b/drivers/scsi/scsi_transport_sas.c
  @@ -379,9 +379,12 @@ sas_tlr_supported(struct scsi_device *sdev)
{
  const int vpd_len = 32;
  struct sas_end_device *rdev = sas_sdev_to_rdev(sdev);
  -   char *buffer = kzalloc(vpd_len, GFP_KERNEL);
  +   char *buffer;
  int ret = 0;
 
  +   buffer = kzalloc(vpd_len, GFP_KERNEL);
  +   if (!buffer)
  +   goto out;
  if (scsi_get_vpd_page(sdev, 0x90, buffer, vpd_len))
  goto out;
 
 
 For 32 bytes, why not use the stack?

Because the buffer is a DMA target.  You can't DMA to stack because of
padding and cacheline issues.

James


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


Re: [patch] [SCSI] scsi_transport_sas: check for allocation failure

2013-03-08 Thread Douglas Gilbert

On 13-03-08 05:50 PM, James Bottomley wrote:

On Fri, 2013-03-08 at 12:57 -0500, Douglas Gilbert wrote:

On 13-03-08 07:02 AM, Dan Carpenter wrote:

Static checkers complain that this allocation isn't checked.  We
should return zero if the allocation fails.

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

diff --git a/drivers/scsi/scsi_transport_sas.c 
b/drivers/scsi/scsi_transport_sas.c
index 1b68142..a022997 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -379,9 +379,12 @@ sas_tlr_supported(struct scsi_device *sdev)
   {
const int vpd_len = 32;
struct sas_end_device *rdev = sas_sdev_to_rdev(sdev);
-   char *buffer = kzalloc(vpd_len, GFP_KERNEL);
+   char *buffer;
int ret = 0;

+   buffer = kzalloc(vpd_len, GFP_KERNEL);
+   if (!buffer)
+   goto out;
if (scsi_get_vpd_page(sdev, 0x90, buffer, vpd_len))
goto out;



For 32 bytes, why not use the stack?


Because the buffer is a DMA target.  You can't DMA to stack because of
padding and cacheline issues.


And I went to the definition of scsi_get_vpd_page()
to see if that was called out in the header comments.
Guess what ... and those same header comments talked
about freeing a returned pointer. It needs to be
cleaned up, IMO.

Doug Gilbert

/**
 * scsi_get_vpd_page - Get Vital Product Data from a SCSI device
 * @sdev: The device to ask
 * @page: Which Vital Product Data to return
 * @buf: where to store the VPD
 * @buf_len: number of bytes in the VPD buffer area
 *
 * SCSI devices may optionally supply Vital Product Data.  Each 'page'
 * of VPD is defined in the appropriate SCSI document (eg SPC, SBC).
 * If the device supports this VPD page, this routine returns a pointer
 * to a buffer containing the data from that page.  The caller is
 * responsible for calling kfree() on this pointer when it is no longer
 * needed.  If we cannot retrieve the VPD page this routine returns %NULL.
 */
int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf,
  int buf_len)


--
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 5/5] bnx2fc: Bumped version to 1.0.14

2013-03-08 Thread Bhanu Prakash Gollapudi

On 03/08/2013 01:28 PM, Bhanu Prakash Gollapudi wrote:

Signed-off-by: Bhanu Prakash Gollapudi bprak...@broadcom.com
---
  drivers/scsi/bnx2fc/bnx2fc.h  |2 +-
  drivers/scsi/bnx2fc/bnx2fc_fcoe.c |2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h
index 676dba3..1ece6e9 100644
--- a/drivers/scsi/bnx2fc/bnx2fc.h
+++ b/drivers/scsi/bnx2fc/bnx2fc.h
@@ -64,7 +64,7 @@
  #include bnx2fc_constants.h
  
  #define BNX2FC_NAME		bnx2fc

-#define BNX2FC_VERSION 1.0.13
+#define BNX2FC_VERSION 1.0.14
  
  #define PFX			bnx2fc: 
  
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c

index 1e852d6..9ab62da 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -22,7 +22,7 @@ DEFINE_PER_CPU(struct bnx2fc_percpu_s, bnx2fc_percpu);
  
  #define DRV_MODULE_NAME		bnx2fc

  #define DRV_MODULE_VERSIONBNX2FC_VERSION
-#define DRV_MODULE_RELDATE Dec 21, 2012
+#define DRV_MODULE_RELDATE Mar 08, 2012

James, I realized there was a typo in the date - 2012 instead of 2013.

Please apply this patch instead. Sorry for the inconvenience.


Signed-off-by: Bhanu Prakash Gollapudi bprak...@broadcom.com
---
 drivers/scsi/bnx2fc/bnx2fc.h  |2 +-
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h
index 676dba3..1ece6e9 100644
--- a/drivers/scsi/bnx2fc/bnx2fc.h
+++ b/drivers/scsi/bnx2fc/bnx2fc.h
@@ -64,7 +64,7 @@
 #include bnx2fc_constants.h

 #define BNX2FC_NAMEbnx2fc
-#define BNX2FC_VERSION1.0.13
+#define BNX2FC_VERSION1.0.14

 #define PFXbnx2fc: 

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c

index 1e852d6..9ab62da 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -22,7 +22,7 @@ DEFINE_PER_CPU(struct bnx2fc_percpu_s, bnx2fc_percpu);

 #define DRV_MODULE_NAMEbnx2fc
 #define DRV_MODULE_VERSIONBNX2FC_VERSION
-#define DRV_MODULE_RELDATEDec 21, 2012
+#define DRV_MODULE_RELDATEMar 08, 2013


 static char version[] =
--
1.7.1


thanks,
Bhanu
  
  
  static char version[] =




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