Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3715843pxb; Sat, 13 Feb 2021 06:58:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxkYfO5vrrEXdo1YLNmqUUWLlvjJUFjIxesQ+D6gKgzj2GhQbLr35nqj3hSvB/YVPofzWsH X-Received: by 2002:aa7:d901:: with SMTP id a1mr7982733edr.120.1613228295646; Sat, 13 Feb 2021 06:58:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613228295; cv=none; d=google.com; s=arc-20160816; b=kJM8NVtr0i0xFNkETIPKeUuNDC+nTXb6+jZFKLm/kT45yyuwBrjaDlhSnbFWkIiXqd NzApVBm1jGGh4jhHQXlOhBGltvEOH+DlBL5ml5JuYMq3Q9TyJUsNI1c3s0dWkgOU6XFN tzIK1iCXpyjV1ZDoVAHLGHkpfzKjBWNt0fuPCzYicctndTaWLEnqepe8DJ12Q9Ef0+Wm WWHXjej74q/jaAwvCmQTtazlS8zIr35+AEdOmXGYR343FGuGaSuAl+S43JVLr62yCHi1 l7/2tONYo2XltWR2ajdcgxI6r4nUbdoxA4qrxxDp9O/qPWaJlCLfz8pblW9MspgUcpE/ AyYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject:dkim-signature; bh=l4ytx6mSORryC9/ckDkwUt9Y5elBZy+A8DMLR/SeLFA=; b=dohXZDpgMNIDftCgaCK8EZOEUoOFBGLH+0WSCS192XSc7yC+pJLfa/qMSEx/bM/XWU 9cf5ZJPtTQNAiy+xjOycyaXirB9d+z1NHnzdl4GTBDOOR2V6cMjqgUEDsg2UXfag+t1e YiIgphpM8KBH549XYJwJquHs9iuWMnHG9DnBYsx8c9bxdXqSbqzWpQjeifiViRmge1yN 2GKKbYVZdgtB7Qyxkv+45HHS1KmJY8FaFbD5PoU8vfHtgReXDgjLVyifIoiRhcMma4jH 8utmtufjtz8HhzQEaxm9HaaHbCBdv45e2uwduX0Br3p93A45ONpeemvw6l9XSULzeXJO /TlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YkBb++Fq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw10si8785530ejb.36.2021.02.13.06.57.36; Sat, 13 Feb 2021 06:58:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YkBb++Fq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229690AbhBMOxm (ORCPT + 99 others); Sat, 13 Feb 2021 09:53:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24273 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229674AbhBMOxj (ORCPT ); Sat, 13 Feb 2021 09:53:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613227931; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l4ytx6mSORryC9/ckDkwUt9Y5elBZy+A8DMLR/SeLFA=; b=YkBb++FqeCQexIcmLPVkI5USioZuspB2wIiOToCT7mhsRmPb5LgLGjA5vsN5KfVKGLI4Sq boDY8iQv3jbvgvt02p1HnkG+nYZnQRLr/wr/osuMwrtu129NApDYIzz8ou21qZeXHE/vLP YSXa/Vpz6Vc3eu0RNddpjhrrRj2HSXU= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-105-6MgvacdmMYWa7MPEQSoREA-1; Sat, 13 Feb 2021 09:52:09 -0500 X-MC-Unique: 6MgvacdmMYWa7MPEQSoREA-1 Received: by mail-ej1-f72.google.com with SMTP id ia14so2324402ejc.8 for ; Sat, 13 Feb 2021 06:52:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=l4ytx6mSORryC9/ckDkwUt9Y5elBZy+A8DMLR/SeLFA=; b=ZBusX3hNNMR9hrImHHirkxR3EVfW3keEOdqfd7HeWEE4Tw1zUTvIN4FgdzGCy8mAfX +dsY9lHHyLU283bsEhwkHfAttBlVRs4xDfxLuUF13VzRWDyzvMuMZ6YHLdudrFQ4AdcY CS+RXoaDndxbQ35KWS/o+ioktFeX/LJJEltqTn7u48XMMOroGQRMau7MgqfofZTXHPDU ZkgeCbvYjEoX3TquOhI73Ewjt5EIOyu9AwLUhLrk0AUL8Kgg5kS+IpgDxm3wVnGHcFFE fe9JlWhkr/ghRpfRdFxBHCvtimis14JGHPSdkXyInpeoXLS0FVIUxSo1VpTgzeSi4kfO grQg== X-Gm-Message-State: AOAM530YMuoEM5bJHRFi650sJcIal5yXWUNCwBKFtTQ6V1LG3+YBsIMs /YmsEV4280BL2k1DGTN77sP3ZHe7bS8VKBSBRON4D2iNwIgGOFWwHfNGUlIcQo/T9aW7pv2dPn3 IpEb/28Nb8iU1SwTobgP2FcyK X-Received: by 2002:a17:907:9702:: with SMTP id jg2mr7971732ejc.48.1613227928321; Sat, 13 Feb 2021 06:52:08 -0800 (PST) X-Received: by 2002:a17:907:9702:: with SMTP id jg2mr7971712ejc.48.1613227928165; Sat, 13 Feb 2021 06:52:08 -0800 (PST) Received: from x1.localdomain (2001-1c00-0c1e-bf00-1054-9d19-e0f0-8214.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:1054:9d19:e0f0:8214]) by smtp.gmail.com with ESMTPSA id dk18sm7308096edb.92.2021.02.13.06.52.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 13 Feb 2021 06:52:07 -0800 (PST) Subject: Re: [RFC PATCH 1/7] drivers: base: Add resource managed version of delayed work init From: Hans de Goede To: Greg Kroah-Hartman Cc: Matti Vaittinen , mazziesaccount@gmail.com, "Rafael J. Wysocki" , MyungJoo Ham , Chanwoo Choi , Andy Gross , Bjorn Andersson , Jean Delvare , Guenter Roeck , Mark Gross , Sebastian Reichel , Chen-Yu Tsai , Liam Girdwood , Mark Brown , Wim Van Sebroeck , Saravana Kannan , Heikki Krogerus , Andy Shevchenko , Joerg Roedel , Dan Williams , Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-hwmon@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-pm@vger.kernel.org, linux-watchdog@vger.kernel.org References: <1230b0d2ba99ad546d72ab079e76cb1b3df32afb.1613216412.git.matti.vaittinen@fi.rohmeurope.com> <284d4a13-5cc8-e23c-7e99-c03db5415bf1@redhat.com> Message-ID: <529a5122-ff3a-2af0-52ed-b13216fa49d1@redhat.com> Date: Sat, 13 Feb 2021 15:52:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 2/13/21 3:38 PM, Hans de Goede wrote: > Hi, > > On 2/13/21 2:33 PM, Greg Kroah-Hartman wrote: > Having this new devm_delayed_work_autocancel() helper will allow a > bunch of drivers to move away from mixing the 2, which is a good thing > in my book. > > As I said above I believe that having devm_delayed_work_autocancel() (1) > in our toolbox will be a good thing to have. Driver authors can then choose > to use it; or they can choose to not use it if they don't like it. > > I know that the reason why I did not use it in the > drivers/extcon/extcon-intel-int3496.c driver is because it was not available > if it had been available then I would definitely have used it, as it avoids the > mixing of resource-management styles which that driver is currently doing. > > And I think that that is what this is ultimately about, there are 2 styles > of resource-management: > > 1. manual > 2. devm based > > And they both have their pros and cons, problems mostly arise when mixing them > and adding new devm helpers for commonly used cleanup patterns is a good thing > as it helps to get rid of mixing these 2 styles in a single driver. I just noticed that I forgot to fill in the (1) footnote above: 1) And we probably will want one for non delayed work items to: devm_work_autocancel(), but lets cross that bridge when we get there. Also when reviewing: "[RFC PATCH 2/7] extconn: Clean-up few drivers by using managed work init" I noticed that the extcon-qcom-spmi-misc.c and extcon-palmas.c follow the same standard pattern of having an IRQ which queues a delayed work and they both miss the devm_free_irq call before the cancel_delayed_work_sync() on driver release. So just patch 2/7 here fixes 3 driver-release race conditions (fixing 3/4 drivers which it touches) as a bonus to the code-cleanup which it does. So as this clearly seems to be fixing a bunch of bugs, by simply completely removing the buggy code driver remove callbacks, this really seems like a good idea to me. Regards, Hans