Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5072036rdb; Sat, 16 Sep 2023 01:29:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhwlGpsOwAosmmESAnGIFRnLJFlfeyh0Ts25JKCS+KL+v1bYMGYAFp0H9kMp5anPAEhWOd X-Received: by 2002:a05:6808:2c9:b0:3ac:b387:2251 with SMTP id a9-20020a05680802c900b003acb3872251mr3937450oid.28.1694852981169; Sat, 16 Sep 2023 01:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694852981; cv=none; d=google.com; s=arc-20160816; b=RpBUkA1d3P2KwqQODBdWZLj3elSB4puMnF5hJ71JfHZmSslVurLoW0g2ujpN7ouPoK IHJ6YaU2kM2Av8usNeCB6LsTMinQibkcxEWp5FJL+fGXZr/6CKctTp8WZSEapNdv1o6y 4syKPZnhpefpuRyqFjaNjExilmMJk1TX/3OAYPBmA22teslpYVU3Qalu+lujTLG6x7JP XVqABwvTZoCJ+KWZOzWwRGw/0qiClaXTTn+eeTM/ubE3shhtmgw3rZ2InqQ12r0KAJdG bLk6S2Ng4GEf2+5duAvmE46AKsOiuW5yoTBvrL7g/PAteCCHK3g2f95CQ5ixBmHaa7fP Qlyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=/4UHa0/oq66alw95ljztJJEQxyAHYh4BXAB2kPfRssY=; fh=wO4ytbah9qUZed6ou2EO7RxCWRZKElCIy8iIE+y6Chs=; b=JVicV58vc3wkSNLqpCIf/jTSaIXCvYpIpK7KCQr0jM8NYlNbslLSjr9jGAASMl/Wjz t2/ckDTSO3YRYzfBGL7SvXA8KdKVHQnvMBEYBKZqQfj8KUo8noybtWq9Vif9C8bBsDve hOJYq5ZxXYyeEk1Z81GEMZyDZEFTEJzMeQaBe4i/fb18eskH5TDaJh0OZKY32IIZFvjf w07CGJhvY0bJ0KGuhDk6Otmm6tyw1R6vaTQf1t1oDfXVIJYfjQhuHG7r3vfn0A1SIcc9 /0kHGG9o79mf42hsA6lMPsb8EsNZYM6q/90GBKfLkslW0s6kjGzs0ZkhiiSIkGrBsK+9 YCTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=deNEYaTE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id lb2-20020a17090b4a4200b0025bf45ac365si7446086pjb.82.2023.09.16.01.29.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 01:29:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=deNEYaTE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7AE388072171; Fri, 15 Sep 2023 06:45:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235407AbjIONpK (ORCPT + 99 others); Fri, 15 Sep 2023 09:45:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235355AbjIONpK (ORCPT ); Fri, 15 Sep 2023 09:45:10 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D806B1BEB for ; Fri, 15 Sep 2023 06:45:04 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-501bef6e0d3so3469997e87.1 for ; Fri, 15 Sep 2023 06:45:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694785500; x=1695390300; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/4UHa0/oq66alw95ljztJJEQxyAHYh4BXAB2kPfRssY=; b=deNEYaTEQ1hUfIPELdlPJVagpRyXes8SOnT3NewE+W8HKtQsATTgmmfB68eutYn7j3 6xhEijKhs9ZI6PY1WYsbFwkE/TFVL0O31nnSqiU23u++j3YrssfGU8tSeYuOQ+t47tBA pdLQCm4cphD0tu34fCmrTgbDsatBdOjt3HOjg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694785500; x=1695390300; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/4UHa0/oq66alw95ljztJJEQxyAHYh4BXAB2kPfRssY=; b=IwDqKvW8FUBGTtuuWADh2HxZ/w7Am7KIYj0Eb2xQVHioDdJ7kYLk5OvAvvjZw9A/lA 5jBb/WyrRPzpyV9I6BCUdvBCQYXXeen1JAX09qvD7JteO6dO9tuLCuSfvo22Ay+FiDll TGFIna5CyQojrY0JWK4pIKHTQHGblaDv33864jrJpUtaNfuLxulPaRmfcEL7DPfPMJCM 05Ji4yX094bh4EUK+OMUsI3jkap3fp7ZFciywF8VJPoDs62wy/lTnAscDaV47rZF0VPn UBQyarTmwjTqVImAq3+R0FsXF4CM/h0baJyFkRW+75SB+qOVcv5uwUWBeTpbVANm3jOf nklQ== X-Gm-Message-State: AOJu0YzeEqc0wdEuSijiVq+AWzHKHHnzZfA25UN3gTuRUqws1W0BnMFC 3zHOkJQJaK0B8Do95+GjbiUkvHx2E2oBgDV+1+EOVc8+ X-Received: by 2002:ac2:58c5:0:b0:4fe:d0f:1f1b with SMTP id u5-20020ac258c5000000b004fe0d0f1f1bmr1422569lfo.65.1694785500085; Fri, 15 Sep 2023 06:45:00 -0700 (PDT) Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com. [209.85.167.48]) by smtp.gmail.com with ESMTPSA id o8-20020a056512050800b004fb757bd429sm649939lfb.96.2023.09.15.06.44.59 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Sep 2023 06:44:59 -0700 (PDT) Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5009dd43130so2600e87.1 for ; Fri, 15 Sep 2023 06:44:59 -0700 (PDT) X-Received: by 2002:a50:d09e:0:b0:525:573c:6444 with SMTP id v30-20020a50d09e000000b00525573c6444mr118963edd.1.1694785478523; Fri, 15 Sep 2023 06:44:38 -0700 (PDT) MIME-Version: 1.0 References: <20230901234015.566018-1-dianders@chromium.org> <20230901163944.RFT.2.I9115e5d094a43e687978b0699cc1fe9f2a3452ea@changeid> In-Reply-To: From: Doug Anderson Date: Fri, 15 Sep 2023 06:44:21 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFT PATCH 2/6] drm: Call drm_atomic_helper_shutdown() at shutdown time for misc drivers To: suijingfeng Cc: dri-devel@lists.freedesktop.org, Maxime Ripard , airlied@gmail.com, airlied@redhat.com, alain.volmat@foss.st.com, alexander.deucher@amd.com, alexandre.belloni@bootlin.com, alison.wang@nxp.com, bbrezillon@kernel.org, christian.koenig@amd.com, claudiu.beznea@microchip.com, daniel@ffwll.ch, drawat.floss@gmail.com, javierm@redhat.com, jernej.skrabec@gmail.com, jfalempe@redhat.com, jstultz@google.com, kong.kongxinwei@hisilicon.com, kraxel@redhat.com, linus.walleij@linaro.org, linux-arm-kernel@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, liviu.dudau@arm.com, nicolas.ferre@microchip.com, paul.kocialkowski@bootlin.com, sam@ravnborg.org, samuel@sholland.org, spice-devel@lists.freedesktop.org, stefan@agner.ch, sumit.semwal@linaro.org, tiantao6@hisilicon.com, tomi.valkeinen@ideasonboard.com, tzimmermann@suse.de, virtualization@lists.linux-foundation.org, wens@csie.org, xinliang.liu@linaro.org, yongqin.liu@linaro.org, zackr@vmware.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 15 Sep 2023 06:45:10 -0700 (PDT) Hi, On Fri, Sep 15, 2023 at 2:11=E2=80=AFAM suijingfeng wrote: > > Hi, > > > On 2023/9/2 07:39, Douglas Anderson wrote: > > Based on grepping through the source code these drivers appear 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. > > > > All of the drivers in this patch were fairly straightforward to fix > > since they already had a call to drm_atomic_helper_shutdown() at > > remove/unbind time but were just lacking one at system shutdown. The > > only hitch is that some of these drivers use the component model to > > register/unregister their DRM devices. The shutdown callback is part > > of the original device. The typical solution here, based on how other > > DRM drivers do this, is to keep track of whether the device is bound > > based on drvdata. In most cases the drvdata is the drm_device, so we > > can just make sure it is NULL when the device is not bound. In some > > drivers, this required minor code changes. To make things simpler, > > drm_atomic_helper_shutdown() has been modified to consider a NULL > > drm_device as a noop in the patch ("drm/atomic-helper: > > drm_atomic_helper_shutdown(NULL) should be a noop"). > > > > Suggested-by: Maxime Ripard > > Signed-off-by: Douglas Anderson > > --- > > > I have just tested the whole series, thanks for the patch. For drm/loongs= on only: > > > Reviewed-by: Sui Jingfeng > Tested-by: Sui Jingfeng Thanks! > By the way, I add 'pr_info("lsdc_pci_shutdown\n");' into the lsdc_pci_shu= tdown() function, > And seeing that lsdc_pci_shutdown() will be called when reboot and shutdo= wn the machine. > I did not witness something weird happen at present. As you have said, th= is is useful for > drm panels drivers. But for the rest(drm/hibmc, drm/ast, drm/mgag200 and = drm/loongson etc) > drivers, you didn't mention what's the benefit for those drivers. I didn't mention it because I have no idea! I presume that for non-drm_panel use cases it's not a huge deal, otherwise it wouldn't have been missing from so many drivers. Thus, my "one sentence" reason for the non-drm_panel case is just "we should do this because the documentation of the API says we should", which is already in the commit message. ;-) If you have a specific other benefit you'd like me to list then I'm happy t= o. > Probably, you can > mention it with at least one sentence at the next version. I also prefer = to alter the > lsdc_pci_shutdown() function as the following pattern: > > > static void lsdc_pci_shutdown(struct pci_dev *pdev) > { > > struct drm_device *ddev =3D pci_get_drvdata(pdev); > > drm_atomic_helper_shutdown(ddev); > } I was hoping to land this patch without spinning it unless there's a good reason. How strongly do you feel about needing to change the above? I will note that I coded it the way I did specifically to try to follow the style in the documentation in "drm_drv.c". In the example "driver_shutdown()" function you can see that they combined it into one line and so I followed that style. ;-) That being said, I have no problem changing this if I spin the patch. -Doug