Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1583970 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2017-02-18 21:50 +0100 |
| Last post | 2017-02-18 22:50 +0100 |
| Articles | 20 on this page of 49 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 00/29] IB/mlx: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 21:50 +0100
[PATCH 04/29] IB/mlx4: Improve another size determination in alloc_pv_object() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:00 +0100
Re: [PATCH 04/29] IB/mlx4: Improve another size determination in alloc_pv_object() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:10 +0100
[PATCH 01/29] IB/mlx4: Use kcalloc() in mlx4_ib_alloc_pv_bufs() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:00 +0100
Re: [PATCH 01/29] IB/mlx4: Use kcalloc() in mlx4_ib_alloc_pv_bufs() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:10 +0100
[PATCH 09/29] IB/mlx4: Move an assignment out of a check in forward_trap() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:00 +0100
Re: [PATCH 09/29] IB/mlx4: Move an assignment out of a check in forward_trap() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:20 +0100
[PATCH 03/29] IB/mlx4: Improve another size determination in mlx4_ib_alloc_demux_ctx() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:00 +0100
Re: [PATCH 03/29] IB/mlx4: Improve another size determination in mlx4_ib_alloc_demux_ctx() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:10 +0100
[PATCH 06/29] IB/mlx4: Delete three unnecessary return statements SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:00 +0100
Re: [PATCH 06/29] IB/mlx4: Delete three unnecessary return statements Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:10 +0100
[PATCH 05/29] IB/mlx4: Fix a typo in a comment line SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:00 +0100
Re: [PATCH 05/29] IB/mlx4: Fix a typo in a comment line Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:10 +0100
[PATCH 07/29] IB/mlx4: Split a condition check in handle_slaves_guid_change() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:00 +0100
Re: [PATCH 07/29] IB/mlx4: Split a condition check in handle_slaves_guid_change() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:10 +0100
[PATCH 10/29] IB/mlx4: Enclose 15 expressions for the sizeof operator by parentheses SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:00 +0100
Re: [PATCH 10/29] IB/mlx4: Enclose 15 expressions for the sizeof operator by parentheses Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:30 +0100
[PATCH 15/29] IB/mlx4: Delete an unnecessary return statement in do_slave_init() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:10 +0100
Re: [PATCH 15/29] IB/mlx4: Delete an unnecessary return statement in do_slave_init() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 23:40 +0100
[PATCH 11/29] IB/mlx4: Use kmalloc_array() in three functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:10 +0100
Re: [PATCH 11/29] IB/mlx4: Use kmalloc_array() in three functions Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:30 +0100
[PATCH 13/29] IB/mlx4: Split a condition check in five functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:10 +0100
Re: [PATCH 13/29] IB/mlx4: Split a condition check in five functions Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:30 +0100
[PATCH 12/29] IB/mlx4: Enclose 17 expressions for the sizeof operator by parentheses SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:10 +0100
Re: [PATCH 12/29] IB/mlx4: Enclose 17 expressions for the sizeof operator by parentheses Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:30 +0100
[PATCH 18/29] IB/mlx4: Delete an unnecessary variable initialisation in mlx4_ib_add() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:10 +0100
[PATCH 19/29] IB/mlx4: Delete an unnecessary variable assignment in mlx4_ib_add() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:10 +0100
Re: [PATCH 19/29] IB/mlx4: Delete an unnecessary variable assignment in mlx4_ib_add() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 20:50 +0100
[PATCH 14/29] IB/mlx4: Delete an unnecessary variable in __mlx4_ib_query_gid() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:10 +0100
[PATCH 17/29] IB/mlx4: Improve another size determination in mlx4_ib_add() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:10 +0100
Re: [PATCH 17/29] IB/mlx4: Improve another size determination in mlx4_ib_add() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:40 +0100
Re: [PATCH 17/29] IB/mlx4: Improve another size determination in mlx4_ib_add() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:40 +0100
[PATCH 22/29] IB/mlx4: Use kmalloc_array() in alloc_proxy_bufs() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
Re: [PATCH 22/29] IB/mlx4: Use kmalloc_array() in alloc_proxy_bufs() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 21:00 +0100
[PATCH 20/29] IB/mlx4: Delete an error message for a failed memory allocation in mlx4_ib_add() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
Re: [PATCH 20/29] IB/mlx4: Delete an error message for a failed memory allocation in mlx4_ib_add() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 20:50 +0100
[PATCH 21/29] IB/mlx4: Delete unnecessary braces in mlx4_ib_add() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
Re: [PATCH 21/29] IB/mlx4: Delete unnecessary braces in mlx4_ib_add() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 21:10 +0100
[PATCH 29/29] IB/mlx5: Use kmalloc_array() in create_srq_kernel() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
[PATCH 24/29] IB/mlx4: Delete unwanted spaces behind usages of the sizeof operator SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
[PATCH 28/29] IB/mlx5: Less function calls in create_kernel_qp() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
[PATCH 27/29] IB/mlx5: Use kmalloc_array() in create_kernel_qp() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
[PATCH 23/29] IB/mlx4: Improve size determinations in create_qp_common() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
Re: [PATCH 23/29] IB/mlx4: Improve size determinations in create_qp_common() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 21:00 +0100
[PATCH 16/29] IB/mlx4: Improve another size determination in do_slave_init() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:20 +0100
[PATCH 08/29] IB/mlx4: Delete an unnecessary check before the function call "kfree" in free_pv_object() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:30 +0100
Re: [PATCH 08/29] IB/mlx4: Delete an unnecessary check before the function call "kfree" in free_pv_object() Majd Dibbiny <majd@mellanox.com> - 2017-02-19 18:20 +0100
[PATCH 26/29] IB/mlx4: Enclose 14 expressions for the sizeof operator by parentheses SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:30 +0100
[PATCH 25/29] IB/mlx4: Add spaces for better code readability SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-18 22:50 +0100
Page 2 of 3 — ← Prev page 1 [2] 3 Next page →
| From | Majd Dibbiny <majd@mellanox.com> |
|---|---|
| Date | 2017-02-19 18:30 +0100 |
| Subject | Re: [PATCH 11/29] IB/mlx4: Use kmalloc_array() in three functions |
| Message-ID | <tcDt8-1Jy-21@gated-at.bofh.it> |
| In reply to | #1583983 |
> On Feb 18, 2017, at 11:07 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 10:32:32 +0100
>
> Multiplications for the size determination of memory allocations
> indicated that array data structures should be processed.
> Thus use the corresponding function "kmalloc_array".
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index ba6af84cc236..350c9148340e 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -304,7 +304,9 @@ static int mlx4_ib_add_gid(struct ib_device *device,
> ctx->refcount++;
> }
> if (!ret && hw_update) {
> - gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
> + gids = kmalloc_array(MLX4_MAX_PORT_GIDS,
> + sizeof(*gids),
> + GFP_ATOMIC);
> if (!gids) {
> ret = -ENOMEM;
> } else {
> @@ -359,7 +361,9 @@ static int mlx4_ib_del_gid(struct ib_device *device,
> if (!ret && hw_update) {
> int i;
>
> - gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
> + gids = kmalloc_array(MLX4_MAX_PORT_GIDS,
> + sizeof(*gids),
> + GFP_ATOMIC);
> if (!gids) {
> ret = -ENOMEM;
> } else {
> @@ -2828,9 +2832,9 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
> goto err_counter;
>
> ibdev->ib_uc_qpns_bitmap =
> - kmalloc(BITS_TO_LONGS(ibdev->steer_qpn_count) *
> - sizeof(long),
> - GFP_KERNEL);
> + kmalloc_array(BITS_TO_LONGS(ibdev->steer_qpn_count),
> + sizeof(long),
> + GFP_KERNEL);
> if (!ibdev->ib_uc_qpns_bitmap)
> goto err_steer_qp_release;
>
> --
> 2.11.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:10 +0100 |
| Subject | [PATCH 13/29] IB/mlx4: Split a condition check in five functions |
| Message-ID | <tckqt-70u-11@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 14:43:34 +0100
The kfree() function was called in up to two cases during error handling
even if the passed variable contained a null pointer.
* Split a condition check for memory allocation failures.
* Adjust jump targets according to the Linux coding style convention.
* Delete initialisations for variables at the beginning
which became unnecessary with this refactoring.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/mlx4/main.c | 90 +++++++++++++++++++++++++--------------
1 file changed, 59 insertions(+), 31 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index b3b5ded85166..c0c299ffa0f6 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -432,8 +432,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
struct ib_udata *uhw)
{
struct mlx4_ib_dev *dev = to_mdev(ibdev);
- struct ib_smp *in_mad = NULL;
- struct ib_smp *out_mad = NULL;
+ struct ib_smp *in_mad;
+ struct ib_smp *out_mad;
int err;
int have_ib_ports;
struct mlx4_uverbs_ex_query_device cmd;
@@ -458,10 +458,14 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
resp.response_length = offsetof(typeof(resp), response_length) +
sizeof(resp.response_length);
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+ if (!in_mad)
+ return -ENOMEM;
+
out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
- err = -ENOMEM;
- if (!in_mad || !out_mad)
- goto out;
+ if (!out_mad) {
+ err = -ENOMEM;
+ goto free_in_mad;
+ }
init_query_mad(in_mad);
in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
@@ -570,9 +574,9 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
goto out;
}
out:
- kfree(in_mad);
kfree(out_mad);
-
+free_in_mad:
+ kfree(in_mad);
return err;
}
@@ -588,16 +592,21 @@ mlx4_ib_port_link_layer(struct ib_device *device, u8 port_num)
static int ib_link_query_port(struct ib_device *ibdev, u8 port,
struct ib_port_attr *props, int netw_view)
{
- struct ib_smp *in_mad = NULL;
- struct ib_smp *out_mad = NULL;
+ struct ib_smp *in_mad;
+ struct ib_smp *out_mad;
int ext_active_speed;
int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
- int err = -ENOMEM;
+ int err;
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+ if (!in_mad)
+ return -ENOMEM;
+
out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
- if (!in_mad || !out_mad)
- goto out;
+ if (!out_mad) {
+ err = -ENOMEM;
+ goto free_in_mad;
+ }
init_query_mad(in_mad);
in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
@@ -670,8 +679,9 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
props->active_speed = IB_SPEED_SDR;
out:
- kfree(in_mad);
kfree(out_mad);
+free_in_mad:
+ kfree(in_mad);
return err;
}
@@ -763,17 +773,22 @@ static int mlx4_ib_query_port(struct ib_device *ibdev, u8 port,
int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
union ib_gid *gid, int netw_view)
{
- struct ib_smp *in_mad = NULL;
- struct ib_smp *out_mad = NULL;
- int err = -ENOMEM;
+ struct ib_smp *in_mad;
+ struct ib_smp *out_mad;
+ int err;
struct mlx4_ib_dev *dev = to_mdev(ibdev);
int clear = 0;
int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+ if (!in_mad)
+ return -ENOMEM;
+
out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
- if (!in_mad || !out_mad)
- goto out;
+ if (!out_mad) {
+ err = -ENOMEM;
+ goto free_in_mad;
+ }
init_query_mad(in_mad);
in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
@@ -811,8 +826,9 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
out:
if (clear)
memset(gid->raw + 8, 0, 8);
- kfree(in_mad);
kfree(out_mad);
+free_in_mad:
+ kfree(in_mad);
return err;
}
@@ -902,15 +918,20 @@ static void mlx4_init_sl2vl_tbl(struct mlx4_ib_dev *mdev)
int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
u16 *pkey, int netw_view)
{
- struct ib_smp *in_mad = NULL;
- struct ib_smp *out_mad = NULL;
+ struct ib_smp *in_mad;
+ struct ib_smp *out_mad;
int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
- int err = -ENOMEM;
+ int err;
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+ if (!in_mad)
+ return -ENOMEM;
+
out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
- if (!in_mad || !out_mad)
- goto out;
+ if (!out_mad) {
+ err = -ENOMEM;
+ goto free_in_mad;
+ }
init_query_mad(in_mad);
in_mad->attr_id = IB_SMP_ATTR_PKEY_TABLE;
@@ -927,8 +948,9 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
*pkey = be16_to_cpu(((__be16 *) out_mad->data)[index % 32]);
out:
- kfree(in_mad);
kfree(out_mad);
+free_in_mad:
+ kfree(in_mad);
return err;
}
@@ -2083,15 +2105,20 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
static int init_node_data(struct mlx4_ib_dev *dev)
{
- struct ib_smp *in_mad = NULL;
- struct ib_smp *out_mad = NULL;
+ struct ib_smp *in_mad;
+ struct ib_smp *out_mad;
int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
- int err = -ENOMEM;
+ int err;
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+ if (!in_mad)
+ return -ENOMEM;
+
out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
- if (!in_mad || !out_mad)
- goto out;
+ if (!out_mad) {
+ err = -ENOMEM;
+ goto free_in_mad;
+ }
init_query_mad(in_mad);
in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
@@ -2114,8 +2141,9 @@ static int init_node_data(struct mlx4_ib_dev *dev)
memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8);
out:
- kfree(in_mad);
kfree(out_mad);
+free_in_mad:
+ kfree(in_mad);
return err;
}
--
2.11.1
[toc] | [prev] | [next] | [standalone]
| From | Majd Dibbiny <majd@mellanox.com> |
|---|---|
| Date | 2017-02-19 18:30 +0100 |
| Subject | Re: [PATCH 13/29] IB/mlx4: Split a condition check in five functions |
| Message-ID | <tcDt7-1Jy-5@gated-at.bofh.it> |
| In reply to | #1583985 |
> On Feb 18, 2017, at 11:08 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 14:43:34 +0100
>
> The kfree() function was called in up to two cases during error handling
> even if the passed variable contained a null pointer.
>
> * Split a condition check for memory allocation failures.
>
> * Adjust jump targets according to the Linux coding style convention.
>
> * Delete initialisations for variables at the beginning
> which became unnecessary with this refactoring.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 90 +++++++++++++++++++++++++--------------
> 1 file changed, 59 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index b3b5ded85166..c0c299ffa0f6 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -432,8 +432,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
> struct ib_udata *uhw)
> {
> struct mlx4_ib_dev *dev = to_mdev(ibdev);
> - struct ib_smp *in_mad = NULL;
> - struct ib_smp *out_mad = NULL;
> + struct ib_smp *in_mad;
> + struct ib_smp *out_mad;
> int err;
> int have_ib_ports;
> struct mlx4_uverbs_ex_query_device cmd;
> @@ -458,10 +458,14 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
> resp.response_length = offsetof(typeof(resp), response_length) +
> sizeof(resp.response_length);
> in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> + if (!in_mad)
> + return -ENOMEM;
> +
> out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
> - err = -ENOMEM;
> - if (!in_mad || !out_mad)
> - goto out;
> + if (!out_mad) {
> + err = -ENOMEM;
> + goto free_in_mad;
> + }
>
> init_query_mad(in_mad);
> in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
> @@ -570,9 +574,9 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
> goto out;
> }
> out:
> - kfree(in_mad);
> kfree(out_mad);
> -
> +free_in_mad:
> + kfree(in_mad);
> return err;
> }
>
> @@ -588,16 +592,21 @@ mlx4_ib_port_link_layer(struct ib_device *device, u8 port_num)
> static int ib_link_query_port(struct ib_device *ibdev, u8 port,
> struct ib_port_attr *props, int netw_view)
> {
> - struct ib_smp *in_mad = NULL;
> - struct ib_smp *out_mad = NULL;
> + struct ib_smp *in_mad;
> + struct ib_smp *out_mad;
> int ext_active_speed;
> int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
> - int err = -ENOMEM;
> + int err;
>
> in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> + if (!in_mad)
> + return -ENOMEM;
> +
> out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
> - if (!in_mad || !out_mad)
> - goto out;
> + if (!out_mad) {
> + err = -ENOMEM;
> + goto free_in_mad;
> + }
>
> init_query_mad(in_mad);
> in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
> @@ -670,8 +679,9 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
> props->active_speed = IB_SPEED_SDR;
>
> out:
> - kfree(in_mad);
> kfree(out_mad);
> +free_in_mad:
> + kfree(in_mad);
> return err;
> }
>
> @@ -763,17 +773,22 @@ static int mlx4_ib_query_port(struct ib_device *ibdev, u8 port,
> int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
> union ib_gid *gid, int netw_view)
> {
> - struct ib_smp *in_mad = NULL;
> - struct ib_smp *out_mad = NULL;
> - int err = -ENOMEM;
> + struct ib_smp *in_mad;
> + struct ib_smp *out_mad;
> + int err;
> struct mlx4_ib_dev *dev = to_mdev(ibdev);
> int clear = 0;
> int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
>
> in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> + if (!in_mad)
> + return -ENOMEM;
> +
> out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
> - if (!in_mad || !out_mad)
> - goto out;
> + if (!out_mad) {
> + err = -ENOMEM;
> + goto free_in_mad;
> + }
>
> init_query_mad(in_mad);
> in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
> @@ -811,8 +826,9 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
> out:
> if (clear)
> memset(gid->raw + 8, 0, 8);
> - kfree(in_mad);
> kfree(out_mad);
> +free_in_mad:
> + kfree(in_mad);
> return err;
> }
>
> @@ -902,15 +918,20 @@ static void mlx4_init_sl2vl_tbl(struct mlx4_ib_dev *mdev)
> int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
> u16 *pkey, int netw_view)
> {
> - struct ib_smp *in_mad = NULL;
> - struct ib_smp *out_mad = NULL;
> + struct ib_smp *in_mad;
> + struct ib_smp *out_mad;
> int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
> - int err = -ENOMEM;
> + int err;
>
> in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> + if (!in_mad)
> + return -ENOMEM;
> +
> out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
> - if (!in_mad || !out_mad)
> - goto out;
> + if (!out_mad) {
> + err = -ENOMEM;
> + goto free_in_mad;
> + }
>
> init_query_mad(in_mad);
> in_mad->attr_id = IB_SMP_ATTR_PKEY_TABLE;
> @@ -927,8 +948,9 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
> *pkey = be16_to_cpu(((__be16 *) out_mad->data)[index % 32]);
>
> out:
> - kfree(in_mad);
> kfree(out_mad);
> +free_in_mad:
> + kfree(in_mad);
> return err;
> }
>
> @@ -2083,15 +2105,20 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
>
> static int init_node_data(struct mlx4_ib_dev *dev)
> {
> - struct ib_smp *in_mad = NULL;
> - struct ib_smp *out_mad = NULL;
> + struct ib_smp *in_mad;
> + struct ib_smp *out_mad;
> int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
> - int err = -ENOMEM;
> + int err;
>
> in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> + if (!in_mad)
> + return -ENOMEM;
> +
> out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
> - if (!in_mad || !out_mad)
> - goto out;
> + if (!out_mad) {
> + err = -ENOMEM;
> + goto free_in_mad;
> + }
>
> init_query_mad(in_mad);
> in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
> @@ -2114,8 +2141,9 @@ static int init_node_data(struct mlx4_ib_dev *dev)
> memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8);
>
> out:
> - kfree(in_mad);
> kfree(out_mad);
> +free_in_mad:
> + kfree(in_mad);
> return err;
> }
>
> --
> 2.11.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:10 +0100 |
| Subject | [PATCH 12/29] IB/mlx4: Enclose 17 expressions for the sizeof operator by parentheses |
| Message-ID | <tckqu-70u-15@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 11:28:41 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script "checkpatch.pl" pointed information out like the following.
WARNING: sizeof … should be sizeof(…)
Thus fix the affected source code places.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/mlx4/main.c | 35 +++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 350c9148340e..b3b5ded85166 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -457,8 +457,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
resp.response_length = offsetof(typeof(resp), response_length) +
sizeof(resp.response_length);
- in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
- out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+ in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+ out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
err = -ENOMEM;
if (!in_mad || !out_mad)
goto out;
@@ -471,8 +471,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
if (err)
goto out;
- memset(props, 0, sizeof *props);
-
+ memset(props, 0, sizeof(*props));
have_ib_ports = num_ib_ports(dev->dev);
props->fw_ver = dev->dev->caps.fw_ver;
@@ -595,8 +594,8 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
int err = -ENOMEM;
- in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
- out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+ in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+ out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
if (!in_mad || !out_mad)
goto out;
@@ -771,8 +770,8 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
int clear = 0;
int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
- in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
- out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+ in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+ out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
if (!in_mad || !out_mad)
goto out;
@@ -908,8 +907,8 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
int err = -ENOMEM;
- in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
- out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+ in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+ out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
if (!in_mad || !out_mad)
goto out;
@@ -1280,7 +1279,7 @@ static struct ib_pd *mlx4_ib_alloc_pd(struct ib_device *ibdev,
struct mlx4_ib_pd *pd;
int err;
- pd = kmalloc(sizeof *pd, GFP_KERNEL);
+ pd = kmalloc(sizeof(*pd), GFP_KERNEL);
if (!pd)
return ERR_PTR(-ENOMEM);
@@ -1319,7 +1318,7 @@ static struct ib_xrcd *mlx4_ib_alloc_xrcd(struct ib_device *ibdev,
if (!(to_mdev(ibdev)->dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC))
return ERR_PTR(-ENOSYS);
- xrcd = kmalloc(sizeof *xrcd, GFP_KERNEL);
+ xrcd = kmalloc(sizeof(*xrcd), GFP_KERNEL);
if (!xrcd)
return ERR_PTR(-ENOMEM);
@@ -1367,7 +1366,7 @@ static int add_gid_entry(struct ib_qp *ibqp, union ib_gid *gid)
struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
struct mlx4_ib_gid_entry *ge;
- ge = kzalloc(sizeof *ge, GFP_KERNEL);
+ ge = kzalloc(sizeof(*ge), GFP_KERNEL);
if (!ge)
return -ENOMEM;
@@ -2089,8 +2088,8 @@ static int init_node_data(struct mlx4_ib_dev *dev)
int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
int err = -ENOMEM;
- in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
- out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+ in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+ out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
if (!in_mad || !out_mad)
goto out;
@@ -2600,7 +2599,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
if (num_ports == 0)
return NULL;
- ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof *ibdev);
+ ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof(*ibdev));
if (!ibdev) {
dev_err(&dev->persist->pdev->dev,
"Device struct alloc failed\n");
@@ -3301,12 +3300,12 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
break;
case MLX4_DEV_EVENT_PORT_MGMT_CHANGE:
- ew = kmalloc(sizeof *ew, GFP_ATOMIC);
+ ew = kmalloc(sizeof(*ew), GFP_ATOMIC);
if (!ew)
break;
INIT_WORK(&ew->work, handle_port_mgmt_change_event);
- memcpy(&ew->ib_eqe, eqe, sizeof *eqe);
+ memcpy(&ew->ib_eqe, eqe, sizeof(*eqe));
ew->ib_dev = ibdev;
/* need to queue only for port owner, which uses GEN_EQE */
if (mlx4_is_master(dev))
--
2.11.1
[toc] | [prev] | [next] | [standalone]
| From | Majd Dibbiny <majd@mellanox.com> |
|---|---|
| Date | 2017-02-19 18:30 +0100 |
| Subject | Re: [PATCH 12/29] IB/mlx4: Enclose 17 expressions for the sizeof operator by parentheses |
| Message-ID | <tcDt7-1Jy-11@gated-at.bofh.it> |
| In reply to | #1583986 |
> On Feb 18, 2017, at 11:02 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 11:28:41 +0100
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> The script "checkpatch.pl" pointed information out like the following.
>
> WARNING: sizeof … should be sizeof(…)
>
> Thus fix the affected source code places.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 35 +++++++++++++++++------------------
> 1 file changed, 17 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 350c9148340e..b3b5ded85166 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -457,8 +457,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
>
> resp.response_length = offsetof(typeof(resp), response_length) +
> sizeof(resp.response_length);
> - in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
> - out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
> + in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> + out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
> err = -ENOMEM;
> if (!in_mad || !out_mad)
> goto out;
> @@ -471,8 +471,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
> if (err)
> goto out;
>
> - memset(props, 0, sizeof *props);
> -
> + memset(props, 0, sizeof(*props));
> have_ib_ports = num_ib_ports(dev->dev);
>
> props->fw_ver = dev->dev->caps.fw_ver;
> @@ -595,8 +594,8 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
> int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
> int err = -ENOMEM;
>
> - in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
> - out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
> + in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> + out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
> if (!in_mad || !out_mad)
> goto out;
>
> @@ -771,8 +770,8 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
> int clear = 0;
> int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
>
> - in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
> - out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
> + in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> + out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
> if (!in_mad || !out_mad)
> goto out;
>
> @@ -908,8 +907,8 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
> int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
> int err = -ENOMEM;
>
> - in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
> - out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
> + in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> + out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
> if (!in_mad || !out_mad)
> goto out;
>
> @@ -1280,7 +1279,7 @@ static struct ib_pd *mlx4_ib_alloc_pd(struct ib_device *ibdev,
> struct mlx4_ib_pd *pd;
> int err;
>
> - pd = kmalloc(sizeof *pd, GFP_KERNEL);
> + pd = kmalloc(sizeof(*pd), GFP_KERNEL);
> if (!pd)
> return ERR_PTR(-ENOMEM);
>
> @@ -1319,7 +1318,7 @@ static struct ib_xrcd *mlx4_ib_alloc_xrcd(struct ib_device *ibdev,
> if (!(to_mdev(ibdev)->dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC))
> return ERR_PTR(-ENOSYS);
>
> - xrcd = kmalloc(sizeof *xrcd, GFP_KERNEL);
> + xrcd = kmalloc(sizeof(*xrcd), GFP_KERNEL);
> if (!xrcd)
> return ERR_PTR(-ENOMEM);
>
> @@ -1367,7 +1366,7 @@ static int add_gid_entry(struct ib_qp *ibqp, union ib_gid *gid)
> struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
> struct mlx4_ib_gid_entry *ge;
>
> - ge = kzalloc(sizeof *ge, GFP_KERNEL);
> + ge = kzalloc(sizeof(*ge), GFP_KERNEL);
> if (!ge)
> return -ENOMEM;
>
> @@ -2089,8 +2088,8 @@ static int init_node_data(struct mlx4_ib_dev *dev)
> int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
> int err = -ENOMEM;
>
> - in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
> - out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
> + in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> + out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
> if (!in_mad || !out_mad)
> goto out;
>
> @@ -2600,7 +2599,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
> if (num_ports == 0)
> return NULL;
>
> - ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof *ibdev);
> + ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof(*ibdev));
> if (!ibdev) {
> dev_err(&dev->persist->pdev->dev,
> "Device struct alloc failed\n");
> @@ -3301,12 +3300,12 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
> break;
>
> case MLX4_DEV_EVENT_PORT_MGMT_CHANGE:
> - ew = kmalloc(sizeof *ew, GFP_ATOMIC);
> + ew = kmalloc(sizeof(*ew), GFP_ATOMIC);
> if (!ew)
> break;
>
> INIT_WORK(&ew->work, handle_port_mgmt_change_event);
> - memcpy(&ew->ib_eqe, eqe, sizeof *eqe);
> + memcpy(&ew->ib_eqe, eqe, sizeof(*eqe));
> ew->ib_dev = ibdev;
> /* need to queue only for port owner, which uses GEN_EQE */
> if (mlx4_is_master(dev))
> --
> 2.11.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:10 +0100 |
| Subject | [PATCH 18/29] IB/mlx4: Delete an unnecessary variable initialisation in mlx4_ib_add() |
| Message-ID | <tckqu-70u-19@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 15:52:31 +0100
The local variable "new_counter_index" will be set to an appropriate pointer
a bit later. Thus omit the explicit initialisation at the beginning.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/mlx4/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index f3194f2a6e62..4e08e4d57181 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2612,7 +2612,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
int num_req_counters;
int allocated;
u32 counter_index;
- struct counter_index *new_counter_index = NULL;
+ struct counter_index *new_counter_index;
pr_info_once("%s", mlx4_ib_version);
--
2.11.1
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:10 +0100 |
| Subject | [PATCH 19/29] IB/mlx4: Delete an unnecessary variable assignment in mlx4_ib_add() |
| Message-ID | <tckqu-70u-21@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 16:00:28 +0100
Delete an assignment for the local variable "num_ports" at the beginning
because it was initialised with the same value.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/mlx4/main.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 4e08e4d57181..21b88d5ceda4 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2615,8 +2615,6 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
struct counter_index *new_counter_index;
pr_info_once("%s", mlx4_ib_version);
-
- num_ports = 0;
mlx4_foreach_ib_transport_port(i, dev)
num_ports++;
--
2.11.1
[toc] | [prev] | [next] | [standalone]
| From | Majd Dibbiny <majd@mellanox.com> |
|---|---|
| Date | 2017-02-19 20:50 +0100 |
| Subject | Re: [PATCH 19/29] IB/mlx4: Delete an unnecessary variable assignment in mlx4_ib_add() |
| Message-ID | <tcFEC-31O-1@gated-at.bofh.it> |
| In reply to | #1583988 |
> On Feb 18, 2017, at 11:09 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 16:00:28 +0100
>
> Delete an assignment for the local variable "num_ports" at the beginning
> because it was initialised with the same value.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 4e08e4d57181..21b88d5ceda4 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2615,8 +2615,6 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
> struct counter_index *new_counter_index;
>
> pr_info_once("%s", mlx4_ib_version);
> -
> - num_ports = 0;
> mlx4_foreach_ib_transport_port(i, dev)
> num_ports++;
>
> --
> 2.11.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:10 +0100 |
| Subject | [PATCH 14/29] IB/mlx4: Delete an unnecessary variable in __mlx4_ib_query_gid() |
| Message-ID | <tckqu-70u-23@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 15:04:50 +0100
* Call the function "memset" directly in an if branch without using
an intermediate variable.
* Delete the local variable "clear" which became unnecessary with
this refactoring.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/mlx4/main.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index c0c299ffa0f6..89bbb61d62f5 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -777,7 +777,6 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
struct ib_smp *out_mad;
int err;
struct mlx4_ib_dev *dev = to_mdev(ibdev);
- int clear = 0;
int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
@@ -806,8 +805,8 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
if (mlx4_is_mfunc(dev->dev) && !netw_view) {
if (index) {
/* For any index > 0, return the null guid */
+ memset(gid->raw + 8, 0, 8);
err = 0;
- clear = 1;
goto out;
}
}
@@ -824,8 +823,6 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
memcpy(gid->raw + 8, out_mad->data + (index % 8) * 8, 8);
out:
- if (clear)
- memset(gid->raw + 8, 0, 8);
kfree(out_mad);
free_in_mad:
kfree(in_mad);
--
2.11.1
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:10 +0100 |
| Subject | [PATCH 17/29] IB/mlx4: Improve another size determination in mlx4_ib_add() |
| Message-ID | <tckqu-70u-25@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 15:43:54 +0100
Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/mlx4/main.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index b78f17623121..f3194f2a6e62 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2825,9 +2825,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
}
if (mlx4_is_bonded(dev))
for (i = 1; i < ibdev->num_ports ; ++i) {
- new_counter_index =
- kmalloc(sizeof(struct counter_index),
- GFP_KERNEL);
+ new_counter_index = kmalloc(sizeof(*new_counter_index),
+ GFP_KERNEL);
if (!new_counter_index)
goto err_counter;
new_counter_index->index = counter_index;
--
2.11.1
[toc] | [prev] | [next] | [standalone]
| From | Majd Dibbiny <majd@mellanox.com> |
|---|---|
| Date | 2017-02-19 18:40 +0100 |
| Subject | Re: [PATCH 17/29] IB/mlx4: Improve another size determination in mlx4_ib_add() |
| Message-ID | <tcDCN-1MT-7@gated-at.bofh.it> |
| In reply to | #1583990 |
> On Feb 18, 2017, at 11:06 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 15:43:54 +0100
>
> Replace the specification of a data structure by a pointer dereference
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index b78f17623121..f3194f2a6e62 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2825,9 +2825,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
> }
> if (mlx4_is_bonded(dev))
> for (i = 1; i < ibdev->num_ports ; ++i) {
> - new_counter_index =
> - kmalloc(sizeof(struct counter_index),
> - GFP_KERNEL);
> + new_counter_index = kmalloc(sizeof(*new_counter_index),
> + GFP_KERNEL);
> if (!new_counter_index)
> goto err_counter;
> new_counter_index->index = counter_index;
> --
> 2.11.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>
[toc] | [prev] | [next] | [standalone]
| From | Majd Dibbiny <majd@mellanox.com> |
|---|---|
| Date | 2017-02-19 18:40 +0100 |
| Subject | Re: [PATCH 17/29] IB/mlx4: Improve another size determination in mlx4_ib_add() |
| Message-ID | <tcDCO-1MT-29@gated-at.bofh.it> |
| In reply to | #1583990 |
> On Feb 18, 2017, at 11:06 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 15:43:54 +0100
>
> Replace the specification of a data structure by a pointer dereference
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index b78f17623121..f3194f2a6e62 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2825,9 +2825,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
> }
> if (mlx4_is_bonded(dev))
> for (i = 1; i < ibdev->num_ports ; ++i) {
> - new_counter_index =
> - kmalloc(sizeof(struct counter_index),
> - GFP_KERNEL);
> + new_counter_index = kmalloc(sizeof(*new_counter_index),
> + GFP_KERNEL);
> if (!new_counter_index)
> goto err_counter;
> new_counter_index->index = counter_index;
> --
> 2.11.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:20 +0100 |
| Subject | [PATCH 22/29] IB/mlx4: Use kmalloc_array() in alloc_proxy_bufs() |
| Message-ID | <tckA9-73M-3@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 16:56:52 +0100
* A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".
This issue was detected by using the Coccinelle software.
* Replace the specification of a data structure by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/mlx4/qp.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 7d76f769233c..11fec4a8fae5 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -554,9 +554,9 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
{
int i;
- qp->sqp_proxy_rcv =
- kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt,
- GFP_KERNEL);
+ qp->sqp_proxy_rcv = kmalloc_array(qp->rq.wqe_cnt,
+ sizeof(*qp->sqp_proxy_rcv),
+ GFP_KERNEL);
if (!qp->sqp_proxy_rcv)
return -ENOMEM;
for (i = 0; i < qp->rq.wqe_cnt; i++) {
--
2.11.1
[toc] | [prev] | [next] | [standalone]
| From | Majd Dibbiny <majd@mellanox.com> |
|---|---|
| Date | 2017-02-19 21:00 +0100 |
| Subject | Re: [PATCH 22/29] IB/mlx4: Use kmalloc_array() in alloc_proxy_bufs() |
| Message-ID | <tcFOh-35c-5@gated-at.bofh.it> |
| In reply to | #1583991 |
> On Feb 18, 2017, at 11:12 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 16:56:52 +0100
>
> * A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus use the corresponding function "kmalloc_array".
>
> This issue was detected by using the Coccinelle software.
>
> * Replace the specification of a data structure by a pointer dereference
> to make the corresponding size determination a bit safer according to
> the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/qp.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> index 7d76f769233c..11fec4a8fae5 100644
> --- a/drivers/infiniband/hw/mlx4/qp.c
> +++ b/drivers/infiniband/hw/mlx4/qp.c
> @@ -554,9 +554,9 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
> {
> int i;
>
> - qp->sqp_proxy_rcv =
> - kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt,
> - GFP_KERNEL);
> + qp->sqp_proxy_rcv = kmalloc_array(qp->rq.wqe_cnt,
> + sizeof(*qp->sqp_proxy_rcv),
> + GFP_KERNEL);
> if (!qp->sqp_proxy_rcv)
> return -ENOMEM;
> for (i = 0; i < qp->rq.wqe_cnt; i++) {
> --
> 2.11.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:20 +0100 |
| Subject | [PATCH 20/29] IB/mlx4: Delete an error message for a failed memory allocation in mlx4_ib_add() |
| Message-ID | <tckA9-73M-5@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 16:15:20 +0100
Omit an extra message for a memory allocation failure in this function.
Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/mlx4/main.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 21b88d5ceda4..33b46c463ffa 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2623,11 +2623,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
return NULL;
ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof(*ibdev));
- if (!ibdev) {
- dev_err(&dev->persist->pdev->dev,
- "Device struct alloc failed\n");
+ if (!ibdev)
return NULL;
- }
iboe = &ibdev->iboe;
--
2.11.1
[toc] | [prev] | [next] | [standalone]
| From | Majd Dibbiny <majd@mellanox.com> |
|---|---|
| Date | 2017-02-19 20:50 +0100 |
| Subject | Re: [PATCH 20/29] IB/mlx4: Delete an error message for a failed memory allocation in mlx4_ib_add() |
| Message-ID | <tcFEC-31O-13@gated-at.bofh.it> |
| In reply to | #1583992 |
> On Feb 18, 2017, at 11:10 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 16:15:20 +0100
>
> Omit an extra message for a memory allocation failure in this function.
>
> Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 21b88d5ceda4..33b46c463ffa 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2623,11 +2623,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
> return NULL;
>
> ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof(*ibdev));
> - if (!ibdev) {
> - dev_err(&dev->persist->pdev->dev,
> - "Device struct alloc failed\n");
> + if (!ibdev)
> return NULL;
> - }
Not a big fan of this change.
9 out of the 15 drivers have this print in case of a failure..
>
> iboe = &ibdev->iboe;
>
> --
> 2.11.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:20 +0100 |
| Subject | [PATCH 21/29] IB/mlx4: Delete unnecessary braces in mlx4_ib_add() |
| Message-ID | <tckA9-73M-7@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 16:32:41 +0100
Do not use curly brackets at one source code place
where a single statement should be sufficient.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/mlx4/main.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 33b46c463ffa..b950538e036e 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2898,9 +2898,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
}
if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2) {
err = mlx4_config_roce_v2_port(dev, ROCE_V2_UDP_DPORT);
- if (err) {
+ if (err)
goto err_notif;
- }
}
}
--
2.11.1
[toc] | [prev] | [next] | [standalone]
| From | Majd Dibbiny <majd@mellanox.com> |
|---|---|
| Date | 2017-02-19 21:10 +0100 |
| Subject | Re: [PATCH 21/29] IB/mlx4: Delete unnecessary braces in mlx4_ib_add() |
| Message-ID | <tcFXX-3nI-1@gated-at.bofh.it> |
| In reply to | #1583994 |
> On Feb 18, 2017, at 11:12 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 16:32:41 +0100
>
> Do not use curly brackets at one source code place
> where a single statement should be sufficient.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 33b46c463ffa..b950538e036e 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2898,9 +2898,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
> }
> if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2) {
> err = mlx4_config_roce_v2_port(dev, ROCE_V2_UDP_DPORT);
> - if (err) {
> + if (err)
> goto err_notif;
> - }
> }
> }
>
> --
> 2.11.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:20 +0100 |
| Subject | [PATCH 29/29] IB/mlx5: Use kmalloc_array() in create_srq_kernel() |
| Message-ID | <tckAa-73M-11@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 21:18:15 +0100
* A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".
This issue was detected by using the Coccinelle software.
* Replace the specification of a data type by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/mlx5/srq.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c
index 7cb145f9a6db..8ba1953177af 100644
--- a/drivers/infiniband/hw/mlx5/srq.c
+++ b/drivers/infiniband/hw/mlx5/srq.c
@@ -195,8 +195,9 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
goto err_buf;
}
mlx5_fill_page_array(&srq->buf, in->pas);
-
- srq->wrid = kmalloc(srq->msrq.max * sizeof(u64), GFP_KERNEL);
+ srq->wrid = kmalloc_array(srq->msrq.max,
+ sizeof(*srq->wrid),
+ GFP_KERNEL);
if (!srq->wrid) {
err = -ENOMEM;
goto err_in;
--
2.11.1
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-02-18 22:20 +0100 |
| Subject | [PATCH 24/29] IB/mlx4: Delete unwanted spaces behind usages of the sizeof operator |
| Message-ID | <tckAa-73M-13@gated-at.bofh.it> |
| In reply to | #1583970 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 18:33:00 +0100
* Replace the source code "sizeof (" by "sizeof("
according to the Linux coding style convention.
* Adjust indentation at a few places.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/mlx4/qp.c | 128 ++++++++++++++++++++--------------------
1 file changed, 63 insertions(+), 65 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index cc7bd257a1fd..47a647c1d94f 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -340,39 +340,39 @@ static int send_wqe_overhead(enum mlx4_ib_qp_type type, u32 flags)
*/
switch (type) {
case MLX4_IB_QPT_UD:
- return sizeof (struct mlx4_wqe_ctrl_seg) +
- sizeof (struct mlx4_wqe_datagram_seg) +
+ return sizeof(struct mlx4_wqe_ctrl_seg) +
+ sizeof(struct mlx4_wqe_datagram_seg) +
((flags & MLX4_IB_QP_LSO) ? MLX4_IB_LSO_HEADER_SPARE : 0);
case MLX4_IB_QPT_PROXY_SMI_OWNER:
case MLX4_IB_QPT_PROXY_SMI:
case MLX4_IB_QPT_PROXY_GSI:
- return sizeof (struct mlx4_wqe_ctrl_seg) +
- sizeof (struct mlx4_wqe_datagram_seg) + 64;
+ return sizeof(struct mlx4_wqe_ctrl_seg) +
+ sizeof(struct mlx4_wqe_datagram_seg) + 64;
case MLX4_IB_QPT_TUN_SMI_OWNER:
case MLX4_IB_QPT_TUN_GSI:
- return sizeof (struct mlx4_wqe_ctrl_seg) +
- sizeof (struct mlx4_wqe_datagram_seg);
+ return sizeof(struct mlx4_wqe_ctrl_seg) +
+ sizeof(struct mlx4_wqe_datagram_seg);
case MLX4_IB_QPT_UC:
- return sizeof (struct mlx4_wqe_ctrl_seg) +
- sizeof (struct mlx4_wqe_raddr_seg);
+ return sizeof(struct mlx4_wqe_ctrl_seg) +
+ sizeof(struct mlx4_wqe_raddr_seg);
case MLX4_IB_QPT_RC:
- return sizeof (struct mlx4_wqe_ctrl_seg) +
- sizeof (struct mlx4_wqe_masked_atomic_seg) +
- sizeof (struct mlx4_wqe_raddr_seg);
+ return sizeof(struct mlx4_wqe_ctrl_seg) +
+ sizeof(struct mlx4_wqe_masked_atomic_seg) +
+ sizeof(struct mlx4_wqe_raddr_seg);
case MLX4_IB_QPT_SMI:
case MLX4_IB_QPT_GSI:
- return sizeof (struct mlx4_wqe_ctrl_seg) +
+ return sizeof(struct mlx4_wqe_ctrl_seg) +
ALIGN(MLX4_IB_UD_HEADER_SIZE +
DIV_ROUND_UP(MLX4_IB_UD_HEADER_SIZE,
MLX4_INLINE_ALIGN) *
- sizeof (struct mlx4_wqe_inline_seg),
- sizeof (struct mlx4_wqe_data_seg)) +
+ sizeof(struct mlx4_wqe_inline_seg),
+ sizeof(struct mlx4_wqe_data_seg)) +
ALIGN(4 +
- sizeof (struct mlx4_wqe_inline_seg),
- sizeof (struct mlx4_wqe_data_seg));
+ sizeof(struct mlx4_wqe_inline_seg),
+ sizeof(struct mlx4_wqe_data_seg));
default:
- return sizeof (struct mlx4_wqe_ctrl_seg);
+ return sizeof(struct mlx4_wqe_ctrl_seg);
}
}
@@ -396,7 +396,8 @@ static int set_rq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
qp->rq.wqe_cnt = roundup_pow_of_two(max(1U, cap->max_recv_wr));
qp->rq.max_gs = roundup_pow_of_two(max(1U, cap->max_recv_sge));
- qp->rq.wqe_shift = ilog2(qp->rq.max_gs * sizeof (struct mlx4_wqe_data_seg));
+ qp->rq.wqe_shift = ilog2(qp->rq.max_gs
+ * sizeof(struct mlx4_wqe_data_seg));
}
/* leave userspace return values as they were, so as not to break ABI */
@@ -424,7 +425,7 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
if (cap->max_send_wr > (dev->dev->caps.max_wqes - MLX4_IB_SQ_MAX_SPARE) ||
cap->max_send_sge > min(dev->dev->caps.max_sq_sg, dev->dev->caps.max_rq_sg) ||
cap->max_inline_data + send_wqe_overhead(type, qp->flags) +
- sizeof (struct mlx4_wqe_inline_seg) > dev->dev->caps.max_sq_desc_sz)
+ sizeof(struct mlx4_wqe_inline_seg) > dev->dev->caps.max_sq_desc_sz)
return -EINVAL;
/*
@@ -436,8 +437,8 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
cap->max_send_sge + 2 > dev->dev->caps.max_sq_sg)
return -EINVAL;
- s = max(cap->max_send_sge * sizeof (struct mlx4_wqe_data_seg),
- cap->max_inline_data + sizeof (struct mlx4_wqe_inline_seg)) +
+ s = max(cap->max_send_sge * sizeof(struct mlx4_wqe_data_seg),
+ cap->max_inline_data + sizeof(struct mlx4_wqe_inline_seg)) +
send_wqe_overhead(type, qp->flags);
if (s > dev->dev->caps.max_sq_desc_sz)
@@ -507,7 +508,7 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
qp->sq.max_gs = (min(dev->dev->caps.max_sq_desc_sz,
(qp->sq_max_wqes_per_wr << qp->sq.wqe_shift)) -
send_wqe_overhead(type, qp->flags)) /
- sizeof (struct mlx4_wqe_data_seg);
+ sizeof(struct mlx4_wqe_data_seg);
qp->buf_size = (qp->rq.wqe_cnt << qp->rq.wqe_shift) +
(qp->sq.wqe_cnt << qp->sq.wqe_shift);
@@ -561,13 +562,13 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
return -ENOMEM;
for (i = 0; i < qp->rq.wqe_cnt; i++) {
qp->sqp_proxy_rcv[i].addr =
- kmalloc(sizeof (struct mlx4_ib_proxy_sqp_hdr),
+ kmalloc(sizeof(struct mlx4_ib_proxy_sqp_hdr),
GFP_KERNEL);
if (!qp->sqp_proxy_rcv[i].addr)
goto err;
qp->sqp_proxy_rcv[i].map =
ib_dma_map_single(dev, qp->sqp_proxy_rcv[i].addr,
- sizeof (struct mlx4_ib_proxy_sqp_hdr),
+ sizeof(struct mlx4_ib_proxy_sqp_hdr),
DMA_FROM_DEVICE);
if (ib_dma_mapping_error(dev, qp->sqp_proxy_rcv[i].map)) {
kfree(qp->sqp_proxy_rcv[i].addr);
@@ -580,7 +581,7 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
while (i > 0) {
--i;
ib_dma_unmap_single(dev, qp->sqp_proxy_rcv[i].map,
- sizeof (struct mlx4_ib_proxy_sqp_hdr),
+ sizeof(struct mlx4_ib_proxy_sqp_hdr),
DMA_FROM_DEVICE);
kfree(qp->sqp_proxy_rcv[i].addr);
}
@@ -595,7 +596,7 @@ static void free_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
for (i = 0; i < qp->rq.wqe_cnt; i++) {
ib_dma_unmap_single(dev, qp->sqp_proxy_rcv[i].map,
- sizeof (struct mlx4_ib_proxy_sqp_hdr),
+ sizeof(struct mlx4_ib_proxy_sqp_hdr),
DMA_FROM_DEVICE);
kfree(qp->sqp_proxy_rcv[i].addr);
}
@@ -2318,7 +2319,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
/* for proxy-qp0 sends, need to add in size of tunnel header */
/* for tunnel-qp0 sends, tunnel header is already in s/g list */
if (sqp->qp.mlx4_ib_qp_type == MLX4_IB_QPT_PROXY_SMI_OWNER)
- send_size += sizeof (struct mlx4_ib_tunnel_header);
+ send_size += sizeof(struct mlx4_ib_tunnel_header);
ib_ud_header_init(send_size, 1, 0, 0, 0, 0, 0, 0, &sqp->ud_header);
@@ -2400,7 +2401,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
}
*mlx_seg_len =
- ALIGN(i * sizeof (struct mlx4_wqe_inline_seg) + header_size, 16);
+ ALIGN(i * sizeof(struct mlx4_wqe_inline_seg) + header_size, 16);
return 0;
}
@@ -2678,7 +2679,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
}
*mlx_seg_len =
- ALIGN(i * sizeof (struct mlx4_wqe_inline_seg) + header_size, 16);
+ ALIGN(i * sizeof(struct mlx4_wqe_inline_seg) + header_size, 16);
return 0;
}
@@ -2769,7 +2770,7 @@ static void set_masked_atomic_seg(struct mlx4_wqe_masked_atomic_seg *aseg,
static void set_datagram_seg(struct mlx4_wqe_datagram_seg *dseg,
struct ib_ud_wr *wr)
{
- memcpy(dseg->av, &to_mah(wr->ah)->av, sizeof (struct mlx4_av));
+ memcpy(dseg->av, &to_mah(wr->ah)->av, sizeof(struct mlx4_av));
dseg->dqpn = cpu_to_be32(wr->remote_qpn);
dseg->qkey = cpu_to_be32(wr->remote_qkey);
dseg->vlan = to_mah(wr->ah)->av.eth.vlan;
@@ -2791,7 +2792,7 @@ static void set_tunnel_datagram_seg(struct mlx4_ib_dev *dev,
sqp_av.sl_tclass_flowlabel = av->ib.sl_tclass_flowlabel &
cpu_to_be32(0xf0000000);
- memcpy(dseg->av, &sqp_av, sizeof (struct mlx4_av));
+ memcpy(dseg->av, &sqp_av, sizeof(struct mlx4_av));
if (qpt == MLX4_IB_QPT_PROXY_GSI)
dseg->dqpn = cpu_to_be32(dev->dev->caps.qp1_tunnel[port - 1]);
else
@@ -2817,10 +2818,10 @@ static void build_tunnel_header(struct ib_ud_wr *wr, void *wqe, unsigned *mlx_se
spc = MLX4_INLINE_ALIGN -
((unsigned long) (inl + 1) & (MLX4_INLINE_ALIGN - 1));
- if (sizeof (hdr) <= spc) {
- memcpy(inl + 1, &hdr, sizeof (hdr));
+ if (sizeof(hdr) <= spc) {
+ memcpy(inl + 1, &hdr, sizeof(hdr));
wmb();
- inl->byte_count = cpu_to_be32(1 << 31 | sizeof (hdr));
+ inl->byte_count = cpu_to_be32(1 << 31 | sizeof(hdr));
i = 1;
} else {
memcpy(inl + 1, &hdr, spc);
@@ -2828,14 +2829,14 @@ static void build_tunnel_header(struct ib_ud_wr *wr, void *wqe, unsigned *mlx_se
inl->byte_count = cpu_to_be32(1 << 31 | spc);
inl = (void *) (inl + 1) + spc;
- memcpy(inl + 1, (void *) &hdr + spc, sizeof (hdr) - spc);
+ memcpy(inl + 1, (void *) &hdr + spc, sizeof(hdr) - spc);
wmb();
- inl->byte_count = cpu_to_be32(1 << 31 | (sizeof (hdr) - spc));
+ inl->byte_count = cpu_to_be32(1 << 31 | (sizeof(hdr) - spc));
i = 2;
}
*mlx_seg_len =
- ALIGN(i * sizeof (struct mlx4_wqe_inline_seg) + sizeof (hdr), 16);
+ ALIGN(i * sizeof(struct mlx4_wqe_inline_seg) + sizeof(hdr), 16);
}
static void set_mlx_icrc_seg(void *dseg)
@@ -3022,27 +3023,23 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
case IB_WR_MASKED_ATOMIC_FETCH_AND_ADD:
set_raddr_seg(wqe, atomic_wr(wr)->remote_addr,
atomic_wr(wr)->rkey);
- wqe += sizeof (struct mlx4_wqe_raddr_seg);
-
+ wqe += sizeof(struct mlx4_wqe_raddr_seg);
set_atomic_seg(wqe, atomic_wr(wr));
- wqe += sizeof (struct mlx4_wqe_atomic_seg);
-
- size += (sizeof (struct mlx4_wqe_raddr_seg) +
- sizeof (struct mlx4_wqe_atomic_seg)) / 16;
-
+ wqe += sizeof(struct mlx4_wqe_atomic_seg);
+ size += (sizeof(struct mlx4_wqe_raddr_seg) +
+ sizeof(struct mlx4_wqe_atomic_seg))
+ / 16;
break;
case IB_WR_MASKED_ATOMIC_CMP_AND_SWP:
set_raddr_seg(wqe, atomic_wr(wr)->remote_addr,
atomic_wr(wr)->rkey);
- wqe += sizeof (struct mlx4_wqe_raddr_seg);
-
+ wqe += sizeof(struct mlx4_wqe_raddr_seg);
set_masked_atomic_seg(wqe, atomic_wr(wr));
- wqe += sizeof (struct mlx4_wqe_masked_atomic_seg);
-
- size += (sizeof (struct mlx4_wqe_raddr_seg) +
- sizeof (struct mlx4_wqe_masked_atomic_seg)) / 16;
-
+ wqe += sizeof(struct mlx4_wqe_masked_atomic_seg);
+ size += (sizeof(struct mlx4_wqe_raddr_seg) +
+ sizeof(struct mlx4_wqe_masked_atomic_seg))
+ / 16;
break;
case IB_WR_RDMA_READ:
@@ -3050,16 +3047,17 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
case IB_WR_RDMA_WRITE_WITH_IMM:
set_raddr_seg(wqe, rdma_wr(wr)->remote_addr,
rdma_wr(wr)->rkey);
- wqe += sizeof (struct mlx4_wqe_raddr_seg);
- size += sizeof (struct mlx4_wqe_raddr_seg) / 16;
+ wqe += sizeof(struct mlx4_wqe_raddr_seg);
+ size += sizeof(struct mlx4_wqe_raddr_seg) / 16;
break;
case IB_WR_LOCAL_INV:
ctrl->srcrb_flags |=
cpu_to_be32(MLX4_WQE_CTRL_STRONG_ORDER);
set_local_inv_seg(wqe, wr->ex.invalidate_rkey);
- wqe += sizeof (struct mlx4_wqe_local_inval_seg);
- size += sizeof (struct mlx4_wqe_local_inval_seg) / 16;
+ wqe += sizeof(struct mlx4_wqe_local_inval_seg);
+ size += sizeof(struct mlx4_wqe_local_inval_seg)
+ / 16;
break;
case IB_WR_REG_MR:
@@ -3092,13 +3090,13 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
set_datagram_seg(wqe, ud_wr(wr));
/* set the forced-loopback bit in the data seg av */
*(__be32 *) wqe |= cpu_to_be32(0x80000000);
- wqe += sizeof (struct mlx4_wqe_datagram_seg);
- size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
+ wqe += sizeof(struct mlx4_wqe_datagram_seg);
+ size += sizeof(struct mlx4_wqe_datagram_seg) / 16;
break;
case MLX4_IB_QPT_UD:
set_datagram_seg(wqe, ud_wr(wr));
- wqe += sizeof (struct mlx4_wqe_datagram_seg);
- size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
+ wqe += sizeof(struct mlx4_wqe_datagram_seg);
+ size += sizeof(struct mlx4_wqe_datagram_seg) / 16;
if (wr->opcode == IB_WR_LSO) {
err = build_lso_seg(wqe, ud_wr(wr), qp, &seglen,
@@ -3139,8 +3137,8 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
set_tunnel_datagram_seg(to_mdev(ibqp->device), wqe,
ud_wr(wr),
qp->mlx4_ib_qp_type);
- wqe += sizeof (struct mlx4_wqe_datagram_seg);
- size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
+ wqe += sizeof(struct mlx4_wqe_datagram_seg);
+ size += sizeof(struct mlx4_wqe_datagram_seg) / 16;
build_tunnel_header(ud_wr(wr), wqe, &seglen);
wqe += seglen;
size += seglen / 16;
@@ -3171,7 +3169,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
dseg = wqe;
dseg += wr->num_sge - 1;
- size += wr->num_sge * (sizeof (struct mlx4_wqe_data_seg) / 16);
+ size += wr->num_sge * (sizeof(struct mlx4_wqe_data_seg) / 16);
/* Add one more inline data segment for ICRC for MLX sends */
if (unlikely(qp->mlx4_ib_qp_type == MLX4_IB_QPT_SMI ||
@@ -3179,7 +3177,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
qp->mlx4_ib_qp_type &
(MLX4_IB_QPT_PROXY_SMI_OWNER | MLX4_IB_QPT_TUN_SMI_OWNER))) {
set_mlx_icrc_seg(dseg + 1);
- size += sizeof (struct mlx4_wqe_data_seg) / 16;
+ size += sizeof(struct mlx4_wqe_data_seg) / 16;
}
for (i = wr->num_sge - 1; i >= 0; --i, --dseg)
@@ -3304,10 +3302,10 @@ int mlx4_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_GSI)) {
ib_dma_sync_single_for_device(ibqp->device,
qp->sqp_proxy_rcv[ind].map,
- sizeof (struct mlx4_ib_proxy_sqp_hdr),
+ sizeof(struct mlx4_ib_proxy_sqp_hdr),
DMA_FROM_DEVICE);
scat->byte_count =
- cpu_to_be32(sizeof (struct mlx4_ib_proxy_sqp_hdr));
+ cpu_to_be32(sizeof(struct mlx4_ib_proxy_sqp_hdr));
/* use dma lkey from upper layer entry */
scat->lkey = cpu_to_be32(wr->sg_list->lkey);
scat->addr = cpu_to_be64(qp->sqp_proxy_rcv[ind].map);
--
2.11.1
[toc] | [prev] | [next] | [standalone]
Page 2 of 3 — ← Prev page 1 [2] 3 Next page →
Back to top | Article view | linux.kernel
csiph-web