linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] net: ethernet: reduce calls to memset(,0)
@ 2019-02-27  6:04 Robert Eshleman
  2019-02-27  6:09 ` [PATCH 2/8] net/mlxsw: use pci_zalloc_consistent instead of pci_alloc_consistent Robert Eshleman
                   ` (8 more replies)
  0 siblings, 9 replies; 16+ messages in thread
From: Robert Eshleman @ 2019-02-27  6:04 UTC (permalink / raw)
  To: bobbyeshleman; +Cc: David S. Miller, netdev, linux-kernel

This patch series removes calls to memset(,0) that are
redundant when used in conjunction with a zalloc call or
by simple zero-assignment of structs.

Robert Eshleman (8):
  net/mlx4: use kzalloc instead of kmalloc
  net/mlxsw: use pci_zalloc_consistent instead of pci_alloc_consistent
  tlan: use pci_zalloc instead of pci_alloc
  qed: remove unnecessary memsets
  at12: use pci_zalloc instead of pci_alloc
  netxen: remove unnecessary memset(,0) calls
  net: seeq: replace kmalloc / memset(,0) with kzalloc
  net: ethernet: ixp4xx_eth: remove memset(,0) with zalloc

 drivers/net/ethernet/atheros/atlx/atl2.c      |  5 +-
 drivers/net/ethernet/mellanox/mlx4/cmd.c      |  1 -
 drivers/net/ethernet/mellanox/mlx4/en_rx.c    |  3 +-
 drivers/net/ethernet/mellanox/mlxsw/pci.c     |  7 +-
 .../ethernet/qlogic/netxen/netxen_nic_ctx.c   | 36 ++++------
 drivers/net/ethernet/qlogic/qed/qed_cxt.c     |  4 +-
 drivers/net/ethernet/qlogic/qed/qed_hw.c      |  3 +-
 drivers/net/ethernet/qlogic/qed/qed_mcp.c     | 70 ++++++-------------
 drivers/net/ethernet/seeq/ether3.c            |  3 +-
 drivers/net/ethernet/ti/tlan.c                |  9 ++-
 drivers/net/ethernet/xscale/ixp4xx_eth.c      |  7 +-
 11 files changed, 52 insertions(+), 96 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 2/8] net/mlxsw: use pci_zalloc_consistent instead of pci_alloc_consistent
  2019-02-27  6:04 [PATCH 0/8] net: ethernet: reduce calls to memset(,0) Robert Eshleman
@ 2019-02-27  6:09 ` Robert Eshleman
  2019-02-27  6:09 ` [PATCH 3/8] tlan: use pci_zalloc instead of pci_alloc Robert Eshleman
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Robert Eshleman @ 2019-02-27  6:09 UTC (permalink / raw)
  To: bobbyeshleman
  Cc: Tariq Toukan, David S. Miller, Jiri Pirko, Ido Schimmel, netdev,
	linux-rdma, linux-kernel

This patch replaces a call to pci_alloc_consistent and then
memset(0,) with a single call to pci_zalloc_consistent.

Signed-off-by: Robert Eshleman <bobbyeshleman@gmail.com>
---
 drivers/net/ethernet/mellanox/mlxsw/pci.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c
index a2321fe8d6a0..388f349573f3 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/pci.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c
@@ -830,12 +830,11 @@ static int mlxsw_pci_queue_init(struct mlxsw_pci *mlxsw_pci, char *mbox,
 		tasklet_init(&q->tasklet, q_ops->tasklet, (unsigned long) q);
 
 	mem_item->size = MLXSW_PCI_AQ_SIZE;
-	mem_item->buf = pci_alloc_consistent(mlxsw_pci->pdev,
-					     mem_item->size,
-					     &mem_item->mapaddr);
+	mem_item->buf = pci_zalloc_consistent(mlxsw_pci->pdev,
+					      mem_item->size,
+					      &mem_item->mapaddr);
 	if (!mem_item->buf)
 		return -ENOMEM;
-	memset(mem_item->buf, 0, mem_item->size);
 
 	q->elem_info = kcalloc(q->count, sizeof(*q->elem_info), GFP_KERNEL);
 	if (!q->elem_info) {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/8] tlan: use pci_zalloc instead of pci_alloc
  2019-02-27  6:04 [PATCH 0/8] net: ethernet: reduce calls to memset(,0) Robert Eshleman
  2019-02-27  6:09 ` [PATCH 2/8] net/mlxsw: use pci_zalloc_consistent instead of pci_alloc_consistent Robert Eshleman
@ 2019-02-27  6:09 ` Robert Eshleman
  2019-02-27  6:22   ` Joe Perches
  2019-02-27  6:09 ` [PATCH 4/8] qed: remove unnecessary memsets Robert Eshleman
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 16+ messages in thread
From: Robert Eshleman @ 2019-02-27  6:09 UTC (permalink / raw)
  To: bobbyeshleman
  Cc: Tariq Toukan, David S. Miller, Samuel Chessman, netdev,
	linux-rdma, linux-kernel

This patch replaces a pci_alloc_consistent and memset(,0) call
with a single call to pci_zalloc_consistent.

Signed-off-by: Robert Eshleman <bobbyeshleman@gmail.com>
---
 drivers/net/ethernet/ti/tlan.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/ti/tlan.c b/drivers/net/ethernet/ti/tlan.c
index b4ab1a5f6cd0..e1f7e71c3b21 100644
--- a/drivers/net/ethernet/ti/tlan.c
+++ b/drivers/net/ethernet/ti/tlan.c
@@ -845,17 +845,16 @@ static int tlan_init(struct net_device *dev)
 
 	dma_size = (TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS)
 		* (sizeof(struct tlan_list));
-	priv->dma_storage = pci_alloc_consistent(priv->pci_dev,
-						 dma_size,
-						 &priv->dma_storage_dma);
+	priv->dma_storage = pci_zalloc_consistent(priv->pci_dev,
+						  dma_size,
+						  &priv->dma_storage_dma);
 	priv->dma_size = dma_size;
 
-	if (priv->dma_storage == NULL) {
+	if (!priv->dma_storage) {
 		pr_err("Could not allocate lists and buffers for %s\n",
 		       dev->name);
 		return -ENOMEM;
 	}
-	memset(priv->dma_storage, 0, dma_size);
 	priv->rx_list = (struct tlan_list *)
 		ALIGN((unsigned long)priv->dma_storage, 8);
 	priv->rx_list_dma = ALIGN(priv->dma_storage_dma, 8);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 4/8] qed: remove unnecessary memsets
  2019-02-27  6:04 [PATCH 0/8] net: ethernet: reduce calls to memset(,0) Robert Eshleman
  2019-02-27  6:09 ` [PATCH 2/8] net/mlxsw: use pci_zalloc_consistent instead of pci_alloc_consistent Robert Eshleman
  2019-02-27  6:09 ` [PATCH 3/8] tlan: use pci_zalloc instead of pci_alloc Robert Eshleman
@ 2019-02-27  6:09 ` Robert Eshleman
  2019-02-27 12:39   ` Michal Kalderon
  2019-02-27  6:09 ` [PATCH 5/8] at12: use pci_zalloc instead of pci_alloc Robert Eshleman
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 16+ messages in thread
From: Robert Eshleman @ 2019-02-27  6:09 UTC (permalink / raw)
  To: bobbyeshleman
  Cc: Tariq Toukan, David S. Miller, Ariel Elior, GR-everest-linux-l2,
	netdev, linux-rdma, linux-kernel

This patch replaces unnecessary memset(,0) calls with
simply assigning structs to zero.

Signed-off-by: Robert Eshleman <bobbyeshleman@gmail.com>
---
 drivers/net/ethernet/qlogic/qed/qed_cxt.c |  4 +-
 drivers/net/ethernet/qlogic/qed/qed_hw.c  |  3 +-
 drivers/net/ethernet/qlogic/qed/qed_mcp.c | 70 ++++++++---------------
 3 files changed, 25 insertions(+), 52 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_cxt.c b/drivers/net/ethernet/qlogic/qed/qed_cxt.c
index c2ad405b2f50..0452ef2fdf1d 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_cxt.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_cxt.c
@@ -902,12 +902,10 @@ static int qed_cxt_src_t2_alloc(struct qed_hwfn *p_hwfn)
 	struct qed_cxt_mngr *p_mngr = p_hwfn->p_cxt_mngr;
 	u32 conn_num, total_size, ent_per_page, psz, i;
 	struct qed_ilt_client_cfg *p_src;
-	struct qed_src_iids src_iids;
+	struct qed_src_iids src_iids = {0};
 	struct qed_dma_mem *p_t2;
 	int rc;
 
-	memset(&src_iids, 0, sizeof(src_iids));
-
 	/* if the SRC ILT client is inactive - there are no connection
 	 * requiring the searcer, leave.
 	 */
diff --git a/drivers/net/ethernet/qlogic/qed/qed_hw.c b/drivers/net/ethernet/qlogic/qed/qed_hw.c
index 70504dcf4087..b8ca3a31409b 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_hw.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_hw.c
@@ -831,7 +831,7 @@ int qed_dmae_sanity(struct qed_hwfn *p_hwfn,
 		    struct qed_ptt *p_ptt, const char *phase)
 {
 	u32 size = PAGE_SIZE / 2, val;
-	struct qed_dmae_params params;
+	struct qed_dmae_params params = {0};
 	int rc = 0;
 	dma_addr_t p_phys;
 	void *p_virt;
@@ -864,7 +864,6 @@ int qed_dmae_sanity(struct qed_hwfn *p_hwfn,
 		   (u64)p_phys,
 		   p_virt, (u64)(p_phys + size), (u8 *)p_virt + size, size);
 
-	memset(&params, 0, sizeof(params));
 	rc = qed_dmae_host2host(p_hwfn, p_ptt, p_phys, p_phys + size,
 				size / 4 /* size_in_dwords */, &params);
 	if (rc) {
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
index e7f18e34ff0d..e1b72fc819a9 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
@@ -642,10 +642,9 @@ int qed_mcp_cmd(struct qed_hwfn *p_hwfn,
 		u32 *o_mcp_resp,
 		u32 *o_mcp_param)
 {
-	struct qed_mcp_mb_params mb_params;
+	struct qed_mcp_mb_params mb_params = {0};
 	int rc;
 
-	memset(&mb_params, 0, sizeof(mb_params));
 	mb_params.cmd = cmd;
 	mb_params.param = param;
 
@@ -667,10 +666,9 @@ qed_mcp_nvm_wr_cmd(struct qed_hwfn *p_hwfn,
 		   u32 *o_mcp_resp,
 		   u32 *o_mcp_param, u32 i_txn_size, u32 *i_buf)
 {
-	struct qed_mcp_mb_params mb_params;
+	struct qed_mcp_mb_params mb_params = {0};
 	int rc;
 
-	memset(&mb_params, 0, sizeof(mb_params));
 	mb_params.cmd = cmd;
 	mb_params.param = param;
 	mb_params.p_data_src = i_buf;
@@ -695,11 +693,10 @@ int qed_mcp_nvm_rd_cmd(struct qed_hwfn *p_hwfn,
 		       u32 *o_mcp_resp,
 		       u32 *o_mcp_param, u32 *o_txn_size, u32 *o_buf)
 {
-	struct qed_mcp_mb_params mb_params;
+	struct qed_mcp_mb_params mb_params = {0};
 	u8 raw_data[MCP_DRV_NVM_BUF_LEN];
 	int rc;
 
-	memset(&mb_params, 0, sizeof(mb_params));
 	mb_params.cmd = cmd;
 	mb_params.param = param;
 	mb_params.p_data_dst = raw_data;
@@ -821,13 +818,12 @@ __qed_mcp_load_req(struct qed_hwfn *p_hwfn,
 		   struct qed_load_req_in_params *p_in_params,
 		   struct qed_load_req_out_params *p_out_params)
 {
-	struct qed_mcp_mb_params mb_params;
-	struct load_req_stc load_req;
+	struct qed_mcp_mb_params mb_params = {0};
+	struct load_req_stc load_req = {0};
 	struct load_rsp_stc load_rsp;
 	u32 hsi_ver;
 	int rc;
 
-	memset(&load_req, 0, sizeof(load_req));
 	load_req.drv_ver_0 = p_in_params->drv_ver_0;
 	load_req.drv_ver_1 = p_in_params->drv_ver_1;
 	load_req.fw_ver = p_in_params->fw_ver;
@@ -843,7 +839,6 @@ __qed_mcp_load_req(struct qed_hwfn *p_hwfn,
 		  DRV_ID_MCP_HSI_VER_CURRENT :
 		  (p_in_params->hsi_ver << DRV_ID_MCP_HSI_VER_SHIFT);
 
-	memset(&mb_params, 0, sizeof(mb_params));
 	mb_params.cmd = DRV_MSG_CODE_LOAD_REQ;
 	mb_params.param = PDA_COMP | hsi_ver | p_hwfn->cdev->drv_type;
 	mb_params.p_data_src = &load_req;
@@ -959,12 +954,11 @@ int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
 		     struct qed_ptt *p_ptt,
 		     struct qed_load_req_params *p_params)
 {
-	struct qed_load_req_out_params out_params;
-	struct qed_load_req_in_params in_params;
+	struct qed_load_req_out_params out_params = {0};
+	struct qed_load_req_in_params in_params = {0};
 	u8 mfw_drv_role, mfw_force_cmd;
 	int rc;
 
-	memset(&in_params, 0, sizeof(in_params));
 	in_params.hsi_ver = QED_LOAD_REQ_HSI_VER_DEFAULT;
 	in_params.drv_ver_0 = QED_VERSION;
 	in_params.drv_ver_1 = qed_get_config_bitmap();
@@ -981,7 +975,6 @@ int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
 	in_params.force_cmd = mfw_force_cmd;
 	in_params.avoid_eng_reset = p_params->avoid_eng_reset;
 
-	memset(&out_params, 0, sizeof(out_params));
 	rc = __qed_mcp_load_req(p_hwfn, p_ptt, &in_params, &out_params);
 	if (rc)
 		return rc;
@@ -1072,7 +1065,7 @@ int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
 
 int qed_mcp_unload_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
 {
-	struct qed_mcp_mb_params mb_params;
+	struct qed_mcp_mb_params mb_params = {0};
 	u32 wol_param;
 
 	switch (p_hwfn->cdev->wol_config) {
@@ -1091,7 +1084,6 @@ int qed_mcp_unload_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
 		wol_param = DRV_MB_PARAM_UNLOAD_WOL_MCP;
 	}
 
-	memset(&mb_params, 0, sizeof(mb_params));
 	mb_params.cmd = DRV_MSG_CODE_UNLOAD_REQ;
 	mb_params.param = wol_param;
 	mb_params.flags = QED_MB_FLAG_CAN_SLEEP | QED_MB_FLAG_AVOID_BLOCK;
@@ -1101,17 +1093,15 @@ int qed_mcp_unload_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
 
 int qed_mcp_unload_done(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
 {
-	struct qed_mcp_mb_params mb_params;
-	struct mcp_mac wol_mac;
+	struct qed_mcp_mb_params mb_params = {0};
+	struct mcp_mac wol_mac = {0};
 
-	memset(&mb_params, 0, sizeof(mb_params));
 	mb_params.cmd = DRV_MSG_CODE_UNLOAD_DONE;
 
 	/* Set the primary MAC if WoL is enabled */
 	if (p_hwfn->cdev->wol_config == QED_OV_WOL_ENABLED) {
 		u8 *p_mac = p_hwfn->cdev->wol_mac;
 
-		memset(&wol_mac, 0, sizeof(wol_mac));
 		wol_mac.mac_upper = p_mac[0] << 8 | p_mac[1];
 		wol_mac.mac_lower = p_mac[2] << 24 | p_mac[3] << 16 |
 				    p_mac[4] << 8 | p_mac[5];
@@ -1167,7 +1157,7 @@ int qed_mcp_ack_vf_flr(struct qed_hwfn *p_hwfn,
 	u32 mfw_func_offsize = qed_rd(p_hwfn, p_ptt, addr);
 	u32 func_addr = SECTION_ADDR(mfw_func_offsize,
 				     MCP_PF_ID(p_hwfn));
-	struct qed_mcp_mb_params mb_params;
+	struct qed_mcp_mb_params mb_params = {0};
 	int rc;
 	int i;
 
@@ -1176,7 +1166,6 @@ int qed_mcp_ack_vf_flr(struct qed_hwfn *p_hwfn,
 			   "Acking VFs [%08x,...,%08x] - %08x\n",
 			   i * 32, (i + 1) * 32 - 1, vfs_to_ack[i]);
 
-	memset(&mb_params, 0, sizeof(mb_params));
 	mb_params.cmd = DRV_MSG_CODE_VF_DISABLED_DONE;
 	mb_params.p_data_src = vfs_to_ack;
 	mb_params.data_src_size = VF_MAX_STATIC / 8;
@@ -1455,13 +1444,12 @@ static void qed_mcp_handle_link_change(struct qed_hwfn *p_hwfn,
 int qed_mcp_set_link(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, bool b_up)
 {
 	struct qed_mcp_link_params *params = &p_hwfn->mcp_info->link_input;
-	struct qed_mcp_mb_params mb_params;
-	struct eth_phy_cfg phy_cfg;
+	struct qed_mcp_mb_params mb_params = {0};
+	struct eth_phy_cfg phy_cfg = {0};
 	int rc = 0;
 	u32 cmd;
 
 	/* Set the shmem configuration according to params */
-	memset(&phy_cfg, 0, sizeof(phy_cfg));
 	cmd = b_up ? DRV_MSG_CODE_INIT_PHY : DRV_MSG_CODE_LINK_RESET;
 	if (!params->speed.autoneg)
 		phy_cfg.speed = params->speed.forced_speed;
@@ -1505,7 +1493,6 @@ int qed_mcp_set_link(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, bool b_up)
 			   "Resetting link\n");
 	}
 
-	memset(&mb_params, 0, sizeof(mb_params));
 	mb_params.cmd = cmd;
 	mb_params.p_data_src = &phy_cfg;
 	mb_params.data_src_size = sizeof(phy_cfg);
@@ -1534,7 +1521,7 @@ static void qed_mcp_send_protocol_stats(struct qed_hwfn *p_hwfn,
 {
 	enum qed_mcp_protocol_type stats_type;
 	union qed_mcp_protocol_stats stats;
-	struct qed_mcp_mb_params mb_params;
+	struct qed_mcp_mb_params mb_params = {0};
 	u32 hsi_param;
 
 	switch (type) {
@@ -1561,7 +1548,6 @@ static void qed_mcp_send_protocol_stats(struct qed_hwfn *p_hwfn,
 
 	qed_get_protocol_stats(p_hwfn->cdev, stats_type, &stats);
 
-	memset(&mb_params, 0, sizeof(mb_params));
 	mb_params.cmd = DRV_MSG_CODE_GET_STATS;
 	mb_params.param = hsi_param;
 	mb_params.p_data_src = &stats;
@@ -2370,20 +2356,18 @@ qed_mcp_send_drv_version(struct qed_hwfn *p_hwfn,
 			 struct qed_ptt *p_ptt,
 			 struct qed_mcp_drv_version *p_ver)
 {
-	struct qed_mcp_mb_params mb_params;
-	struct drv_version_stc drv_version;
+	struct qed_mcp_mb_params mb_params = {0};
+	struct drv_version_stc drv_version = {0};
 	__be32 val;
 	u32 i;
 	int rc;
 
-	memset(&drv_version, 0, sizeof(drv_version));
 	drv_version.version = p_ver->version;
 	for (i = 0; i < (MCP_DRV_VER_STR_SIZE - 4) / sizeof(u32); i++) {
 		val = cpu_to_be32(*((u32 *)&p_ver->name[i * sizeof(u32)]));
 		*(__be32 *)&drv_version.name[i * sizeof(u32)] = val;
 	}
 
-	memset(&mb_params, 0, sizeof(mb_params));
 	mb_params.cmd = DRV_MSG_CODE_SET_VERSION;
 	mb_params.p_data_src = &drv_version;
 	mb_params.data_src_size = sizeof(drv_version);
@@ -2536,11 +2520,10 @@ int qed_mcp_ov_update_mtu(struct qed_hwfn *p_hwfn,
 int qed_mcp_ov_update_mac(struct qed_hwfn *p_hwfn,
 			  struct qed_ptt *p_ptt, u8 *mac)
 {
-	struct qed_mcp_mb_params mb_params;
+	struct qed_mcp_mb_params mb_params = {0};
 	u32 mfw_mac[2];
 	int rc;
 
-	memset(&mb_params, 0, sizeof(mb_params));
 	mb_params.cmd = DRV_MSG_CODE_SET_VMAC;
 	mb_params.param = DRV_MSG_CODE_VMAC_TYPE_MAC <<
 			  DRV_MSG_CODE_VMAC_TYPE_SHIFT;
@@ -3197,12 +3180,10 @@ qed_mcp_resc_allocation_msg(struct qed_hwfn *p_hwfn,
 			    struct qed_resc_alloc_in_params *p_in_params,
 			    struct qed_resc_alloc_out_params *p_out_params)
 {
-	struct qed_mcp_mb_params mb_params;
-	struct resource_info mfw_resc_info;
+	struct qed_mcp_mb_params mb_params = {0};
+	struct resource_info mfw_resc_info = {0};
 	int rc;
 
-	memset(&mfw_resc_info, 0, sizeof(mfw_resc_info));
-
 	mfw_resc_info.res_id = qed_mcp_get_mfw_res_id(p_in_params->res_id);
 	if (mfw_resc_info.res_id == RESOURCE_NUM_INVALID) {
 		DP_ERR(p_hwfn,
@@ -3224,7 +3205,6 @@ qed_mcp_resc_allocation_msg(struct qed_hwfn *p_hwfn,
 		return -EINVAL;
 	}
 
-	memset(&mb_params, 0, sizeof(mb_params));
 	mb_params.cmd = p_in_params->cmd;
 	mb_params.param = QED_RESC_ALLOC_VERSION;
 	mb_params.p_data_src = &mfw_resc_info;
@@ -3277,15 +3257,13 @@ qed_mcp_set_resc_max_val(struct qed_hwfn *p_hwfn,
 			 enum qed_resources res_id,
 			 u32 resc_max_val, u32 *p_mcp_resp)
 {
-	struct qed_resc_alloc_out_params out_params;
-	struct qed_resc_alloc_in_params in_params;
+	struct qed_resc_alloc_out_params out_params = {0};
+	struct qed_resc_alloc_in_params in_params = {0};
 	int rc;
 
-	memset(&in_params, 0, sizeof(in_params));
 	in_params.cmd = DRV_MSG_SET_RESOURCE_VALUE_MSG;
 	in_params.res_id = res_id;
 	in_params.resc_max_val = resc_max_val;
-	memset(&out_params, 0, sizeof(out_params));
 	rc = qed_mcp_resc_allocation_msg(p_hwfn, p_ptt, &in_params,
 					 &out_params);
 	if (rc)
@@ -3302,14 +3280,12 @@ qed_mcp_get_resc_info(struct qed_hwfn *p_hwfn,
 		      enum qed_resources res_id,
 		      u32 *p_mcp_resp, u32 *p_resc_num, u32 *p_resc_start)
 {
-	struct qed_resc_alloc_out_params out_params;
-	struct qed_resc_alloc_in_params in_params;
+	struct qed_resc_alloc_out_params out_params = {0};
+	struct qed_resc_alloc_in_params in_params = {0};
 	int rc;
 
-	memset(&in_params, 0, sizeof(in_params));
 	in_params.cmd = DRV_MSG_GET_RESOURCE_ALLOC_MSG;
 	in_params.res_id = res_id;
-	memset(&out_params, 0, sizeof(out_params));
 	rc = qed_mcp_resc_allocation_msg(p_hwfn, p_ptt, &in_params,
 					 &out_params);
 	if (rc)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 5/8] at12: use pci_zalloc instead of pci_alloc
  2019-02-27  6:04 [PATCH 0/8] net: ethernet: reduce calls to memset(,0) Robert Eshleman
                   ` (2 preceding siblings ...)
  2019-02-27  6:09 ` [PATCH 4/8] qed: remove unnecessary memsets Robert Eshleman
@ 2019-02-27  6:09 ` Robert Eshleman
  2019-02-28 14:00   ` Christoph Hellwig
  2019-02-27  6:09 ` [PATCH 6/8] netxen: remove unnecessary memset(,0) calls Robert Eshleman
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 16+ messages in thread
From: Robert Eshleman @ 2019-02-27  6:09 UTC (permalink / raw)
  To: bobbyeshleman
  Cc: Jay Cliburn, Chris Snook, David S. Miller, Tariq Toukan, netdev,
	linux-kernel, linux-rdma

This patch replaces a pci_alloc and memset(,0) call
with a single call to pci_zalloc.

Signed-off-by: Robert Eshleman <bobbyeshleman@gmail.com>
---
 drivers/net/ethernet/atheros/atlx/atl2.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c b/drivers/net/ethernet/atheros/atlx/atl2.c
index bb41becb6609..a145c2d1b1d2 100644
--- a/drivers/net/ethernet/atheros/atlx/atl2.c
+++ b/drivers/net/ethernet/atheros/atlx/atl2.c
@@ -300,11 +300,10 @@ static s32 atl2_setup_ring_resources(struct atl2_adapter *adapter)
 		adapter->txs_ring_size * 4 + 7 +	/* dword align */
 		adapter->rxd_ring_size * 1536 + 127;	/* 128bytes align */
 
-	adapter->ring_vir_addr = pci_alloc_consistent(pdev, size,
-		&adapter->ring_dma);
+	adapter->ring_vir_addr = pci_zalloc_consistent(pdev, size,
+						       &adapter->ring_dma);
 	if (!adapter->ring_vir_addr)
 		return -ENOMEM;
-	memset(adapter->ring_vir_addr, 0, adapter->ring_size);
 
 	/* Init TXD Ring */
 	adapter->txd_dma = adapter->ring_dma ;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 6/8] netxen: remove unnecessary memset(,0) calls
  2019-02-27  6:04 [PATCH 0/8] net: ethernet: reduce calls to memset(,0) Robert Eshleman
                   ` (3 preceding siblings ...)
  2019-02-27  6:09 ` [PATCH 5/8] at12: use pci_zalloc instead of pci_alloc Robert Eshleman
@ 2019-02-27  6:09 ` Robert Eshleman
  2019-02-27  6:09 ` [PATCH 7/8] net: seeq: replace kmalloc / memset(,0) with kzalloc Robert Eshleman
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Robert Eshleman @ 2019-02-27  6:09 UTC (permalink / raw)
  To: bobbyeshleman
  Cc: Tariq Toukan, David S. Miller, Manish Chopra, Rahul Verma,
	GR-Linux-NIC-Dev, netdev, linux-rdma, linux-kernel

This patch reduces calls to memset(,0) by replacing memset(,0)
calls that only zero-out newly declared structs with simply
assigning those structs to zero structs.

It also removes a pci_alloc_consistent call followed by a memset(,0)
call by simply using pci_zalloc_consistent.

Signed-off-by: Robert Eshleman <bobbyeshleman@gmail.com>
---
 .../ethernet/qlogic/netxen/netxen_nic_ctx.c   | 36 +++++++------------
 1 file changed, 13 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
index 7503aa222392..f2010c032361 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
@@ -99,8 +99,7 @@ netxen_issue_cmd(struct netxen_adapter *adapter, struct netxen_cmd_args *cmd)
 static int
 netxen_get_minidump_template_size(struct netxen_adapter *adapter)
 {
-	struct netxen_cmd_args cmd;
-	memset(&cmd, 0, sizeof(cmd));
+	struct netxen_cmd_args cmd = {0};
 	cmd.req.cmd = NX_CDRP_CMD_TEMP_SIZE;
 	memset(&cmd.rsp, 1, sizeof(struct _cdrp_cmd));
 	netxen_issue_cmd(adapter, &cmd);
@@ -120,7 +119,7 @@ netxen_get_minidump_template(struct netxen_adapter *adapter)
 	dma_addr_t md_template_addr;
 	void *addr;
 	u32 size;
-	struct netxen_cmd_args cmd;
+	struct netxen_cmd_args cmd = {0};
 	size = adapter->mdump.md_template_size;
 
 	if (size == 0) {
@@ -135,7 +134,6 @@ netxen_get_minidump_template(struct netxen_adapter *adapter)
 		return -ENOMEM;
 	}
 
-	memset(&cmd, 0, sizeof(cmd));
 	memset(&cmd.rsp, 1, sizeof(struct _cdrp_cmd));
 	cmd.req.cmd = NX_CDRP_CMD_GET_TEMP_HDR;
 	cmd.req.arg1 = LSD(md_template_addr);
@@ -233,9 +231,8 @@ nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, int mtu)
 {
 	u32 rcode = NX_RCODE_SUCCESS;
 	struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
-	struct netxen_cmd_args cmd;
+	struct netxen_cmd_args cmd = {0};
 
-	memset(&cmd, 0, sizeof(cmd));
 	cmd.req.cmd = NX_CDRP_CMD_SET_MTU;
 	cmd.req.arg1 = recv_ctx->context_id;
 	cmd.req.arg2 = mtu;
@@ -254,9 +251,8 @@ int
 nx_fw_cmd_set_gbe_port(struct netxen_adapter *adapter,
 			u32 speed, u32 duplex, u32 autoneg)
 {
-	struct netxen_cmd_args cmd;
+	struct netxen_cmd_args cmd = {0};
 
-	memset(&cmd, 0, sizeof(cmd));
 	cmd.req.cmd = NX_CDRP_CMD_CONFIG_GBE_PORT;
 	cmd.req.arg1 = speed;
 	cmd.req.arg2 = duplex;
@@ -276,7 +272,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
 	nx_cardrsp_sds_ring_t *prsp_sds;
 	struct nx_host_rds_ring *rds_ring;
 	struct nx_host_sds_ring *sds_ring;
-	struct netxen_cmd_args cmd;
+	struct netxen_cmd_args cmd = {0};
 
 	dma_addr_t hostrq_phys_addr, cardrsp_phys_addr;
 	u64 phys_addr;
@@ -359,7 +355,6 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
 	}
 
 	phys_addr = hostrq_phys_addr;
-	memset(&cmd, 0, sizeof(cmd));
 	cmd.req.arg1 = (u32)(phys_addr >> 32);
 	cmd.req.arg2 = (u32)(phys_addr & 0xffffffff);
 	cmd.req.arg3 = rq_size;
@@ -413,9 +408,8 @@ static void
 nx_fw_cmd_destroy_rx_ctx(struct netxen_adapter *adapter)
 {
 	struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
-	struct netxen_cmd_args cmd;
+	struct netxen_cmd_args cmd = {0};
 
-	memset(&cmd, 0, sizeof(cmd));
 	cmd.req.arg1 = recv_ctx->context_id;
 	cmd.req.arg2 = NX_DESTROY_CTX_RESET;
 	cmd.req.arg3 = 0;
@@ -520,9 +514,8 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter)
 static void
 nx_fw_cmd_destroy_tx_ctx(struct netxen_adapter *adapter)
 {
-	struct netxen_cmd_args cmd;
+	struct netxen_cmd_args cmd = {0};
 
-	memset(&cmd, 0, sizeof(cmd));
 	cmd.req.arg1 = adapter->tx_context_id;
 	cmd.req.arg2 = NX_DESTROY_CTX_RESET;
 	cmd.req.arg3 = 0;
@@ -538,9 +531,8 @@ int
 nx_fw_cmd_query_phy(struct netxen_adapter *adapter, u32 reg, u32 *val)
 {
 	u32 rcode;
-	struct netxen_cmd_args cmd;
+	struct netxen_cmd_args cmd = {0};
 
-	memset(&cmd, 0, sizeof(cmd));
 	cmd.req.arg1 = reg;
 	cmd.req.arg2 = 0;
 	cmd.req.arg3 = 0;
@@ -561,9 +553,8 @@ int
 nx_fw_cmd_set_phy(struct netxen_adapter *adapter, u32 reg, u32 val)
 {
 	u32 rcode;
-	struct netxen_cmd_args cmd;
+	struct netxen_cmd_args cmd = {0};
 
-	memset(&cmd, 0, sizeof(cmd));
 	cmd.req.arg1 = reg;
 	cmd.req.arg2 = val;
 	cmd.req.arg3 = 0;
@@ -763,15 +754,14 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter)
 	recv_ctx = &adapter->recv_ctx;
 	tx_ring = adapter->tx_ring;
 
-	addr = pci_alloc_consistent(pdev,
-			sizeof(struct netxen_ring_ctx) + sizeof(uint32_t),
-			&recv_ctx->phys_addr);
-	if (addr == NULL) {
+	addr = pci_zalloc_consistent(pdev,
+				     sizeof(struct netxen_ring_ctx) + sizeof(uint32_t),
+				     &recv_ctx->phys_addr);
+	if (!addr) {
 		dev_err(&pdev->dev, "failed to allocate hw context\n");
 		return -ENOMEM;
 	}
 
-	memset(addr, 0, sizeof(struct netxen_ring_ctx));
 	recv_ctx->hwctx = addr;
 	recv_ctx->hwctx->ctx_id = cpu_to_le32(port);
 	recv_ctx->hwctx->cmd_consumer_offset =
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 7/8] net: seeq: replace kmalloc / memset(,0) with kzalloc
  2019-02-27  6:04 [PATCH 0/8] net: ethernet: reduce calls to memset(,0) Robert Eshleman
                   ` (4 preceding siblings ...)
  2019-02-27  6:09 ` [PATCH 6/8] netxen: remove unnecessary memset(,0) calls Robert Eshleman
@ 2019-02-27  6:09 ` Robert Eshleman
  2019-02-28  0:48   ` Robert Eshleman
  2019-02-27  6:09 ` [PATCH 8/8] net: ethernet: ixp4xx_eth: remove memset(,0) with zalloc Robert Eshleman
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 16+ messages in thread
From: Robert Eshleman @ 2019-02-27  6:09 UTC (permalink / raw)
  To: bobbyeshleman
  Cc: Tariq Toukan, David S. Miller, Russell King, netdev, linux-rdma,
	linux-kernel, linux-arm-kernel

This patch reduces a call to memset(,0) by replacing
a kmalloc call with a kzalloc call.

Signed-off-by: Robert Eshleman <bobbyeshleman@gmail.com>
---
 drivers/net/ethernet/seeq/ether3.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/seeq/ether3.c b/drivers/net/ethernet/seeq/ether3.c
index d1bb73bf9914..7456cf08a48f 100644
--- a/drivers/net/ethernet/seeq/ether3.c
+++ b/drivers/net/ethernet/seeq/ether3.c
@@ -223,7 +223,7 @@ ether3_addr(char *addr, struct expansion_card *ec)
 static int
 ether3_ramtest(struct net_device *dev, unsigned char byte)
 {
-	unsigned char *buffer = kmalloc(RX_END, GFP_KERNEL);
+	unsigned char *buffer = kzalloc(RX_END, GFP_KERNEL);
 	int i,ret = 0;
 	int max_errors = 4;
 	int bad = -1;
@@ -231,7 +231,6 @@ ether3_ramtest(struct net_device *dev, unsigned char byte)
 	if (!buffer)
 		return 1;
 
-	memset(buffer, byte, RX_END);
 	ether3_setbuffer(dev, buffer_write, 0);
 	ether3_writebuffer(dev, buffer, TX_END);
 	ether3_setbuffer(dev, buffer_write, RX_START);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 8/8] net: ethernet: ixp4xx_eth: remove memset(,0) with zalloc
  2019-02-27  6:04 [PATCH 0/8] net: ethernet: reduce calls to memset(,0) Robert Eshleman
                   ` (5 preceding siblings ...)
  2019-02-27  6:09 ` [PATCH 7/8] net: seeq: replace kmalloc / memset(,0) with kzalloc Robert Eshleman
@ 2019-02-27  6:09 ` Robert Eshleman
  2019-02-27  6:09 ` [PATCH 1/8] net/mlx4: use kzalloc instead of kmalloc Robert Eshleman
  2019-02-28 14:25 ` [PATCH 0/8] net: ethernet: reduce calls to memset(,0) Christoph Hellwig
  8 siblings, 0 replies; 16+ messages in thread
From: Robert Eshleman @ 2019-02-27  6:09 UTC (permalink / raw)
  To: bobbyeshleman
  Cc: Tariq Toukan, David S. Miller, Krzysztof Halasa, netdev,
	linux-rdma, linux-kernel

This patch removes a call to memset(,0) by replacing the
prior call to dma_pool_alloc with a call to dma_pool_zalloc.

Signed-off-by: Robert Eshleman <bobbyeshleman@gmail.com>
---
 drivers/net/ethernet/xscale/ixp4xx_eth.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index aee55c03def0..8471e1857d53 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -1107,11 +1107,10 @@ static int init_queues(struct port *port)
 		if (!dma_pool)
 			return -ENOMEM;
 	}
-
-	if (!(port->desc_tab = dma_pool_alloc(dma_pool, GFP_KERNEL,
-					      &port->desc_tab_phys)))
+	port->desc_tab = dma_pool_zalloc(dma_pool, GFP_KERNEL,
+					 &port->desc_tab_phys);
+	if (!port->desc_tab)
 		return -ENOMEM;
-	memset(port->desc_tab, 0, POOL_ALLOC_SIZE);
 	memset(port->rx_buff_tab, 0, sizeof(port->rx_buff_tab)); /* tables */
 	memset(port->tx_buff_tab, 0, sizeof(port->tx_buff_tab));
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 1/8] net/mlx4: use kzalloc instead of kmalloc
  2019-02-27  6:04 [PATCH 0/8] net: ethernet: reduce calls to memset(,0) Robert Eshleman
                   ` (6 preceding siblings ...)
  2019-02-27  6:09 ` [PATCH 8/8] net: ethernet: ixp4xx_eth: remove memset(,0) with zalloc Robert Eshleman
@ 2019-02-27  6:09 ` Robert Eshleman
  2019-02-28  8:40   ` Tariq Toukan
  2019-02-28 14:25 ` [PATCH 0/8] net: ethernet: reduce calls to memset(,0) Christoph Hellwig
  8 siblings, 1 reply; 16+ messages in thread
From: Robert Eshleman @ 2019-02-27  6:09 UTC (permalink / raw)
  To: bobbyeshleman
  Cc: Tariq Toukan, David S. Miller, netdev, linux-rdma, linux-kernel

This patch replaces a kmalloc/memset(,0) call with a call to kzalloc.
It also removes a memset(,0) call that always follows a *zalloc call.

Signed-off-by: Robert Eshleman <bobbyeshleman@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx4/cmd.c   | 1 -
 drivers/net/ethernet/mellanox/mlx4/en_rx.c | 3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index e65bc3c95630..7bfa6e850e5f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -3307,7 +3307,6 @@ int mlx4_get_counter_stats(struct mlx4_dev *dev, int counter_index,
 	if (IS_ERR(mailbox))
 		return PTR_ERR(mailbox);
 
-	memset(mailbox->buf, 0, sizeof(struct mlx4_counter));
 	if_stat_in_mod = counter_index;
 	if (reset)
 		if_stat_in_mod |= MLX4_QUERY_IF_STAT_RESET;
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 9a0881cb7f51..f55805d206ef 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -1044,7 +1044,7 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn,
 	struct mlx4_qp_context *context;
 	int err = 0;
 
-	context = kmalloc(sizeof(*context), GFP_KERNEL);
+	context = kzalloc(sizeof(*context), GFP_KERNEL);
 	if (!context)
 		return -ENOMEM;
 
@@ -1055,7 +1055,6 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn,
 	}
 	qp->event = mlx4_en_sqp_event;
 
-	memset(context, 0, sizeof(*context));
 	mlx4_en_fill_qp_context(priv, ring->actual_size, ring->stride, 0, 0,
 				qpn, ring->cqn, -1, context);
 	context->db_rec_addr = cpu_to_be64(ring->wqres.db.dma);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 3/8] tlan: use pci_zalloc instead of pci_alloc
  2019-02-27  6:09 ` [PATCH 3/8] tlan: use pci_zalloc instead of pci_alloc Robert Eshleman
@ 2019-02-27  6:22   ` Joe Perches
  2019-02-28  0:41     ` Robert Eshleman
  0 siblings, 1 reply; 16+ messages in thread
From: Joe Perches @ 2019-02-27  6:22 UTC (permalink / raw)
  To: Robert Eshleman
  Cc: Tariq Toukan, David S. Miller, Samuel Chessman, netdev,
	linux-rdma, linux-kernel

On Tue, 2019-02-26 at 22:09 -0800, Robert Eshleman wrote:
> This patch replaces a pci_alloc_consistent and memset(,0) call
> with a single call to pci_zalloc_consistent.
[]
> diff --git a/drivers/net/ethernet/ti/tlan.c b/drivers/net/ethernet/ti/tlan.c
[]
> @@ -845,17 +845,16 @@ static int tlan_init(struct net_device *dev)
>  
>  	dma_size = (TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS)
>  		* (sizeof(struct tlan_list));
> -	priv->dma_storage = pci_alloc_consistent(priv->pci_dev,
> -						 dma_size,
> -						 &priv->dma_storage_dma);
> +	priv->dma_storage = pci_zalloc_consistent(priv->pci_dev,
> +						  dma_size,
> +						  &priv->dma_storage_dma);
>  	priv->dma_size = dma_size;
>  
> -	if (priv->dma_storage == NULL) {
> +	if (!priv->dma_storage) {
>  		pr_err("Could not allocate lists and buffers for %s\n",
>  		       dev->name);

unrelated trivia:

This pr_err (and likely others in this file)
could be replace by netdev_err



^ permalink raw reply	[flat|nested] 16+ messages in thread

* RE: [PATCH 4/8] qed: remove unnecessary memsets
  2019-02-27  6:09 ` [PATCH 4/8] qed: remove unnecessary memsets Robert Eshleman
@ 2019-02-27 12:39   ` Michal Kalderon
  0 siblings, 0 replies; 16+ messages in thread
From: Michal Kalderon @ 2019-02-27 12:39 UTC (permalink / raw)
  To: Robert Eshleman
  Cc: Tariq Toukan, David S. Miller, Ariel Elior, GR-everest-linux-l2,
	netdev, linux-rdma, linux-kernel

> From: Robert Eshleman <bobbyeshleman@gmail.com>
> Sent: Wednesday, February 27, 2019 8:10 AM
> 
> This patch replaces unnecessary memset(,0) calls with simply assigning
> structs to zero.
> 
> Signed-off-by: Robert Eshleman <bobbyeshleman@gmail.com>
> ---
>  drivers/net/ethernet/qlogic/qed/qed_cxt.c |  4 +-
> drivers/net/ethernet/qlogic/qed/qed_hw.c  |  3 +-
> drivers/net/ethernet/qlogic/qed/qed_mcp.c | 70 ++++++++---------------
>  3 files changed, 25 insertions(+), 52 deletions(-)
> 
> diff --git a/drivers/net/ethernet/qlogic/qed/qed_cxt.c
> b/drivers/net/ethernet/qlogic/qed/qed_cxt.c
> index c2ad405b2f50..0452ef2fdf1d 100644
> --- a/drivers/net/ethernet/qlogic/qed/qed_cxt.c
> +++ b/drivers/net/ethernet/qlogic/qed/qed_cxt.c
> @@ -902,12 +902,10 @@ static int qed_cxt_src_t2_alloc(struct qed_hwfn
> *p_hwfn)
>  	struct qed_cxt_mngr *p_mngr = p_hwfn->p_cxt_mngr;
>  	u32 conn_num, total_size, ent_per_page, psz, i;
>  	struct qed_ilt_client_cfg *p_src;
> -	struct qed_src_iids src_iids;
> +	struct qed_src_iids src_iids = {0};
>  	struct qed_dma_mem *p_t2;
>  	int rc;
> 
> -	memset(&src_iids, 0, sizeof(src_iids));
> -
>  	/* if the SRC ILT client is inactive - there are no connection
>  	 * requiring the searcer, leave.
>  	 */
> diff --git a/drivers/net/ethernet/qlogic/qed/qed_hw.c
> b/drivers/net/ethernet/qlogic/qed/qed_hw.c
> index 70504dcf4087..b8ca3a31409b 100644
> --- a/drivers/net/ethernet/qlogic/qed/qed_hw.c
> +++ b/drivers/net/ethernet/qlogic/qed/qed_hw.c
> @@ -831,7 +831,7 @@ int qed_dmae_sanity(struct qed_hwfn *p_hwfn,
>  		    struct qed_ptt *p_ptt, const char *phase)  {
>  	u32 size = PAGE_SIZE / 2, val;
> -	struct qed_dmae_params params;
> +	struct qed_dmae_params params = {0};
>  	int rc = 0;
>  	dma_addr_t p_phys;
>  	void *p_virt;
> @@ -864,7 +864,6 @@ int qed_dmae_sanity(struct qed_hwfn *p_hwfn,
>  		   (u64)p_phys,
>  		   p_virt, (u64)(p_phys + size), (u8 *)p_virt + size, size);
> 
> -	memset(&params, 0, sizeof(params));
>  	rc = qed_dmae_host2host(p_hwfn, p_ptt, p_phys, p_phys + size,
>  				size / 4 /* size_in_dwords */, &params);
>  	if (rc) {
> diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
> b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
> index e7f18e34ff0d..e1b72fc819a9 100644
> --- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
> +++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
> @@ -642,10 +642,9 @@ int qed_mcp_cmd(struct qed_hwfn *p_hwfn,
>  		u32 *o_mcp_resp,
>  		u32 *o_mcp_param)
>  {
> -	struct qed_mcp_mb_params mb_params;
> +	struct qed_mcp_mb_params mb_params = {0};
>  	int rc;
> 
> -	memset(&mb_params, 0, sizeof(mb_params));
>  	mb_params.cmd = cmd;
>  	mb_params.param = param;
> 
> @@ -667,10 +666,9 @@ qed_mcp_nvm_wr_cmd(struct qed_hwfn *p_hwfn,
>  		   u32 *o_mcp_resp,
>  		   u32 *o_mcp_param, u32 i_txn_size, u32 *i_buf)  {
> -	struct qed_mcp_mb_params mb_params;
> +	struct qed_mcp_mb_params mb_params = {0};
>  	int rc;
> 
> -	memset(&mb_params, 0, sizeof(mb_params));
>  	mb_params.cmd = cmd;
>  	mb_params.param = param;
>  	mb_params.p_data_src = i_buf;
> @@ -695,11 +693,10 @@ int qed_mcp_nvm_rd_cmd(struct qed_hwfn
> *p_hwfn,
>  		       u32 *o_mcp_resp,
>  		       u32 *o_mcp_param, u32 *o_txn_size, u32 *o_buf)  {
> -	struct qed_mcp_mb_params mb_params;
> +	struct qed_mcp_mb_params mb_params = {0};
>  	u8 raw_data[MCP_DRV_NVM_BUF_LEN];
>  	int rc;
> 
> -	memset(&mb_params, 0, sizeof(mb_params));
>  	mb_params.cmd = cmd;
>  	mb_params.param = param;
>  	mb_params.p_data_dst = raw_data;
> @@ -821,13 +818,12 @@ __qed_mcp_load_req(struct qed_hwfn *p_hwfn,
>  		   struct qed_load_req_in_params *p_in_params,
>  		   struct qed_load_req_out_params *p_out_params)  {
> -	struct qed_mcp_mb_params mb_params;
> -	struct load_req_stc load_req;
> +	struct qed_mcp_mb_params mb_params = {0};
> +	struct load_req_stc load_req = {0};
>  	struct load_rsp_stc load_rsp;
>  	u32 hsi_ver;
>  	int rc;
> 
> -	memset(&load_req, 0, sizeof(load_req));
>  	load_req.drv_ver_0 = p_in_params->drv_ver_0;
>  	load_req.drv_ver_1 = p_in_params->drv_ver_1;
>  	load_req.fw_ver = p_in_params->fw_ver; @@ -843,7 +839,6 @@
> __qed_mcp_load_req(struct qed_hwfn *p_hwfn,
>  		  DRV_ID_MCP_HSI_VER_CURRENT :
>  		  (p_in_params->hsi_ver << DRV_ID_MCP_HSI_VER_SHIFT);
> 
> -	memset(&mb_params, 0, sizeof(mb_params));
>  	mb_params.cmd = DRV_MSG_CODE_LOAD_REQ;
>  	mb_params.param = PDA_COMP | hsi_ver | p_hwfn->cdev-
> >drv_type;
>  	mb_params.p_data_src = &load_req;
> @@ -959,12 +954,11 @@ int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
>  		     struct qed_ptt *p_ptt,
>  		     struct qed_load_req_params *p_params)  {
> -	struct qed_load_req_out_params out_params;
> -	struct qed_load_req_in_params in_params;
> +	struct qed_load_req_out_params out_params = {0};
> +	struct qed_load_req_in_params in_params = {0};
>  	u8 mfw_drv_role, mfw_force_cmd;
>  	int rc;
> 
> -	memset(&in_params, 0, sizeof(in_params));
>  	in_params.hsi_ver = QED_LOAD_REQ_HSI_VER_DEFAULT;
>  	in_params.drv_ver_0 = QED_VERSION;
>  	in_params.drv_ver_1 = qed_get_config_bitmap(); @@ -981,7 +975,6
> @@ int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
>  	in_params.force_cmd = mfw_force_cmd;
>  	in_params.avoid_eng_reset = p_params->avoid_eng_reset;
> 
> -	memset(&out_params, 0, sizeof(out_params));
>  	rc = __qed_mcp_load_req(p_hwfn, p_ptt, &in_params,
> &out_params);
>  	if (rc)
>  		return rc;
> @@ -1072,7 +1065,7 @@ int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
> 
>  int qed_mcp_unload_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
> {
> -	struct qed_mcp_mb_params mb_params;
> +	struct qed_mcp_mb_params mb_params = {0};
>  	u32 wol_param;
> 
>  	switch (p_hwfn->cdev->wol_config) {
> @@ -1091,7 +1084,6 @@ int qed_mcp_unload_req(struct qed_hwfn
> *p_hwfn, struct qed_ptt *p_ptt)
>  		wol_param = DRV_MB_PARAM_UNLOAD_WOL_MCP;
>  	}
> 
> -	memset(&mb_params, 0, sizeof(mb_params));
>  	mb_params.cmd = DRV_MSG_CODE_UNLOAD_REQ;
>  	mb_params.param = wol_param;
>  	mb_params.flags = QED_MB_FLAG_CAN_SLEEP |
> QED_MB_FLAG_AVOID_BLOCK; @@ -1101,17 +1093,15 @@ int
> qed_mcp_unload_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
> 
>  int qed_mcp_unload_done(struct qed_hwfn *p_hwfn, struct qed_ptt
> *p_ptt)  {
> -	struct qed_mcp_mb_params mb_params;
> -	struct mcp_mac wol_mac;
> +	struct qed_mcp_mb_params mb_params = {0};
> +	struct mcp_mac wol_mac = {0};
> 
> -	memset(&mb_params, 0, sizeof(mb_params));
>  	mb_params.cmd = DRV_MSG_CODE_UNLOAD_DONE;
> 
>  	/* Set the primary MAC if WoL is enabled */
>  	if (p_hwfn->cdev->wol_config == QED_OV_WOL_ENABLED) {
>  		u8 *p_mac = p_hwfn->cdev->wol_mac;
> 
> -		memset(&wol_mac, 0, sizeof(wol_mac));
>  		wol_mac.mac_upper = p_mac[0] << 8 | p_mac[1];
>  		wol_mac.mac_lower = p_mac[2] << 24 | p_mac[3] << 16 |
>  				    p_mac[4] << 8 | p_mac[5];
> @@ -1167,7 +1157,7 @@ int qed_mcp_ack_vf_flr(struct qed_hwfn
> *p_hwfn,
>  	u32 mfw_func_offsize = qed_rd(p_hwfn, p_ptt, addr);
>  	u32 func_addr = SECTION_ADDR(mfw_func_offsize,
>  				     MCP_PF_ID(p_hwfn));
> -	struct qed_mcp_mb_params mb_params;
> +	struct qed_mcp_mb_params mb_params = {0};
>  	int rc;
>  	int i;
> 
> @@ -1176,7 +1166,6 @@ int qed_mcp_ack_vf_flr(struct qed_hwfn
> *p_hwfn,
>  			   "Acking VFs [%08x,...,%08x] - %08x\n",
>  			   i * 32, (i + 1) * 32 - 1, vfs_to_ack[i]);
> 
> -	memset(&mb_params, 0, sizeof(mb_params));
>  	mb_params.cmd = DRV_MSG_CODE_VF_DISABLED_DONE;
>  	mb_params.p_data_src = vfs_to_ack;
>  	mb_params.data_src_size = VF_MAX_STATIC / 8; @@ -1455,13
> +1444,12 @@ static void qed_mcp_handle_link_change(struct qed_hwfn
> *p_hwfn,  int qed_mcp_set_link(struct qed_hwfn *p_hwfn, struct qed_ptt
> *p_ptt, bool b_up)  {
>  	struct qed_mcp_link_params *params = &p_hwfn->mcp_info-
> >link_input;
> -	struct qed_mcp_mb_params mb_params;
> -	struct eth_phy_cfg phy_cfg;
> +	struct qed_mcp_mb_params mb_params = {0};
> +	struct eth_phy_cfg phy_cfg = {0};
>  	int rc = 0;
>  	u32 cmd;
> 
>  	/* Set the shmem configuration according to params */
> -	memset(&phy_cfg, 0, sizeof(phy_cfg));
>  	cmd = b_up ? DRV_MSG_CODE_INIT_PHY :
> DRV_MSG_CODE_LINK_RESET;
>  	if (!params->speed.autoneg)
>  		phy_cfg.speed = params->speed.forced_speed; @@ -1505,7
> +1493,6 @@ int qed_mcp_set_link(struct qed_hwfn *p_hwfn, struct
> qed_ptt *p_ptt, bool b_up)
>  			   "Resetting link\n");
>  	}
> 
> -	memset(&mb_params, 0, sizeof(mb_params));
>  	mb_params.cmd = cmd;
>  	mb_params.p_data_src = &phy_cfg;
>  	mb_params.data_src_size = sizeof(phy_cfg); @@ -1534,7 +1521,7
> @@ static void qed_mcp_send_protocol_stats(struct qed_hwfn *p_hwfn,  {
>  	enum qed_mcp_protocol_type stats_type;
>  	union qed_mcp_protocol_stats stats;
> -	struct qed_mcp_mb_params mb_params;
> +	struct qed_mcp_mb_params mb_params = {0};
>  	u32 hsi_param;
> 
>  	switch (type) {
> @@ -1561,7 +1548,6 @@ static void qed_mcp_send_protocol_stats(struct
> qed_hwfn *p_hwfn,
> 
>  	qed_get_protocol_stats(p_hwfn->cdev, stats_type, &stats);
> 
> -	memset(&mb_params, 0, sizeof(mb_params));
>  	mb_params.cmd = DRV_MSG_CODE_GET_STATS;
>  	mb_params.param = hsi_param;
>  	mb_params.p_data_src = &stats;
> @@ -2370,20 +2356,18 @@ qed_mcp_send_drv_version(struct qed_hwfn
> *p_hwfn,
>  			 struct qed_ptt *p_ptt,
>  			 struct qed_mcp_drv_version *p_ver)
>  {
> -	struct qed_mcp_mb_params mb_params;
> -	struct drv_version_stc drv_version;
> +	struct qed_mcp_mb_params mb_params = {0};
> +	struct drv_version_stc drv_version = {0};
>  	__be32 val;
>  	u32 i;
>  	int rc;
> 
> -	memset(&drv_version, 0, sizeof(drv_version));
>  	drv_version.version = p_ver->version;
>  	for (i = 0; i < (MCP_DRV_VER_STR_SIZE - 4) / sizeof(u32); i++) {
>  		val = cpu_to_be32(*((u32 *)&p_ver->name[i *
> sizeof(u32)]));
>  		*(__be32 *)&drv_version.name[i * sizeof(u32)] = val;
>  	}
> 
> -	memset(&mb_params, 0, sizeof(mb_params));
>  	mb_params.cmd = DRV_MSG_CODE_SET_VERSION;
>  	mb_params.p_data_src = &drv_version;
>  	mb_params.data_src_size = sizeof(drv_version); @@ -2536,11
> +2520,10 @@ int qed_mcp_ov_update_mtu(struct qed_hwfn *p_hwfn,  int
> qed_mcp_ov_update_mac(struct qed_hwfn *p_hwfn,
>  			  struct qed_ptt *p_ptt, u8 *mac)
>  {
> -	struct qed_mcp_mb_params mb_params;
> +	struct qed_mcp_mb_params mb_params = {0};
>  	u32 mfw_mac[2];
>  	int rc;
> 
> -	memset(&mb_params, 0, sizeof(mb_params));
>  	mb_params.cmd = DRV_MSG_CODE_SET_VMAC;
>  	mb_params.param = DRV_MSG_CODE_VMAC_TYPE_MAC <<
>  			  DRV_MSG_CODE_VMAC_TYPE_SHIFT;
> @@ -3197,12 +3180,10 @@ qed_mcp_resc_allocation_msg(struct qed_hwfn
> *p_hwfn,
>  			    struct qed_resc_alloc_in_params *p_in_params,
>  			    struct qed_resc_alloc_out_params
> *p_out_params)  {
> -	struct qed_mcp_mb_params mb_params;
> -	struct resource_info mfw_resc_info;
> +	struct qed_mcp_mb_params mb_params = {0};
> +	struct resource_info mfw_resc_info = {0};
>  	int rc;
> 
> -	memset(&mfw_resc_info, 0, sizeof(mfw_resc_info));
> -
>  	mfw_resc_info.res_id = qed_mcp_get_mfw_res_id(p_in_params-
> >res_id);
>  	if (mfw_resc_info.res_id == RESOURCE_NUM_INVALID) {
>  		DP_ERR(p_hwfn,
> @@ -3224,7 +3205,6 @@ qed_mcp_resc_allocation_msg(struct qed_hwfn
> *p_hwfn,
>  		return -EINVAL;
>  	}
> 
> -	memset(&mb_params, 0, sizeof(mb_params));
>  	mb_params.cmd = p_in_params->cmd;
>  	mb_params.param = QED_RESC_ALLOC_VERSION;
>  	mb_params.p_data_src = &mfw_resc_info; @@ -3277,15 +3257,13
> @@ qed_mcp_set_resc_max_val(struct qed_hwfn *p_hwfn,
>  			 enum qed_resources res_id,
>  			 u32 resc_max_val, u32 *p_mcp_resp)
>  {
> -	struct qed_resc_alloc_out_params out_params;
> -	struct qed_resc_alloc_in_params in_params;
> +	struct qed_resc_alloc_out_params out_params = {0};
> +	struct qed_resc_alloc_in_params in_params = {0};
>  	int rc;
> 
> -	memset(&in_params, 0, sizeof(in_params));
>  	in_params.cmd = DRV_MSG_SET_RESOURCE_VALUE_MSG;
>  	in_params.res_id = res_id;
>  	in_params.resc_max_val = resc_max_val;
> -	memset(&out_params, 0, sizeof(out_params));
>  	rc = qed_mcp_resc_allocation_msg(p_hwfn, p_ptt, &in_params,
>  					 &out_params);
>  	if (rc)
> @@ -3302,14 +3280,12 @@ qed_mcp_get_resc_info(struct qed_hwfn
> *p_hwfn,
>  		      enum qed_resources res_id,
>  		      u32 *p_mcp_resp, u32 *p_resc_num, u32 *p_resc_start)
> {
> -	struct qed_resc_alloc_out_params out_params;
> -	struct qed_resc_alloc_in_params in_params;
> +	struct qed_resc_alloc_out_params out_params = {0};
> +	struct qed_resc_alloc_in_params in_params = {0};
>  	int rc;
> 
> -	memset(&in_params, 0, sizeof(in_params));
>  	in_params.cmd = DRV_MSG_GET_RESOURCE_ALLOC_MSG;
>  	in_params.res_id = res_id;
> -	memset(&out_params, 0, sizeof(out_params));
>  	rc = qed_mcp_resc_allocation_msg(p_hwfn, p_ptt, &in_params,
>  					 &out_params);
>  	if (rc)
> --
> 2.20.1

Thanks, 

Acked-by: Michal Kalderon <michal.kalderon@marvell.com>



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 3/8] tlan: use pci_zalloc instead of pci_alloc
  2019-02-27  6:22   ` Joe Perches
@ 2019-02-28  0:41     ` Robert Eshleman
  0 siblings, 0 replies; 16+ messages in thread
From: Robert Eshleman @ 2019-02-28  0:41 UTC (permalink / raw)
  To: Joe Perches
  Cc: Tariq Toukan, David S. Miller, Samuel Chessman, netdev,
	linux-rdma, linux-kernel

On Tue, Feb 26, 2019 at 10:22:06PM -0800, Joe Perches wrote:
> On Tue, 2019-02-26 at 22:09 -0800, Robert Eshleman wrote:
> > This patch replaces a pci_alloc_consistent and memset(,0) call
> > with a single call to pci_zalloc_consistent.
> []
> > diff --git a/drivers/net/ethernet/ti/tlan.c b/drivers/net/ethernet/ti/tlan.c
> []
> > @@ -845,17 +845,16 @@ static int tlan_init(struct net_device *dev)
> >  
> >  	dma_size = (TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS)
> >  		* (sizeof(struct tlan_list));
> > -	priv->dma_storage = pci_alloc_consistent(priv->pci_dev,
> > -						 dma_size,
> > -						 &priv->dma_storage_dma);
> > +	priv->dma_storage = pci_zalloc_consistent(priv->pci_dev,
> > +						  dma_size,
> > +						  &priv->dma_storage_dma);
> >  	priv->dma_size = dma_size;
> >  
> > -	if (priv->dma_storage == NULL) {
> > +	if (!priv->dma_storage) {
> >  		pr_err("Could not allocate lists and buffers for %s\n",
> >  		       dev->name);
> 
> unrelated trivia:
> 
> This pr_err (and likely others in this file)
> could be replace by netdev_err
> 

Definitely good to know (I may make that change too).  Thanks Joe.

-Bobby

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 7/8] net: seeq: replace kmalloc / memset(,0) with kzalloc
  2019-02-27  6:09 ` [PATCH 7/8] net: seeq: replace kmalloc / memset(,0) with kzalloc Robert Eshleman
@ 2019-02-28  0:48   ` Robert Eshleman
  0 siblings, 0 replies; 16+ messages in thread
From: Robert Eshleman @ 2019-02-28  0:48 UTC (permalink / raw)
  To: Robert Eshleman
  Cc: Tariq Toukan, David S. Miller, Russell King, netdev, linux-rdma,
	linux-kernel, linux-arm-kernel

On Tue, Feb 26, 2019 at 10:09:54PM -0800, Robert Eshleman wrote:
> This patch reduces a call to memset(,0) by replacing
> a kmalloc call with a kzalloc call.
> 
> Signed-off-by: Robert Eshleman <bobbyeshleman@gmail.com>
> ---
>  drivers/net/ethernet/seeq/ether3.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/seeq/ether3.c b/drivers/net/ethernet/seeq/ether3.c
> index d1bb73bf9914..7456cf08a48f 100644
> --- a/drivers/net/ethernet/seeq/ether3.c
> +++ b/drivers/net/ethernet/seeq/ether3.c
> @@ -223,7 +223,7 @@ ether3_addr(char *addr, struct expansion_card *ec)
>  static int
>  ether3_ramtest(struct net_device *dev, unsigned char byte)
>  {
> -	unsigned char *buffer = kmalloc(RX_END, GFP_KERNEL);
> +	unsigned char *buffer = kzalloc(RX_END, GFP_KERNEL);
>  	int i,ret = 0;
>  	int max_errors = 4;
>  	int bad = -1;
> @@ -231,7 +231,6 @@ ether3_ramtest(struct net_device *dev, unsigned char byte)
>  	if (!buffer)
>  		return 1;
>  
> -	memset(buffer, byte, RX_END);

Byte is not zero, so the intent of this patch does not apply here.
Dropping this from the patch set in v2.


>  	ether3_setbuffer(dev, buffer_write, 0);
>  	ether3_writebuffer(dev, buffer, TX_END);
>  	ether3_setbuffer(dev, buffer_write, RX_START);
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/8] net/mlx4: use kzalloc instead of kmalloc
  2019-02-27  6:09 ` [PATCH 1/8] net/mlx4: use kzalloc instead of kmalloc Robert Eshleman
@ 2019-02-28  8:40   ` Tariq Toukan
  0 siblings, 0 replies; 16+ messages in thread
From: Tariq Toukan @ 2019-02-28  8:40 UTC (permalink / raw)
  To: Robert Eshleman
  Cc: Tariq Toukan, David S. Miller, netdev, linux-rdma, linux-kernel



On 2/27/2019 8:09 AM, Robert Eshleman wrote:
> This patch replaces a kmalloc/memset(,0) call with a call to kzalloc.
> It also removes a memset(,0) call that always follows a *zalloc call.
> 
> Signed-off-by: Robert Eshleman <bobbyeshleman@gmail.com>
> ---
>   drivers/net/ethernet/mellanox/mlx4/cmd.c   | 1 -
>   drivers/net/ethernet/mellanox/mlx4/en_rx.c | 3 +--
>   2 files changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
> index e65bc3c95630..7bfa6e850e5f 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
> @@ -3307,7 +3307,6 @@ int mlx4_get_counter_stats(struct mlx4_dev *dev, int counter_index,
>   	if (IS_ERR(mailbox))
>   		return PTR_ERR(mailbox);
>   
> -	memset(mailbox->buf, 0, sizeof(struct mlx4_counter));
>   	if_stat_in_mod = counter_index;
>   	if (reset)
>   		if_stat_in_mod |= MLX4_QUERY_IF_STAT_RESET;
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> index 9a0881cb7f51..f55805d206ef 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> @@ -1044,7 +1044,7 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn,
>   	struct mlx4_qp_context *context;
>   	int err = 0;
>   
> -	context = kmalloc(sizeof(*context), GFP_KERNEL);
> +	context = kzalloc(sizeof(*context), GFP_KERNEL);
>   	if (!context)
>   		return -ENOMEM;
>   
> @@ -1055,7 +1055,6 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn,
>   	}
>   	qp->event = mlx4_en_sqp_event;
>   
> -	memset(context, 0, sizeof(*context));
>   	mlx4_en_fill_qp_context(priv, ring->actual_size, ring->stride, 0, 0,
>   				qpn, ring->cqn, -1, context);
>   	context->db_rec_addr = cpu_to_be64(ring->wqres.db.dma);
> 

Hi,

Thanks for your patch.
It looks good, but misses one similar point you might want to cover:

in drivers/net/ethernet/mellanox/mlx4/port.c:1780 :
memset(context, 0, sizeof(*context));

Tariq

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 5/8] at12: use pci_zalloc instead of pci_alloc
  2019-02-27  6:09 ` [PATCH 5/8] at12: use pci_zalloc instead of pci_alloc Robert Eshleman
@ 2019-02-28 14:00   ` Christoph Hellwig
  0 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2019-02-28 14:00 UTC (permalink / raw)
  To: Robert Eshleman
  Cc: Jay Cliburn, Chris Snook, David S. Miller, Tariq Toukan, netdev,
	linux-kernel, linux-rdma

On Tue, Feb 26, 2019 at 10:09:52PM -0800, Robert Eshleman wrote:
> This patch replaces a pci_alloc and memset(,0) call
> with a single call to pci_zalloc.

Please don't move from one deprecated API to another one.  If you feel
like cleaning up DMA API calls please move to dma_alloc_coherent,
and do that for the whole DMA API usage.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/8] net: ethernet: reduce calls to memset(,0)
  2019-02-27  6:04 [PATCH 0/8] net: ethernet: reduce calls to memset(,0) Robert Eshleman
                   ` (7 preceding siblings ...)
  2019-02-27  6:09 ` [PATCH 1/8] net/mlx4: use kzalloc instead of kmalloc Robert Eshleman
@ 2019-02-28 14:25 ` Christoph Hellwig
  8 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2019-02-28 14:25 UTC (permalink / raw)
  To: Robert Eshleman; +Cc: David S. Miller, netdev, linux-kernel

On Tue, Feb 26, 2019 at 10:04:54PM -0800, Robert Eshleman wrote:
> This patch series removes calls to memset(,0) that are
> redundant when used in conjunction with a zalloc call or
> by simple zero-assignment of structs.

NAK.  pci_zalloc_consistent is just as deprecated as
pci_alloc_consistent, and if you look at the implementation you'll
see that we actual zero the memory for both of them.

If you want to do some DMA-related busy work please just bulk convert
drivers from the PCI DMA API to the proper generic DMA API.  Bonus
points for automatіng that using a cocchinelle script.

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-02-28 14:25 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-27  6:04 [PATCH 0/8] net: ethernet: reduce calls to memset(,0) Robert Eshleman
2019-02-27  6:09 ` [PATCH 2/8] net/mlxsw: use pci_zalloc_consistent instead of pci_alloc_consistent Robert Eshleman
2019-02-27  6:09 ` [PATCH 3/8] tlan: use pci_zalloc instead of pci_alloc Robert Eshleman
2019-02-27  6:22   ` Joe Perches
2019-02-28  0:41     ` Robert Eshleman
2019-02-27  6:09 ` [PATCH 4/8] qed: remove unnecessary memsets Robert Eshleman
2019-02-27 12:39   ` Michal Kalderon
2019-02-27  6:09 ` [PATCH 5/8] at12: use pci_zalloc instead of pci_alloc Robert Eshleman
2019-02-28 14:00   ` Christoph Hellwig
2019-02-27  6:09 ` [PATCH 6/8] netxen: remove unnecessary memset(,0) calls Robert Eshleman
2019-02-27  6:09 ` [PATCH 7/8] net: seeq: replace kmalloc / memset(,0) with kzalloc Robert Eshleman
2019-02-28  0:48   ` Robert Eshleman
2019-02-27  6:09 ` [PATCH 8/8] net: ethernet: ixp4xx_eth: remove memset(,0) with zalloc Robert Eshleman
2019-02-27  6:09 ` [PATCH 1/8] net/mlx4: use kzalloc instead of kmalloc Robert Eshleman
2019-02-28  8:40   ` Tariq Toukan
2019-02-28 14:25 ` [PATCH 0/8] net: ethernet: reduce calls to memset(,0) Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).