Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1501866rdb; Mon, 4 Sep 2023 17:06:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0rWAwKnYDQxoyuwI4owp+qWIvfp7qW7858hPn0gqRLcRogjMnGtoQ43Vog0LtflXO4SYh X-Received: by 2002:a19:3844:0:b0:500:9d32:8deb with SMTP id d4-20020a193844000000b005009d328debmr6453275lfj.51.1693872404450; Mon, 04 Sep 2023 17:06:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693872404; cv=none; d=google.com; s=arc-20160816; b=V/NYxpAsB1Mjr/BP/zFXvLBX4p/zNig9QwL/FbVtRdvHfCwZNCtVXy5lI87NlLqzRy pKAUS3GOnEXXqYpSWBALxuM0TWo+l34g1RwPdwciQL0NyMbh3mKlFMDAtzN5q1PW2Seh Xxz/SweuZR8iqKLXXV/McuLMJZXZJpGbOKx/7x8zYlnr04h2O3iwjdeymyNIySvXQbYS Ss15CJmhKSUaxicY6UN/QFFh97fT0O0K9AD4OJqOw69ZspSu3IFMUEWuxEtNr3i1Ou5a 2wEk3tuabTtHZ0yu3smkHPTyhCBKW2ZfahE9pQMoLEIDfdcbWnvRzZbOcLscT1J2RSLa LB6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Tw6BjEdmTEnEK69ocWJcU3RD1jG8jFmpOeU7wO40c6A=; fh=WRKTPRgx5LoFgDofu8zek4TNVTwUyP61tLYlq7Avt5I=; b=F9AtVq0gM4uHMAZWUxquRu6GjtTac7UCcbraeyVpwaV6dSsGa0oBcEUBYKsKgg+Erk UzcQiOLGvXufOxtfieRl2+fqOY7tu5GrYMMo1Br+EEH+48UdgbGzb4AK7zFL+zRJr2IX 6mNQyFJ4H0EwnVPbftJg/Mtj2vY/UiBnitxBU/ld7XvD/jlZOpKeC2mO5dLiM+l7HJ7Q qlhLjaNlLj/k7/ZIRs14QCW6XQKGeF2zstwxdsm/VyhpvmKFgbLa8kCB5Zlw2byOTj57 +F/64+wOv9bE3YcrIaf4rS2OG/BfJwahy+jZKikv6D71VXaosHirsW81MWQaorvLnsqc Ar9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=fvj4V4dY; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o20-20020aa7d3d4000000b00523409dcaabsi7156580edr.617.2023.09.04.17.06.18; Mon, 04 Sep 2023 17:06:44 -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=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=fvj4V4dY; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344130AbjIDH4H (ORCPT + 99 others); Mon, 4 Sep 2023 03:56:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352472AbjIDHz7 (ORCPT ); Mon, 4 Sep 2023 03:55:59 -0400 Received: from pandora.armlinux.org.uk (unknown [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7570E11A for ; Mon, 4 Sep 2023 00:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Tw6BjEdmTEnEK69ocWJcU3RD1jG8jFmpOeU7wO40c6A=; b=fvj4V4dYvMEO9DUFGeMrMD+gLy vGzwRqG6X13kViRNkQHTvSEhuaeQzBWsP0lxlydYy8I7dqybu33YTUTfRLFyaEjTMWJwZpkU6nnBf 1q4jcQ17aX34e9TO9D1pdv6pcvCL/gegKpOlHqVPW+bdkm3UXi2ESeSeZL2yBy3bRVnbRwhaPMr9g M6xayiiS+stvWYSAnBBitM6+fVVE9K3d2yGN5ZEbk328f4fSp/Sw6Tgn/ag0CnFyXVWUCdH5qz1bQ uWYhfIRwTWFpqA4gTBuNb9xotmxkqYYJlyRMAbXSqm4CVtLZMLUaKedbZpSofzz0CuYRHdpVvPdV0 PLusFdrA==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:42072) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qd4Qy-0006Zd-0w; Mon, 04 Sep 2023 08:55:44 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qd4Qx-0002LJ-NQ; Mon, 04 Sep 2023 08:55:43 +0100 Date: Mon, 4 Sep 2023 08:55:43 +0100 From: "Russell King (Oracle)" To: Maxime Ripard , Greg Kroah-Hartman Cc: Douglas Anderson , dri-devel@lists.freedesktop.org, airlied@gmail.com, daniel@ffwll.ch, linux-kernel@vger.kernel.org Subject: Re: [RFT PATCH 01/15] drm/armada: Call drm_atomic_helper_shutdown() at shutdown time Message-ID: References: <20230901234202.566951-1-dianders@chromium.org> <20230901164111.RFT.1.I3d5598bd73a59b5ded71430736c93f67dc5dea61@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Russell King (Oracle) X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,RDNS_NONE, SPF_HELO_NONE,SPF_NONE autolearn=no 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 Mon, Sep 04, 2023 at 09:36:10AM +0200, Maxime Ripard wrote: > On Sun, Sep 03, 2023 at 04:53:42PM +0100, Russell King (Oracle) wrote: > > On Fri, Sep 01, 2023 at 04:41:12PM -0700, Douglas Anderson wrote: > > > Based on grepping through the source code this driver appears to be > > > missing a call to drm_atomic_helper_shutdown() at system shutdown > > > time. Among other things, this means that if a panel is in use that it > > > won't be cleanly powered off at system shutdown time. > > > > > > The fact that we should call drm_atomic_helper_shutdown() in the case > > > of OS shutdown/restart comes straight out of the kernel doc "driver > > > instance overview" in drm_drv.c. > > > > > > This driver was fairly easy to update. The drm_device is stored in the > > > drvdata so we just have to make sure the drvdata is NULL whenever the > > > device is not bound. > > > > ... and there I think you have a misunderstanding of the driver model. > > Please have a look at device_unbind_cleanup() which will be called if > > probe fails, or when the device is removed (in other words, when it is > > not bound to a driver.) > > > > Also, devices which aren't bound to a driver won't have their shutdown > > method called (because there is no driver currently bound to that > > device.) So, ->probe must have completed successfully, and ->remove > > must not have been called for that device. > > > > So, I think that all these dev_set_drvdata(dev, NULL) that you're > > adding are just asking for a kernel janitor to come along later and > > remove them because they serve no purpose... so best not introduce > > them in the first place. > > What would that hypothetical janitor clean up exactly? Code making sure > that there's no dangling pointer? Doesn't look very wise to me. How can there be a dangling pointer when the driver core removes the pointer for the driver in these cases? If I were to accept the argument that the driver core _might_ "forget" to NULL out this pointer, then that argument by extension also means that no one should make use of the devm_* stuff either, just in case the driver core forgets to release that stuff. Best have every driver manually release those resources. Nope, that doesn't work, because driver authors tend to write buggy cleanup paths. There are janitors that go around removing this stuff, and janitorial patches tend to keep coming even if one says nak at any particular point... and yes, janitors do go around removing this unnecessary junk from drivers. You will find examples of this removal in commit ec3b1ce2ca34, 5cdade2d77dd, c7cb175bb1ef Moreover: 7efb10383181 is also removing unnecessary driver code. Testing for driver data being NULL when we know that a _successful_ probe has happened (because ->remove won't be called unless we were successful) and the probe always sets drvdata non-NULL is also useless code. If ultimately you don't trust the driver model to do what it's been doing for more than the last decade, then I wonder whether you should be trusting the kernel to manage your hardware! Anyway, I've said no to this patch for a driver that I'm marked as maintainer for, so at least do not make the changes I am objecting to to that driver. Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!