Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2118129iob; Thu, 5 May 2022 16:22:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfAJZCIYiebfYUff0JkRM40HwW2GEgK1kAKSEv54Ly6Lqs9gKEcrnsW6LSRMAE0ou/8JK7 X-Received: by 2002:a63:e649:0:b0:3c1:d54f:fc4b with SMTP id p9-20020a63e649000000b003c1d54ffc4bmr411266pgj.374.1651792925510; Thu, 05 May 2022 16:22:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651792925; cv=none; d=google.com; s=arc-20160816; b=WMJYb/6C5bF/QgVcRfEXpoc2V+SgppRhpIXWoDNz0tUcdANqhJs+AODYKZM1diF+zz 1bxmwD7ia7rJWlcbV1LkvZbd+zfOcjXLdFkG7E014s255aZH0MzdICSi/AvXDIbMGlV7 8h6875QUUbfepWGIFpVEABjAF/j+wtqTt6HUY1bKMDaN4T3jyfoJ6IxXJNDtDfwGVgrd /+90IcSIoQ1G5wsk+RajmavkTvOjzWGe66nUOZQS9OvxteRwi33AEjrpK1Wqu8pkJwMA zznt98KEHTY9tmS2P+j3KIIgAunR6Df78DupbelrgaRMYdrFOj5KnmijImlCk6lv2CSN 4oMw== 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:message-id:subject:cc:to:from:date:dkim-signature; bh=nd7QNghQW8LARprbqtCzIE+R5+NJaXA4ski1ugmRTkM=; b=Dgn7GEzpzjMiAb3cIW6i8cmucwgPrSe3c0ulhnkdix5oFsScYTAnmuJil0x68FrsWN KH9dnJUNuJaFh3pwo2pMj6C7XdGvvm3DevMBsJYbxATwuqUAYfuX4MK0bpa9YbUx/pBe hCudWQCrqssCP2TzjIhMwnXi9Z8yxDnBoB/MEtILE1rFRDDp76/71xmyyjTKaTZvfog6 Ab4TL49KJuYLJLEicVkkz00mVST+EfBZbM5w2rHWw5sxqALhcu/NkFe1eRk2yDXBj6aa tsRn7hPgi963HZ9ryhccMCSMAv76rppG6S5aXlD68slFcvtIQN9M8B9NBKjmtkNY+Qcw f3uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=UhKdPC9O; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j131-20020a636e89000000b003a2b62df230si3006609pgc.772.2022.05.05.16.21.50; Thu, 05 May 2022 16:22:05 -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=@lunn.ch header.s=20171124 header.b=UhKdPC9O; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380564AbiEEOZs (ORCPT + 99 others); Thu, 5 May 2022 10:25:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380562AbiEEOZn (ORCPT ); Thu, 5 May 2022 10:25:43 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [185.16.172.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 028225A59A; Thu, 5 May 2022 07:22:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=nd7QNghQW8LARprbqtCzIE+R5+NJaXA4ski1ugmRTkM=; b=UhKdPC9O2krISj7KyPErZVIFze 5Hdt9X/vLTlYnLknZvrGnD58ETP7dTx9tEwgEdk5WDeoLcd3CEpadGYa9djMVHVrCSCufHlvQc/tu w2bCfA1FKnpzjSNVFPgnUabDSDCRiuIsaHWt8xgivElTF1pdYmqdRQnwKtn2N+V0meR0=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1nmcMc-001NCa-1K; Thu, 05 May 2022 16:21:54 +0200 Date: Thu, 5 May 2022 16:21:54 +0200 From: Andrew Lunn To: Ansuel Smith 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 Message-ID: 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: <6273d126.1c69fb81.7d047.4a30@mx.google.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,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 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. 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? Andrew