Received: by 2002:ab2:6991:0:b0:1f2:fff1:ace7 with SMTP id v17csp252214lqo; Wed, 27 Mar 2024 11:58:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXhIZrmW4Gh9lOYZPs+hh7cqU+PNYAqBODGwPsOYpCde1liToeFUvmKNK4PZwiy/iDaYRXWZWhXgGO7DJIu1xP3z0aPtqUOtekDzKBa9A== X-Google-Smtp-Source: AGHT+IG52c0hYBv/7kUuGu92Mf/BnwwJAWh7gP0SXonj+HjNcFbDqg1EwDifWUv4aAQxjXpdctj1 X-Received: by 2002:a17:906:1997:b0:a46:ead8:21d5 with SMTP id g23-20020a170906199700b00a46ead821d5mr220110ejd.64.1711565911865; Wed, 27 Mar 2024 11:58:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711565911; cv=pass; d=google.com; s=arc-20160816; b=bJyovMygaz36R6p2eot8HY6KTA4o95NQ00IEeIFSaslH41VtFQBECZOGVODQIETaGK NbuZGMO2t7eRNPjG6QiDQc7ubySIAhVDG8n51DPVxcgfG7qdmtB5UO0yrkF6t4oOKmu2 TS9tP4KmDPqD7S8B7Y/TjPwU6WmA/wpH1E5E7LC0E6gXWu7OEnJ6ZqzzLUWoBB4V9ijS t9VCZzGWgeHP7wKv9E9/eKuSEGN9YGVPL1HCr2uyZLVLLu7/+hc9sBYdW2CNU7G7o9zc rRxDwdR2zhsuRepOlagOrabjdaxD12ayoHB1+JEhZg1PiJTaB6B78vLNjVaMP9p3mBhn R2hg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:message-id:in-reply-to:date:references:subject:cc:to :from:dkim-signature; bh=czYHTrM0wtAxG0LIQv6vcEczY0Ry59Oqi5ztIyvRl+w=; fh=t5e1Jsj0G4qFSjoYW1RjtNTWMzoezlwo89yeYSELtGw=; b=GkMd0G8ZS+faTBothns4TF6AwpGK3b4P2a4ecDrhtQ4qZmWdj2d1O+pPBuT7jCh1FJ g6DclYTaycKQf4dFEOSUGQBPhvXRg95w+st86o51mrbZMHPWrO3ieoO8JdfAlu4SOvFA B2FBI8O+NvatPDyvdLY0Cl8MATufdBSEfpjUR8gIM+DdnVqXbqP7GlozBROBp8U5Y6uP xMrEjEDjsXf+czLNCIYbsCe/qkkksVbeNK+B9XOAIcv6xfEd5TJb5P3R6Lo+2BEMpcuf 2Kn9MWUx93labt0mGakPhIidi5m1dd3d8uvooqYUUaHAY9FJTq5i/xT9JV3/r98MNu7C RpPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JzcAO3EW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-5393-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5393-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hu10-20020a170907a08a00b00a48475a0ee1si3710455ejc.547.2024.03.27.11.58.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 11:58:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-5393-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JzcAO3EW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-5393-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5393-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 am.mirrors.kernel.org (Postfix) with ESMTPS id C51471F35404 for ; Wed, 27 Mar 2024 18:49:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BC89612DD8C; Wed, 27 Mar 2024 18:48:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JzcAO3EW" 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 9860112A144 for ; Wed, 27 Mar 2024 18:48:56 +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=1711565336; cv=none; b=Vhcp00yPL6bm3pVd/J4ensD104J5Orjz5D/6V8gTA8XU6Gl4YYjOiqY+vLE6087Tz8zPJL5ZKAe3Rsru7al69Pd2nS1M4Stnai6IaRRlqehNdLTXGNhJ44I+cF+mJnq9G2U/eiXCpBya8/qq2JMw0/te5DbH6f1GhPCApC1UoaI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711565336; c=relaxed/simple; bh=PJj5tJI5Uq0v6Gm5m6XtsNrMIeh/6WHKpLNA5pIoB5A=; h=From:To:Cc:Subject:References:Date:In-Reply-To:Message-ID: MIME-Version:Content-Type; b=FLszLUmHTdSA2HjuBZfghhTj2+q8I1TF6mthLJn1JLtDEYEYV/GDgePin5e9tIoTyV30ASv5NAjGRhmirfvicl+zfeOgvneM7EpcAGe2HK98MGGwL2TudA3Ra/7l5Um/g2JsgjS5RO6zyNkFA8zkEK1EQQjizLahY/EI9RjRibw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JzcAO3EW; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF8CDC433F1; Wed, 27 Mar 2024 18:48:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711565336; bh=PJj5tJI5Uq0v6Gm5m6XtsNrMIeh/6WHKpLNA5pIoB5A=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=JzcAO3EWJbcibtBQdyVXlE2JG9Tt32Rw3UqYyB6G+D6wIKya+59uV2LgKG0OY8kDR 6OMmNhpDSMPRt8UZRsUMgwcgtaUJ9O8epS1je1vBD5xOl6Z5+VLvk26Ms+1KkRt99g RE6xausnsYZ3ZJJtOYkQq6vUQAXmX47sPgI0SvoSSkk1X9gGkaKCMJU4gGqCJUEG5N ytyeg/9G0i6Rou2clV68jQ8b55Q74x5sJ5PzncArxPSeIyO6AtLIL8h7vRh95DCl53 LMuvfU9mNfrgTCsnwtWh3kDssetDD0ThlPLp3JAPVF7bdOzZi0/fUvfU5NbTJeiLaT rJqQL0aLInu/g== From: Kalle Valo To: Bitterblue Smith Cc: Ping-Ke Shih , "linux-wireless@vger.kernel.org" , "Larry.Finger@lwfinger.net" , "s.l-h@gmx.de" , "chewitt@libreelec.tv" Subject: Re: [PATCH v3 11/12] wifi: rtlwifi: Add rtl8192du/sw.{c,h} References: <7f4b3309-1580-48f3-9426-29f1eb4052fd@gmail.com> <2eb79c8c-cf2c-4696-b958-e8d961628e17@gmail.com> <66565618-3638-47e5-afe5-3530214da0c9@gmail.com> Date: Wed, 27 Mar 2024 20:48:53 +0200 In-Reply-To: <66565618-3638-47e5-afe5-3530214da0c9@gmail.com> (Bitterblue Smith's message of "Wed, 27 Mar 2024 16:07:20 +0200") Message-ID: <87ttkrzf1m.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Bitterblue Smith writes: > On 22/03/2024 08:04, Ping-Ke Shih wrote: >> On Wed, 2024-03-20 at 21:43 +0200, Bitterblue Smith wrote: > > [...] > >>> +DEFINE_MUTEX(globalmutex_power); >>> +DEFINE_MUTEX(globalmutex_for_fwdownload); >>> +DEFINE_MUTEX(globalmutex_for_power_and_efuse); >>> +DEFINE_MUTEX(globalmutex_for_mac0_2g_mac1_5g); >> >> The consumers of globalmutex_for_mac0_2g_mac1_5g are complex. Why do they >> check mutex_is_locked()? Race conditions between two instances? >> > > I couldn't think of a sufficiently short name, like > "lock_mac0_2g_mac1_5g", so I used mutex_is_locked(). That's probably > a bad idea. It should be like this: > > /* Let the first starting mac load RF parameters and do LCK */ > if (rtlhal->macphymode == DUALMAC_DUALPHY && > ((rtlhal->interfaceindex == 0 && rtlhal->bandset == BAND_ON_2_4G) || > (rtlhal->interfaceindex == 1 && rtlhal->bandset == BAND_ON_5G))) { > mutex_lock(&globalmutex_for_mac0_2g_mac1_5g); > lock_mac0_2g_mac1_5g = true; > } Few quick comments, I haven't reviewed the actual patchset yet: The mutexes look too finegrained and makes me suspicious about the locking design. Having global variables like globalmutex_power is a big no no. They would not work if there are two devices on the same host, right? Conditional locking is usually something to avoid. I'm starting to wonder if extending rtlwifi is actually the right approach. We have modern drivers like rtl8xxxu, rtw88 etc. with better design. -- https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches