From patchwork Wed Jan 19 22:40:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 533288 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1290647imr; Wed, 19 Jan 2022 14:40:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXmUgrR450GTmTUHvGCFf72xwe7s7nFG4VjMN8U9JjtIW0vzUXv0qi/yhubKF8Kla+haYh X-Received: by 2002:a05:6402:5291:: with SMTP id en17mr8121229edb.256.1642632025896; Wed, 19 Jan 2022 14:40:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642632025; cv=none; d=google.com; s=arc-20160816; b=bqrHyYKjj0UqO4bEI5BmlsUjd/pa5u9Os4C2+Mx91UXYgIj/MeNfPakbtwsmm28Ogw +Ev1mCfhmstuduUaL3CcE3eZYstJ1AmzVn2thIMJtWPEpT0guhFWt4i5MPr8g/ieO3ar /3XbLEKOa6DwKqlftI6JL/jUx5zheuyiaWK9IqI9aumQamQviEWbPVUwyPt2dKTaWpVT XcqS2F1JRq2f6apZC7h2LGjtre9gir0a9Day1kOi90nIjNFvnV3AFD6InK95gQzdKIit srn79QBR/6LmTBMO5QzlM2wgOvoG975EXXt3vbkBSTNs2Bk58GHcFXpioLSoJREpCRqU tY+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to; bh=fcrABPHetp/abgLA6a2UTAJ+uLZHWUMNeuXPlKsp0+A=; b=pLPmNT+UC+E/WVj85Z8ieZW70qWjkRlYPME1rpDrs5HlfK6ZzYJRV71l3VmRjzx1PO aSCB98Lkc4w3NCH0Txh2OX/5ftZS7TwD1tmguXS6t+z6yEPtmQiHt1NHwq7g5dwQIlHr ufSpv+Tz3t/zzE6e03GQORq5qDZUBorA6jOQ63G8q50UjdNH8dg8FYdHckKxgEgK4Dqh p1yYwqDY8atz9iugohBe/joIUPkaGqMbf77zaG5JQgT4SjZt9ESHeG5J9fFpO8fVtzZ2 6IpdiHia/tv0Sl6mwsB96ksN87H3v08yUNHCgWePtQMJiOd41sx9FDunq9wOYy2iy8jn xVNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jWOEYTd4; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id g19si595049ejt.871.2022.01.19.14.40.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 14:40:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jWOEYTd4; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=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 EA28710E7D6; Wed, 19 Jan 2022 22:40:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by gabe.freedesktop.org (Postfix) with ESMTPS id CB5D510E282 for ; Wed, 19 Jan 2022 22:40:11 +0000 (UTC) Received: by mail-lf1-x130.google.com with SMTP id br17so14167964lfb.6 for ; Wed, 19 Jan 2022 14:40:11 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=fcrABPHetp/abgLA6a2UTAJ+uLZHWUMNeuXPlKsp0+A=; b=jWOEYTd4/98J7TX3piHkafZN7e/oZDWbLM3BBNiFbjV7H7X3hIHFC2IML5D+T8t27Z yuzfQfEdtI2eh6E3hgZYQLluskPxEqssDqU2i0hpI06LyuweVuM4XPe8j5Z5LCwxB+ht 4eMPTFnbMV5s31aD2oKFcUk81OhE3lZklWQVdM4NjskrlNqCqppnaQcjWdSV522fVphj WQuo8XIA7u7t/Mc5/fNsQspv4yTwJotaLp3AkEj6s1GK2Lwm8W7qfMakPQodjj3m0bzB UM2UVl8CGY9x+rktSa1p9Wpwz7x0fzIIDutW7XTOuft1ZIuuMVG+osy5ub/HEqFqAM27 DetQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fcrABPHetp/abgLA6a2UTAJ+uLZHWUMNeuXPlKsp0+A=; b=zBFtzKzH02hllr3SNSTSutmctNAHfJCk10y2P1NBDsr8gQqJb7zzQe7rT51EJbPmm5 zhbplOwQnCwSMgA69XglXR2JvZ6v6qGNpL2t2fGzfxTDYxOvNdC5fklfXBVnsohVnYGh Y3ud5vzPDWRx6J4Abw+9JdvrBj439pqNTrEIBUQsjILDsfcOW9VessBsTqOlp6q6ZHEa C5TMEur4ny1kK9zZKgYPIfZ11EQ8XpD/o8n/nBBAcxdGaYtM8/OFABRotR1oHZlBbEKN 6Lsw30wtzbGzI82HTirsc+Hpp/xzy+4s591Uhf5g55EkF740tNnsF3KVu2sbE2V1iPGc ys0g== X-Gm-Message-State: AOAM530oLtvNsdOhL4550x178jlMGupTwNMGmQvdNwkIBItDjjVZeZir hqolFtavmEVpQ7xiC5tYi/EISA== X-Received: by 2002:a05:6512:12c9:: with SMTP id p9mr21185355lfg.75.1642632010138; Wed, 19 Jan 2022 14:40:10 -0800 (PST) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id c25sm102719lfh.35.2022.01.19.14.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 14:40:09 -0800 (PST) From: Dmitry Baryshkov To: Bjorn Andersson , Rob Clark , Sean Paul , Abhinav Kumar Subject: [PATCH v2 4/4] drm/msm: stop using device's match data pointer Date: Thu, 20 Jan 2022 01:40:05 +0300 Message-Id: <20220119224005.3104578-5-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220119224005.3104578-1-dmitry.baryshkov@linaro.org> References: <20220119224005.3104578-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, Stephen Boyd , freedreno@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Let's make the match's data pointer a (sub-)driver's private data. The only user currently is the msm_drm_init() function, using this data to select kms_init callback. Pass this callback through the driver's private data instead. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 10 ++++--- drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 14 +++++---- drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 11 ++++--- drivers/gpu/drm/msm/msm_drv.c | 38 ++++++------------------ drivers/gpu/drm/msm/msm_drv.h | 5 +--- drivers/gpu/drm/msm/msm_kms.h | 4 --- drivers/gpu/drm/msm/msm_mdss.c | 23 +++++++------- 7 files changed, 41 insertions(+), 64 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c index a46aa36bc5db..c466cbc56e16 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c @@ -1175,7 +1175,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) return rc; } -struct msm_kms *dpu_kms_init(struct drm_device *dev) +static int dpu_kms_init(struct drm_device *dev) { struct msm_drm_private *priv; struct dpu_kms *dpu_kms; @@ -1183,7 +1183,7 @@ struct msm_kms *dpu_kms_init(struct drm_device *dev) if (!dev) { DPU_ERROR("drm device node invalid\n"); - return ERR_PTR(-EINVAL); + return -EINVAL; } priv = dev->dev_private; @@ -1192,11 +1192,11 @@ struct msm_kms *dpu_kms_init(struct drm_device *dev) irq = irq_of_parse_and_map(dpu_kms->pdev->dev.of_node, 0); if (irq < 0) { DPU_ERROR("failed to get irq: %d\n", irq); - return ERR_PTR(irq); + return irq; } dpu_kms->base.irq = irq; - return &dpu_kms->base; + return 0; } static int dpu_bind(struct device *dev, struct device *master, void *data) @@ -1207,6 +1207,8 @@ static int dpu_bind(struct device *dev, struct device *master, void *data) struct dpu_kms *dpu_kms; int ret = 0; + priv->kms_init = dpu_kms_init; + dpu_kms = devm_kzalloc(&pdev->dev, sizeof(*dpu_kms), GFP_KERNEL); if (!dpu_kms) return -ENOMEM; diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c index c5c0650414c5..2e5f6b6fd3c3 100644 --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c @@ -389,7 +389,7 @@ static void read_mdp_hw_revision(struct mdp4_kms *mdp4_kms, DRM_DEV_INFO(dev->dev, "MDP4 version v%d.%d", *major, *minor); } -struct msm_kms *mdp4_kms_init(struct drm_device *dev) +static int mdp4_kms_init(struct drm_device *dev) { struct platform_device *pdev = to_platform_device(dev->dev); struct mdp4_platform_config *config = mdp4_get_config(pdev); @@ -403,8 +403,7 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev) mdp4_kms = kzalloc(sizeof(*mdp4_kms), GFP_KERNEL); if (!mdp4_kms) { DRM_DEV_ERROR(dev->dev, "failed to allocate kms\n"); - ret = -ENOMEM; - goto fail; + return -ENOMEM; } ret = mdp_kms_init(&mdp4_kms->base, &kms_funcs); @@ -551,12 +550,13 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev) dev->mode_config.max_width = 2048; dev->mode_config.max_height = 2048; - return kms; + return 0; fail: if (kms) mdp4_destroy(kms); - return ERR_PTR(ret); + + return ret; } static struct mdp4_platform_config *mdp4_get_config(struct platform_device *dev) @@ -583,6 +583,8 @@ static int mdp4_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; + priv->kms_init = mdp4_kms_init; + platform_set_drvdata(pdev, priv); /* @@ -600,7 +602,7 @@ static int mdp4_remove(struct platform_device *pdev) } static const struct of_device_id mdp4_dt_match[] = { - { .compatible = "qcom,mdp4", .data = (void *)KMS_MDP4 }, + { .compatible = "qcom,mdp4" }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, mdp4_dt_match); diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c index 81bd434980cf..3b7d7c77c503 100644 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c @@ -551,7 +551,7 @@ static int get_clk(struct platform_device *pdev, struct clk **clkp, return 0; } -struct msm_kms *mdp5_kms_init(struct drm_device *dev) +static int mdp5_kms_init(struct drm_device *dev) { struct msm_drm_private *priv = dev->dev_private; struct platform_device *pdev; @@ -565,7 +565,7 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev) /* priv->kms would have been populated by the MDP5 driver */ kms = priv->kms; if (!kms) - return NULL; + return -ENOMEM; mdp5_kms = to_mdp5_kms(to_mdp_kms(kms)); pdev = mdp5_kms->pdev; @@ -644,11 +644,12 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev) dev->max_vblank_count = 0; /* max_vblank_count is set on each CRTC */ dev->vblank_disable_immediate = true; - return kms; + return 0; fail: if (kms) mdp5_kms_destroy(kms); - return ERR_PTR(ret); + + return ret; } static void mdp5_destroy(struct platform_device *pdev) @@ -810,6 +811,8 @@ static int mdp5_init(struct platform_device *pdev, struct drm_device *dev) u32 major, minor; int ret; + priv->kms_init = mdp5_kms_init; + mdp5_kms = devm_kzalloc(&pdev->dev, sizeof(*mdp5_kms), GFP_KERNEL); if (!mdp5_kms) { ret = -ENOMEM; diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 629f3ac7a88c..b046ea4790db 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -256,13 +256,6 @@ static int msm_drm_uninit(struct device *dev) return 0; } -static int get_mdp_ver(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - - return (int) (unsigned long) of_device_get_match_data(dev); -} - #include bool msm_use_mmu(struct drm_device *dev) @@ -349,7 +342,6 @@ static int msm_init_vram(struct drm_device *dev) static int msm_drm_init(struct device *dev, const struct drm_driver *drv) { - struct platform_device *pdev = to_platform_device(dev); struct msm_drm_private *priv = dev_get_drvdata(dev); struct drm_device *ddev; struct msm_kms *kms; @@ -397,30 +389,18 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) msm_gem_shrinker_init(ddev); - switch (get_mdp_ver(pdev)) { - case KMS_MDP4: - kms = mdp4_kms_init(ddev); - priv->kms = kms; - break; - case KMS_MDP5: - kms = mdp5_kms_init(ddev); - break; - case KMS_DPU: - kms = dpu_kms_init(ddev); - priv->kms = kms; - break; - default: + if (priv->kms_init) { + ret = priv->kms_init(ddev); + if (ret) { + DRM_DEV_ERROR(dev, "failed to load kms\n"); + priv->kms = NULL; + goto err_msm_uninit; + } + kms = priv->kms; + } else { /* valid only for the dummy headless case, where of_node=NULL */ WARN_ON(dev->of_node); kms = NULL; - break; - } - - if (IS_ERR(kms)) { - DRM_DEV_ERROR(dev, "failed to load kms\n"); - ret = PTR_ERR(kms); - priv->kms = NULL; - goto err_msm_uninit; } /* Enable normalization of plane zpos */ diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 6895c056be19..ff19b1bfcbaa 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -139,6 +139,7 @@ struct msm_drm_private { struct drm_device *dev; struct msm_kms *kms; + int (*kms_init)(struct drm_device *dev); /* subordinate devices, if present: */ struct platform_device *gpu_pdev; @@ -451,10 +452,6 @@ static inline void msm_dp_debugfs_init(struct msm_dp *dp_display, #endif -#define KMS_MDP4 4 -#define KMS_MDP5 5 -#define KMS_DPU 3 - void __init msm_mdp4_register(void); void __exit msm_mdp4_unregister(void); void __init msm_mdp_register(void); diff --git a/drivers/gpu/drm/msm/msm_kms.h b/drivers/gpu/drm/msm/msm_kms.h index 13c2eb0b2bcf..1f571372e928 100644 --- a/drivers/gpu/drm/msm/msm_kms.h +++ b/drivers/gpu/drm/msm/msm_kms.h @@ -194,10 +194,6 @@ static inline void msm_kms_destroy(struct msm_kms *kms) msm_atomic_destroy_pending_timer(&kms->pending_timers[i]); } -struct msm_kms *mdp4_kms_init(struct drm_device *dev); -struct msm_kms *mdp5_kms_init(struct drm_device *dev); -struct msm_kms *dpu_kms_init(struct drm_device *dev); - extern const struct of_device_id dpu_dt_match[]; extern const struct of_device_id mdp5_dt_match[]; diff --git a/drivers/gpu/drm/msm/msm_mdss.c b/drivers/gpu/drm/msm/msm_mdss.c index 759076357e0e..f83dca99f03d 100644 --- a/drivers/gpu/drm/msm/msm_mdss.c +++ b/drivers/gpu/drm/msm/msm_mdss.c @@ -314,11 +314,11 @@ static const struct dev_pm_ops mdss_pm_ops = { .complete = msm_pm_complete, }; -static int get_mdp_ver(struct platform_device *pdev) +static bool get_is_mdp5(struct platform_device *pdev) { struct device *dev = &pdev->dev; - return (int) (unsigned long) of_device_get_match_data(dev); + return (bool) (unsigned long) of_device_get_match_data(dev); } static int find_mdp_node(struct device *dev, void *data) @@ -331,21 +331,18 @@ static int mdss_probe(struct platform_device *pdev) { struct msm_mdss *mdss; struct msm_drm_private *priv; - int mdp_ver = get_mdp_ver(pdev); + bool is_mdp5 = get_is_mdp5(pdev); struct device *mdp_dev; struct device *dev = &pdev->dev; int ret; - if (mdp_ver != KMS_MDP5 && mdp_ver != KMS_DPU) - return -EINVAL; - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; platform_set_drvdata(pdev, priv); - mdss = msm_mdss_init(pdev, mdp_ver == KMS_MDP5); + mdss = msm_mdss_init(pdev, is_mdp5); if (IS_ERR(mdss)) { ret = PTR_ERR(mdss); platform_set_drvdata(pdev, NULL); @@ -409,12 +406,12 @@ static int mdss_remove(struct platform_device *pdev) } static const struct of_device_id mdss_dt_match[] = { - { .compatible = "qcom,mdss", .data = (void *)KMS_MDP5 }, - { .compatible = "qcom,sdm845-mdss", .data = (void *)KMS_DPU }, - { .compatible = "qcom,sc7180-mdss", .data = (void *)KMS_DPU }, - { .compatible = "qcom,sc7280-mdss", .data = (void *)KMS_DPU }, - { .compatible = "qcom,sm8150-mdss", .data = (void *)KMS_DPU }, - { .compatible = "qcom,sm8250-mdss", .data = (void *)KMS_DPU }, + { .compatible = "qcom,mdss", .data = (void *)true }, + { .compatible = "qcom,sdm845-mdss", .data = (void *)false }, + { .compatible = "qcom,sc7180-mdss", .data = (void *)false }, + { .compatible = "qcom,sc7280-mdss", .data = (void *)false }, + { .compatible = "qcom,sm8150-mdss", .data = (void *)false }, + { .compatible = "qcom,sm8250-mdss", .data = (void *)false }, {} }; MODULE_DEVICE_TABLE(of, dt_match);