[PATCH] IB: cxgb3: iwch_cm: Remove some unused functions

2015-01-11 Thread Rickard Strandqvist
Removes some functions that are not used anywhere:
iwch_resume_tid() iwch_quiesce_tid()

This was partially found by using a static code analysis program called 
cppcheck.

Signed-off-by: Rickard Strandqvist 
---
 drivers/infiniband/hw/cxgb3/iwch_cm.c |   42 -
 drivers/infiniband/hw/cxgb3/iwch_cm.h |2 --
 2 files changed, 44 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c 
b/drivers/infiniband/hw/cxgb3/iwch_cm.c
index cb78b1e..ae8ff80 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
@@ -183,48 +183,6 @@ static void release_tid(struct t3cdev *tdev, u32 hwtid, 
struct sk_buff *skb)
return;
 }
 
-int iwch_quiesce_tid(struct iwch_ep *ep)
-{
-   struct cpl_set_tcb_field *req;
-   struct sk_buff *skb = get_skb(NULL, sizeof(*req), GFP_KERNEL);
-
-   if (!skb)
-   return -ENOMEM;
-   req = (struct cpl_set_tcb_field *) skb_put(skb, sizeof(*req));
-   req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD));
-   req->wr.wr_lo = htonl(V_WR_TID(ep->hwtid));
-   OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SET_TCB_FIELD, ep->hwtid));
-   req->reply = 0;
-   req->cpu_idx = 0;
-   req->word = htons(W_TCB_RX_QUIESCE);
-   req->mask = cpu_to_be64(1ULL << S_TCB_RX_QUIESCE);
-   req->val = cpu_to_be64(1 << S_TCB_RX_QUIESCE);
-
-   skb->priority = CPL_PRIORITY_DATA;
-   return iwch_cxgb3_ofld_send(ep->com.tdev, skb);
-}
-
-int iwch_resume_tid(struct iwch_ep *ep)
-{
-   struct cpl_set_tcb_field *req;
-   struct sk_buff *skb = get_skb(NULL, sizeof(*req), GFP_KERNEL);
-
-   if (!skb)
-   return -ENOMEM;
-   req = (struct cpl_set_tcb_field *) skb_put(skb, sizeof(*req));
-   req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD));
-   req->wr.wr_lo = htonl(V_WR_TID(ep->hwtid));
-   OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SET_TCB_FIELD, ep->hwtid));
-   req->reply = 0;
-   req->cpu_idx = 0;
-   req->word = htons(W_TCB_RX_QUIESCE);
-   req->mask = cpu_to_be64(1ULL << S_TCB_RX_QUIESCE);
-   req->val = 0;
-
-   skb->priority = CPL_PRIORITY_DATA;
-   return iwch_cxgb3_ofld_send(ep->com.tdev, skb);
-}
-
 static void set_emss(struct iwch_ep *ep, u16 opt)
 {
PDBG("%s ep %p opt %u\n", __func__, ep, opt);
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.h 
b/drivers/infiniband/hw/cxgb3/iwch_cm.h
index b9efadf..22e6663 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.h
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.h
@@ -220,8 +220,6 @@ int iwch_destroy_listen(struct iw_cm_id *cm_id);
 int iwch_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len);
 int iwch_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param 
*conn_param);
 int iwch_ep_disconnect(struct iwch_ep *ep, int abrupt, gfp_t gfp);
-int iwch_quiesce_tid(struct iwch_ep *ep);
-int iwch_resume_tid(struct iwch_ep *ep);
 void __free_ep(struct kref *kref);
 void iwch_rearp(struct iwch_ep *ep);
 int iwch_ep_redirect(void *ctx, struct dst_entry *old, struct dst_entry *new, 
struct l2t_entry *l2t);
-- 
1.7.10.4

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


[PATCH] IB: qib: qib_iba7322: Remove unused function

2015-01-11 Thread Rickard Strandqvist
Remove the function qib_read_ureg() that is not used anywhere.

This was partially found by using a static code analysis program called 
cppcheck.

Signed-off-by: Rickard Strandqvist 
---
 drivers/infiniband/hw/qib/qib_iba7322.c |   22 --
 1 file changed, 22 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c 
b/drivers/infiniband/hw/qib/qib_iba7322.c
index a7eb325..a57b1a2 100644
--- a/drivers/infiniband/hw/qib/qib_iba7322.c
+++ b/drivers/infiniband/hw/qib/qib_iba7322.c
@@ -783,28 +783,6 @@ static inline u32 qib_read_ureg32(const struct qib_devdata 
*dd,
 }
 
 /**
- * qib_read_ureg - read virtualized per-context register
- * @dd: device
- * @regno: register number
- * @ctxt: context number
- *
- * Return the contents of a register that is virtualized to be per context.
- * Returns -1 on errors (not distinguishable from valid contents at
- * runtime; we may add a separate error variable at some point).
- */
-static inline u64 qib_read_ureg(const struct qib_devdata *dd,
-   enum qib_ureg regno, int ctxt)
-{
-
-   if (!dd->kregbase || !(dd->flags & QIB_PRESENT))
-   return 0;
-   return readq(regno + (u64 __iomem *)(
-   (dd->ureg_align * ctxt) + (dd->userbase ?
-(char __iomem *)dd->userbase :
-(char __iomem *)dd->kregbase + dd->uregbase)));
-}
-
-/**
  * qib_write_ureg - write virtualized per-context register
  * @dd: device
  * @regno: register number
-- 
1.7.10.4

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


[PATCH] infiniband: core: cm: Remove unused function

2015-01-11 Thread Rickard Strandqvist
Remove the function cm_is_active_peer() that is not used anywhere.

This was partially found by using a static code analysis program called 
cppcheck.

Signed-off-by: Rickard Strandqvist 
---
 drivers/infiniband/core/cm.c |8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index e28a494..106dfee 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -1224,14 +1224,6 @@ static int cm_issue_rej(struct cm_port *port,
return ret;
 }
 
-static inline int cm_is_active_peer(__be64 local_ca_guid, __be64 
remote_ca_guid,
-   __be32 local_qpn, __be32 remote_qpn)
-{
-   return (be64_to_cpu(local_ca_guid) > be64_to_cpu(remote_ca_guid) ||
-   ((local_ca_guid == remote_ca_guid) &&
-(be32_to_cpu(local_qpn) > be32_to_cpu(remote_qpn;
-}
-
 static void cm_format_paths_from_req(struct cm_req_msg *req_msg,
struct ib_sa_path_rec *primary_path,
struct ib_sa_path_rec *alt_path)
-- 
1.7.10.4

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


[PATCH] infiniband: hw: ipath: ipath_wc_ppc64.c: Remove unused function

2014-12-20 Thread Rickard Strandqvist
Remove the function ipath_unordered_wc() that is not used anywhere.

This was partially found by using a static code analysis program called 
cppcheck.

Signed-off-by: Rickard Strandqvist 
---
 drivers/infiniband/hw/ipath/ipath_kernel.h|3 ---
 drivers/infiniband/hw/ipath/ipath_wc_ppc64.c  |   13 -
 drivers/infiniband/hw/ipath/ipath_wc_x86_64.c |   15 ---
 3 files changed, 31 deletions(-)

diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h 
b/drivers/infiniband/hw/ipath/ipath_kernel.h
index 6559af6..e08db70 100644
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -908,9 +908,6 @@ void ipath_chip_cleanup(struct ipath_devdata *);
 /* clean up any chip type-specific stuff */
 void ipath_chip_done(void);
 
-/* check to see if we have to force ordering for write combining */
-int ipath_unordered_wc(void);
-
 void ipath_disarm_piobufs(struct ipath_devdata *, unsigned first,
  unsigned cnt);
 void ipath_cancel_sends(struct ipath_devdata *, int);
diff --git a/drivers/infiniband/hw/ipath/ipath_wc_ppc64.c 
b/drivers/infiniband/hw/ipath/ipath_wc_ppc64.c
index 1d7bd82..1a7e20a 100644
--- a/drivers/infiniband/hw/ipath/ipath_wc_ppc64.c
+++ b/drivers/infiniband/hw/ipath/ipath_wc_ppc64.c
@@ -47,16 +47,3 @@ int ipath_enable_wc(struct ipath_devdata *dd)
 {
return 0;
 }
-
-/**
- * ipath_unordered_wc - indicate whether write combining is unordered
- *
- * Because our performance depends on our ability to do write
- * combining mmio writes in the most efficient way, we need to
- * know if we are on a processor that may reorder stores when
- * write combining.
- */
-int ipath_unordered_wc(void)
-{
-   return 1;
-}
diff --git a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c 
b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
index 3428acb..4ad0b93 100644
--- a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
+++ b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
@@ -167,18 +167,3 @@ void ipath_disable_wc(struct ipath_devdata *dd)
dd->ipath_wc_cookie = 0; /* even on failure */
}
 }
-
-/**
- * ipath_unordered_wc - indicate whether write combining is ordered
- *
- * Because our performance depends on our ability to do write combining mmio
- * writes in the most efficient way, we need to know if we are on an Intel
- * or AMD x86_64 processor.  AMD x86_64 processors flush WC buffers out in
- * the order completed, and so no special flushing is required to get
- * correct ordering.  Intel processors, however, will flush write buffers
- * out in "random" orders, and so explicit ordering is needed at times.
- */
-int ipath_unordered_wc(void)
-{
-   return boot_cpu_data.x86_vendor != X86_VENDOR_AMD;
-}
-- 
1.7.10.4

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


Re: [PATCH] infiniband: hw: cxgb3: cxio_hal.c: Cleaning up missing null-terminate after strncpy call

2014-08-18 Thread Rickard Strandqvist
2014-08-18 16:27 GMT+02:00 Steve Wise :
>
>
>> -Original Message-
>> From: linux-kernel-ow...@vger.kernel.org 
>> [mailto:linux-kernel-ow...@vger.kernel.org]
>> On Behalf Of Rickard Strandqvist
>> Sent: Sunday, August 17, 2014 5:40 PM
>> To: Steve Wise; Roland Dreier
>> Cc: Rickard Strandqvist; Sean Hefty; Hal Rosenstock; 
>> linux-rdma@vger.kernel.org; linux-
>> ker...@vger.kernel.org
>> Subject: [PATCH] infiniband: hw: cxgb3: cxio_hal.c: Cleaning up missing 
>> null-terminate
> after
>> strncpy call
>>
>> Added a guaranteed null-terminate after call to strncpy.
>>
>> Signed-off-by: Rickard Strandqvist 
>> ---
>>  drivers/infiniband/hw/cxgb3/cxio_hal.c |1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.c
>> b/drivers/infiniband/hw/cxgb3/cxio_hal.c
>> index de1c61b4..5fc04e4 100644
>> --- a/drivers/infiniband/hw/cxgb3/cxio_hal.c
>> +++ b/drivers/infiniband/hw/cxgb3/cxio_hal.c
>> @@ -933,6 +933,7 @@ int cxio_rdev_open(struct cxio_rdev *rdev_p)
>>   netdev_p = rdev_p->t3cdev_p->lldev;
>>   strncpy(rdev_p->dev_name, rdev_p->t3cdev_p->name,
>>   T3_MAX_DEV_NAME_LEN);
>> + rdev_p->dev_name[T3_MAX_DEV_NAME_LEN - 1] = '\0';
>>   } else {
>>   PDBG("%s t3cdev_p or dev_name must be set\n", __func__);
>>   return -EINVAL;
>
> cxio_rdev_open() is called only by open_rnic_dev() which allocates the device 
> structure by
> calling ib_alloc_device() which uses kzalloc().  So this change really isn't 
> needed, is
> it?
>
> Steve.
>



Hi

Sure, strlcpy is preferable in many ways if we only can guarantee that
it is safe.
I have seldom received so much criticism when I start switching to
strlcpy, although much of it was justified :)
Even Linus was getting into the debate.  See more:

https://plus.google.com/111049168280159033135/posts/1amLbuhWbh5


I change to strlcpy only when I'm sure it will not cause any other problems.
But if you or anyone else can guarantee that in this case, so I'd make
a new patch with strlcpy.

And no Steve, or then you have to use:
strncpy(rdev_p->dev_name, rdev_p->t3cdev_p->name,
T3_MAX_DEV_NAME_LEN - 1);

But the kzalloc should mean that there will not be a problem to switch
to strlcpy ..

Do we agree, I'll make a new path with strlcpy?


I have run a static code analysis programs cppcheck, including finding
this type of problem.
But since I noticed that there were so many mistakes in addition, I
have now looked through all use of strncpy in kernel


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


[PATCH] infiniband: hw: cxgb3: cxio_hal.c: Cleaning up missing null-terminate after strncpy call

2014-08-17 Thread Rickard Strandqvist
Added a guaranteed null-terminate after call to strncpy.

Signed-off-by: Rickard Strandqvist 
---
 drivers/infiniband/hw/cxgb3/cxio_hal.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.c 
b/drivers/infiniband/hw/cxgb3/cxio_hal.c
index de1c61b4..5fc04e4 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_hal.c
+++ b/drivers/infiniband/hw/cxgb3/cxio_hal.c
@@ -933,6 +933,7 @@ int cxio_rdev_open(struct cxio_rdev *rdev_p)
netdev_p = rdev_p->t3cdev_p->lldev;
strncpy(rdev_p->dev_name, rdev_p->t3cdev_p->name,
T3_MAX_DEV_NAME_LEN);
+   rdev_p->dev_name[T3_MAX_DEV_NAME_LEN - 1] = '\0';
} else {
PDBG("%s t3cdev_p or dev_name must be set\n", __func__);
return -EINVAL;
-- 
1.7.10.4

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


[PATCH] infiniband: hw: ipath: ipath_diag.c: Cleaning up code that is not handled properly.

2014-06-06 Thread Rickard Strandqvist
None of the code is adapted to handle a struct ipath_diag_pkt.

This was partly found using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist 
---
 drivers/infiniband/hw/ipath/ipath_diag.c |6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/infiniband/hw/ipath/ipath_diag.c 
b/drivers/infiniband/hw/ipath/ipath_diag.c
index e2f9a51..39ba797 100644
--- a/drivers/infiniband/hw/ipath/ipath_diag.c
+++ b/drivers/infiniband/hw/ipath/ipath_diag.c
@@ -327,7 +327,6 @@ static ssize_t ipath_diagpkt_write(struct file *fp,
 {
u32 __iomem *piobuf;
u32 plen, pbufn, maxlen_reserve;
-   struct ipath_diag_pkt odp;
struct ipath_diag_xpkt dp;
u32 *tmpbuf = NULL;
struct ipath_devdata *dd;
@@ -341,11 +340,6 @@ static ssize_t ipath_diagpkt_write(struct file *fp,
ret = -EFAULT;
goto bail;
}
-   } else if (count == sizeof(odp)) {
-   if (copy_from_user(&odp, data, sizeof(odp))) {
-   ret = -EFAULT;
-   goto bail;
-   }
} else {
ret = -EINVAL;
goto bail;
-- 
1.7.10.4

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


[PATCH] infiniband: hw: ehca: ehca_mrmw.c: Fix for possible null pointer dereference

2014-05-17 Thread Rickard Strandqvist
There is otherwise a risk of a possible null pointer dereference.

Was largely found by using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist 
---
 drivers/infiniband/hw/ehca/ehca_mrmw.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/ehca/ehca_mrmw.c 
b/drivers/infiniband/hw/ehca/ehca_mrmw.c
index 3488e8c..1fe4344 100644
--- a/drivers/infiniband/hw/ehca/ehca_mrmw.c
+++ b/drivers/infiniband/hw/ehca/ehca_mrmw.c
@@ -316,9 +316,8 @@ struct ib_mr *ehca_reg_user_mr(struct ib_pd *pd, u64 start, 
u64 length,
 {
struct ib_mr *ib_mr;
struct ehca_mr *e_mr;
-   struct ehca_shca *shca =
-   container_of(pd->device, struct ehca_shca, ib_device);
-   struct ehca_pd *e_pd = container_of(pd, struct ehca_pd, ib_pd);
+   struct ehca_shca *shca;
+   struct ehca_pd *e_pd;
struct ehca_mr_pginfo pginfo;
int ret, page_shift;
u32 num_kpages;
@@ -330,6 +329,9 @@ struct ib_mr *ehca_reg_user_mr(struct ib_pd *pd, u64 start, 
u64 length,
return ERR_PTR(-EFAULT);
}
 
+   shca = container_of(pd->device, struct ehca_shca, ib_device);
+   e_pd = container_of(pd, struct ehca_pd, ib_pd);
+
if (((mr_access_flags & IB_ACCESS_REMOTE_WRITE) &&
 !(mr_access_flags & IB_ACCESS_LOCAL_WRITE)) ||
((mr_access_flags & IB_ACCESS_REMOTE_ATOMIC) &&
-- 
1.7.10.4

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