Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1033154lqp; Fri, 22 Mar 2024 03:43:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU8Qeh6vfZu699aPDgVmqA0oSIGzOZJfWBgC139aozsXue3IeReTNXwS+kHNEj5o9oaSpVLDHjfHo2qjMqPkHEhdrEN0O7yS1BOiR900g== X-Google-Smtp-Source: AGHT+IGCOvv+ZW1axkekd5uSSIg1oAkf2FmBz1vCNLVij734MwanYHCablfauEXUHylWWUxG6K9C X-Received: by 2002:a05:6808:13d6:b0:3c3:b7d1:a33e with SMTP id d22-20020a05680813d600b003c3b7d1a33emr1505140oiw.33.1711104198175; Fri, 22 Mar 2024 03:43:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711104198; cv=pass; d=google.com; s=arc-20160816; b=Exp6HPhKQ5U+hepjUUMJBSun5H6d1nv3xmSqpH1rgtG36nSRmcEpmCPFHHcB3KqzRg u+qUQ0Uth+Cssc9uZuScLei8rRoinn5k//29XhWUggF0pxuGn5WMLCAs+2NMDH/mo7Wi M3BE90bcPmub61XiaXYgt1FT2lQBEMokmxwAfCxTPnfmwEnYXdBK3EFtfUD/ScOFSLRM vtI9w5wxAjpE74KQxxelkmHQkBMk5cq46eh13C1LSjXO8/ipayOiVpzt9whceYpsbuJ/ yXItuaf+z6JCpvf5Zhv2YYG7DfdvqK4P1E7qFI9APNwcULMtrmoo1DarHOA5nTT8OwVf b7xA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mvKhvgOCmSNef1BTKpr/gz40TYpITJicDoYfk1GQ5kE=; fh=532g2Y+/9Wzo65zrbFecIp6HW5XQoV5hjjQEHiydX04=; b=tkKs4FGg8tdD63QxavaSsorqMdrzN3iHLcSSEHk303ckpEKZN9DKgryYc2/Yue5/C+ XZ5wfcr/TpwluET9Tu43cCKXtAPJ8daEiw0bPuvVaQujp4vmGtsK9uMoVeqD78O02rk7 E90Sc+UvNwiwI6NY0JjMdKiXgpcEeJQRKlulUf/7rMRymku0YhXcwF3SSYW/aObKPERN 8N3i8qJ/hpJDDqm3VXqTmTq08C+tO19qih+gayqd9zjUkB/C4rteaki30tv/H4nHO3hy 1S1Trxd4sP58JzcspQKxEkU7ta90lntFh2Oq3EQmbblM/ZxInggGUo/RM5wQ2RSMv9Cg y8eg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="jlZfA/Ok"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-111317-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111317-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. [147.75.199.223]) by mx.google.com with ESMTPS id n10-20020a05622a040a00b00430b0ab909asi1663350qtx.759.2024.03.22.03.43.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 03:43:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111317-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="jlZfA/Ok"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-111317-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111317-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 DF8BC1C20AE6 for ; Fri, 22 Mar 2024 10:43:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 117B93CF65; Fri, 22 Mar 2024 10:43:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jlZfA/Ok" 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 392C27E6; Fri, 22 Mar 2024 10:43:10 +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=1711104191; cv=none; b=ME3zBfCJ2a350Uc4X11U0QxFk89WmRjm2hoynV0tN2+vLO8NsEgSsGWhlCr8QlriWqkYzLhz9CUS67pSoegYwuS0KWzk8CJ5r8Q7ca/UDKJD6TVScFcvfg/iNU+/NDIaI14bbSVLr8xh6p9oIr3i8qQrtUteLRLrgOoGEuue3yQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711104191; c=relaxed/simple; bh=gIU75Sab8N34yflwxn9vXeXb4fy5IFzZtVW946fjV4g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kbdSWWF1ce1g4cdU9VQYfL2oMyB8fxypXAR8G9siSCe/+Xc6dC7jskRlPEL7iYiagdkN3luuoP7i8od1/qLIkNg6cYx6qTq3rNsao8CpmOQns38szsMF811oaTXPzNyn1uIgRZ6IeSajbb92yHzV9LhoMFfje9iEzXlV7tSD+H0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jlZfA/Ok; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48BBAC433F1; Fri, 22 Mar 2024 10:43:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711104190; bh=gIU75Sab8N34yflwxn9vXeXb4fy5IFzZtVW946fjV4g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jlZfA/OkY6f1wSYV+TNcTlqIoHFpyJwc8UgryNf7aK3HaVV91TyS6q6yL7bcz50Rs atf9f+wwMjib97Ei3jG13Y2HSOLhhh4lUAvkVeQU9E/y9LhM1qoSstkFGMWE9W1qf8 XmXUxlbpjjiFC/FeFs9io/i1X18M9KyqWydRV3zWU1DXeB2yi5BrcWwSarY71HyOde HivAY11FODDdvLE1OYem89cDax2GcqPvmuDcFyAQ+wdKRctNbq+rzXTGc1z0kq27Kz x2IqJZ+oYb/KLjZGbtmVxR0tRD2actyFdDkMI1T6SdjdrL8+M+maBDWQ+h9wUilJwP aMG5F6CDgbFaA== Date: Fri, 22 Mar 2024 10:43:03 +0000 From: Lee Jones To: George Stark Cc: andy.shevchenko@gmail.com, pavel@ucw.cz, vadimp@nvidia.com, christophe.leroy@csgroup.eu, hdegoede@redhat.com, mazziesaccount@gmail.com, peterz@infradead.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com, nikitos.tr@gmail.com, marek.behun@nic.cz, kabel@kernel.org, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@salutedevices.com Subject: Re: [PATCH v7 0/8] devm_led_classdev_register() usage problem Message-ID: <20240322104303.GN13211@google.com> References: <20240314201856.1991899-1-gnstark@salutedevices.com> <20240321181133.GG13211@google.com> <9bfd0ccc-a5d8-446c-a08c-bbc36a4d66eb@salutedevices.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9bfd0ccc-a5d8-446c-a08c-bbc36a4d66eb@salutedevices.com> On Fri, 22 Mar 2024, George Stark wrote: > Hello Lee > > On 3/21/24 21:11, Lee Jones wrote: > > On Thu, 14 Mar 2024, George Stark wrote: > > > > > This patch series fixes the problem of devm_led_classdev_register misusing. > > > > > > The basic problem is described in [1]. Shortly when devm_led_classdev_register() > > > is used then led_classdev_unregister() called after driver's remove() callback. > > > led_classdev_unregister() calls driver's brightness_set callback and that callback > > > may use resources which were destroyed already in driver's remove(). > > > > > > After discussion with maintainers [2] [3] we decided: > > > 1) don't touch led subsystem core code and don't remove led_set_brightness() from it > > > but fix drivers > > > 2) don't use devm_led_classdev_unregister > > > > > > So the solution is to use devm wrappers for all resources > > > driver's brightness_set() depends on. And introduce dedicated devm wrapper > > > for mutex as it's often used resource. > > ... > > > > locking/mutex: introduce devm_mutex_init() > > > leds: aw2013: use devm API to cleanup module's resources > > > leds: aw200xx: use devm API to cleanup module's resources > > > leds: lp3952: use devm API to cleanup module's resources > > > leds: lm3532: use devm API to cleanup module's resources > > > leds: nic78bx: use devm API to cleanup module's resources > > > leds: mlxreg: use devm_mutex_init() for mutex initialization > > > leds: an30259a: use devm_mutex_init() for mutex initialization > > > > > > drivers/leds/leds-an30259a.c | 14 ++++---------- > > > drivers/leds/leds-aw200xx.c | 32 +++++++++++++++++++++----------- > > > drivers/leds/leds-aw2013.c | 25 +++++++++++++------------ > > > drivers/leds/leds-lm3532.c | 29 +++++++++++++++++------------ > > > drivers/leds/leds-lp3952.c | 21 +++++++++++---------- > > > drivers/leds/leds-mlxreg.c | 14 +++++--------- > > > drivers/leds/leds-nic78bx.c | 23 +++++++++++++---------- > > > include/linux/mutex.h | 27 +++++++++++++++++++++++++++ > > > kernel/locking/mutex-debug.c | 11 +++++++++++ > > > 9 files changed, 122 insertions(+), 74 deletions(-) > > > > Doesn't apply to v6.8. > > > > What base was used for this? > > I've just pulled git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git > and v7 was applied cleanly. linux-next is ok too. > > v6.8 is lack of recent patch 6969d0a2ba1adc9ba6a49b9805f24080896c255c > v7's patch #2 depends on it No problem. I'll wait for v6.9-rc1. -- Lee Jones [李琼斯]