From nobody Thu Nov 14 16:53:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66FA97FBC9 for ; Wed, 7 Feb 2024 14:53:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707317603; cv=none; b=ef1yHOBtPubJkTNAi2n4NGonhWLEl9QFL8HPuWgymED3Ojxlr1vYjDIPYArMJb0/9oRqc9XtpmC1FCJwkjlEOvIvx+CHq7jZL3oI7NngUIhJLetHRT1n5wwuyBeeAdMhkWfPsWyj3AjA5jVxiv/xkfDs1kw6Ei5Ia5LHjQwGYQU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707317603; c=relaxed/simple; bh=FRESMp3mK4eodAj8xjfDcef8szgxRgcVu5YmFtftXyQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FK4j2yrc/unoIk5/CkDOiUuwzig4UoFvKjKXxD7Ynm4iawRUacG1cfGbnjXnwfo/T3EGshMS9JkbkB5yjtT//JehlLIlsL2OjjnNDURaBZiO50QMjWTao4bSoZfZvdGmIgEL9uy6ItbQ9ueiZ2+Cmekw5GY2K9KoAqIPAff1RGQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=VroG5qhj; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="VroG5qhj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1707317600; bh=FRESMp3mK4eodAj8xjfDcef8szgxRgcVu5YmFtftXyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VroG5qhjK5El2FkUj+KywtRKuBWVctYI+DdkC+kdw1yTTUFtRP3BMBoNoUI2uJGVg TwazTRF6twnzxDyOjVznkqW8lEOmPZwqjfCPAJU0fUbIhOMiJfyK2ASmarHPElURcc LhI1AKR1h4tRNiflQpQprGZ1BLY8VQ6f8JQfxAUS4ZHMMBHE5ZOR5fDkFbDyf/M1EB 1YulZ23GS14fQplL/L4f3gLUdaddrhYC0ItPEAWKe6YAQPuuU3TS12PHHb3c5pAiXW epvCD6kNFPb+0ijwkRPmIVfMEVou3oZ+jgCn4+r0azEdQeaJ7lIZxnoVw/fAtRjeQA /ayr828V0Pmkw== Received: from IcarusMOD.eternityproject.eu (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 034A03782059; Wed, 7 Feb 2024 14:53:19 +0000 (UTC) From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: fshao@chromium.org, p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, Alexandre Mergnat Subject: [PATCH v5 6/9] drm/mediatek: dsi: Register DSI host after acquiring clocks and PHY Date: Wed, 7 Feb 2024 15:53:04 +0100 Message-ID: <20240207145307.1626009-7-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240207145307.1626009-1-angelogioacchino.delregno@collabora.com> References: <20240207145307.1626009-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Registering the dsi host with its ops before getting dsi->regs is simply wrong: even though there's nothing (for now) asynchronously calling those ops before the end of the probe function, installing ops that are using iospace(s) and clocks before even initializing those is too fragile. Register the DSI host after getting clocks, iospace and PHY. This wil also allow to simplify the error paths in a later commit. Reviewed-by: Alexandre Mergnat Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dsi.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/= mtk_dsi.c index 52758cab0abf..b3dd6251d611 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -1114,14 +1114,6 @@ static int mtk_dsi_probe(struct platform_device *pde= v) if (!dsi) return -ENOMEM; =20 - dsi->host.ops =3D &mtk_dsi_ops; - dsi->host.dev =3D dev; - ret =3D mipi_dsi_host_register(&dsi->host); - if (ret < 0) { - dev_err(dev, "failed to register DSI host: %d\n", ret); - return ret; - } - dsi->driver_data =3D of_device_get_match_data(dev); =20 dsi->engine_clk =3D devm_clk_get(dev, "engine"); @@ -1130,7 +1122,7 @@ static int mtk_dsi_probe(struct platform_device *pdev) =20 if (ret !=3D -EPROBE_DEFER) dev_err(dev, "Failed to get engine clock: %d\n", ret); - goto err_unregister_host; + return ret; } =20 dsi->digital_clk =3D devm_clk_get(dev, "digital"); @@ -1139,14 +1131,14 @@ static int mtk_dsi_probe(struct platform_device *pd= ev) =20 if (ret !=3D -EPROBE_DEFER) dev_err(dev, "Failed to get digital clock: %d\n", ret); - goto err_unregister_host; + return ret; } =20 dsi->hs_clk =3D devm_clk_get(dev, "hs"); if (IS_ERR(dsi->hs_clk)) { ret =3D PTR_ERR(dsi->hs_clk); dev_err(dev, "Failed to get hs clock: %d\n", ret); - goto err_unregister_host; + return ret; } =20 regs =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -1154,20 +1146,28 @@ static int mtk_dsi_probe(struct platform_device *pd= ev) if (IS_ERR(dsi->regs)) { ret =3D PTR_ERR(dsi->regs); dev_err(dev, "Failed to ioremap memory: %d\n", ret); - goto err_unregister_host; + return ret; } =20 dsi->phy =3D devm_phy_get(dev, "dphy"); if (IS_ERR(dsi->phy)) { ret =3D PTR_ERR(dsi->phy); dev_err(dev, "Failed to get MIPI-DPHY: %d\n", ret); - goto err_unregister_host; + return ret; } =20 irq_num =3D platform_get_irq(pdev, 0); if (irq_num < 0) { ret =3D irq_num; - goto err_unregister_host; + return ret; + } + + dsi->host.ops =3D &mtk_dsi_ops; + dsi->host.dev =3D dev; + ret =3D mipi_dsi_host_register(&dsi->host); + if (ret < 0) { + dev_err(dev, "failed to register DSI host: %d\n", ret); + return ret; } =20 ret =3D devm_request_irq(&pdev->dev, irq_num, mtk_dsi_irq, --=20 2.43.0