Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp556550imi; Fri, 22 Jul 2022 04:58:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sc9bKHm2nn4EIjomuev5651xpCxVaKRBl8Y3MpcB00TxdIyqw+tx+Qwhfbd2g53dtFuj1p X-Received: by 2002:a17:906:6a14:b0:72b:64bd:ea2b with SMTP id qw20-20020a1709066a1400b0072b64bdea2bmr191450ejc.680.1658491094142; Fri, 22 Jul 2022 04:58:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658491094; cv=none; d=google.com; s=arc-20160816; b=m1+Zp+Kwd4QIO+7PBZ/ooUClRevuelw5s4XIiq7cUxi9dilu0hjvHTHmfEhl3EGRFZ dWUKhyMOa1rXNqFEREzpSjcFopfvJi92ET4ILR84iN2UQflsg1encSOXK2YwmJ4hJBaX 1WCKzXmvAV9Z0RKeXsI8b7bn2ownbLqdLhWPJv9jMvWliMssUM2Vf2N3osZbeRa4uE7J K8Vq+je9F89Rk1Co4aoNcsTgjeMpMNLfOpkuwSitCFGurIjn2vTjeDlwLArI61FJ9dep BI5B6FqNHko8uvJa84aPjEed2MbBvR9w6YElZ3g8Qj8DiJ0uYuFMB91XLr8pnsxMq6jh EG6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ByHDj6/WZNLvf+U8I4CMzhK6/AcSzDl8NnQYMdbCHC0=; b=vzVE9zX9gb3ybS2SZj6hFomYzA9kYHel5r4jKfdBXaUxWzoRVIXE1pTxrZJpL2tGKy yN887KWbnm1TCiGQ3YwD0WuKVS7paxPyv29CkkbHICo/4bqUg59gRYZ6SB1bIhgLuQe0 q7ngLEzBnjSwcNN1KbEAL8lub1sM+ZTlj7d/ZolWa9xnmlR74cLrJpQYfh6WvZfW5EHf plKRnJJKEfPdLfsnuZwxpHdiSmL2DeZQ9MtkPlVe9IgPnG5xu/DwMslSymxlQa0gCv9H bbZ9Kq58Er9ZPf1xlyovIJgaD8zhS9oXuUQR+0WRkPtZSrJVMj5psWT2j4hXy0PoHh1f 8U4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@pqrs.dk header.s=google header.b=FSMwh2vz; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb10-20020a170907160a00b0072b394cb930si6087465ejc.784.2022.07.22.04.57.54; Fri, 22 Jul 2022 04:58:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@pqrs.dk header.s=google header.b=FSMwh2vz; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235079AbiGVL5E (ORCPT + 65 others); Fri, 22 Jul 2022 07:57:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234744AbiGVL4z (ORCPT ); Fri, 22 Jul 2022 07:56:55 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72952A9B8C for ; Fri, 22 Jul 2022 04:56:53 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id z22so5553226edd.6 for ; Fri, 22 Jul 2022 04:56:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqrs.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ByHDj6/WZNLvf+U8I4CMzhK6/AcSzDl8NnQYMdbCHC0=; b=FSMwh2vz58WxOv5apuHGTlYbe8dQNKcB8eRfB22RfKdiB3t/ALd2FrPamvdCAh0gbW OQwuReunohVucJw3yYODEQzuMUfykVnM1DMctWhXxEwmPfXTgRhkb2h2lhnojwZ6i9YH 1nCNf7qLZ4/MiX9uPvfYxBjXPafrojGA14pgY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ByHDj6/WZNLvf+U8I4CMzhK6/AcSzDl8NnQYMdbCHC0=; b=YWd7n91ns1+bHwmPCUVpMzm0A0I1GFBXQUGF5h3YVYUnCcAuRcqiwArBlkR/+uhGvv vHu5CQSLvs2iJDmE+JVhT7QfrVUz2ZBlEYDGLAAMjz4DVwswSc19mgMFO2QFrYeIaipg KKrYFVUJRwTY01+Dkd7BWpohZUtA0j7vkazpR0H/LWrGTVk5VHXzPtC64/UNleJ0Ij/g 40TQhdblYyhvHvxHsd7MvZjWRtG0LHFl6aMHwTGJDHjm1lKOs0DnajPr38FGIOGclZsO fJ6xCc4ITSGDfCjHTSpJCFJbj+H6L/yxZo3DJVx+eygwdBRm0qVdn+ZCDgYjq/tdUyFV qwGw== X-Gm-Message-State: AJIora/MrxloQYaDG3ZPMqaG+WQKiBz341MmYJT7nP9AftRz93U7uiL6 A0bYSln2KUOrGWAEmu44EbWhKw== X-Received: by 2002:a05:6402:444c:b0:43b:d375:e932 with SMTP id o12-20020a056402444c00b0043bd375e932mr226594edb.399.1658491011990; Fri, 22 Jul 2022 04:56:51 -0700 (PDT) Received: from localhost.localdomain (80.71.142.18.ipv4.parknet.dk. [80.71.142.18]) by smtp.gmail.com with ESMTPSA id kx6-20020a170907774600b0072b3182368fsm1934370ejc.77.2022.07.22.04.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 04:56:51 -0700 (PDT) From: =?UTF-8?q?Alvin=20=C5=A0ipraga?= To: Arend van Spriel , Franky Lin , Hante Meuleman , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Wright Feng , Chi-Hsien Lin , Ahmad Fatoum , =?UTF-8?q?Alvin=20=C5=A0ipraga?= , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, SHA-cyfmac-dev-list@infineon.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] brcmfmac: fix scheduling while atomic issue when deleting flowring Date: Fri, 22 Jul 2022 13:56:27 +0200 Message-Id: <20220722115632.620681-3-alvin@pqrs.dk> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220722115632.620681-1-alvin@pqrs.dk> References: <20220722115632.620681-1-alvin@pqrs.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Wright Feng We should not sleep while holding the spin lock. It makes 'scheduling while atomic' in brcmf_msgbuf_delete_flowring. And to avoid race condition between deleting flowring and txflow, we only hold spin lock when seting flowring status to RING_CLOSING. Signed-off-by: Wright Feng Signed-off-by: Chi-Hsien Lin Signed-off-by: Ahmad Fatoum Signed-off-by: Alvin Šipraga --- .../broadcom/brcm80211/brcmfmac/flowring.c | 5 +---- .../wireless/broadcom/brcm80211/brcmfmac/msgbuf.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c index 096f6b969dd8..e1127d7e086d 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c @@ -419,7 +419,6 @@ void brcmf_flowring_configure_addr_mode(struct brcmf_flowring *flow, int ifidx, flowid = flow->hash[i].flowid; if (flow->rings[flowid]->status != RING_OPEN) continue; - flow->rings[flowid]->status = RING_CLOSING; brcmf_msgbuf_delete_flowring(drvr, flowid); } } @@ -458,10 +457,8 @@ void brcmf_flowring_delete_peer(struct brcmf_flowring *flow, int ifidx, if ((sta || (memcmp(hash[i].mac, peer, ETH_ALEN) == 0)) && (hash[i].ifidx == ifidx)) { flowid = flow->hash[i].flowid; - if (flow->rings[flowid]->status == RING_OPEN) { - flow->rings[flowid]->status = RING_CLOSING; + if (flow->rings[flowid]->status == RING_OPEN) brcmf_msgbuf_delete_flowring(drvr, flowid); - } } } diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c index 174584b42972..cec53f934940 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c @@ -1400,22 +1400,24 @@ void brcmf_msgbuf_delete_flowring(struct brcmf_pub *drvr, u16 flowid) struct brcmf_msgbuf *msgbuf = (struct brcmf_msgbuf *)drvr->proto->pd; struct msgbuf_tx_flowring_delete_req *delete; struct brcmf_commonring *commonring; - struct brcmf_commonring *commonring_del; - + struct brcmf_commonring *commonring_del = msgbuf->flowrings[flowid]; + struct brcmf_flowring *flow = msgbuf->flow; void *ret_ptr; u8 ifidx; int err; int retry = BRCMF_MAX_TXSTATUS_WAIT_RETRIES; - /* wait for commonring txflow finished */ - commonring_del = msgbuf->flowrings[flowid]; + /* make sure it is not in txflow */ brcmf_commonring_lock(commonring_del); + flow->rings[flowid]->status = RING_CLOSING; + brcmf_commonring_unlock(commonring_del); + + /* wait for commonring txflow finished */ while (retry && atomic_read(&commonring_del->outstanding_tx)) { usleep_range(5000, 10000); retry--; } - brcmf_commonring_unlock(commonring_del); - if (!retry && atomic_read(&commonring_del->outstanding_tx)) { + if (!retry) { brcmf_err("timed out waiting for txstatus\n"); atomic_set(&commonring_del->outstanding_tx, 0); } -- 2.37.0