From patchwork Thu Mar 30 07:41:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13193533 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 834FEC77B61 for ; Thu, 30 Mar 2023 07:41:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229458AbjC3Hlz (ORCPT ); Thu, 30 Mar 2023 03:41:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjC3Hly (ORCPT ); Thu, 30 Mar 2023 03:41:54 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40CC144A2 for ; Thu, 30 Mar 2023 00:41:53 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E7E6721B01; Thu, 30 Mar 2023 07:41:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680162111; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sqn+2z7EyTf7nLrUP9hk+hPnBxXhVceTrbTzbVoeGag=; b=GIxWZRcC4uZTDremJzF5frTCOnmYarsxDVzhv7TuEmoB7zlifIZA7v7Oa+NxL9IlZx7B3p 9s5O9HX/9oHZHu72/cKnHVbHr493TWB6fy/86HgEkSKMZ3UM1Ixzqm8olI7HJzIWsIdb52 RXEpas4UyBb++/nE1WjpslaIQW9VSPs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680162111; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sqn+2z7EyTf7nLrUP9hk+hPnBxXhVceTrbTzbVoeGag=; b=ogd3bO968HyHGUVriFjZdxrensTQqlTI7ka913cso5M740hjERn4e9p9Bktio9ACt3tM4n GL7RxHYLZ1kltYAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B27611390D; Thu, 30 Mar 2023 07:41:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kPG3Kj89JWSZfQAAMHmgww (envelope-from ); Thu, 30 Mar 2023 07:41:51 +0000 From: Thomas Zimmermann To: robdclark@gmail.com, quic_abhinavk@quicinc.com, dmitry.baryshkov@linaro.org, sean@poorly.run, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 1/6] drm/msm: Clear aperture ownership outside of fbdev code Date: Thu, 30 Mar 2023 09:41:44 +0200 Message-Id: <20230330074150.7637-2-tzimmermann@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330074150.7637-1-tzimmermann@suse.de> References: <20230330074150.7637-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Move aperture management out of the fbdev code. It is unrelated and needs to run even if fbdev support has been disabled. Call the helper at the top of msm_drm_init() to take over hardware from other drivers. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/msm/msm_drv.c | 6 ++++++ drivers/gpu/drm/msm/msm_fbdev.c | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index aca48c868c14..5211140ec50b 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -411,6 +412,11 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) if (drm_firmware_drivers_only()) return -ENODEV; + /* the fw fb could be anywhere in memory */ + ret = drm_aperture_remove_framebuffers(false, drv); + if (ret) + return ret; + ddev = drm_dev_alloc(drv, dev); if (IS_ERR(ddev)) { DRM_DEV_ERROR(dev, "failed to allocate drm_device\n"); diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c index d26aa52217ce..fc7d0406a9f9 100644 --- a/drivers/gpu/drm/msm/msm_fbdev.c +++ b/drivers/gpu/drm/msm/msm_fbdev.c @@ -4,7 +4,6 @@ * Author: Rob Clark */ -#include #include #include #include @@ -154,11 +153,6 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev) goto fail; } - /* the fw fb could be anywhere in memory */ - ret = drm_aperture_remove_framebuffers(false, dev->driver); - if (ret) - goto fini; - ret = drm_fb_helper_initial_config(helper); if (ret) goto fini; From patchwork Thu Mar 30 07:41:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13193532 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81053C77B62 for ; Thu, 30 Mar 2023 07:41:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229495AbjC3Hl4 (ORCPT ); Thu, 30 Mar 2023 03:41:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbjC3Hly (ORCPT ); Thu, 30 Mar 2023 03:41:54 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74EE8423A for ; Thu, 30 Mar 2023 00:41:53 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E25371FE93; Thu, 30 Mar 2023 07:41:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680162112; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B23GwBjXyqlLfWI6saGLFzkXcQ1lh31OLApNscq2YIA=; b=n+ou+Aa5zsGKe5lp+65Yc9KV0GEjMVjavrB2j5W8qqdGTkigZiSNawRRhsyH5jIBTk11HM 6VPgB1V/3FUoYfB/VT7E9UyHAEQD7H76m1NEcRSPq+4OtKBJjoUkAp5RESGxIKCNzNrOnj sJ1L8CCbx/jjFcutqmxL2hgEryx0g1w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680162112; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B23GwBjXyqlLfWI6saGLFzkXcQ1lh31OLApNscq2YIA=; b=LsUzS8SzQufe5Jk28N3qdv1SFm4xrpHvsFk6chPbeovB++jVH4GJqrDxA5LUHBiQMcYevx ow+yI5M1vOpjVcDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id ECFDF1348E; Thu, 30 Mar 2023 07:41:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2LbTOD89JWSZfQAAMHmgww (envelope-from ); Thu, 30 Mar 2023 07:41:51 +0000 From: Thomas Zimmermann To: robdclark@gmail.com, quic_abhinavk@quicinc.com, dmitry.baryshkov@linaro.org, sean@poorly.run, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 2/6] drm/msm: Remove fb from struct msm_fbdev Date: Thu, 30 Mar 2023 09:41:45 +0200 Message-Id: <20230330074150.7637-3-tzimmermann@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330074150.7637-1-tzimmermann@suse.de> References: <20230330074150.7637-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Fbdev's struct fb_helper stores a pointer to the framebuffer. Remove struct msm_fbdev.fb, which contains thre same value. No functional changes. Signed-off-by: Thomas Zimmermann Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/msm_fbdev.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c index fc7d0406a9f9..323a79d9ef83 100644 --- a/drivers/gpu/drm/msm/msm_fbdev.c +++ b/drivers/gpu/drm/msm/msm_fbdev.c @@ -14,8 +14,6 @@ #include "msm_gem.h" #include "msm_kms.h" -static int msm_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma); - /* * fbdev funcs, to implement legacy fbdev interface on top of drm driver */ @@ -24,9 +22,16 @@ static int msm_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma); struct msm_fbdev { struct drm_fb_helper base; - struct drm_framebuffer *fb; }; +static int msm_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma) +{ + struct drm_fb_helper *helper = (struct drm_fb_helper *)info->par; + struct drm_gem_object *bo = msm_framebuffer_bo(helper->fb, 0); + + return drm_gem_prime_mmap(bo, vma); +} + static const struct fb_ops msm_fb_ops = { .owner = THIS_MODULE, DRM_FB_HELPER_DEFAULT_OPS, @@ -42,19 +47,9 @@ static const struct fb_ops msm_fb_ops = { .fb_mmap = msm_fbdev_mmap, }; -static int msm_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma) -{ - struct drm_fb_helper *helper = (struct drm_fb_helper *)info->par; - struct msm_fbdev *fbdev = to_msm_fbdev(helper); - struct drm_gem_object *bo = msm_framebuffer_bo(fbdev->fb, 0); - - return drm_gem_prime_mmap(bo, vma); -} - static int msm_fbdev_create(struct drm_fb_helper *helper, struct drm_fb_helper_surface_size *sizes) { - struct msm_fbdev *fbdev = to_msm_fbdev(helper); struct drm_device *dev = helper->dev; struct msm_drm_private *priv = dev->dev_private; struct drm_framebuffer *fb = NULL; @@ -101,7 +96,6 @@ static int msm_fbdev_create(struct drm_fb_helper *helper, DBG("fbi=%p, dev=%p", fbi, dev); - fbdev->fb = fb; helper->fb = fb; fbi->fbops = &msm_fb_ops; @@ -118,7 +112,7 @@ static int msm_fbdev_create(struct drm_fb_helper *helper, fbi->fix.smem_len = bo->size; DBG("par=%p, %dx%d", fbi->par, fbi->var.xres, fbi->var.yres); - DBG("allocated %dx%d fb", fbdev->fb->width, fbdev->fb->height); + DBG("allocated %dx%d fb", fb->width, fb->height); return 0; @@ -173,6 +167,7 @@ void msm_fbdev_free(struct drm_device *dev) { struct msm_drm_private *priv = dev->dev_private; struct drm_fb_helper *helper = priv->fbdev; + struct drm_framebuffer *fb = helper->fb; struct msm_fbdev *fbdev; DBG(); @@ -184,11 +179,10 @@ void msm_fbdev_free(struct drm_device *dev) fbdev = to_msm_fbdev(priv->fbdev); /* this will free the backing object */ - if (fbdev->fb) { - struct drm_gem_object *bo = - msm_framebuffer_bo(fbdev->fb, 0); + if (fb) { + struct drm_gem_object *bo = msm_framebuffer_bo(fb, 0); msm_gem_put_vaddr(bo); - drm_framebuffer_remove(fbdev->fb); + drm_framebuffer_remove(fb); } drm_fb_helper_unprepare(helper); From patchwork Thu Mar 30 07:41:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13193535 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B637FC77B6E for ; Thu, 30 Mar 2023 07:41:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229502AbjC3Hl6 (ORCPT ); Thu, 30 Mar 2023 03:41:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbjC3Hly (ORCPT ); Thu, 30 Mar 2023 03:41:54 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B672D44B3 for ; Thu, 30 Mar 2023 00:41:53 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 74ED521B02; Thu, 30 Mar 2023 07:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680162112; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vcvhcEND3/VqOUwWY/SeF/V2jpDMmKQzcmR38yg5AUE=; b=H6XGFuFH0bOqILWli3e2CAPzycS/vX7IPY6VUUa9+w7feMaUnLGrF7jjJhdeTEipg2dfs0 td2b0ml5bGohkztNC4N6ZoWKIY7BMP62jW7g7Ut8GUgnnnINzUXe71EY5XpwPci/AnVPVG j7BATlLdrdlkgFeurwoedTckLvJBWWA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680162112; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vcvhcEND3/VqOUwWY/SeF/V2jpDMmKQzcmR38yg5AUE=; b=uqcDY3w0og4FOhlasw1uowo+lrl3uu6r5c+CCCK4HYlPbZ2n7FWMxAnZAPN2rm6M/gmuGy tsFxEEQnUDrcYqBw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3442A1390D; Thu, 30 Mar 2023 07:41:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YGXjC0A9JWSZfQAAMHmgww (envelope-from ); Thu, 30 Mar 2023 07:41:52 +0000 From: Thomas Zimmermann To: robdclark@gmail.com, quic_abhinavk@quicinc.com, dmitry.baryshkov@linaro.org, sean@poorly.run, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 3/6] drm/msm: Remove struct msm_fbdev Date: Thu, 30 Mar 2023 09:41:46 +0200 Message-Id: <20230330074150.7637-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330074150.7637-1-tzimmermann@suse.de> References: <20230330074150.7637-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Remove struct msm_fbdev, which is an empty wrapper around struct drm_fb_helper. Use the latter directly. No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/msm/msm_fbdev.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c index 323a79d9ef83..0985486d194b 100644 --- a/drivers/gpu/drm/msm/msm_fbdev.c +++ b/drivers/gpu/drm/msm/msm_fbdev.c @@ -18,12 +18,6 @@ * fbdev funcs, to implement legacy fbdev interface on top of drm driver */ -#define to_msm_fbdev(x) container_of(x, struct msm_fbdev, base) - -struct msm_fbdev { - struct drm_fb_helper base; -}; - static int msm_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma) { struct drm_fb_helper *helper = (struct drm_fb_helper *)info->par; @@ -129,16 +123,13 @@ static const struct drm_fb_helper_funcs msm_fb_helper_funcs = { struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev) { struct msm_drm_private *priv = dev->dev_private; - struct msm_fbdev *fbdev; struct drm_fb_helper *helper; int ret; - fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL); - if (!fbdev) + helper = kzalloc(sizeof(*helper), GFP_KERNEL); + if (!helper) return NULL; - helper = &fbdev->base; - drm_fb_helper_prepare(dev, helper, 32, &msm_fb_helper_funcs); ret = drm_fb_helper_init(dev, helper); @@ -159,7 +150,6 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev) drm_fb_helper_fini(helper); fail: drm_fb_helper_unprepare(helper); - kfree(fbdev); return NULL; } @@ -168,7 +158,6 @@ void msm_fbdev_free(struct drm_device *dev) struct msm_drm_private *priv = dev->dev_private; struct drm_fb_helper *helper = priv->fbdev; struct drm_framebuffer *fb = helper->fb; - struct msm_fbdev *fbdev; DBG(); @@ -176,8 +165,6 @@ void msm_fbdev_free(struct drm_device *dev) drm_fb_helper_fini(helper); - fbdev = to_msm_fbdev(priv->fbdev); - /* this will free the backing object */ if (fb) { struct drm_gem_object *bo = msm_framebuffer_bo(fb, 0); @@ -186,7 +173,7 @@ void msm_fbdev_free(struct drm_device *dev) } drm_fb_helper_unprepare(helper); - kfree(fbdev); + kfree(helper); priv->fbdev = NULL; } From patchwork Thu Mar 30 07:41:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13193534 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B99EBC77B6D for ; Thu, 30 Mar 2023 07:41:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229453AbjC3Hl4 (ORCPT ); Thu, 30 Mar 2023 03:41:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjC3Hly (ORCPT ); Thu, 30 Mar 2023 03:41:54 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F22E244B8 for ; Thu, 30 Mar 2023 00:41:53 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 68AF61FE94; Thu, 30 Mar 2023 07:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680162112; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9Fs0TSV7YnG4gHE7IXONT2StiMW8F6KBBESqQJ4Y8tQ=; b=ispgUMQfezZGd8KfSNuTJ8D8mOmKS12saNrk3sxCmKvi60U2/ofbZ40y9sGJwp10UMHeA5 YqTI1yIaJvTqRiPS8Nw8jML9WEEyGIaH+NcewnYAzokn+utBM78qGsH3XXsmrAG3smeKHm xm+UVd0WySAxe1GGD0W5ZNNIjuKCq2o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680162112; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9Fs0TSV7YnG4gHE7IXONT2StiMW8F6KBBESqQJ4Y8tQ=; b=TrZOlcAE6K7Fnae3QgtvZdRNcATyPlT/NIlwCqkB6VoIuSU/upOQCz5oITYTU58SZ9hzrX DpHof8QR98w8pOCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6E31B1348E; Thu, 30 Mar 2023 07:41:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uEsAGkA9JWSZfQAAMHmgww (envelope-from ); Thu, 30 Mar 2023 07:41:52 +0000 From: Thomas Zimmermann To: robdclark@gmail.com, quic_abhinavk@quicinc.com, dmitry.baryshkov@linaro.org, sean@poorly.run, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 4/6] drm/msm: Remove fbdev from struct msm_drm_private Date: Thu, 30 Mar 2023 09:41:47 +0200 Message-Id: <20230330074150.7637-5-tzimmermann@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330074150.7637-1-tzimmermann@suse.de> References: <20230330074150.7637-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The DRM device stores a pointer to the fbdev helper. Remove struct msm_drm_private.fbdev, which contains the same value. No functional changes. Signed-off-by: Thomas Zimmermann Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/msm_debugfs.c | 5 ++--- drivers/gpu/drm/msm/msm_drv.c | 4 ++-- drivers/gpu/drm/msm/msm_drv.h | 2 -- drivers/gpu/drm/msm/msm_fbdev.c | 8 ++------ 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_debugfs.c b/drivers/gpu/drm/msm/msm_debugfs.c index d6ecff0ab618..d4b31165708f 100644 --- a/drivers/gpu/drm/msm/msm_debugfs.c +++ b/drivers/gpu/drm/msm/msm_debugfs.c @@ -241,12 +241,11 @@ static int msm_fb_show(struct seq_file *m, void *arg) { struct drm_info_node *node = (struct drm_info_node *) m->private; struct drm_device *dev = node->minor->dev; - struct msm_drm_private *priv = dev->dev_private; struct drm_framebuffer *fb, *fbdev_fb = NULL; - if (priv->fbdev) { + if (dev->fb_helper) { seq_printf(m, "fbcon "); - fbdev_fb = priv->fbdev->fb; + fbdev_fb = dev->fb_helper->fb; msm_framebuffer_describe(fbdev_fb, m); } diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 5211140ec50b..9f076b9ab19b 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -242,7 +242,7 @@ static int msm_drm_uninit(struct device *dev) msm_rd_debugfs_cleanup(priv); #ifdef CONFIG_DRM_FBDEV_EMULATION - if (fbdev && priv->fbdev) + if (ddev->fb_helper) msm_fbdev_free(ddev); #endif @@ -537,7 +537,7 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) #ifdef CONFIG_DRM_FBDEV_EMULATION if (kms && fbdev) - priv->fbdev = msm_fbdev_init(ddev); + msm_fbdev_init(ddev); #endif ret = msm_debugfs_late_init(ddev); diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 9f0c184b02a0..852f88c36621 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -129,8 +129,6 @@ struct msm_drm_private { bool is_a2xx; bool has_cached_coherent; - struct drm_fb_helper *fbdev; - struct msm_rd_state *rd; /* debugfs to dump all submits */ struct msm_rd_state *hangrd; /* debugfs to dump hanging submits */ struct msm_perf_state *perf; diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c index 0985486d194b..95b193a5e0d5 100644 --- a/drivers/gpu/drm/msm/msm_fbdev.c +++ b/drivers/gpu/drm/msm/msm_fbdev.c @@ -122,7 +122,6 @@ static const struct drm_fb_helper_funcs msm_fb_helper_funcs = { /* initialize fbdev helper */ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev) { - struct msm_drm_private *priv = dev->dev_private; struct drm_fb_helper *helper; int ret; @@ -142,8 +141,6 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev) if (ret) goto fini; - priv->fbdev = helper; - return helper; fini: @@ -155,8 +152,7 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev) void msm_fbdev_free(struct drm_device *dev) { - struct msm_drm_private *priv = dev->dev_private; - struct drm_fb_helper *helper = priv->fbdev; + struct drm_fb_helper *helper = dev->fb_helper; struct drm_framebuffer *fb = helper->fb; DBG(); @@ -175,5 +171,5 @@ void msm_fbdev_free(struct drm_device *dev) drm_fb_helper_unprepare(helper); kfree(helper); - priv->fbdev = NULL; + dev->fb_helper = NULL; } From patchwork Thu Mar 30 07:41:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13193536 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DFE3C77B6F for ; Thu, 30 Mar 2023 07:41:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229470AbjC3Hl5 (ORCPT ); Thu, 30 Mar 2023 03:41:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbjC3Hlz (ORCPT ); Thu, 30 Mar 2023 03:41:55 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B9A64681 for ; Thu, 30 Mar 2023 00:41:54 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E4B4821B04; Thu, 30 Mar 2023 07:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680162112; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k930eYMGmtYlGfmZvFTN92NO2Rqb8IiXQ99gQmEMF70=; b=tiW9h0L8QChUMGotD1CXWHHRKCw/4CVPj4AIzOjaS420AvV5VS37oRdi4OgWIjOV9O2kn8 3HRinAMfGPQmWXO25OH1+wOBBHSI2CHnEhUJQQteS0B4ImcZHytIN/tNVKRGulEIUgVJEP 9I/4hPCRjY6p7moWb93jmvoCJUyEwyA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680162112; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k930eYMGmtYlGfmZvFTN92NO2Rqb8IiXQ99gQmEMF70=; b=51La0ssuDzuehYIXDX97g8BY7P8gQA/PCjWP2mzCdMls/IzYDKDXPp5r9B7i8lq8nwnf6Y zZddapDX2q+e3FCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id AF7041390D; Thu, 30 Mar 2023 07:41:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2NjUKUA9JWSZfQAAMHmgww (envelope-from ); Thu, 30 Mar 2023 07:41:52 +0000 From: Thomas Zimmermann To: robdclark@gmail.com, quic_abhinavk@quicinc.com, dmitry.baryshkov@linaro.org, sean@poorly.run, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 5/6] drm/msm: Initialize fbdev DRM client Date: Thu, 30 Mar 2023 09:41:48 +0200 Message-Id: <20230330074150.7637-6-tzimmermann@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330074150.7637-1-tzimmermann@suse.de> References: <20230330074150.7637-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Initialize the fbdev client in the fbdev code with empty helper functions. Also clean up the client. The helpers will later implement various functionality of the DRM client. No functional changes. Signed-off-by: Thomas Zimmermann Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/msm_fbdev.c | 38 +++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c index 95b193a5e0d5..6c3665c5f4f6 100644 --- a/drivers/gpu/drm/msm/msm_fbdev.c +++ b/drivers/gpu/drm/msm/msm_fbdev.c @@ -119,6 +119,30 @@ static const struct drm_fb_helper_funcs msm_fb_helper_funcs = { .fb_probe = msm_fbdev_create, }; +/* + * struct drm_client + */ + +static void msm_fbdev_client_unregister(struct drm_client_dev *client) +{ } + +static int msm_fbdev_client_restore(struct drm_client_dev *client) +{ + return 0; +} + +static int msm_fbdev_client_hotplug(struct drm_client_dev *client) +{ + return 0; +} + +static const struct drm_client_funcs msm_fbdev_client_funcs = { + .owner = THIS_MODULE, + .unregister = msm_fbdev_client_unregister, + .restore = msm_fbdev_client_restore, + .hotplug = msm_fbdev_client_hotplug, +}; + /* initialize fbdev helper */ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev) { @@ -131,10 +155,16 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev) drm_fb_helper_prepare(dev, helper, 32, &msm_fb_helper_funcs); + ret = drm_client_init(dev, &helper->client, "fbdev", &msm_fbdev_client_funcs); + if (ret) { + drm_err(dev, "Failed to register client: %d\n", ret); + goto err_drm_fb_helper_unprepare; + } + ret = drm_fb_helper_init(dev, helper); if (ret) { DRM_DEV_ERROR(dev->dev, "could not init fbdev: ret=%d\n", ret); - goto fail; + goto err_drm_client_release; } ret = drm_fb_helper_initial_config(helper); @@ -145,8 +175,11 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev) fini: drm_fb_helper_fini(helper); -fail: +err_drm_client_release: + drm_client_release(&helper->client); +err_drm_fb_helper_unprepare: drm_fb_helper_unprepare(helper); + kfree(helper); return NULL; } @@ -168,6 +201,7 @@ void msm_fbdev_free(struct drm_device *dev) drm_framebuffer_remove(fb); } + drm_client_release(&helper->client); drm_fb_helper_unprepare(helper); kfree(helper); From patchwork Thu Mar 30 07:41:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13193537 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53464C761AF for ; Thu, 30 Mar 2023 07:41:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229379AbjC3Hl6 (ORCPT ); Thu, 30 Mar 2023 03:41:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjC3Hl4 (ORCPT ); Thu, 30 Mar 2023 03:41:56 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 815DE449A for ; Thu, 30 Mar 2023 00:41:54 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EA6D31FE95; Thu, 30 Mar 2023 07:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680162113; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jjCvHpF+Kph2AgTs69/ppHdfUEOcbkMXSLFRHnMYSQ0=; b=NSuN7zqRmkNGSKELGbYljGLhQeLePBiI60aUyywMJZhh/VT3ILUPPqX7+zLQF50L0RY6Wr ri5mogFsBm4SXW5a2RMht6raSxPtPk86RFC5Hzl/7rtjfqEJmIahKLF460JpibPP8n5cSR OX9/hTRmzDf24VrGg9r7GsU5yuNaKTo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680162113; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jjCvHpF+Kph2AgTs69/ppHdfUEOcbkMXSLFRHnMYSQ0=; b=AotYkq8iJJuSFjYyBAj/6yLkccy+cFE9bat9DwLjvUDbNVUHQ7tKi4toXs7Sxo8Pcw0Tzr 5jYp3ErR/OoozkBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id EAEF51348E; Thu, 30 Mar 2023 07:41:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oE5bOEA9JWSZfQAAMHmgww (envelope-from ); Thu, 30 Mar 2023 07:41:52 +0000 From: Thomas Zimmermann To: robdclark@gmail.com, quic_abhinavk@quicinc.com, dmitry.baryshkov@linaro.org, sean@poorly.run, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 6/6] drm/msm: Implement fbdev emulation as in-kernel client Date: Thu, 30 Mar 2023 09:41:49 +0200 Message-Id: <20230330074150.7637-7-tzimmermann@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330074150.7637-1-tzimmermann@suse.de> References: <20230330074150.7637-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Move code from ad-hoc fbdev callbacks into DRM client functions and remove the old callbacks. The functions instruct the client to poll for changed output or restore the display. The DRM core calls both, the old callbacks and the new client helpers, from the same places. The new functions perform the same operation as before, so there's no change in functionality. Replace all code that initializes or releases fbdev emulation throughout the driver. Instead initialize the fbdev client by a single call to msm_fbdev_setup() after msm has registered its DRM device. As in most drivers, msm's fbdev emulation now acts like a regular DRM client. The fbdev client setup consists of the initial preparation and the hot-plugging of the display. The latter creates the fbdev device and sets up the fbdev framebuffer. The setup performs display hot-plugging once. If no display can be detected, DRM probe helpers re-run the detection on each hotplug event. A call to drm_dev_unregister() releases the client automatically. No further action is required within msm. If the fbdev framebuffer has been fully set up, struct fb_ops.fb_destroy implements the release. For partially initialized emulation, the fbdev client reverts the initial setup. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/msm/msm_debugfs.c | 1 + drivers/gpu/drm/msm/msm_drv.c | 15 +--- drivers/gpu/drm/msm/msm_drv.h | 10 ++- drivers/gpu/drm/msm/msm_fbdev.c | 113 ++++++++++++++++++------------ 4 files changed, 80 insertions(+), 59 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_debugfs.c b/drivers/gpu/drm/msm/msm_debugfs.c index d4b31165708f..54f5c91a3e19 100644 --- a/drivers/gpu/drm/msm/msm_debugfs.c +++ b/drivers/gpu/drm/msm/msm_debugfs.c @@ -10,6 +10,7 @@ #include #include +#include #include #include diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 9f076b9ab19b..339e3523ccb7 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -54,7 +54,6 @@ static const struct drm_mode_config_funcs mode_config_funcs = { .fb_create = msm_framebuffer_create, - .output_poll_changed = drm_fb_helper_output_poll_changed, .atomic_check = drm_atomic_helper_check, .atomic_commit = drm_atomic_helper_commit, }; @@ -241,11 +240,6 @@ static int msm_drm_uninit(struct device *dev) msm_perf_debugfs_cleanup(priv); msm_rd_debugfs_cleanup(priv); -#ifdef CONFIG_DRM_FBDEV_EMULATION - if (ddev->fb_helper) - msm_fbdev_free(ddev); -#endif - msm_disp_snapshot_destroy(ddev); drm_mode_config_cleanup(ddev); @@ -535,17 +529,15 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) } drm_mode_config_reset(ddev); -#ifdef CONFIG_DRM_FBDEV_EMULATION - if (kms && fbdev) - msm_fbdev_init(ddev); -#endif - ret = msm_debugfs_late_init(ddev); if (ret) goto err_msm_uninit; drm_kms_helper_poll_init(ddev); + if (kms && fbdev) + msm_fbdev_setup(ddev); + return 0; err_msm_uninit: @@ -1074,7 +1066,6 @@ static const struct drm_driver msm_driver = { DRIVER_SYNCOBJ, .open = msm_open, .postclose = msm_postclose, - .lastclose = drm_fb_helper_lastclose, .dumb_create = msm_gem_dumb_create, .dumb_map_offset = msm_gem_dumb_map_offset, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 852f88c36621..11a9d2ce07a1 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -304,8 +303,13 @@ struct drm_framebuffer *msm_framebuffer_create(struct drm_device *dev, struct drm_framebuffer * msm_alloc_stolen_fb(struct drm_device *dev, int w, int h, int p, uint32_t format); -struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev); -void msm_fbdev_free(struct drm_device *dev); +#ifdef CONFIG_DRM_FBDEV_EMULATION +void msm_fbdev_setup(struct drm_device *dev); +#else +static inline void msm_fbdev_setup(struct drm_device *dev) +{ +} +#endif struct hdmi; #ifdef CONFIG_DRM_MSM_HDMI diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c index 6c3665c5f4f6..33570ef504bf 100644 --- a/drivers/gpu/drm/msm/msm_fbdev.c +++ b/drivers/gpu/drm/msm/msm_fbdev.c @@ -4,7 +4,8 @@ * Author: Rob Clark */ -#include +#include +#include #include #include #include @@ -26,6 +27,25 @@ static int msm_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma) return drm_gem_prime_mmap(bo, vma); } +static void msm_fbdev_fb_destroy(struct fb_info *info) +{ + struct drm_fb_helper *helper = (struct drm_fb_helper *)info->par; + struct drm_framebuffer *fb = helper->fb; + struct drm_gem_object *bo = msm_framebuffer_bo(fb, 0); + + DBG(); + + drm_fb_helper_fini(helper); + + /* this will free the backing object */ + msm_gem_put_vaddr(bo); + drm_framebuffer_remove(fb); + + drm_client_release(&helper->client); + drm_fb_helper_unprepare(helper); + kfree(helper); +} + static const struct fb_ops msm_fb_ops = { .owner = THIS_MODULE, DRM_FB_HELPER_DEFAULT_OPS, @@ -39,6 +59,7 @@ static const struct fb_ops msm_fb_ops = { .fb_copyarea = drm_fb_helper_sys_copyarea, .fb_imageblit = drm_fb_helper_sys_imageblit, .fb_mmap = msm_fbdev_mmap, + .fb_destroy = msm_fbdev_fb_destroy, }; static int msm_fbdev_create(struct drm_fb_helper *helper, @@ -124,16 +145,52 @@ static const struct drm_fb_helper_funcs msm_fb_helper_funcs = { */ static void msm_fbdev_client_unregister(struct drm_client_dev *client) -{ } +{ + struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client); + + if (fb_helper->info) { + drm_fb_helper_unregister_info(fb_helper); + } else { + drm_client_release(&fb_helper->client); + drm_fb_helper_unprepare(fb_helper); + kfree(fb_helper); + } +} static int msm_fbdev_client_restore(struct drm_client_dev *client) { + drm_fb_helper_lastclose(client->dev); + return 0; } static int msm_fbdev_client_hotplug(struct drm_client_dev *client) { + struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client); + struct drm_device *dev = client->dev; + int ret; + + if (dev->fb_helper) + return drm_fb_helper_hotplug_event(dev->fb_helper); + + ret = drm_fb_helper_init(dev, fb_helper); + if (ret) + goto err_drm_err; + + if (!drm_drv_uses_atomic_modeset(dev)) + drm_helper_disable_unused_functions(dev); + + ret = drm_fb_helper_initial_config(fb_helper); + if (ret) + goto err_drm_fb_helper_fini; + return 0; + +err_drm_fb_helper_fini: + drm_fb_helper_fini(fb_helper); +err_drm_err: + drm_err(dev, "Failed to setup fbdev emulation (ret=%d)\n", ret); + return ret; } static const struct drm_client_funcs msm_fbdev_client_funcs = { @@ -144,15 +201,17 @@ static const struct drm_client_funcs msm_fbdev_client_funcs = { }; /* initialize fbdev helper */ -struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev) +void msm_fbdev_setup(struct drm_device *dev) { struct drm_fb_helper *helper; int ret; + drm_WARN(dev, !dev->registered, "Device has not been registered.\n"); + drm_WARN(dev, dev->fb_helper, "fb_helper is already set!\n"); + helper = kzalloc(sizeof(*helper), GFP_KERNEL); if (!helper) - return NULL; - + return; drm_fb_helper_prepare(dev, helper, 32, &msm_fb_helper_funcs); ret = drm_client_init(dev, &helper->client, "fbdev", &msm_fbdev_client_funcs); @@ -161,49 +220,15 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev) goto err_drm_fb_helper_unprepare; } - ret = drm_fb_helper_init(dev, helper); - if (ret) { - DRM_DEV_ERROR(dev->dev, "could not init fbdev: ret=%d\n", ret); - goto err_drm_client_release; - } - - ret = drm_fb_helper_initial_config(helper); + ret = msm_fbdev_client_hotplug(&helper->client); if (ret) - goto fini; + drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); - return helper; + drm_client_register(&helper->client); -fini: - drm_fb_helper_fini(helper); -err_drm_client_release: - drm_client_release(&helper->client); -err_drm_fb_helper_unprepare: - drm_fb_helper_unprepare(helper); - kfree(helper); - return NULL; -} + return; -void msm_fbdev_free(struct drm_device *dev) -{ - struct drm_fb_helper *helper = dev->fb_helper; - struct drm_framebuffer *fb = helper->fb; - - DBG(); - - drm_fb_helper_unregister_info(helper); - - drm_fb_helper_fini(helper); - - /* this will free the backing object */ - if (fb) { - struct drm_gem_object *bo = msm_framebuffer_bo(fb, 0); - msm_gem_put_vaddr(bo); - drm_framebuffer_remove(fb); - } - - drm_client_release(&helper->client); +err_drm_fb_helper_unprepare: drm_fb_helper_unprepare(helper); kfree(helper); - - dev->fb_helper = NULL; }