Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3274767pxx; Mon, 2 Nov 2020 04:55:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNVz6nz6+fQnFHdzqBIxa06/SzIcV3JVt5AL3DE86/+XXZIKCaZQaMMANmxN5QcYHOWOWE X-Received: by 2002:a17:906:3087:: with SMTP id 7mr15056192ejv.375.1604321750332; Mon, 02 Nov 2020 04:55:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604321750; cv=none; d=google.com; s=arc-20160816; b=TyvfL/CUIqsZ0BU6qQXkw+YaLsQmSItZqi+/zuNwYkXbifxzsxu29vZ9DdpG4WamPj CVHTdKJwTJ8MHQUjsoMZ96ys9PNDRzIOm5GIRetirP045I+FV4l/LfQYTRvU7Vsj7loy h98eC3PLF6YFZ7rB2mkl+c8hR5WKvvBrKog3q/UWcqz/z9OYDuKBvBT5DO3QjFr06q7d 7WzSv2jxYklcsfTZT9mq1KmbtCVmc7W2xDxWNWxIsizfR0+VXu1wqK24ObCXoNkmt+FC xnkPG0luF1qt26VciA7iIJ1+1Su1CK6rDM+nh0Z8KIOv8zdCcB4PmscKC7R+rGsiebka kicg== 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=fMkq/VIu6fd+U26qy11bcn48l177zp7DNZNLDcC8+t4=; b=caAKC8zBVjsiccTI4lmrph8jKpnJVmpzYiv5TqEZMLBERvbhfjrk7WCW2W+xxzG/C/ dx6ESUzjlv5aN/ob0Ox8B9BsTj6WYCUlTuSsy+2CZ+bIZYWLJeAHDFeSo/KgZzhIN5Mb H9CbmfXbgXnBW5LImH0Ze66FBAZA3v60jHbpcPYZ+l/BcualCFYTDRmy1qPEX8LdJFqi VCL6TdNfFdm0ABXo5SKaYCfZbeNLpGnIJ5f4RmfBQ11Q86poiudgJMhbWVImBPjfDgmu bOlJxzxg4LTkCU/PQ+4AzBoQf/MDuNgrV428BnWhBc5RPBL96/wMIQyYG5aaQOorPJrr 49JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b="NDVwt/pV"; 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 b21si11975024ejz.183.2020.11.02.04.55.27; Mon, 02 Nov 2020 04:55:50 -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=@ffwll.ch header.s=google header.b="NDVwt/pV"; 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 S1728882AbgKBMwG (ORCPT + 99 others); Mon, 2 Nov 2020 07:52:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728687AbgKBMwG (ORCPT ); Mon, 2 Nov 2020 07:52:06 -0500 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F479C0617A6 for ; Mon, 2 Nov 2020 04:52:04 -0800 (PST) Received: by mail-ot1-x342.google.com with SMTP id m26so12436951otk.11 for ; Mon, 02 Nov 2020 04:52:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=fMkq/VIu6fd+U26qy11bcn48l177zp7DNZNLDcC8+t4=; b=NDVwt/pVYEC750UTJE0s4J6JfMRuJGuZ5axCjsm/867iyTvOIQA71kEJ7rOwvA2uJK h2YIoyHvvyTzzEIOxqYrJJgzjB+hrNaFdipkdkPZ8SY+qC4/fqqKc90SaigG6BmW48bt tYRZIBm/F4Qpu5EDpooS+V6HzkMoBTCfnWFOQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=fMkq/VIu6fd+U26qy11bcn48l177zp7DNZNLDcC8+t4=; b=CFv5DSJp1f9ac/0fBflWYNQGKcochq1c87Ami7sPqyUWBrWQG0ak11azcl0T7+7Z4k 98FUdAtLw0stcRflwmNRjjxYq+VyT3Qcad0mvGA4GpwUidhgy5TyZj77Aw9odBogl4b1 NVEK7zQdEAC2Kcam7grKQkr+ufbvuMZeh4x9Bih+rOnoamE1el+LMTs2E4ycz26oQm1Q bbXT97/pI2QAY3TahQ4YcftFvg4xQuReOILsj2H2kGTL24mI5EbHv3xDLDZDmTNeNkk+ /xTiPrLVhHyJkYFXa3MnQYoC28yrVTBBttboVE9gdzJxlGUkT5YpWNr/2ScfL2kWXZp6 ATOQ== X-Gm-Message-State: AOAM532d1+AKb8Agd6JKrka+xqtS8d2aljEbC1I0uyx2Qnm7qpdO5Rk7 GrbTChY5/wtVi93gZ6V4cwrB6AZUF17KyerowX9ByQ== X-Received: by 2002:a9d:6e81:: with SMTP id a1mr11349917otr.303.1604321523932; Mon, 02 Nov 2020 04:52:03 -0800 (PST) MIME-Version: 1.0 References: <1604315990-56787-1-git-send-email-tiantao6@hisilicon.com> <8a76d144-f8ba-bbbc-9177-53088f6dc73a@suse.de> In-Reply-To: From: Daniel Vetter Date: Mon, 2 Nov 2020 13:51:52 +0100 Message-ID: Subject: Re: [PATCH] drm/irq: Add irq as false detection To: Thomas Zimmermann Cc: Tian Tao , Maarten Lankhorst , Maxime Ripard , Dave Airlie , dri-devel , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 2, 2020 at 1:40 PM Thomas Zimmermann wrot= e: > > Hi > > Am 02.11.20 um 13:09 schrieb Thomas Zimmermann: > > Hi > > > > Am 02.11.20 um 12:19 schrieb Tian Tao: > >> Add the detection of false for irq, so that the EINVAL is not > >> returned when dev->irq_enabled is false. > >> > >> Signed-off-by: Tian Tao > >> --- > >> drivers/gpu/drm/drm_irq.c | 3 +++ > >> 1 file changed, 3 insertions(+) > >> > >> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c > >> index 09d6e9e..7537a3d 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; > >> + > > > > Dereferencing a pointer before NULL-checking it, is Yoda programming. := ) > > I'd just drop the test for !dev and assume that dev is always valid. > > > > I suggest to change the int return value to void and return nothing. > > > > Re-reading the actual implementation of this function, this location > > might be too early. Further below there already is a test for > > irq_enabled. Put a drm_WARN_ON around it and it should be fine. This wa= y > > the vblank handlers will be disabled and erroneous callers will see a > > warning in the kernel's log. > > In addition to these changes, you could also add a managed > implementation of drm_irq_install(). The canonical name should be > devm_drm_irq_install(). The function would call drm_irq_install() and > register a cleanup handler via devm_add_action(). Example code is at [1]. > > KMS drivers, such as hibmc, would then not have to bother about > uninstalling the DRM irq. Yup, devm_ is the right fix here imo, not trying to make the uninstall hook resilient against drivers which can't keep track of stuff. So if that's all there is, imo this patch is a bad idea, since we have proper tools to make driver unloading easier on driver author's nowadays. -Daniel > Best regards > Thomas > > [1] > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/d= rivers/gpu/drm/drm_drv.c#n664 > > > > > > Best regards > > Thomas > > > >> irq_enabled =3D dev->irq_enabled; > >> dev->irq_enabled =3D false; > >> > >> > > > > > > _______________________________________________ > > dri-devel mailing list > > dri-devel@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/dri-devel > > > > -- > Thomas Zimmermann > Graphics Driver Developer > SUSE Software Solutions Germany GmbH > Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany > (HRB 36809, AG N=C3=BCrnberg) > Gesch=C3=A4ftsf=C3=BChrer: Felix Imend=C3=B6rffer --=20 Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch