From patchwork Thu Aug 29 06:05:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 172538 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1759409ily; Wed, 28 Aug 2019 23:06:01 -0700 (PDT) X-Received: by 2002:a17:902:a9c3:: with SMTP id b3mr8050846plr.179.1567058761649; Wed, 28 Aug 2019 23:06:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567058761; cv=none; d=google.com; s=arc-20160816; b=hw4YUjp/ohxeE2Jd0iKE0eKQNKw6jIBFQH1tm75SalVn8aDCYGCd+jVFq4kQG51koz fmkxY91J0CSj9jwjWeI7kGyyP4QLFNpCBOsaMHgr7AhAJwEUwMP4YguGCq0PT8sIh5/z qDzVf4I4T0mCMZ6mqy/t6eCsMucPlt9hKkuRYz6scPgmijxMiSoMOjgA8SA4z4y3+izm K2tex7QqWCPrjf3anJsYs5UBTvB3EXJUF7Xlsmw5U7rhFGLhSQKvyqns0xnq59FJ3hzg 751je3fNLwI20sdm4Rt79xd3B+LKqQD8HUUHnB70Rf8sVJXZf5z7ZcRV4YLG+woKMrY8 z/pw== 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=eMIJ3TsGhGRnuDNUUwc9l4LSobYBmRitdXnR8ZzJ74U=; b=nSVGm2lx8jJjMPhayzdl9Em3wk0hyQqexK/3Lq1XodKQMUDJMBzVgmsDKQwF1LnPoS 62OPWvNWXP94yRSzELmWG0SEdHaquoy1aOIAT0UC08Zp7IuEK4gkCotP54vzQs3YXaNE u+pYOgrQOcRdyOqxvsku71VB2AaaLHFUIc0dcvnj/WCUr5xTVnY/I5Sl64Q7CEcgZFsw CfjnAUveRyh8Jy114J7bIRQAWN8l3Ck9fy1bCg44J50IE8C3s7jl2Z41CWWdX4OPprps OFJlEu4Se5HVJk0+t7O28VxeiH7rxODiEpHhgaor14+H8yV8tzV/YmMFFdswWVX+zUhS 4CGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eQ1LpoJs; 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 31sor958353pgy.17.2019.08.28.23.06.01 for (Google Transport Security); Wed, 28 Aug 2019 23:06:01 -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=eQ1LpoJs; 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=eMIJ3TsGhGRnuDNUUwc9l4LSobYBmRitdXnR8ZzJ74U=; b=eQ1LpoJsZsj+y0hpH5fbRMtmOsIeHPLYeOUl7EV7TPv9Alp6hnVmYUlBqiJ1LPjKLc TZ3MvG2VKp8n7i1bTTjar/PCjptvFh/iTHeXAcKFcmJLt4oaJnpJY0yn5GjN3ARMrWUc tQj0cIlhCJj4R30g4+Huh6uF2W9e94AM42pZUebGhRLersAUdVLtzw1aM/N+32Oe/LdI KcGJGlfMYabqhQeABTnmZmmcwA3/Ux7HWLmk9In+wHtCQ1AE7nenJpkSAzqTfU7WkiKk BmU/zIFSLMUAucQHecW9+6PAUgr+Nzko5xNGAmt3QAAqyasd9s+mtXMXMXC0u5324V+d 0jEg== 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=eMIJ3TsGhGRnuDNUUwc9l4LSobYBmRitdXnR8ZzJ74U=; b=qffhzLR9r9UumBxJxL8y+nWTF6UaQopT9L2ec0CI5UUqkmWStlixdtLPRK/fP3ufK+ mrdrn/30acJ4H7Vz5HFY6kzMmujFCTD+cqLgZ81kKSZ3zg+yzmhq+hrmqg8suz+G5zIu yZI2mK3OOoB6GkEXOMBJmCRnBFWQTIHaorxWwCs4BWuoN1itKNnrYkBLraPE7bGDUbj2 04vIsyTY4rtXwYCR08SDfDOyf41t1spQp59OzxSt6nNphd3rb6RplA99mWCKc/+t3CDt 0mq6MsVfYcZmisD8KI8n+L3Iz6pJ2Go2iz2I99xul1Q9cGu/IsQ+l9kceubmOGkgQ4BE F6bg== X-Gm-Message-State: APjAAAVCRbyIokUKtT03Zc27mpiguGqXgWGNGVo0kT/NboeAbLtxRaMk aF2Il2qcTS/pLe02lXITwKcwL+0d X-Google-Smtp-Source: APXvYqyNUXSxwwJvVKiyeJmH5S2YfzX34ueJxZOAozvHNaJhvrDmMYSk/wPXaSO8RPguBig9q6Iy7A== X-Received: by 2002:a65:6152:: with SMTP id o18mr6507955pgv.279.1567058760907; Wed, 28 Aug 2019 23:06:00 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id a6sm1504397pfa.162.2019.08.28.23.05.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2019 23:06:00 -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: [RFC][PATCH] drm: kirin: Fix dsi probe/attach logic Date: Thu, 29 Aug 2019 06:05:50 +0000 Message-Id: <20190829060550.62095-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 --- 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! Also there is an outstanding regression on the db410c since it similarly uses the adv7511 and probably needs a similar rework. --- drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c | 111 ++++++++++--------- 1 file changed, 56 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..696cee1a1219 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,15 +859,19 @@ 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); if (ret) return ret; - platform_set_drvdata(pdev, data); + ret = dsi_host_init(&pdev->dev, dsi); + if (ret) + return ret; - return component_add(&pdev->dev, &dsi_ops); + platform_set_drvdata(pdev, data); + return 0; } static int dsi_remove(struct platform_device *pdev)