mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Tian Tao <tiantao6@hisilicon.com>,
	maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	airlied@linux.ie, daniel@ffwll.ch,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/irq: Add irq as false detection
Date: Mon, 2 Nov 2020 13:40:15 +0100	[thread overview]
Message-ID: <d0b8c494-0d08-11ae-c0e9-988dbf9ecd35@suse.de> (raw)
In-Reply-To: <8a76d144-f8ba-bbbc-9177-53088f6dc73a@suse.de>


[-- Attachment #1.1.1: Type: text/plain, Size: 2267 bytes --]

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 <tiantao6@hisilicon.com>
>> ---
>>  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 way
> 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.

Best regards
Thomas

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/drm_drv.c#n664


> 
> Best regards
> Thomas
> 
>>  	irq_enabled = dev->irq_enabled;
>>  	dev->irq_enabled = 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ürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer

[-- Attachment #1.1.2: OpenPGP_0x680DC11D530B7A23.asc --]
[-- Type: application/pgp-keys, Size: 4259 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

  parent reply	other threads:[~2020-11-02 12:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-02 11:19 Tian Tao
2020-11-02 12:09 ` Thomas Zimmermann
2020-11-02 12:32   ` tiantao (H)
2020-11-02 12:40   ` Thomas Zimmermann [this message]
2020-11-02 12:51     ` Daniel Vetter
2020-11-02 18:30 ` [kbuild] " Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d0b8c494-0d08-11ae-c0e9-988dbf9ecd35@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=tiantao6@hisilicon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®