From patchwork Tue Oct 5 23:13:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 515263 Delivered-To: patch@linaro.org Received: by 2002:ac0:890a:0:0:0:0:0 with SMTP id 10csp39670imy; Tue, 5 Oct 2021 16:11:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKkIBeZIcspR4M6DGsDRx5GsRFhURxwxfbi8LYENkXt8/g1lCNOvnH3tookAR+S3q58Hjq X-Received: by 2002:a50:da04:: with SMTP id z4mr29802024edj.52.1633475508736; Tue, 05 Oct 2021 16:11:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633475508; cv=none; d=google.com; s=arc-20160816; b=pIkcWH9tX44OQyCwR5Aa8cGirVon73EpDrNp0j/trjABthjcwPGr539Q6ibjM0GXIB kbO6g0dkrf2Cr6Zk6zh3xj8X1mY2rkfDPZ/htU+gC0d4ga20QL9sj4QTxizlvIDvGTRq btrBOx6KY5KmJa8IalZrfcRufcxCbXPcUdkB1IqwO182TuYXfzvFDmbGyjrTDOEnvB9/ 0eTEid7TGRQEab2stXLL+/2gEowSCA5QGDxb6bnNLPD94HEMZTckQ9XXBsZ0tFwAi07G vBmix6JNhlfi5B3wnB1jLZKG9ZYcV0p5LrkasuGFjpGapBGthV8iUXPC0qMAeT0/80TO 3bFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2pICawon058eA4UB8HcOkQdvCRqMMsaUR9GicnZohrY=; b=qxs5ja6u+C1NU30DeQUf5AWmpcf52i/s+wLJjTl0ujDiKzKXmjItd1Vn3yiKMyuGmg 2qGcJ6lTGuKXwhT9FrN/ArVL9rXmWZ+TfPNFJPD2GtbDXoFVt11hrQHOFnj2+p+tb/aR os5cyz6Q6/DOPR1WyKio9ePqpiPjfu6dsc7z1y5xk4hf6Vc4DWOxRdz1J74JSsYnIDB5 NmLRNomooWGwfYuPI8sXgPiJythjeVpncez6qFgxxzY2/eY7XjPyarKodd3NR2pukYj3 IY4xtHTLiffOPoXldQ4IilhlxQyF4/GbSYl1a/VeQDr3S+Ka+olHtf56V8Oy7Jzc7lHD Rkdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gDnrJ5JF; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds19si24535102ejc.662.2021.10.05.16.11.48; Tue, 05 Oct 2021 16:11:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gDnrJ5JF; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236986AbhJEXNg (ORCPT + 17 others); Tue, 5 Oct 2021 19:13:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236931AbhJEXNf (ORCPT ); Tue, 5 Oct 2021 19:13:35 -0400 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F936C061749 for ; Tue, 5 Oct 2021 16:11:44 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id r43-20020a05683044ab00b0054716b40005so884905otv.4 for ; Tue, 05 Oct 2021 16:11:44 -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 :mime-version:content-transfer-encoding; bh=2pICawon058eA4UB8HcOkQdvCRqMMsaUR9GicnZohrY=; b=gDnrJ5JFLbOUKCpkUvWM2yB+49MeeImDcivrMw6hANITtE/4wU0nEhJ73Egi+NKPwE zQOELXNY4rgLcSRRT+XK8WhWUjuq/qNqCYvpjaRcK56v+IZ0oNkYX667H5Na0WSAiiK8 LTeoPRNxS6spJ+ZbBkvERZMG/MJ7Q0/nx7COelZmajl9KwYUyJZHr9siSIU78Mx9nw4C kSZ2OOzbPxEkMwnR0wgGdsIN/sxy4AlJGHYUJHIYh8PpYAuXajsmPhbRmtBx/2bYHj+L nmxxdeDbvjLH27xgG59usxIPcvW/vGWe1OEQ0ExVlA0caXbiQZRK0MjXLJZab7NeZ+Ul bR3A== 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=2pICawon058eA4UB8HcOkQdvCRqMMsaUR9GicnZohrY=; b=bfiSsxBhVE729DsnQm9jlLsgOohHfpHvNAVU8GveuboMpUiGOE6Iydr5U0h6kxqC2f rqGRv2JWOMd/XVqq6kD06JX3RIsW+BRwyHhuGrlOo6WeephrEkj0S7a+ua9g3GAstlsG pKS4fK1tTpFqCA4vooDbH1lgVvcdHLL6woWpybaY68l61v4Yr8dgKsBtVBkORs1qKBJK yh2TIfaWgsMOjahDq7a7LQKhix+2q2DyQ9C47Xn/Ttuj6mK8zdTzLRRY/YA6OMEKZun7 GWckUOtNj1GGb/a5vgQCs9uNJmgx+j0mD4TFIRT2P5gIssxP6P663C98dW41+KN8ulsv GxLg== X-Gm-Message-State: AOAM531sgCw1j6HhkAYMGRGBEEsYNql+3ePJlinUGMZDMNHKWCfDul71 uSQR2zA68aeW6jQ6BADkOUii0g== X-Received: by 2002:a05:6830:1644:: with SMTP id h4mr15913882otr.199.1633475503733; Tue, 05 Oct 2021 16:11:43 -0700 (PDT) Received: from localhost.localdomain ([2600:1700:a0:3dc8:205:1bff:fec0:b9b3]) by smtp.gmail.com with ESMTPSA id v9sm1665141oth.62.2021.10.05.16.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 16:11:43 -0700 (PDT) From: Bjorn Andersson To: Rob Clark , Sean Paul , David Airlie , Daniel Vetter , Abhinav Kumar , Dmitry Baryshkov , Kalyan Thota , Kuogee Hsieh Cc: Rob Herring , Stephen Boyd , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/7] drm/msm/dp: Remove global g_dp_display variable Date: Tue, 5 Oct 2021 16:13:17 -0700 Message-Id: <20211005231323.2663520-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20211005231323.2663520-1-bjorn.andersson@linaro.org> References: <20211005231323.2663520-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org As the Qualcomm DisplayPort driver only supports a single instance of the driver the commonly used struct dp_display is kept in a global variable. As we introduce additional instances this obviously doesn't work. Replace this with a combination of existing references to adjacent objects and drvdata. Reviewed-by: Abhinav Kumar Reviewed-by: Stephen Boyd Signed-off-by: Bjorn Andersson --- Changes since v3: - None drivers/gpu/drm/msm/dp/dp_display.c | 80 ++++++++--------------------- 1 file changed, 21 insertions(+), 59 deletions(-) -- 2.29.2 diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index fbe4c2cd52a3..5d3ee5ef07c2 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -27,7 +27,6 @@ #include "dp_audio.h" #include "dp_debug.h" -static struct msm_dp *g_dp_display; #define HPD_STRING_SIZE 30 enum { @@ -121,6 +120,13 @@ static const struct of_device_id dp_dt_match[] = { {} }; +static struct dp_display_private *dev_get_dp_display_private(struct device *dev) +{ + struct msm_dp *dp = dev_get_drvdata(dev); + + return container_of(dp, struct dp_display_private, dp_display); +} + static int dp_add_event(struct dp_display_private *dp_priv, u32 event, u32 data, u32 delay) { @@ -197,15 +203,12 @@ static int dp_display_bind(struct device *dev, struct device *master, void *data) { int rc = 0; - struct dp_display_private *dp; - struct drm_device *drm; + struct dp_display_private *dp = dev_get_dp_display_private(dev); struct msm_drm_private *priv; + struct drm_device *drm; drm = dev_get_drvdata(master); - dp = container_of(g_dp_display, - struct dp_display_private, dp_display); - dp->dp_display.drm_dev = drm; priv = drm->dev_private; priv->dp = &(dp->dp_display); @@ -240,13 +243,10 @@ static int dp_display_bind(struct device *dev, struct device *master, static void dp_display_unbind(struct device *dev, struct device *master, void *data) { - struct dp_display_private *dp; + struct dp_display_private *dp = dev_get_dp_display_private(dev); struct drm_device *drm = dev_get_drvdata(master); struct msm_drm_private *priv = drm->dev_private; - dp = container_of(g_dp_display, - struct dp_display_private, dp_display); - dp_power_client_deinit(dp->power); dp_aux_unregister(dp->aux); priv->dp = NULL; @@ -379,38 +379,17 @@ static void dp_display_host_deinit(struct dp_display_private *dp) static int dp_display_usbpd_configure_cb(struct device *dev) { - int rc = 0; - struct dp_display_private *dp; - - if (!dev) { - DRM_ERROR("invalid dev\n"); - rc = -EINVAL; - goto end; - } - - dp = container_of(g_dp_display, - struct dp_display_private, dp_display); + struct dp_display_private *dp = dev_get_dp_display_private(dev); dp_display_host_init(dp, false); - rc = dp_display_process_hpd_high(dp); -end: - return rc; + return dp_display_process_hpd_high(dp); } static int dp_display_usbpd_disconnect_cb(struct device *dev) { int rc = 0; - struct dp_display_private *dp; - - if (!dev) { - DRM_ERROR("invalid dev\n"); - rc = -EINVAL; - return rc; - } - - dp = container_of(g_dp_display, - struct dp_display_private, dp_display); + struct dp_display_private *dp = dev_get_dp_display_private(dev); dp_add_event(dp, EV_USER_NOTIFICATION, false, 0); @@ -472,15 +451,7 @@ static int dp_display_usbpd_attention_cb(struct device *dev) { int rc = 0; u32 sink_request; - struct dp_display_private *dp; - - if (!dev) { - DRM_ERROR("invalid dev\n"); - return -EINVAL; - } - - dp = container_of(g_dp_display, - struct dp_display_private, dp_display); + struct dp_display_private *dp = dev_get_dp_display_private(dev); /* check for any test request issued by sink */ rc = dp_link_process_request(dp->link); @@ -647,7 +618,7 @@ static int dp_hpd_unplug_handle(struct dp_display_private *dp, u32 data) DRM_DEBUG_DP("hpd_state=%d\n", state); /* signal the disconnect event early to ensure proper teardown */ - dp_display_handle_plugged_change(g_dp_display, false); + dp_display_handle_plugged_change(&dp->dp_display, false); /* enable HDP plug interrupt to prepare for next plugin */ dp_catalog_hpd_config_intr(dp->catalog, DP_DP_HPD_PLUG_INT_MASK, true); @@ -842,9 +813,7 @@ static int dp_display_prepare(struct msm_dp *dp) static int dp_display_enable(struct dp_display_private *dp, u32 data) { int rc = 0; - struct msm_dp *dp_display; - - dp_display = g_dp_display; + struct msm_dp *dp_display = &dp->dp_display; DRM_DEBUG_DP("sink_count=%d\n", dp->link->sink_count); if (dp_display->power_on) { @@ -880,9 +849,7 @@ static int dp_display_post_enable(struct msm_dp *dp_display) static int dp_display_disable(struct dp_display_private *dp, u32 data) { - struct msm_dp *dp_display; - - dp_display = g_dp_display; + struct msm_dp *dp_display = &dp->dp_display; if (!dp_display->power_on) return 0; @@ -1237,14 +1204,13 @@ static int dp_display_probe(struct platform_device *pdev) } mutex_init(&dp->event_mutex); - g_dp_display = &dp->dp_display; /* Store DP audio handle inside DP display */ - g_dp_display->dp_audio = dp->audio; + dp->dp_display.dp_audio = dp->audio; init_completion(&dp->audio_comp); - platform_set_drvdata(pdev, g_dp_display); + platform_set_drvdata(pdev, &dp->dp_display); rc = component_add(&pdev->dev, &dp_display_comp_ops); if (rc) { @@ -1257,10 +1223,7 @@ static int dp_display_probe(struct platform_device *pdev) static int dp_display_remove(struct platform_device *pdev) { - struct dp_display_private *dp; - - dp = container_of(g_dp_display, - struct dp_display_private, dp_display); + struct dp_display_private *dp = dev_get_dp_display_private(&pdev->dev); dp_display_deinit_sub_modules(dp); @@ -1315,8 +1278,7 @@ static int dp_pm_resume(struct device *dev) else dp->dp_display.is_connected = false; - dp_display_handle_plugged_change(g_dp_display, - dp->dp_display.is_connected); + dp_display_handle_plugged_change(dp_display, dp->dp_display.is_connected); DRM_DEBUG_DP("After, sink_count=%d is_connected=%d core_inited=%d power_on=%d\n", dp->link->sink_count, dp->dp_display.is_connected,