Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3302827pxu; Tue, 15 Dec 2020 03:54:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJyD0yiSzUwNJn4bb3LuDDxkS2eOxixBO4ufYCBeSgFTihgjOm6UJsfGpbijUC20M9UuuFA+ X-Received: by 2002:a17:906:2681:: with SMTP id t1mr7086745ejc.29.1608033258968; Tue, 15 Dec 2020 03:54:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608033258; cv=none; d=google.com; s=arc-20160816; b=t6SKgbny+tItFxr+dMaO8kVxn++BdB3ZYn4b3Jp3/rwr0zEgoosbJR533gjdhawsdN MgScL0/w2gNhnPTIWEzvxqwHxpNLbHPpYC1Ya2BRKhMbgHGuZHlxwLE29To6BHzp+YMQ EF8jx9xArbwCLJODIlxUjLIF/kwkwqin9mAXHOBB/BT8x2qgqGVzt23dO4bGMgtmV76d KZAy0BgJ0v+8szeVq2YM12f+leLMARlBWjWzXkhqoqm+P51grYHjUPwwJuPKTOl4pieD YWFJwaR4LpzvEooiVlvQi9BdKPyFH73TsC7ryZmj7hgqRdbUch7JSw68AwenrkgY9S+R YE0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=D/5BvS+Ijn6N3Yhuw0h+0d0EdQ0StvevPG/u7Wsyr3I=; b=z6q1HuUuHLk0qvPn2BxDml8WY8+9q6yr+DfdkdanwCaiUtZRTQHo9fpCTneLs0UJol FOAlD++c/8sZ0Ldswxz3ZF3pGP3yGYKK6wC7q1vYQJ36O1W17bDu2N+coFI0ZxNRPRtc +KbULs//ivotnUh9fSiqlinJ0FCzxvhjTQrXk3XtTV1D3wYZAOM5mpnksgkPDptYPn7t rkFnL37hF+ykz18lFGxc4LTJP6KNpm+QPOtKto2nyHLiqFpWxkQC+q/b76lkv2yBrzZM qLiNxE1PpF6Ygv4OBYKQc2eSXlLVa2T9rQWl6Ruz5gaPp9weWkk73gy/IXzUuS6aAub2 KF8w== 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 se25si739271ejb.82.2020.12.15.03.53.56; Tue, 15 Dec 2020 03:54:18 -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 S1728769AbgLOLuF (ORCPT + 99 others); Tue, 15 Dec 2020 06:50:05 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:9891 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727448AbgLOLtw (ORCPT ); Tue, 15 Dec 2020 06:49:52 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4CwGjb2W9Kz7GgC; Tue, 15 Dec 2020 19:48:19 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Tue, 15 Dec 2020 19:48:45 +0800 From: Tian Tao To: , , , , , , , , CC: Tian Tao Subject: [PATCH drm/hisilicon 1/2] drm/irq: Add the new api to enable pci msi Date: Tue, 15 Dec 2020 19:48:52 +0800 Message-ID: <1608032933-50187-2-git-send-email-tiantao6@hisilicon.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1608032933-50187-1-git-send-email-tiantao6@hisilicon.com> References: <1608032933-50187-1-git-send-email-tiantao6@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add new api devm_drm_msi_install() to register interrupts, no need to call pci_disable_msi() when the drm module is removed. Signed-off-by: Tian Tao --- drivers/gpu/drm/drm_irq.c | 33 +++++++++++++++++++++++++++++++++ include/drm/drm_irq.h | 1 + 2 files changed, 34 insertions(+) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 803af4b..da58b2c 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -246,6 +246,39 @@ int devm_drm_irq_install(struct drm_device *dev, int irq) } EXPORT_SYMBOL(devm_drm_irq_install); +static void devm_drm_msi_uninstall(void *data) +{ + struct drm_device *dev = (struct drm_device *)data; + + pci_disable_msi(dev->pdev); +} + +/** + * devm_drm_msi_install - install IRQ handler + * @dev: DRM device + * + * devm_drm_msi_install is a help function of pci_enable_msi. + * + * if the driver uses devm_drm_msi_install, there is no need + * to call pci_disable_msi when the drm module get unloaded, + * as this will done automagically. + * + * Returns: + * Zero on success or a negative error code on failure. + */ +int devm_drm_msi_install(struct drm_device *dev) +{ + int ret; + + ret = pci_enable_msi(dev->pdev); + if (ret) + return ret; + + return devm_add_action_or_reset(dev->dev, + devm_drm_msi_uninstall, dev); +} +EXPORT_SYMBOL(devm_drm_msi_install); + #if IS_ENABLED(CONFIG_DRM_LEGACY) int drm_legacy_irq_control(struct drm_device *dev, void *data, struct drm_file *file_priv) diff --git a/include/drm/drm_irq.h b/include/drm/drm_irq.h index 631b22f..c8dff45 100644 --- a/include/drm/drm_irq.h +++ b/include/drm/drm_irq.h @@ -29,4 +29,5 @@ struct drm_device; int drm_irq_install(struct drm_device *dev, int irq); int drm_irq_uninstall(struct drm_device *dev); int devm_drm_irq_install(struct drm_device *dev, int irq); +int devm_drm_msi_install(struct drm_device *dev); #endif -- 2.7.4