From patchwork Fri Sep 20 04:09:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 174117 Delivered-To: patches@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1941039ill; Thu, 19 Sep 2019 21:09:21 -0700 (PDT) X-Received: by 2002:a17:90a:22b0:: with SMTP id s45mr2047300pjc.22.1568952561221; Thu, 19 Sep 2019 21:09:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568952561; cv=none; d=google.com; s=arc-20160816; b=j4tkmHB/FofIPVrD1PtVHFs8L8aUOjHC/O2+4LBwh0lJGMLNrot34GmMiJXNjGrWD2 SlXQDerOckTbkFdWNEi/N8XUgPLN16IWaoyO0iB51xH0N7IFk7uiJiHWWlMPiUi52Tlb TWuclV2HXbryOoGlXFhUIEyeGGyPd1uqPXAn7P5ctCNyfU2kP2R41vn5XNdQJcP830O8 2l851lJTalnRsX35aHrjlBY5DX6RZuYZHvBwiFR8l3380yHMXAyYXux7hz7ZYlM6f6nP mk7nCEkqu3d3EzqDlaeK/Pa8r6eTjdub+PmuOyYZD8YPg1VGy+l6ZbOP+cG7mVKHbtaP kMOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=0oUa+nPUEvwigLfR3fD8q9hrkFh2FBtsVieYBDhI8lY=; b=IyvYKuoZB7pXs/wGWqAzBIBNIcaa2bpkA+wi1BhsGRhpfxiQ013pWp2Jb/nH0HAMB5 HKksVdNvjax1hh2D0v9Bi5JAoR+Ra3mwezVDLHtCD2QZPLbabwRgtIXlluO79sanfvVZ EiOSjcGCsNpVMp5uOhvgGmAq8dBvucE1+Lqk5cAM13QjIh/M2jNcEMT6iLwDWXplESf7 5AO/uRaOgdACOT/PUZp9bziP2TiEzTnyfbHNn68n0mmuMIGI8GCWGO3z+BnQ3EQDUSvt ff4zJRjVklvsgfWX5isZwFym2TaqkIzE7tTiHJnKZbp/a20bDQViRweyH8wrMp6kpkAF j+1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t+0UPmc6; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id h1sor969364pls.22.2019.09.19.21.09.21 for (Google Transport Security); Thu, 19 Sep 2019 21:09:21 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t+0UPmc6; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=0oUa+nPUEvwigLfR3fD8q9hrkFh2FBtsVieYBDhI8lY=; b=t+0UPmc6wGPCQgjN9ywEuN9WkeB4yE3EoKdnC8or0/CUcF7IpBsa4Rt0AeodxY9H26 Sbke6hm2L/NupFGFy45tfdG3STwZqZf7Ua8kaKoewEJuk32RIYTE+pQPSgKJWoWpjJaf aC3BrfxI1C39ZD82M4DZGnVpeuO0VgypfiNmkLPu+MG6qaofXd5+96VqCG4juHyl7ZcZ vXXlBYVzt5WYfFy4groT8mAqQFms1w7IKufmCEOhiviYQVBboiVIAQjvndEfaOJNt6je yNELpJlBttA3BHjldBXrP+4GDVTQe3C1frBIjoOBib3P/wCY8v/25hqcWrINtPnfQDib mtWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0oUa+nPUEvwigLfR3fD8q9hrkFh2FBtsVieYBDhI8lY=; b=k9nO3y0g8fNsX7wiHwcq59+Ei6mc4o+cwvcBxhUUmI0E96r+AAFL3ysaiExfbUsozt q/Axvc0Y2R+e3MHeuRY125SHmYOpG/iAjTvRkIiL8GX8Lx/fO9JwFU+XOXevDS2hGIk7 I9+bENazNNWj+Rvk9gberKCpHzs5Ye63oQI6p4YMzqE4VTD1udZK5DEKOxxNsSVrdoi6 /i5YxHTeE03CrWbowmibvWcf/Mblgpnh91MM5JNae+xmMr9yTcEowMiVDY+JzWYwJ9vk LxRmw/SVFHTdiECQcQIrXP0uhObh7bV8yjsVNQxvM9D2iciwxNcX/xWbjOvJpdGF3i0n TIuQ== X-Gm-Message-State: APjAAAU8Fuo741au+JUtn1heBStrd/dKEG5oJ2r1BFsxlj0KwF9IV0kl 7v8XbSbUGR4fuKImsxOKSA7pBbj1 X-Google-Smtp-Source: APXvYqzH4t1yaoaVE0lE/1Nd2Gz2y6Q1Kf1m10aa38+RZcv73Em0v3I7/rmIsWDBianbHj/CqX5Avg== X-Received: by 2002:a17:902:8a88:: with SMTP id p8mr14449000plo.152.1568952560554; Thu, 19 Sep 2019 21:09:20 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id d5sm610016pfa.180.2019.09.19.21.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 21:09:19 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Andrzej Hajda , Matt Redfearn , Xinliang Liu , Rongrong Zou , Laurent Pinchart , Neil Armstrong , Jonas Karlman , Jernej Skrabec , Thierry Reding , David Airlie , Sean Paul , Sam Ravnborg , "dri-devel@lists.freedesktop.org" Subject: [PATCH v2] drm: kirin: Fix dsi probe/attach logic Date: Fri, 20 Sep 2019 04:09:15 +0000 Message-Id: <20190920040915.73599-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 Since commit 83f35bc3a852 ("drm/bridge: adv7511: Attach to DSI host at probe time") landed in -next the HiKey board would fail to boot, looping: adv7511 2-0039: failed to find dsi host messages over and over. Andrzej Hajda suggested this is due to a circular dependency issue, and that the adv7511 change is correcting the improper order used earlier. Unfortunately this means the DSI drivers that use adv7511 need to also need to be updated to use the proper ordering to continue to work. This patch tries to reorder the initialization to register the dsi_host first, and then call component_add via dsi_host_attach, instead of doing that at probe time. This seems to resolve the issue with the HiKey board. Cc: Andrzej Hajda Cc: Matt Redfearn Cc: Xinliang Liu Cc: Rongrong Zou Cc: Laurent Pinchart Cc: Neil Armstrong Cc: Jonas Karlman Cc: Jernej Skrabec Cc: Thierry Reding Cc: David Airlie , Cc: Sean Paul Cc: Sam Ravnborg Cc: "dri-devel@lists.freedesktop.org" Fixes: 83f35bc3a852 ("drm/bridge: adv7511: Attach to DSI host at probe time") Signed-off-by: John Stultz Change-Id: Ia42345f81b4955a732d0251f1d1ddb118f885299 --- v2: Reordered platform_set_drvdata and dsi_host_init, suggested by Andrzej Note: I'm really not super familiar with the DSI code here, and am mostly just trying to refactor the existing code in a similar fashion to the suggested dw-mipi-dsi-rockchip.c implementation. Careful review would be greatly appreciated! --- drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c | 107 +++++++++---------- 1 file changed, 52 insertions(+), 55 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c index 5bf8138941de..0ddf22a8be0f 100644 --- a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c +++ b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c @@ -79,6 +79,7 @@ struct dsi_hw_ctx { }; struct dw_dsi { + struct device *dev; struct drm_encoder encoder; struct drm_bridge *bridge; struct mipi_dsi_host host; @@ -724,51 +725,6 @@ static int dw_drm_encoder_init(struct device *dev, return 0; } -static int dsi_host_attach(struct mipi_dsi_host *host, - struct mipi_dsi_device *mdsi) -{ - struct dw_dsi *dsi = host_to_dsi(host); - - if (mdsi->lanes < 1 || mdsi->lanes > 4) { - DRM_ERROR("dsi device params invalid\n"); - return -EINVAL; - } - - dsi->lanes = mdsi->lanes; - dsi->format = mdsi->format; - dsi->mode_flags = mdsi->mode_flags; - - return 0; -} - -static int dsi_host_detach(struct mipi_dsi_host *host, - struct mipi_dsi_device *mdsi) -{ - /* do nothing */ - return 0; -} - -static const struct mipi_dsi_host_ops dsi_host_ops = { - .attach = dsi_host_attach, - .detach = dsi_host_detach, -}; - -static int dsi_host_init(struct device *dev, struct dw_dsi *dsi) -{ - struct mipi_dsi_host *host = &dsi->host; - int ret; - - host->dev = dev; - host->ops = &dsi_host_ops; - ret = mipi_dsi_host_register(host); - if (ret) { - DRM_ERROR("failed to register dsi host\n"); - return ret; - } - - return 0; -} - static int dsi_bridge_init(struct drm_device *dev, struct dw_dsi *dsi) { struct drm_encoder *encoder = &dsi->encoder; @@ -796,10 +752,6 @@ static int dsi_bind(struct device *dev, struct device *master, void *data) if (ret) return ret; - ret = dsi_host_init(dev, dsi); - if (ret) - return ret; - ret = dsi_bridge_init(drm_dev, dsi); if (ret) return ret; @@ -817,13 +769,22 @@ static const struct component_ops dsi_ops = { .unbind = dsi_unbind, }; -static int dsi_parse_dt(struct platform_device *pdev, struct dw_dsi *dsi) +static int dsi_host_attach(struct mipi_dsi_host *host, + struct mipi_dsi_device *mdsi) { - struct dsi_hw_ctx *ctx = dsi->ctx; - struct device_node *np = pdev->dev.of_node; - struct resource *res; + struct dw_dsi *dsi = host_to_dsi(host); + struct device_node *np = dsi->dev->of_node; int ret; + if (mdsi->lanes < 1 || mdsi->lanes > 4) { + DRM_ERROR("dsi device params invalid\n"); + return -EINVAL; + } + + dsi->lanes = mdsi->lanes; + dsi->format = mdsi->format; + dsi->mode_flags = mdsi->mode_flags; + /* * Get the endpoint node. In our case, dsi has one output port1 * to which the external HDMI bridge is connected. @@ -832,6 +793,42 @@ static int dsi_parse_dt(struct platform_device *pdev, struct dw_dsi *dsi) if (ret) return ret; + return component_add(dsi->dev, &dsi_ops); +} + +static int dsi_host_detach(struct mipi_dsi_host *host, + struct mipi_dsi_device *mdsi) +{ + /* do nothing */ + return 0; +} + +static const struct mipi_dsi_host_ops dsi_host_ops = { + .attach = dsi_host_attach, + .detach = dsi_host_detach, +}; + +static int dsi_host_init(struct device *dev, struct dw_dsi *dsi) +{ + struct mipi_dsi_host *host = &dsi->host; + int ret; + + host->dev = dev; + host->ops = &dsi_host_ops; + ret = mipi_dsi_host_register(host); + if (ret) { + DRM_ERROR("failed to register dsi host\n"); + return ret; + } + + return 0; +} + +static int dsi_parse_dt(struct platform_device *pdev, struct dw_dsi *dsi) +{ + struct dsi_hw_ctx *ctx = dsi->ctx; + struct resource *res; + ctx->pclk = devm_clk_get(&pdev->dev, "pclk"); if (IS_ERR(ctx->pclk)) { DRM_ERROR("failed to get pclk clock\n"); @@ -862,6 +859,7 @@ static int dsi_probe(struct platform_device *pdev) } dsi = &data->dsi; ctx = &data->ctx; + dsi->dev = &pdev->dev; dsi->ctx = ctx; ret = dsi_parse_dt(pdev, dsi); @@ -869,8 +867,7 @@ static int dsi_probe(struct platform_device *pdev) return ret; platform_set_drvdata(pdev, data); - - return component_add(&pdev->dev, &dsi_ops); + return dsi_host_init(&pdev->dev, dsi); } static int dsi_remove(struct platform_device *pdev)