Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2831460lqp; Mon, 25 Mar 2024 10:22:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVYz/EVNChCvDF0sXUhJ12tvrkLKUorZQSvKBJU6qLyr6sjU4gYBD5P7p48unFBZeecggzgMJ7QfRWxWma5dqcvVLP101Chy9BGA9+yeg== X-Google-Smtp-Source: AGHT+IHDKEt5F8UGc30yy+TvDIaMNLlg9OGzS0LEMSkXFpsy102zzKVqJ2hTP3iSiaEMpR1HNXvU X-Received: by 2002:a05:622a:47cb:b0:431:3d2a:ad2c with SMTP id dp11-20020a05622a47cb00b004313d2aad2cmr9712537qtb.6.1711387373235; Mon, 25 Mar 2024 10:22:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711387373; cv=pass; d=google.com; s=arc-20160816; b=mDN4XBd7MqXFl5KeF/ZPEQtX3RqzWnO5Z4P4iiDGBhMap71cWSO4qqSBoNfYeBvPNS QwgfVbStBMfRUlhbxKtAyVeUpntcU7yqHId+CnXdddmDEvKWap9uNW/7Wm+dZWXhFRox 36VwECuzn034LlTC7hnTNFNYdq6+sgHkKaHk+dX7XA0jPp41NT3RVTXH0GY2X69Fhgxh rL8+ZvKzErs8lmHLID1GUoFpJm4CY3JHXqIBudVUCnMXkzjQJEv2JpO+i3HnMXtYnQFP SkNk4GmG452uo4UUTQoJ5tzvZvJ4sZZANfvguLg9ZqfTFCDDrZjncJhFfKf79Tn+mdlw Wv7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=VP2D/abnVwnMI0ca689bjP6E2w2/Z0tNlagWpbAQusc=; fh=pegCnw1n517BRFKuFQ2sxAAC52QjGBSrPmiRQc9uhx8=; b=iRc5mWDgu9pywXjiefdoEnmlwufqd8wXq86uSWEgB6aaN0S+wr9hUD0pdvQH/1JD4v 2AQYx5Nt0vyPQLRI3l6IbOSLZQpyDIqCYIA83dlK0ZtG8qeiSo/mFL7cmUEVx7AmODUi FoqS2n7WHeMiUEn5d9pgVN+vC8i5swFBSGYEtthvdPICP0FVSZ/5uZ9y/xHP+T3AE55T 7yMCJ0bnWCmMhGJzK71qz85enX6PCVyFUqhqWu5Ry9D/WYxGo+RT8LWoSY5G6qOAwGU7 5/DbunxTCdUhVlYeC5foylMdlu9dLXDGC7Ovc1RG2d50lH7rlA9xbgplqJ8xFS3VXOPD LdAg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vNQUPOgo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-5215-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5215-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id fa15-20020a05622a4ccf00b00430d4945bd5si5996215qtb.572.2024.03.25.10.22.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 10:22:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-5215-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vNQUPOgo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-5215-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5215-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D9B931C3C8FE for ; Mon, 25 Mar 2024 17:22:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CDDC6129E8D; Mon, 25 Mar 2024 16:07:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vNQUPOgo" X-Original-To: linux-wireless@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9F6912A163 for ; Mon, 25 Mar 2024 16:07:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711382847; cv=none; b=KXuNy1Vijf77OGzKMdwE4A2HcvjRWC4O8rTntKrKI9rO0uVdoHxy8CO4mRS5MQFhWI1huHLYauw852wg3s7HKCmi7QSkwz7cWU1CUHIRdM+UNosBDrJ9+eu8jRSK3OnFOUZTbyDtd9lCvfAl4Enjp+qtOENFT8V9/3MATBDN1wY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711382847; c=relaxed/simple; bh=lhtgjswdAt3dPhPOjQVossLy0Om7Cz4LSE9rk1bfwwo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=KThtHn7ucfgdnda659Yu+p28RKas7k9UHmt3oyLHr2k0atMYwgYiTL+i9dqIRNEV0d1/pklSdudU2IKwcR9h85frfKKbSczjaH3u4frD0fBoOR+tWt+8Re3WPws6MQVUOQ00XlDxq/mM8nU7TEk414aA+FSGdXUeNmj6kBRMcPU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vNQUPOgo; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E178CC433F1; Mon, 25 Mar 2024 16:07:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711382847; bh=lhtgjswdAt3dPhPOjQVossLy0Om7Cz4LSE9rk1bfwwo=; h=From:To:Cc:Subject:Date:From; b=vNQUPOgoQvaB8Y2fEAKKpGkcTORMP39jmR/TTIDrpLY/3Hyez4QEVopW53zoacobL 2WVx54LH3Zl95WsOav7lQyR8gtSW2P+9k/p8AryOlhbqp98M14R09YQQ8UVX37Mx86 OphXVsFz0Q/vdCUBv/Quaic1dlY89+Q5NPuC2+G4+YwEdIxxis74IMsi1jr2fY4YqP Zl5NgxYbgjwnYD15ZfPi9NuEKgJLg7bi729pLXisKtOoYbfqwHog5gC+J94VwRG852 jfHF5Ch82oIQ/TazqJzSLd+YRw7qZ3XCLWaSOwuJjG2Xy7GOvnI7LPEaNv/j6CiMRo RAMQP46nti0Vw== From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org, sean.wang@mediatek.com, deren.wu@mediatek.com Subject: [PATCH] mt76: sdio: move mcu queue size check inside critical section Date: Mon, 25 Mar 2024 17:07:16 +0100 Message-ID: X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Even if it is not a real issue at the moment since concurrent access to mcu message queue is protected by mcu mutex, make the code more robust and move mcu queue free space check inside queue spinlock critical section. Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/sdio.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/sdio.c b/drivers/net/wireless/mediatek/mt76/sdio.c index 3e88798df017..6198906946f5 100644 --- a/drivers/net/wireless/mediatek/mt76/sdio.c +++ b/drivers/net/wireless/mediatek/mt76/sdio.c @@ -548,10 +548,7 @@ static int mt76s_tx_queue_skb_raw(struct mt76_dev *dev, struct mt76_queue *q, struct sk_buff *skb, u32 tx_info) { - int ret = -ENOSPC, len = skb->len, pad; - - if (q->queued == q->ndesc) - goto error; + int ret, len = skb->len, pad; pad = round_up(skb->len, 4) - skb->len; ret = mt76_skb_adjust_pad(skb, pad); @@ -560,6 +557,12 @@ mt76s_tx_queue_skb_raw(struct mt76_dev *dev, struct mt76_queue *q, spin_lock_bh(&q->lock); + if (q->queued == q->ndesc) { + ret = -ENOSPC; + spin_unlock_bh(&q->lock); + goto error; + } + q->entry[q->head].buf_sz = len; q->entry[q->head].skb = skb; -- 2.44.0