Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3156507pxx; Mon, 2 Nov 2020 01:12:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTp9iA6aAqeD2Onjoj3Q8JyZPX2Ka5m5XUSSHawamdNCPSdXlQ9+sr9ABmNc2y/Moqfo9b X-Received: by 2002:a17:906:6545:: with SMTP id u5mr14334430ejn.346.1604308371160; Mon, 02 Nov 2020 01:12:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604308371; cv=none; d=google.com; s=arc-20160816; b=nmETz1+YCma8hZlQT+zV7h+vQVqLKtxUka6Mw8fy+pyPvfIstptvg0R3Nb/b8vZPg4 GlLYb+FvDcwF7SWCCWmdq1u9wrla7YnFrGQdwE+v+C5aOgjG/MOhqq34+hAdnDo1UaRx 8/TwpfukHXxbOelI2wT+oAROO5SLEwncaIL0YgwkzV6vvTGQX8Dqg1c0+721kf7Ha1HQ BqMFgVJWDEHImx2mdHdF+MIGYz4LYE6d7os3CSu4oxDXoF1J5i/3e3pOQoeksfsADgMx FQdwhFBaoPOjlTh+dvIpUdnN9ylJ2Zd5wlSe7M1/mrGvQkbkaT14wpEqsIEpKULUvhsv 2L+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:to:subject; bh=4tVFsT5GecGK/Qqm+J3MhJpDlGEBlP3YEKAgqiNt/kM=; b=XFbt/JAwG/tVxkJjri2gTFL9OkWvDlBJVkKeti5bDQZfB0sYBfe0px+bR84Qmt8ZaB jJGZgSRvwoEtFCttUFhIoddyKC/f9nFePQ/pAJ4OJnCcb8KetkJMfPdrW83yLX3plkxB Ll9v7SbCYbohFZiR6adSURqlCEYUardQjbrQF1rHWVs+9XTQIHCxNWZ1RGr0NoCG+mMD Zqv3t4b/e4PnZ1E3ixAgTRQF+Frq7id7FByuTUAbr8+aL1BIPLb+mZq5DwB8gTElf8Qn AxAkMpGcJ7aLDZVCk8ILjk12veYphVWSH5nQc45aohVWly+h0PDR2Q97YWnWO/TpiHSJ Pdnw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ci22si9474796ejc.413.2020.11.02.01.12.28; Mon, 02 Nov 2020 01:12:51 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728340AbgKBJId (ORCPT + 99 others); Mon, 2 Nov 2020 04:08:33 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:6729 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727806AbgKBJIc (ORCPT ); Mon, 2 Nov 2020 04:08:32 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CPn936cbxzkdXL; Mon, 2 Nov 2020 17:06:47 +0800 (CST) Received: from [127.0.0.1] (10.57.60.129) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Mon, 2 Nov 2020 17:06:43 +0800 Subject: Re: [PATCH] drm/hisilicon: Remove redundant null check To: Thomas Zimmermann , Tian Tao , , , , , , , , References: <1604050046-64539-1-git-send-email-tiantao6@hisilicon.com> <2dbbbad0-53cf-52cc-3b6b-0d1547f7e085@suse.de> From: "tiantao (H)" Message-ID: <48f68940-14a4-6ea7-4296-53970cd74015@huawei.com> Date: Mon, 2 Nov 2020 17:06:43 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.57.60.129] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2020/11/2 17:03, Thomas Zimmermann 写道: > Hi > > Am 02.11.20 um 09:46 schrieb tiantao (H): >> >> >> 在 2020/11/2 16:32, Thomas Zimmermann 写道: >>> Hi >>> >>> Am 30.10.20 um 10:27 schrieb Tian Tao: >>>> drm_irq_uninstall can handle the case where dev->irq_enable is false, >>>> so Remove redundant null check. >>>> >>>> Signed-off-by: Tian Tao >>>> --- >>>>   drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 6 +++--- >>>>   1 file changed, 3 insertions(+), 3 deletions(-) >>>> >>>> diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c >>>> b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c >>>> index 0c1b40d..b71589b1 100644 >>>> --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c >>>> +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c >>>> @@ -246,13 +246,13 @@ static int hibmc_unload(struct drm_device *dev) >>>>         drm_atomic_helper_shutdown(dev); >>>>   -    if (dev->irq_enabled) >>>> -        drm_irq_uninstall(dev); >>>> - >>>> +    drm_irq_uninstall(dev); >>> >>> Removing this check would at least result in an error, [1] so rather >>> leave it in for now. >>> >> Now there seems to be no driver to check the return value of >> drm_irq_uninstall > > True. No clean-up code should ever fail. But currently, it's not handled > by drm_irq_uninstall(). > > A better fix would be to have drm_irq_uninstall() return early with a > warning if IRQs are disabled. And for most drivers, a managed version of > drm_irq_install() would be useful. > Codes like the following diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 09d6e9e..572357c 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -172,6 +172,9 @@ int drm_irq_uninstall(struct drm_device *dev) bool irq_enabled; int i; + if(!dev->irq_enabled || !dev) + return 0; > Best regards > Thomas > >>> Instead, we could discuss if drm_irq_install() should become a managed >>> interface. >> >> Codes like the following >> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c >> index 09d6e9e..572357c 100644 >> --- a/drivers/gpu/drm/drm_irq.c >> +++ b/drivers/gpu/drm/drm_irq.c >> @@ -172,6 +172,9 @@ int drm_irq_uninstall(struct drm_device *dev) >>         bool irq_enabled; >>         int i; >> >> +       if(!dev->irq_enabled || !dev) >> +               return 0; >> >>> >>> Best regards >>> Thomas >>> >>> [1] >>> https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/drm_irq.c#L201 >>> >>> >>>>       pci_disable_msi(dev->pdev); >>>> + >>>>       hibmc_kms_fini(priv); >>>>       hibmc_mm_fini(priv); >>>>       dev->dev_private = NULL; >>>> + >>>>       return 0; >>>>   } >>>> >>> >> >