]> git.openfabrics.org - ~aditr/compat-rdma.git/commitdiff
cxgb4: Fix build warnings introduced after T4 configuration file support
authorVipul Pandya <root@silicon.(none)>
Wed, 17 Oct 2012 11:34:50 +0000 (17:04 +0530)
committerVipul Pandya <vipul@chelsio.com>
Wed, 17 Oct 2012 12:21:10 +0000 (05:21 -0700)
This patch adds patch series from linux-next tree to fix build warnings
introduced after T4 configuration file support addition.

Dynamically allocate memory in t4_memory_rw() and get_vpd_params() to reduce
stack foot prints.

Fixes build failure due to missing linux/vmalloc.h include.

Addresses various sparse warnings related to type assignment issues, function
definition and symbol shadowing.

Signed-off-by: Vipul Pandya <vipul@chelsio.com>
linux-next-cherry-picks/0009-cxgb4-Dynamically-allocate-memory-in-t4_memory_rw-an.patch [new file with mode: 0644]
linux-next-cherry-picks/0010-cxgb4-Fix-build-error-due-to-missing-linux-vmalloc.h.patch [new file with mode: 0644]
linux-next-cherry-picks/0011-cxgb4-allocate-enough-data-in-t4_memory_rw.patch [new file with mode: 0644]
linux-next-cherry-picks/0012-cxgb4-Address-various-sparse-warnings.patch [new file with mode: 0644]

diff --git a/linux-next-cherry-picks/0009-cxgb4-Dynamically-allocate-memory-in-t4_memory_rw-an.patch b/linux-next-cherry-picks/0009-cxgb4-Dynamically-allocate-memory-in-t4_memory_rw-an.patch
new file mode 100644 (file)
index 0000000..9ed8f9d
--- /dev/null
@@ -0,0 +1,152 @@
+From 8c357ebd5693b95ca6bb21242838ca3738a68450 Mon Sep 17 00:00:00 2001
+From: Vipul Pandya <vipul@chelsio.com>
+Date: Wed, 3 Oct 2012 03:22:32 +0000
+Subject: [PATCH] cxgb4: Dynamically allocate memory in t4_memory_rw() and get_vpd_params()
+
+This patch changes memory allocation to reduce stack footprint
+
+Signed-off-by: Jay Hernandez <jay@chelsio.com>
+Signed-off-by: Vipul Pandya <vipul@chelsio.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |   43 +++++++++++++++++++--------
+ 1 files changed, 30 insertions(+), 13 deletions(-)
+
+diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+index 35b81d8..137a244 100644
+--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
++++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+@@ -408,7 +408,8 @@ static int t4_memory_rw(struct adapter *adap, int mtype, u32 addr, u32 len,
+                       __be32 *buf, int dir)
+ {
+       u32 pos, start, end, offset, memoffset;
+-      int ret;
++      int ret = 0;
++      __be32 *data;
+
+       /*
+        * Argument sanity checks ...
+@@ -416,6 +417,10 @@ static int t4_memory_rw(struct adapter *adap, int mtype, u32 addr, u32 len,
+       if ((addr & 0x3) || (len & 0x3))
+               return -EINVAL;
+
++      data = vmalloc(MEMWIN0_APERTURE/sizeof(__be32));
++      if (!data)
++              return -ENOMEM;
++
+       /*
+        * Offset into the region of memory which is being accessed
+        * MEM_EDC0 = 0
+@@ -438,7 +443,6 @@ static int t4_memory_rw(struct adapter *adap, int mtype, u32 addr, u32 len,
+       offset = (addr - start)/sizeof(__be32);
+
+       for (pos = start; pos < end; pos += MEMWIN0_APERTURE, offset = 0) {
+-              __be32 data[MEMWIN0_APERTURE/sizeof(__be32)];
+
+               /*
+                * If we're writing, copy the data from the caller's memory
+@@ -452,7 +456,7 @@ static int t4_memory_rw(struct adapter *adap, int mtype, u32 addr, u32 len,
+                       if (offset || len < MEMWIN0_APERTURE) {
+                               ret = t4_mem_win_rw(adap, pos, data, 1);
+                               if (ret)
+-                                      return ret;
++                                      break;
+                       }
+                       while (offset < (MEMWIN0_APERTURE/sizeof(__be32)) &&
+                              len > 0) {
+@@ -466,7 +470,7 @@ static int t4_memory_rw(struct adapter *adap, int mtype, u32 addr, u32 len,
+                */
+               ret = t4_mem_win_rw(adap, pos, data, dir);
+               if (ret)
+-                      return ret;
++                      break;
+
+               /*
+                * If we're reading, copy the data into the caller's memory
+@@ -480,7 +484,8 @@ static int t4_memory_rw(struct adapter *adap, int mtype, u32 addr, u32 len,
+                       }
+       }
+
+-      return 0;
++      vfree(data);
++      return ret;
+ }
+
+ int t4_memory_write(struct adapter *adap, int mtype, u32 addr, u32 len,
+@@ -519,16 +524,21 @@ int get_vpd_params(struct adapter *adapter, struct vpd_params *p)
+       u32 cclk_param, cclk_val;
+       int i, ret;
+       int ec, sn;
+-      u8 vpd[VPD_LEN], csum;
++      u8 *vpd, csum;
+       unsigned int vpdr_len, kw_offset, id_len;
+
+-      ret = pci_read_vpd(adapter->pdev, VPD_BASE, sizeof(vpd), vpd);
++      vpd = vmalloc(VPD_LEN);
++      if (!vpd)
++              return -ENOMEM;
++
++      ret = pci_read_vpd(adapter->pdev, VPD_BASE, VPD_LEN, vpd);
+       if (ret < 0)
+-              return ret;
++              goto out;
+
+       if (vpd[0] != PCI_VPD_LRDT_ID_STRING) {
+               dev_err(adapter->pdev_dev, "missing VPD ID string\n");
+-              return -EINVAL;
++              ret = -EINVAL;
++              goto out;
+       }
+
+       id_len = pci_vpd_lrdt_size(vpd);
+@@ -538,21 +548,24 @@ int get_vpd_params(struct adapter *adapter, struct vpd_params *p)
+       i = pci_vpd_find_tag(vpd, 0, VPD_LEN, PCI_VPD_LRDT_RO_DATA);
+       if (i < 0) {
+               dev_err(adapter->pdev_dev, "missing VPD-R section\n");
+-              return -EINVAL;
++              ret = -EINVAL;
++              goto out;
+       }
+
+       vpdr_len = pci_vpd_lrdt_size(&vpd[i]);
+       kw_offset = i + PCI_VPD_LRDT_TAG_SIZE;
+       if (vpdr_len + kw_offset > VPD_LEN) {
+               dev_err(adapter->pdev_dev, "bad VPD-R length %u\n", vpdr_len);
+-              return -EINVAL;
++              ret = -EINVAL;
++              goto out;
+       }
+
+ #define FIND_VPD_KW(var, name) do { \
+       var = pci_vpd_find_info_keyword(vpd, kw_offset, vpdr_len, name); \
+       if (var < 0) { \
+               dev_err(adapter->pdev_dev, "missing VPD keyword " name "\n"); \
+-              return -EINVAL; \
++              ret = -EINVAL; \
++              goto out; \
+       } \
+       var += PCI_VPD_INFO_FLD_HDR_SIZE; \
+ } while (0)
+@@ -564,7 +577,8 @@ int get_vpd_params(struct adapter *adapter, struct vpd_params *p)
+       if (csum) {
+               dev_err(adapter->pdev_dev,
+                       "corrupted VPD EEPROM, actual csum %u\n", csum);
+-              return -EINVAL;
++              ret = -EINVAL;
++              goto out;
+       }
+
+       FIND_VPD_KW(ec, "EC");
+@@ -587,6 +601,9 @@ int get_vpd_params(struct adapter *adapter, struct vpd_params *p)
+                     FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_CCLK));
+       ret = t4_query_params(adapter, adapter->mbox, 0, 0,
+                             1, &cclk_param, &cclk_val);
++
++out:
++      vfree(vpd);
+       if (ret)
+               return ret;
+       p->cclk = cclk_val;
+--
+1.7.1
+
diff --git a/linux-next-cherry-picks/0010-cxgb4-Fix-build-error-due-to-missing-linux-vmalloc.h.patch b/linux-next-cherry-picks/0010-cxgb4-Fix-build-error-due-to-missing-linux-vmalloc.h.patch
new file mode 100644 (file)
index 0000000..bdf837d
--- /dev/null
@@ -0,0 +1,26 @@
+From c0b8b99287235626a5850ef7e5bfc842d1ebcecd Mon Sep 17 00:00:00 2001
+From: David S. Miller <davem@davemloft.net>
+Date: Wed, 3 Oct 2012 20:50:08 -0400
+Subject: [PATCH] cxgb4: Fix build error due to missing linux/vmalloc.h include.
+
+Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |    1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+
+diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+index 745a1f5..31752b2 100644
+--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+@@ -43,6 +43,7 @@
+ #include <linux/pci.h>
+ #include <linux/spinlock.h>
+ #include <linux/timer.h>
++#include <linux/vmalloc.h>
+ #include <asm/io.h>
+ #include "cxgb4_uld.h"
+ #include "t4_hw.h"
+--
+1.7.1
+
diff --git a/linux-next-cherry-picks/0011-cxgb4-allocate-enough-data-in-t4_memory_rw.patch b/linux-next-cherry-picks/0011-cxgb4-allocate-enough-data-in-t4_memory_rw.patch
new file mode 100644 (file)
index 0000000..63efba4
--- /dev/null
@@ -0,0 +1,29 @@
+From 594f88e96ebaf290e6509b37fff84b310ec1f155 Mon Sep 17 00:00:00 2001
+From: Dan Carpenter <dan.carpenter@oracle.com>
+Date: Mon, 8 Oct 2012 10:12:11 +0300
+Subject: [PATCH] cxgb4: allocate enough data in t4_memory_rw()
+
+MEMWIN0_APERTURE is the size in bytes.
+
+Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+index 137a244..e914c41 100644
+--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
++++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+@@ -417,7 +417,7 @@ static int t4_memory_rw(struct adapter *adap, int mtype, u32 addr, u32 len,
+       if ((addr & 0x3) || (len & 0x3))
+               return -EINVAL;
+
+-      data = vmalloc(MEMWIN0_APERTURE/sizeof(__be32));
++      data = vmalloc(MEMWIN0_APERTURE);
+       if (!data)
+               return -ENOMEM;
+
+--
+1.7.1
+
diff --git a/linux-next-cherry-picks/0012-cxgb4-Address-various-sparse-warnings.patch b/linux-next-cherry-picks/0012-cxgb4-Address-various-sparse-warnings.patch
new file mode 100644 (file)
index 0000000..ff6f923
--- /dev/null
@@ -0,0 +1,206 @@
+From 404d9e3fc322023619cf0a9c5c6efbbaf7e14ee8 Mon Sep 17 00:00:00 2001
+From: Vipul Pandya <vipul@chelsio.com>
+Date: Mon, 8 Oct 2012 02:59:43 +0000
+Subject: [PATCH] cxgb4: Address various sparse warnings
+
+This patch fixes type assignment issues, function definition and symbol
+shadowing which triggered sparse warnings.
+
+Signed-off-by: Jay Hernandez <jay@chelsio.com>
+Signed-off-by: Vipul Pandya <vipul@chelsio.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/chelsio/cxgb4/cxgb4.h      |    1 +
+ drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   54 +++++++++++++----------
+ drivers/net/ethernet/chelsio/cxgb4/t4_hw.c      |   13 +++--
+ 3 files changed, 39 insertions(+), 29 deletions(-)
+
+diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+index 31752b2..a4da893 100644
+--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+@@ -696,6 +696,7 @@ int t4_seeprom_wp(struct adapter *adapter, bool enable);
+ int get_vpd_params(struct adapter *adapter, struct vpd_params *p);
+ int t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size);
+ unsigned int t4_flash_cfg_addr(struct adapter *adapter);
++int t4_load_cfg(struct adapter *adapter, const u8 *cfg_data, unsigned int size);
+ int t4_check_fw_version(struct adapter *adapter);
+ int t4_prep_adapter(struct adapter *adapter);
+ int t4_port_init(struct adapter *adap, int mbox, int pf, int vf);
+diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+index 6b9f6bb..604f4f8 100644
+--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+@@ -443,7 +443,10 @@ int dbfifo_int_thresh = 10; /* 10 == 640 entry threshold */
+ module_param(dbfifo_int_thresh, int, 0644);
+ MODULE_PARM_DESC(dbfifo_int_thresh, "doorbell fifo interrupt threshold");
+
+-int dbfifo_drain_delay = 1000; /* usecs to sleep while draining the dbfifo */
++/*
++ * usecs to sleep while draining the dbfifo
++ */
++static int dbfifo_drain_delay = 1000;
+ module_param(dbfifo_drain_delay, int, 0644);
+ MODULE_PARM_DESC(dbfifo_drain_delay,
+                "usecs to sleep while draining the dbfifo");
+@@ -636,7 +639,7 @@ static void name_msix_vecs(struct adapter *adap)
+ static int request_msix_queue_irqs(struct adapter *adap)
+ {
+       struct sge *s = &adap->sge;
+-      int err, ethqidx, ofldqidx = 0, rdmaqidx = 0, msi = 2;
++      int err, ethqidx, ofldqidx = 0, rdmaqidx = 0, msi_index = 2;
+
+       err = request_irq(adap->msix_info[1].vec, t4_sge_intr_msix, 0,
+                         adap->msix_info[1].desc, &s->fw_evtq);
+@@ -644,56 +647,60 @@ static int request_msix_queue_irqs(struct adapter *adap)
+               return err;
+
+       for_each_ethrxq(s, ethqidx) {
+-              err = request_irq(adap->msix_info[msi].vec, t4_sge_intr_msix, 0,
+-                                adap->msix_info[msi].desc,
++              err = request_irq(adap->msix_info[msi_index].vec,
++                                t4_sge_intr_msix, 0,
++                                adap->msix_info[msi_index].desc,
+                                 &s->ethrxq[ethqidx].rspq);
+               if (err)
+                       goto unwind;
+-              msi++;
++              msi_index++;
+       }
+       for_each_ofldrxq(s, ofldqidx) {
+-              err = request_irq(adap->msix_info[msi].vec, t4_sge_intr_msix, 0,
+-                                adap->msix_info[msi].desc,
++              err = request_irq(adap->msix_info[msi_index].vec,
++                                t4_sge_intr_msix, 0,
++                                adap->msix_info[msi_index].desc,
+                                 &s->ofldrxq[ofldqidx].rspq);
+               if (err)
+                       goto unwind;
+-              msi++;
++              msi_index++;
+       }
+       for_each_rdmarxq(s, rdmaqidx) {
+-              err = request_irq(adap->msix_info[msi].vec, t4_sge_intr_msix, 0,
+-                                adap->msix_info[msi].desc,
++              err = request_irq(adap->msix_info[msi_index].vec,
++                                t4_sge_intr_msix, 0,
++                                adap->msix_info[msi_index].desc,
+                                 &s->rdmarxq[rdmaqidx].rspq);
+               if (err)
+                       goto unwind;
+-              msi++;
++              msi_index++;
+       }
+       return 0;
+
+ unwind:
+       while (--rdmaqidx >= 0)
+-              free_irq(adap->msix_info[--msi].vec,
++              free_irq(adap->msix_info[--msi_index].vec,
+                        &s->rdmarxq[rdmaqidx].rspq);
+       while (--ofldqidx >= 0)
+-              free_irq(adap->msix_info[--msi].vec,
++              free_irq(adap->msix_info[--msi_index].vec,
+                        &s->ofldrxq[ofldqidx].rspq);
+       while (--ethqidx >= 0)
+-              free_irq(adap->msix_info[--msi].vec, &s->ethrxq[ethqidx].rspq);
++              free_irq(adap->msix_info[--msi_index].vec,
++                       &s->ethrxq[ethqidx].rspq);
+       free_irq(adap->msix_info[1].vec, &s->fw_evtq);
+       return err;
+ }
+
+ static void free_msix_queue_irqs(struct adapter *adap)
+ {
+-      int i, msi = 2;
++      int i, msi_index = 2;
+       struct sge *s = &adap->sge;
+
+       free_irq(adap->msix_info[1].vec, &s->fw_evtq);
+       for_each_ethrxq(s, i)
+-              free_irq(adap->msix_info[msi++].vec, &s->ethrxq[i].rspq);
++              free_irq(adap->msix_info[msi_index++].vec, &s->ethrxq[i].rspq);
+       for_each_ofldrxq(s, i)
+-              free_irq(adap->msix_info[msi++].vec, &s->ofldrxq[i].rspq);
++              free_irq(adap->msix_info[msi_index++].vec, &s->ofldrxq[i].rspq);
+       for_each_rdmarxq(s, i)
+-              free_irq(adap->msix_info[msi++].vec, &s->rdmarxq[i].rspq);
++              free_irq(adap->msix_info[msi_index++].vec, &s->rdmarxq[i].rspq);
+ }
+
+ /**
+@@ -2535,9 +2542,8 @@ static int read_eq_indices(struct adapter *adap, u16 qid, u16 *pidx, u16 *cidx)
+
+       ret = t4_mem_win_read_len(adap, addr, (__be32 *)&indices, 8);
+       if (!ret) {
+-              indices = be64_to_cpu(indices);
+-              *cidx = (indices >> 25) & 0xffff;
+-              *pidx = (indices >> 9) & 0xffff;
++              *cidx = (be64_to_cpu(indices) >> 25) & 0xffff;
++              *pidx = (be64_to_cpu(indices) >> 9) & 0xffff;
+       }
+       return ret;
+ }
+@@ -3634,10 +3640,10 @@ static int adap_init0_no_config(struct adapter *adapter, int reset)
+        * field selections will fit in the 36-bit budget.
+        */
+       if (tp_vlan_pri_map != TP_VLAN_PRI_MAP_DEFAULT) {
+-              int i, bits = 0;
++              int j, bits = 0;
+
+-              for (i = TP_VLAN_PRI_MAP_FIRST; i <= TP_VLAN_PRI_MAP_LAST; i++)
+-                      switch (tp_vlan_pri_map & (1 << i)) {
++              for (j = TP_VLAN_PRI_MAP_FIRST; j <= TP_VLAN_PRI_MAP_LAST; j++)
++                      switch (tp_vlan_pri_map & (1 << j)) {
+                       case 0:
+                               /* compressed filter field not enabled */
+                               break;
+diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+index e914c41..32eec15 100644
+--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
++++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+@@ -380,9 +380,11 @@ static int t4_mem_win_rw(struct adapter *adap, u32 addr, __be32 *data, int dir)
+       /* Collecting data 4 bytes at a time upto MEMWIN0_APERTURE */
+       for (i = 0; i < MEMWIN0_APERTURE; i = i+0x4) {
+               if (dir)
+-                      *data++ = t4_read_reg(adap, (MEMWIN0_BASE + i));
++                      *data++ = (__force __be32) t4_read_reg(adap,
++                                                      (MEMWIN0_BASE + i));
+               else
+-                      t4_write_reg(adap, (MEMWIN0_BASE + i), *data++);
++                      t4_write_reg(adap, (MEMWIN0_BASE + i),
++                                   (__force u32) *data++);
+       }
+
+       return 0;
+@@ -744,7 +746,7 @@ static int t4_read_flash(struct adapter *adapter, unsigned int addr,
+               if (ret)
+                       return ret;
+               if (byte_oriented)
+-                      *data = htonl(*data);
++                      *data = (__force __u32) (htonl(*data));
+       }
+       return 0;
+ }
+@@ -992,7 +994,7 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, unsigned int size)
+       int ret, addr;
+       unsigned int i;
+       u8 first_page[SF_PAGE_SIZE];
+-      const u32 *p = (const u32 *)fw_data;
++      const __be32 *p = (const __be32 *)fw_data;
+       const struct fw_hdr *hdr = (const struct fw_hdr *)fw_data;
+       unsigned int sf_sec_size = adap->params.sf_size / adap->params.sf_nsec;
+       unsigned int fw_img_start = adap->params.sf_fw_start;
+@@ -2315,7 +2317,8 @@ int t4_mem_win_read_len(struct adapter *adap, u32 addr, __be32 *data, int len)
+       t4_read_reg(adap, PCIE_MEM_ACCESS_OFFSET);
+
+       for (i = 0; i < len; i += 4)
+-              *data++ = t4_read_reg(adap, (MEMWIN0_BASE + off + i));
++              *data++ = (__force __be32) t4_read_reg(adap,
++                                              (MEMWIN0_BASE + off + i));
+
+       return 0;
+ }
+--
+1.7.1
+