From patchwork Mon Jun 20 15:22:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 70465 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1565496qgy; Mon, 20 Jun 2016 08:24:35 -0700 (PDT) X-Received: by 10.98.48.198 with SMTP id w189mr22133370pfw.125.1466436275364; Mon, 20 Jun 2016 08:24:35 -0700 (PDT) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTP id sq4si5047679pab.243.2016.06.20.08.24.35; Mon, 20 Jun 2016 08:24:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3AA9F6E5CC; Mon, 20 Jun 2016 15:24:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x230.google.com (mail-wm0-x230.google.com [IPv6:2a00:1450:400c:c09::230]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0A70989316 for ; Mon, 20 Jun 2016 15:24:03 +0000 (UTC) Received: by mail-wm0-x230.google.com with SMTP id v199so73862390wmv.0 for ; Mon, 20 Jun 2016 08:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zRUDhMDu0XBB1EsbpVZmfikLpyN22Jo4BomH2GUbIGc=; b=Qg1US/VqW4vvjSt+MquPwXpofwe7Q1uEWYHINaHvp9A4GDxMfttCQleQaVcWYucJ+O ay7Wl5m1dhDO4FGLfHyw1w8MyoWM31b/6+0QxXS4Kb5y/JXQBY9Z3Nkg+1M3xJVLLmJR saLO6X/CeLTAng4Ki7HnRqPhhd8H/btsnj+fM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zRUDhMDu0XBB1EsbpVZmfikLpyN22Jo4BomH2GUbIGc=; b=WpV92LqJ5zVXUd6cnisXMECF2T1v7ygO9fG+10E99Gle6YnDjecmo5wQSE0OKp4B/2 y7Q/NGRJdl2A0uOLlnAvWu19fqhlCwkYxXHSiVuLyaao6tWD4ZkgcsfxPEv188mOGPbC HY7g3TxtQ8EE4v6Jiwr42caFCBdkodEkNrw1X/QgqgJFAMCPFe0APpSQG91vOzD9BDEB cr3ucsjrqhLsawi+/lBaqrZDA82Tg43GL0OYioHZ6G/NWm6c82aJUdJCPVwljKxuZYR8 uw/buwVO7ZEgimR0fG43bFPZy/Yt/NILFqE62WQNwNEoi1XIJX++ojNUKvUVJ8OGTGwW aecw== X-Gm-Message-State: ALyK8tK8W2k3gmGoowaC/V/C60xDud0DRq0vBZFrE5lkunWvhywyKlSDoNEWYCanYIFiVc8X X-Received: by 10.194.87.42 with SMTP id u10mr16594204wjz.152.1466436241100; Mon, 20 Jun 2016 08:24:01 -0700 (PDT) Received: from lmenx321.st.com. ([80.12.51.204]) by smtp.gmail.com with ESMTPSA id zg10sm39707742wjb.1.2016.06.20.08.23.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Jun 2016 08:24:00 -0700 (PDT) From: Benjamin Gaignard To: dri-devel@lists.freedesktop.org, vincent.abriou@st.com, fabien.dessenne@st.com Subject: [PATCH 1/3] drm: Add callbacks for late registering Date: Mon, 20 Jun 2016 17:22:55 +0200 Message-Id: <1466436177-25659-2-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466436177-25659-1-git-send-email-benjamin.gaignard@linaro.org> References: <1466436177-25659-1-git-send-email-benjamin.gaignard@linaro.org> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Like what has been done for connectors add callbacks on encoder, crtc and plane to let driver do actions after drm device registration. Correspondingly, add callbacks called before unregister drm device. Signed-off-by: Benjamin Gaignard --- drivers/gpu/drm/drm_drv.c | 42 ++++++++++++++++++++++++++ include/drm/drm_crtc.h | 77 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index c7101c0..b4f7f62 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -666,6 +666,9 @@ EXPORT_SYMBOL(drm_dev_unref); int drm_dev_register(struct drm_device *dev, unsigned long flags) { int ret; + struct drm_crtc *crtc; + struct drm_plane *plane; + struct drm_encoder *encoder; mutex_lock(&drm_global_mutex); @@ -690,6 +693,27 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags) if (drm_core_check_feature(dev, DRIVER_MODESET)) drm_connector_register_all(dev); + drm_for_each_crtc(crtc, dev) { + if (crtc->funcs->late_register) + ret = crtc->funcs->late_register(crtc); + if (ret) + goto err_minors; + } + + drm_for_each_plane(plane, dev) { + if (plane->funcs->late_register) + ret = plane->funcs->late_register(plane); + if (ret) + goto err_minors; + } + + drm_for_each_encoder(encoder, dev) { + if (encoder->funcs->late_register) + ret = encoder->funcs->late_register(encoder); + if (ret) + goto err_minors; + } + ret = 0; goto out_unlock; @@ -717,12 +741,30 @@ EXPORT_SYMBOL(drm_dev_register); void drm_dev_unregister(struct drm_device *dev) { struct drm_map_list *r_list, *list_temp; + struct drm_crtc *crtc; + struct drm_plane *plane; + struct drm_encoder *encoder; drm_lastclose(dev); if (drm_core_check_feature(dev, DRIVER_MODESET)) drm_connector_unregister_all(dev); + drm_for_each_crtc(crtc, dev) { + if (crtc->funcs->early_unregister) + crtc->funcs->early_unregister(crtc); + } + + drm_for_each_plane(plane, dev) { + if (plane->funcs->early_unregister) + plane->funcs->early_unregister(plane); + } + + drm_for_each_encoder(encoder, dev) { + if (encoder->funcs->early_unregister) + encoder->funcs->early_unregister(encoder); + } + if (dev->driver->unload) dev->driver->unload(dev); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index c273497..b4ab33f 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -704,6 +704,32 @@ struct drm_crtc_funcs { const struct drm_crtc_state *state, struct drm_property *property, uint64_t *val); + + /** + * @late_register: + * + * This optional hook can be used to register additional userspace + * interfaces attached to the crtc like debugfs interfaces. + * It is called late in the driver load sequence from drm_dev_register(). + * Everything added from this callback should be unregistered in + * the early_unregister callback. + * + * Returns: + * + * 0 on success, or a negative error code on failure. + */ + int (*late_register)(struct drm_crtc *crtc); + + /** + * @early_unregister: + * + * This optional hook should be used to unregister the additional + * userspace interfaces attached to the crtc from + * late_unregister(). It is called from drm_dev_unregister(), + * early in the driver unload sequence to disable userspace access + * before data structures are torndown. + */ + void (*early_unregister)(struct drm_crtc *crtc); }; /** @@ -1127,6 +1153,32 @@ struct drm_encoder_funcs { * hotplugged in DRM. */ void (*destroy)(struct drm_encoder *encoder); + + /** + * @late_register: + * + * This optional hook can be used to register additional userspace + * interfaces attached to the encoder like debugfs interfaces. + * It is called late in the driver load sequence from drm_dev_register(). + * Everything added from this callback should be unregistered in + * the early_unregister callback. + * + * Returns: + * + * 0 on success, or a negative error code on failure. + */ + int (*late_register)(struct drm_encoder *encoder); + + /** + * @early_unregister: + * + * This optional hook should be used to unregister the additional + * userspace interfaces attached to the encoder from + * late_unregister(). It is called from drm_dev_unregister(), + * early in the driver unload sequence to disable userspace access + * before data structures are torndown. + */ + void (*early_unregister)(struct drm_encoder *encoder); }; #define DRM_CONNECTOR_MAX_ENCODER 3 @@ -1570,6 +1622,31 @@ struct drm_plane_funcs { const struct drm_plane_state *state, struct drm_property *property, uint64_t *val); + /** + * @late_register: + * + * This optional hook can be used to register additional userspace + * interfaces attached to the plane like debugfs interfaces. + * It is called late in the driver load sequence from drm_dev_register(). + * Everything added from this callback should be unregistered in + * the early_unregister callback. + * + * Returns: + * + * 0 on success, or a negative error code on failure. + */ + int (*late_register)(struct drm_plane *plane); + + /** + * @early_unregister: + * + * This optional hook should be used to unregister the additional + * userspace interfaces attached to the plane from + * late_unregister(). It is called from drm_dev_unregister(), + * early in the driver unload sequence to disable userspace access + * before data structures are torndown. + */ + void (*early_unregister)(struct drm_plane *plane); }; enum drm_plane_type {