Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2679006iob; Fri, 6 May 2022 08:09:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL3beXls11PptL/tQ+kJgkD6ggpVUsl+O1IMH3bpM6VYgehUKPRWRsdI1hMRJy2jRB6nqe X-Received: by 2002:a17:906:6a14:b0:6f4:78b8:39e7 with SMTP id qw20-20020a1709066a1400b006f478b839e7mr3265175ejc.309.1651849780997; Fri, 06 May 2022 08:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651849780; cv=none; d=google.com; s=arc-20160816; b=uYr5dxFAGa7cGR6q/XPKerwABYMlMfXRZF3KP9bLqAkPfC1CnyeyiB8lEdFqljUjJN tg58qwNEz1v4sZDKgySD4JHiFZ49NDbLb8gxiAyi2MtTPmu60J5vmJAHgpymaoDOtavE qir8R8+Sb2nZwrOtH5tJQlt+dMBXvacJ9k2nXt+fsrmht2QTNWtmwvvej++p65r2kFw7 Ei7QXQx0X+wSCSlmTSdxGA1mgM1zAxUFWlRqT76nMF/J9p9dg7/QtkcjKeSr+VUbp+tw LeSHST9ZJGG14l/ShQw/s8fcGlW1NfvZbB5W+P9lsC3xk/48IDtoxaXC24bf87UPeeLl w6vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:subject:cc:to:from:date:message-id:dkim-signature; bh=Kq7x0iDA7TltEgWIVyJIVQzjWE+OkQEjaVsIe6ZS4Ao=; b=Ig0ea6rR8i8w8RU1QE+CJmTXj8jXaBOvFBkWOh1mfr2Py6H/dZLJKNbpc2PaQ+teAQ L1Xf3y0dX+qY9Ar2x6qanLWiVHQhgJQxKncsb4Wf3k5CuCuQgmy5EIQlksqsjLO6RyVx 8XGnPSisknX7DG4O/CXoU770fMne4RJ27H2VyCX7/K7mhD/z+z/mdt2ANsNKPRCO9Ixq bP/zfGz0SpAKDAXepRjeIo5P3obW9CIApfad+aKiLPpEFOCR3ToZ5+x/XtCEKVemGd6a DmLeEEoXowkRc/ToSLQu1QAJTHy48iJqiKbcXiHjpUb1Yclcx8f6u59TdCL0FAQh4K73 uvOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=E5w5ThkW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id og20-20020a1709071dd400b006f4ad735708si4628831ejc.750.2022.05.06.08.09.15; Fri, 06 May 2022 08:09:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=pass header.i=@gmail.com header.s=20210112 header.b=E5w5ThkW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380734AbiEEOrb (ORCPT + 99 others); Thu, 5 May 2022 10:47:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232677AbiEEOr3 (ORCPT ); Thu, 5 May 2022 10:47:29 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55A1756F98; Thu, 5 May 2022 07:43:49 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id y3so9120868ejo.12; Thu, 05 May 2022 07:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:from:to:cc:subject:references:mime-version :content-disposition:in-reply-to; bh=Kq7x0iDA7TltEgWIVyJIVQzjWE+OkQEjaVsIe6ZS4Ao=; b=E5w5ThkWzWHdHiANATxpXQPoCQYWruSW9bUtwe/DD+19o5bVlmRPjugZ9g5gY4CpV4 +WZjTL+smXPm4544qoIoKJo16QKfwBZmoQfZKEzDLkLpCrTVDjLkQhWw3E7Le9q7SiUA 1qwkU5ivdlBYmDvvHPhJmtvLtV2qQDACHnMhYEUcA3QGBSmifpbx5RI416Y+8i4eeT8H Me35vSAeRIRmFoes64+5prFJ7auN7ID+wN5YF3QBS9QrbPCZliOATskun5bkEQWIraUj hDTlK7ngJ3NH/i9dAzR6Ctr6tWz9h77CYdV49/ow5R9O1/lfBi3b0l+zruwchO3KHhwf 2AYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:from:to:cc:subject:references :mime-version:content-disposition:in-reply-to; bh=Kq7x0iDA7TltEgWIVyJIVQzjWE+OkQEjaVsIe6ZS4Ao=; b=XdO8k5hoVbLVQ/TyxKXXO7zh98u0YUnnQIAZHn3xWcKVyTBo35k8Xw+b6Pm6RKXc1h WJ6fuQT7cVdKCHK+eNM7EUxenlcI1NNlTBDxQkclEaj5uG++o0T/pvSpD69uglk7doBr +ht1BfEHI4lNoQyYX7mXyLwxfGRf+gZpvCq4o2ZjnzuQ0VztdQiTVQJKse7qOpGlKkCU 8mPjQOpvyQ0FQWXiNIqg3vZ8qijkfzI9B5cZ099p1GXn/15GqsenWqYjkdUW8CIReb9z sVAjWcehh2G60H2q5i18TZLqd7Pm8+wnXPXbFP02P+ujyAwvkkZnaHp9VG6MSSke01Yo iKrg== X-Gm-Message-State: AOAM533TZdQo6hVnhRB4Dkff/i+G2P4doPHk/TpVr3Llo36oMTFEXBT4 SXmWUJ5u0Wu1AbmZzSm3bVA= X-Received: by 2002:a17:906:5d04:b0:6db:7262:570e with SMTP id g4-20020a1709065d0400b006db7262570emr27108890ejt.8.1651761827682; Thu, 05 May 2022 07:43:47 -0700 (PDT) Received: from Ansuel-xps. (93-42-70-190.ip85.fastwebnet.it. [93.42.70.190]) by smtp.gmail.com with ESMTPSA id jz11-20020a17090775eb00b006f3ef214e51sm793855ejc.183.2022.05.05.07.43.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 May 2022 07:43:47 -0700 (PDT) Message-ID: <6273e2a3.1c69fb81.55947.477f@mx.google.com> X-Google-Original-Message-ID: Date: Thu, 5 May 2022 16:43:45 +0200 From: Ansuel Smith To: Andrew Lunn Cc: Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Pavel Machek , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-leds@vger.kernel.org Subject: Re: [RFC PATCH v6 07/11] leds: trigger: netdev: use mutex instead of spinlocks References: <20220503151633.18760-1-ansuelsmth@gmail.com> <20220503151633.18760-8-ansuelsmth@gmail.com> <6273d126.1c69fb81.7d047.4a30@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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-kernel@vger.kernel.org On Thu, May 05, 2022 at 04:21:54PM +0200, Andrew Lunn wrote: > On Thu, May 05, 2022 at 03:29:09PM +0200, Ansuel Smith wrote: > > On Thu, May 05, 2022 at 03:10:21AM +0200, Andrew Lunn wrote: > > > > @@ -400,7 +400,7 @@ static int netdev_trig_notify(struct notifier_block *nb, > > > > > > > > cancel_delayed_work_sync(&trigger_data->work); > > > > > > > > - spin_lock_bh(&trigger_data->lock); > > > > + mutex_lock(&trigger_data->lock); > > > > > > I'm not sure you can convert a spin_lock_bh() in a mutex_lock(). > > > > > > Did you check this? What context is the notifier called in? > > > > > > Andrew > > > > I had to do this because qca8k use completion to set the value and that > > can sleep... Mhhh any idea how to handle this? > > First step is to define what the lock is protecting. Once you know > that, you should be able to see what you can do without actually > holding the lock. > From what I can see in the code, the lock is really used for the work. It there to handle the device_name store/show and to not remove the dev while a work is in progress... But I can also see that on store and on netdev_trig the work is cancelled, so in theory the problem of "removing dev while a work is in progress" should never happen (as we cancel the work before anyway). So I see the only real use for the lock is the device_name_show. > Do you need the lock when actually setting the LED? > > Or is the lock protecting state information inside trigger_data? > > Can you make a copy of what you need from trigger_data while holding > the lock, release it and then set the LED? > > Maybe a nested mutex and a spin lock? The spin lock protecting > trigger_data, and the mutex protecting setting the LED? I need to check what can I do to move the configuration phase outside the lock. Just to make sure the spinlock ot mutex conversion is not doable cause we are locking unter a netdev notify or for other reason? > > Andrew -- Ansuel