From patchwork Sun Apr 18 21:11:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 423946 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A83F6C433ED for ; Sun, 18 Apr 2021 21:11:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D872610C8 for ; Sun, 18 Apr 2021 21:11:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232880AbhDRVM0 (ORCPT ); Sun, 18 Apr 2021 17:12:26 -0400 Received: from mail.netfilter.org ([217.70.188.207]:35232 "EHLO mail.netfilter.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbhDRVMZ (ORCPT ); Sun, 18 Apr 2021 17:12:25 -0400 Received: from localhost.localdomain (unknown [90.77.255.23]) by mail.netfilter.org (Postfix) with ESMTPSA id B2F1F63E89; Sun, 18 Apr 2021 23:11:25 +0200 (CEST) From: Pablo Neira Ayuso To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, john@phrozen.org, nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, dqfext@gmail.com, frank-w@public-files.de Subject: [PATCH net-next 2/3] net: ethernet: mtk_eth_soc: missing mutex Date: Sun, 18 Apr 2021 23:11:44 +0200 Message-Id: <20210418211145.21914-3-pablo@netfilter.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210418211145.21914-1-pablo@netfilter.org> References: <20210418211145.21914-1-pablo@netfilter.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Patch 2ed37183abb7 ("netfilter: flowtable: separate replace, destroy and stats to different workqueues") splits the workqueue per event type. Add a mutex to serialize updates. Fixes: 502e84e2382d ("net: ethernet: mtk_eth_soc: add flow offloading support") Reported-by: Frank Wunderlich Signed-off-by: Pablo Neira Ayuso --- .../net/ethernet/mediatek/mtk_ppe_offload.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c index 4975106fbc42..2759c875c791 100644 --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c @@ -391,6 +391,8 @@ mtk_flow_offload_stats(struct mtk_eth *eth, struct flow_cls_offload *f) return 0; } +static DEFINE_MUTEX(mtk_flow_offload_mutex); + static int mtk_eth_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv) { @@ -398,6 +400,7 @@ mtk_eth_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_pri struct net_device *dev = cb_priv; struct mtk_mac *mac = netdev_priv(dev); struct mtk_eth *eth = mac->hw; + int err; if (!tc_can_offload(dev)) return -EOPNOTSUPP; @@ -405,18 +408,24 @@ mtk_eth_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_pri if (type != TC_SETUP_CLSFLOWER) return -EOPNOTSUPP; + mutex_lock(&mtk_flow_offload_mutex); switch (cls->command) { case FLOW_CLS_REPLACE: - return mtk_flow_offload_replace(eth, cls); + err = mtk_flow_offload_replace(eth, cls); + break; case FLOW_CLS_DESTROY: - return mtk_flow_offload_destroy(eth, cls); + err = mtk_flow_offload_destroy(eth, cls); + break; case FLOW_CLS_STATS: - return mtk_flow_offload_stats(eth, cls); + err = mtk_flow_offload_stats(eth, cls); + break; default: - return -EOPNOTSUPP; + err = -EOPNOTSUPP; + break; } + mutex_unlock(&mtk_flow_offload_mutex); - return 0; + return err; } static int