From patchwork Thu May 11 12:15:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 99635 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp700145qge; Thu, 11 May 2017 05:17:15 -0700 (PDT) X-Received: by 10.99.173.12 with SMTP id g12mr11979441pgf.225.1494505035533; Thu, 11 May 2017 05:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494505035; cv=none; d=google.com; s=arc-20160816; b=uuIWbYEC5CccdLYL6uel41C/JPlEzgw92WFiJwxxkiF6S77Z2iUjRknYevnUQMbnGl N9bW5J9FbYWEV29yECA2HSrrkGKirATxEXH2zagr4b4ofRtypQ54jN/mmamzyWaDYH4j qVEcAyk2WXP20gNtJnlC1gymHMQoc/y9OaP0hUHKklVd8dAYGDmqiHdSFunZcuNQVVmH SxLEM7+p8URBiJE470DB99FJyzoXspA7ymCoYOZ1W3Gz3IDHuVkOdCxZ4oBDbBlQYcOE W1VG8Qtv1N/XCPcRR/jT2eT81+asAYvjA8AXbLMicnt8MkPLhVYl5Sy7D8nB+9zLTpxI iX5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hFVFmnt5BaSwjWNLApcr4WZqDuLsUEHDgGB+/MMp0O8=; b=CydWsedZVqofsL83J+uEKYJqLkfFBus1mLt+Ktk2DdzPwv4ZXUpe2q9QxO0eN1n14V cdpNNlEAIVwhq2Ak1vRMkdmC29YiJVooUtNq6V2vO/1gkEV1oid8xdwNOXoCqInWGVNf qLqV00DXNsFQdTC9E+7i9rgnnHRjAhe4l0eIPk43sl+6f93wp/F8EhtC9+PMZWRAOo+W heciLFGtANm9qW46FJTyRlprOU87ag/LCRy65d34zd+mlO42yZGZe8FnneK29JmbDPvu 77g43pW4JMhLiaThFLqxc0Ma+U3eMfBomfhyDXgnPDJgPCL5GpCVlogZh6abKyIw9xH1 VMWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p71si1718309pfj.351.2017.05.11.05.17.15; Thu, 11 May 2017 05:17:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932655AbdEKMQ4 (ORCPT + 25 others); Thu, 11 May 2017 08:16:56 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:54884 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754911AbdEKMQx (ORCPT ); Thu, 11 May 2017 08:16:53 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0MPoeo-1d4v8n1xPW-004yKZ; Thu, 11 May 2017 14:16:39 +0200 From: Arnd Bergmann To: Yuval Mintz , Ariel Elior , everest-linux-l2@cavium.com Cc: Arnd Bergmann , "David S. Miller" , Chad Dupuis , Ram Amrani , Manish Rangankar , "Chopra, Manish" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] qed: fix uninitialized data in aRFS intrastructure Date: Thu, 11 May 2017 14:15:14 +0200 Message-Id: <20170511121633.3591880-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:2QNuN0/jhN/G1juUpdMillWO3j4wg0VrTw0aHCQ+cBD628t7wId 4uwt0D2djKKzE/QzRXCtrwwEvl8KK6glLJkw6W6ZWBsgmQUlbJoDOFGmCMFTW7VL9rfmk5p cdhxpCO/5Ud3EwHcm/csKrK3+bTc/uDIoWZndez+zLt0xewpDgJ/AsE1ao3pV2Fgm0oZENA nlairuBrce7S4k5bD6DlA== X-UI-Out-Filterresults: notjunk:1; V01:K0:STKg8X5HxCY=:oOMxW2b8FHja79GOlPJzRF PoKxISMWk+xBqhMf+xB+cLH2v3GThYkj4qoJNb4pryyTcSxkXbyWpxqcvzkUJhx35PcsNfA4/ D3IJ7MDdQ7rRHnRaX8bl44KjSU+otdhEA1ZWfAXjMKtxZeCs6Sle0WN/9zkmFiEiUi5TxYlLS i4szDhiKa8/M6+bN4sX7TcosuGYXXzQwQBl5gIIMsYrOAxMMYkcc0vl+lhErqUeOh2tqNOEWk 4PyY4f5UJNuFVWYkRT7sepj4x+mYOUcRVmy3N6vbl1ZlR2PfF60p8iUcrpIfV7fX9QkwR1cxm T/oDI96bKz3WqkYR1TbQ+iVpJw7tcxHm1uCwXbmSpqxmMiBWnAflS7WAG8ApUUO1F9LyWASCa w9kVMCIclQPtx2PmhG3Z6ZoK6XSHG9hpQUB/6Lfq937uA6KmaKvFtEXjauv7hgvJYLPjNQOT+ LSca3ajXIBbW6sR+grRrcXO2Zee+aJ7bYbdK1FDGMNLuxRbwv2dzVZZcP1OG/K9vbfC06hX3Q xhMNm7gBNF7YbWK5JN8WQsM1BcEjlEOpCkpEZYLYC/IGO+zai0e/PRiGdtMJQQIF6pxgQmvM/ 4lv7gbseF6gIKjE7FuzArqWsSCS5JxXXkdBY2bxHO1OWeV0MtJ2Hb9yZS1zrDVnOp7tJxOqap 6MRZONHr85L9zO0UUx8QhEzeFDpmm9/hQTWXTwfl2bo7d1oIeSZ056ZogTVnOUhqKYQs= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The new code contains an incredibly elaborate way of setting a 64-bit register, which went subtly wrong due to the wrong size in a memset(): ethernet/qlogic/qed/qed_init_fw_funcs.c: In function 'qed_set_rfs_mode_disable': ethernet/qlogic/qed/qed_init_fw_funcs.c:993:3: error: '*((void *)&ramline+4)' is used uninitialized in this function [-Werror=uninitialized] This removes the silly loop and memset, and instead directly writes the correct value to the register. Fixes: d51e4af5c209 ("qed: aRFS infrastructure support") Signed-off-by: Arnd Bergmann --- .../net/ethernet/qlogic/qed/qed_init_fw_funcs.c | 48 +++++----------------- 1 file changed, 11 insertions(+), 37 deletions(-) -- 2.9.0 diff --git a/drivers/net/ethernet/qlogic/qed/qed_init_fw_funcs.c b/drivers/net/ethernet/qlogic/qed/qed_init_fw_funcs.c index 67200c5498ab..a7c2c147a738 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_init_fw_funcs.c +++ b/drivers/net/ethernet/qlogic/qed/qed_init_fw_funcs.c @@ -966,45 +966,29 @@ void qed_set_geneve_enable(struct qed_hwfn *p_hwfn, #define PARSER_ETH_CONN_CM_HDR (0x0) #define CAM_LINE_SIZE sizeof(u32) #define RAM_LINE_SIZE sizeof(u64) -#define REG_SIZE sizeof(u32) +#define CAM_REG(pf_id) (PRS_REG_GFT_CAM + CAM_LINE_SIZE * (pf_id)) +#define RAM_REG(pf_id) (PRS_REG_GFT_PROFILE_MASK_RAM + RAM_LINE_SIZE * (pf_id)) void qed_set_rfs_mode_disable(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, u16 pf_id) { - union gft_cam_line_union camline; - struct gft_ram_line ramline; - u32 *p_ramline, i; - - p_ramline = (u32 *)&ramline; - /*stop using gft logic */ qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_GFT, 0); qed_wr(p_hwfn, p_ptt, PRS_REG_CM_HDR_GFT, 0x0); - memset(&camline, 0, sizeof(union gft_cam_line_union)); - qed_wr(p_hwfn, p_ptt, PRS_REG_GFT_CAM + CAM_LINE_SIZE * pf_id, - camline.cam_line_mapped.camline); - memset(&ramline, 0, sizeof(union gft_cam_line_union)); - - for (i = 0; i < RAM_LINE_SIZE / REG_SIZE; i++) { - u32 hw_addr = PRS_REG_GFT_PROFILE_MASK_RAM; - - hw_addr += (RAM_LINE_SIZE * pf_id + i * REG_SIZE); - - qed_wr(p_hwfn, p_ptt, hw_addr, *(p_ramline + i)); - } + qed_wr(p_hwfn, p_ptt, CAM_REG(pf_id), 0); + qed_wr(p_hwfn, p_ptt, RAM_REG(pf_id), 0); + qed_wr(p_hwfn, p_ptt, RAM_REG(pf_id) + 4, 0); } void qed_set_rfs_mode_enable(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, u16 pf_id, bool tcp, bool udp, bool ipv4, bool ipv6) { - u32 rfs_cm_hdr_event_id, *p_ramline; + u32 rfs_cm_hdr_event_id; union gft_cam_line_union camline; struct gft_ram_line ramline; - int i; rfs_cm_hdr_event_id = qed_rd(p_hwfn, p_ptt, PRS_REG_CM_HDR_GFT); - p_ramline = (u32 *)&ramline; if (!ipv6 && !ipv4) DP_NOTICE(p_hwfn, @@ -1060,8 +1044,7 @@ void qed_set_rfs_mode_enable(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, } /* write characteristics to cam */ - qed_wr(p_hwfn, p_ptt, PRS_REG_GFT_CAM + CAM_LINE_SIZE * pf_id, - camline.cam_line_mapped.camline); + qed_wr(p_hwfn, p_ptt, CAM_REG(pf_id), camline.cam_line_mapped.camline); camline.cam_line_mapped.camline = qed_rd(p_hwfn, p_ptt, PRS_REG_GFT_CAM + CAM_LINE_SIZE * pf_id); @@ -1074,19 +1057,10 @@ void qed_set_rfs_mode_enable(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, SET_FIELD(ramline.low32bits, GFT_RAM_LINE_SRC_PORT, 1); SET_FIELD(ramline.low32bits, GFT_RAM_LINE_DST_PORT, 1); - /* each iteration write to reg */ - for (i = 0; i < RAM_LINE_SIZE / REG_SIZE; i++) - qed_wr(p_hwfn, p_ptt, - PRS_REG_GFT_PROFILE_MASK_RAM + RAM_LINE_SIZE * pf_id + - i * REG_SIZE, *(p_ramline + i)); + qed_wr(p_hwfn, p_ptt, RAM_REG(pf_id), ramline.low32bits); + qed_wr(p_hwfn, p_ptt, RAM_REG(pf_id) + 4, ramline.high32bits); /* set default profile so that no filter match will happen */ - ramline.low32bits = 0xffff; - ramline.high32bits = 0xffff; - - for (i = 0; i < RAM_LINE_SIZE / REG_SIZE; i++) - qed_wr(p_hwfn, p_ptt, - PRS_REG_GFT_PROFILE_MASK_RAM + RAM_LINE_SIZE * - PRS_GFT_CAM_LINES_NO_MATCH + i * REG_SIZE, - *(p_ramline + i)); + qed_wr(p_hwfn, p_ptt, RAM_REG(PRS_GFT_CAM_LINES_NO_MATCH), 0xffff); + qed_wr(p_hwfn, p_ptt, RAM_REG(PRS_GFT_CAM_LINES_NO_MATCH) + 4, 0xffff); }