From patchwork Thu Jan 3 10:02:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Bolotin X-Patchwork-Id: 1020218 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=marvell.com header.i=@marvell.com header.b="ASGV5c06"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43Vk4s6N8jz9s9h for ; Thu, 3 Jan 2019 21:03:09 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730677AbfACKDJ (ORCPT ); Thu, 3 Jan 2019 05:03:09 -0500 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:41150 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730589AbfACKDH (ORCPT ); Thu, 3 Jan 2019 05:03:07 -0500 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x03A018B016142; Thu, 3 Jan 2019 02:03:06 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=BaHhir4Y7m6b2V2txsv2rr3SACiFyvUFeGCdjs21i28=; b=ASGV5c06wmWvwysxmFKoPj1cfVtqh8ylvylbWkJyHZLPbuNRKzTW7O1u/PJrIUst804T yvpi8oOZszKXVfhI6GnsgZQUflkJEwmsWm+NhkBtvYeERXyeJDEhg9rwl0xJYvVRH4B5 G/w5to92gX2Xk5JQl8Wp+GpwSKDfSveF4JyzoXVZSYaPPMB+iuefFiDDVxLhsiYDzfHk qFxEAytm0XvQINsFpUgXcfsn8VfGb8Iog68i3aXlbopKDJrqD5m3a+2ZOWzJUtNkrGor H03gi8acCsGDMF2YwkWY5DURZyioceLfNEZgIbFkLYHNTMalOb6uMTthXkDPfl+sYJip gw== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 2ps9b922g1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 03 Jan 2019 02:03:05 -0800 Received: from SC-EXCH02.marvell.com (10.93.176.82) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 3 Jan 2019 02:03:04 -0800 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 3 Jan 2019 02:03:04 -0800 Received: from lb-tlvb-denis.qlc.com (unknown [10.185.6.94]) by maili.marvell.com (Postfix) with ESMTP id 710413F7040; Thu, 3 Jan 2019 02:03:03 -0800 (PST) From: Denis Bolotin To: , CC: , Denis Bolotin Subject: [PATCH net 1/2] qed: Fix qed_chain_set_prod() for PBL chains with non power of 2 page count Date: Thu, 3 Jan 2019 12:02:39 +0200 Message-ID: <20190103100240.17534-2-dbolotin@marvell.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190103100240.17534-1-dbolotin@marvell.com> References: <20190103100240.17534-1-dbolotin@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-03_04:, , signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901030089 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In PBL chains with non power of 2 page count, the producer is not at the beginning of the chain when index is 0 after a wrap. Therefore, after the producer index wrap around, page index should be calculated more carefully. Signed-off-by: Denis Bolotin Signed-off-by: Ariel Elior --- include/linux/qed/qed_chain.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/include/linux/qed/qed_chain.h b/include/linux/qed/qed_chain.h index 59ddf9a..2dd0a9e 100644 --- a/include/linux/qed/qed_chain.h +++ b/include/linux/qed/qed_chain.h @@ -663,6 +663,37 @@ static inline void *qed_chain_get_last_elem(struct qed_chain *p_chain) static inline void qed_chain_set_prod(struct qed_chain *p_chain, u32 prod_idx, void *p_prod_elem) { + if (p_chain->mode == QED_CHAIN_MODE_PBL) { + u32 cur_prod, page_mask, page_cnt, page_diff; + + cur_prod = is_chain_u16(p_chain) ? p_chain->u.chain16.prod_idx : + p_chain->u.chain32.prod_idx; + + /* Assume that number of elements in a page is power of 2 */ + page_mask = ~p_chain->elem_per_page_mask; + + /* Use "cur_prod - 1" and "prod_idx - 1" since producer index + * reaches the first element of next page before the page index + * is incremented. See qed_chain_produce(). + * Index wrap around is not a problem because the difference + * between current and given producer indices is always + * positive and lower than the chain's capacity. + */ + page_diff = (((cur_prod - 1) & page_mask) - + ((prod_idx - 1) & page_mask)) / + p_chain->elem_per_page; + + page_cnt = qed_chain_get_page_cnt(p_chain); + if (is_chain_u16(p_chain)) + p_chain->pbl.c.u16.prod_page_idx = + (p_chain->pbl.c.u16.prod_page_idx - + page_diff + page_cnt) % page_cnt; + else + p_chain->pbl.c.u32.prod_page_idx = + (p_chain->pbl.c.u32.prod_page_idx - + page_diff + page_cnt) % page_cnt; + } + if (is_chain_u16(p_chain)) p_chain->u.chain16.prod_idx = (u16) prod_idx; else From patchwork Thu Jan 3 10:02:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Bolotin X-Patchwork-Id: 1020219 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=marvell.com header.i=@marvell.com header.b="wKiK7iT3"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43Vk4w4nXbz9s9G for ; Thu, 3 Jan 2019 21:03:12 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730682AbfACKDL (ORCPT ); Thu, 3 Jan 2019 05:03:11 -0500 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:32820 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730589AbfACKDK (ORCPT ); Thu, 3 Jan 2019 05:03:10 -0500 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x03A2G7W027558; Thu, 3 Jan 2019 02:03:09 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=m+Y+N2ufZIGfdm9Lk38TEFU3RkMrB6121zwRW5PGjlk=; b=wKiK7iT3l62Y8OmZvUrUxLVksxJ4W5Z9mkTxslXdYnuLWN3JLCMS8cN5sz6Hex6qXhwu asAtbw43KbygPGqSlV3FHKJac/9Q+w1sB+ORTcnjkGIN32rbu0XYkDateimel9WpKpsH ee42Hsnc1TbjrgcFLXYxGyhnbGMtvMkMjRGKI8MWy21ws7RMm4ie6UuBL/unpd+GADvm TRHPV5ipE5zhP+eq0efh4Ty9VhkhbXwLYKRxt9EyoFXbSJ0dXmJbv3PuFmAvCqh5K8I0 L1udGsU8D6B7SirjlNX1Lq/2/LIDq4cuMkuf4P4diy7O3yEY1xAGrTLUdWs9nn38KbNN Pg== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 2ps9bnt1q9-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 03 Jan 2019 02:03:08 -0800 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 3 Jan 2019 02:03:07 -0800 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 3 Jan 2019 02:03:07 -0800 Received: from lb-tlvb-denis.qlc.com (unknown [10.185.6.94]) by maili.marvell.com (Postfix) with ESMTP id 55A6F3F703F; Thu, 3 Jan 2019 02:03:06 -0800 (PST) From: Denis Bolotin To: , CC: , Denis Bolotin Subject: [PATCH net 2/2] qed: Fix qed_ll2_post_rx_buffer_notify_fw() by adding a write memory barrier Date: Thu, 3 Jan 2019 12:02:40 +0200 Message-ID: <20190103100240.17534-3-dbolotin@marvell.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190103100240.17534-1-dbolotin@marvell.com> References: <20190103100240.17534-1-dbolotin@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-03_04:, , signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901030089 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Make sure chain element is updated before ringing the doorbell. Signed-off-by: Denis Bolotin Signed-off-by: Ariel Elior --- drivers/net/ethernet/qlogic/qed/qed_ll2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c b/drivers/net/ethernet/qlogic/qed/qed_ll2.c index 90afd51..d9237c6 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c +++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c @@ -1619,6 +1619,10 @@ static void qed_ll2_post_rx_buffer_notify_fw(struct qed_hwfn *p_hwfn, cq_prod = qed_chain_get_prod_idx(&p_rx->rcq_chain); rx_prod.bd_prod = cpu_to_le16(bd_prod); rx_prod.cqe_prod = cpu_to_le16(cq_prod); + + /* Make sure chain element is updated before ringing the doorbell */ + dma_wmb(); + DIRECT_REG_WR(p_rx->set_prod_addr, *((u32 *)&rx_prod)); }