From patchwork Sun Sep 24 19:25:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 13397063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 75082CE7A8A for ; Sun, 24 Sep 2023 19:26:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9E30B8905A; Sun, 24 Sep 2023 19:26:54 +0000 (UTC) Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 72EAF10E133 for ; Sun, 24 Sep 2023 19:26:15 +0000 (UTC) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-99c93638322so1194065766b.1 for ; Sun, 24 Sep 2023 12:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695583574; x=1696188374; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d66F58Zyq56V9Vs4Hyo0TkmljKT89gyNoM7Khlph/EE=; b=GBq3f7Ghbc20gh+JduRz49lzYjQuS1i0aZN40Hj4Svrjp3Ozj+mckXfV9g3fd9elug uOo0Pb/tm9ulpDRIsbjPXNYsIzz5RsErYSY3lTXsvDB5SHpt0lfAFEcuf0Go0Z8hpmrd Ohdkg2ny5qdussv3F6Yhxy0/VhEVlnphTDPEx5XwK38y2G0PLGNGBvum3MrbaMO26Ll8 +AaxA+3YttEDsLBDjjPo9bCcPXKeVWW9PC0c6ZTLdwRnu+wgbIsjgEttKSic+hsjNQNL GuLwQFCFuOfnbgLTRuxdCebsum9Ra0YHgo8Ljshz3ARrgNnMctenxLdRmN3EykVp2G38 qFwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695583574; x=1696188374; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d66F58Zyq56V9Vs4Hyo0TkmljKT89gyNoM7Khlph/EE=; b=UusXxIIpoGnXDwFLV+1KAtfDcdcGuYYHEbSDgjJLjLuVBg3ztIxAiV0JjiHZrfUaCS Qs+CdB3CZY85RKPDoQs8anBWNgWrKkRBZotGv32/YksoE6hYLstbetc9J2w6MICZLtCe YoO+uJUeHNxpcwqQwhXlzqnZQZvxkyt9apzUVR+VI1o63jHYcUV90YaSSTws8AuNhN+j fU0WndOpVYf8+mlCLsxq9kjFbXcbojBljcPb7qQ1p0Gv3FockNettM3xG69kO5OMo3CN Ng/iXgALyqhyI7OU2Q8MBsNLTRSFDuT0nZpTU58YV8GoBSACQzr1brGmWnbIV0qkJw46 kL4w== X-Gm-Message-State: AOJu0Yx57noxZ5hetC69kxB1kGLMnAcnU7aW4/+67mA4wVaUX4m1bcbF erH1YkVWm7iPh++D5LRy+8E= X-Google-Smtp-Source: AGHT+IGtAxBgqINvPVkn897Kub7Z+3KXI91OPf9r4wroQNRiKNPXXt+0g0rub6eEA+V8/peXL8DyGw== X-Received: by 2002:a17:906:74d3:b0:9ae:614e:4560 with SMTP id z19-20020a17090674d300b009ae614e4560mr7802850ejl.29.1695583573619; Sun, 24 Sep 2023 12:26:13 -0700 (PDT) Received: from localhost.localdomain (82-149-12-148.dynamic.telemach.net. [82.149.12.148]) by smtp.gmail.com with ESMTPSA id z21-20020a1709063a1500b0099d0c0bb92bsm5317632eje.80.2023.09.24.12.26.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 12:26:13 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, wens@csie.org Subject: [PATCH 1/7] drm/sun4i: dw-hdmi: Deinit PHY in fail path Date: Sun, 24 Sep 2023 21:25:58 +0200 Message-ID: <20230924192604.3262187-2-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230924192604.3262187-1-jernej.skrabec@gmail.com> References: <20230924192604.3262187-1-jernej.skrabec@gmail.com> 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: samuel@sholland.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Jernej Skrabec , linux-sunxi@lists.linux.dev, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Commit 9bf3797796f5 ("drm/sun4i: dw-hdmi: Make HDMI PHY into a platform device") removed code for PHY deinitialization in fail path. Add it back. Fixes: 9bf3797796f5 ("drm/sun4i: dw-hdmi: Make HDMI PHY into a platform device") Signed-off-by: Jernej Skrabec Acked-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c index 4727dfaa8fb9..0b647b030b15 100644 --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c @@ -203,6 +203,7 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, cleanup_encoder: drm_encoder_cleanup(encoder); + sun8i_hdmi_phy_deinit(hdmi->phy); err_disable_clk_tmds: clk_disable_unprepare(hdmi->clk_tmds); err_assert_ctrl_reset: From patchwork Sun Sep 24 19:25:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 13397057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 91BC6CE7A90 for ; Sun, 24 Sep 2023 19:26:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2966B10E1C1; Sun, 24 Sep 2023 19:26:27 +0000 (UTC) Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4C73A10E133 for ; Sun, 24 Sep 2023 19:26:16 +0000 (UTC) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-9ae7383b7ecso893673966b.0 for ; Sun, 24 Sep 2023 12:26:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695583575; x=1696188375; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7GGwz4wHTU6Hq3RRU7lNI3Q1wc2dl9iWY5fWoPCz14w=; b=hQYoHHWVuNiOi195lJWawSH/kQ4An5JTdy4Esg7CVJOlB8riT5YX2Jnoyd+sYL3YaO 5usr0VqqssFVhmxvXzE44tGYSK41XDKyprlBPqdv0rIYXcFTmOxBkWEoY6BG7Kq5TzDs WSLgmBP3dKepYpmq+8Y303UJHQN7GlcPWqQRALlHnWk4oCAbeWGN+UVKo8F0LYIpSBMB wQxIPqa7FzDNPnhBG9WDY3QCMsMPwxRT8u2arHbw4iIF8qyN2WpfvdvI/mh2zxyWHoUQ Tdxt+h/qzDBIqtByUyA2vELekDWHjRhIa1fCuxPvf4JBecgtTH8Z5Qo4cTSvox1B9mBt 2oWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695583575; x=1696188375; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7GGwz4wHTU6Hq3RRU7lNI3Q1wc2dl9iWY5fWoPCz14w=; b=BYo/FbOMMdeY7WSAdV/hU0QCYL8UjKoOZvG5YVJcepMQcib2y881fr8DErtxR7UlWH YI+rSyvEBsGrhtbvfcP56rRr7YVewvvnXognWVOgoFGC22i13cSvjz+gfHF4bAgg4fLN wHIS/X2uQOjCr02fis/zaeeyD28RqlF4KQrioy/g/KvLs78ZceCFohI1p5masI+W7EK7 +Y6nzGkig+dddZJ2x3KSoXnxhpFwm57Qotrs9q3EDqtwaxWC6uAcho9Cs2o3N8Z4bEdF yCq/4/1sLhfdnyzbKqtbA2U4u28sU1NhkiVGpQR3MA7ypCbTer5YsVLKwT3nC1cO9HAf dHjA== X-Gm-Message-State: AOJu0YzxVbv+QtBX1X/j0rcRBXJB4Qrasnn1/xU4SM8AaHKzSAQsbUcR 2EiPPDLyTT/6/6AFVdWxwmo= X-Google-Smtp-Source: AGHT+IGrm0GcL+bThs+FW6loLKtnsAa0IIh3+UexCsckNUEBFlIPvms+brojuoJoSOy/PrKpwCa8JQ== X-Received: by 2002:a17:907:ea5:b0:9a1:e0b1:e919 with SMTP id ho37-20020a1709070ea500b009a1e0b1e919mr13414633ejc.4.1695583574659; Sun, 24 Sep 2023 12:26:14 -0700 (PDT) Received: from localhost.localdomain (82-149-12-148.dynamic.telemach.net. [82.149.12.148]) by smtp.gmail.com with ESMTPSA id z21-20020a1709063a1500b0099d0c0bb92bsm5317632eje.80.2023.09.24.12.26.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 12:26:14 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, wens@csie.org Subject: [PATCH 2/7] drm/sun4i: dw-hdmi: Remove double encoder cleanup Date: Sun, 24 Sep 2023 21:25:59 +0200 Message-ID: <20230924192604.3262187-3-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230924192604.3262187-1-jernej.skrabec@gmail.com> References: <20230924192604.3262187-1-jernej.skrabec@gmail.com> 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: samuel@sholland.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Jernej Skrabec , linux-sunxi@lists.linux.dev, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" It turns out that comment is wrong - dw hdmi driver never does any encoder cleanup. In fact, cleanup is done automatically, in destroy callback of encoder. Even more, encoder memory will be freed when hdmi device is destroyed. However, encoder will be cleaned up after that, in drm_mode_config_cleanup(), which is called later. This will cause use after free bug. Remove redundant encoder cleanup, switch memory allocation to live as long as drm object and while at it, check return code of encoder initialization. Fixes: b7c7436a5ff0 ("drm/sun4i: Implement A83T HDMI driver") Signed-off-by: Jernej Skrabec Acked-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c index 0b647b030b15..8f8d3bdba5ce 100644 --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -107,7 +108,7 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, if (!pdev->dev.of_node) return -ENODEV; - hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL); + hdmi = drmm_kzalloc(drm, sizeof(*hdmi), GFP_KERNEL); if (!hdmi) return -ENOMEM; @@ -180,7 +181,9 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, goto err_disable_clk_tmds; drm_encoder_helper_add(encoder, &sun8i_dw_hdmi_encoder_helper_funcs); - drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_TMDS); + ret = drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_TMDS); + if (ret) + goto err_deinit_phy; plat_data->mode_valid = hdmi->quirks->mode_valid; plat_data->use_drm_infoframe = hdmi->quirks->use_drm_infoframe; @@ -189,20 +192,14 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, platform_set_drvdata(pdev, hdmi); hdmi->hdmi = dw_hdmi_bind(pdev, encoder, plat_data); - - /* - * If dw_hdmi_bind() fails we'll never call dw_hdmi_unbind(), - * which would have called the encoder cleanup. Do it manually. - */ if (IS_ERR(hdmi->hdmi)) { ret = PTR_ERR(hdmi->hdmi); - goto cleanup_encoder; + goto err_deinit_phy; } return 0; -cleanup_encoder: - drm_encoder_cleanup(encoder); +err_deinit_phy: sun8i_hdmi_phy_deinit(hdmi->phy); err_disable_clk_tmds: clk_disable_unprepare(hdmi->clk_tmds); From patchwork Sun Sep 24 19:26:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 13397058 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4F15DCE7A8A for ; Sun, 24 Sep 2023 19:26:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8122410E148; Sun, 24 Sep 2023 19:26:34 +0000 (UTC) Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3904710E133 for ; Sun, 24 Sep 2023 19:26:17 +0000 (UTC) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-9ad810be221so635096166b.2 for ; Sun, 24 Sep 2023 12:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695583575; x=1696188375; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c6KY3l38JJQzo0U3VJY6BsoHFoiqXvY2L3IXiGvOPS0=; b=Ksu+nrzhXcR1FwtkEJ5P+4xs4YZu4a2vkQuBdWGIKfG7T7pU/VeBMbML0y8tEfibLS PjVmqQtynkEzONgzhHZmfKycbYlBUi++J71tJvceSt6GC3Jm7GYyL2CEL1qbXweGtMQU Q7C/u857qmgUNu4ou6h0/NLtkLMDJqvq0FKmUL66voCxRhmnpVo9IlMvR02MPNtJptTq kw/Tv3VU9T810wXvtfGZ2szG4BxU63+jU/LWo5b/+4Qyu231Ngy5utbAeao7+Kww2xNv /N8yEcMcUUoPDjhfe7t01JbPjPflRotAEhkMteK2Q1/szW6Y2qZUFZjc0+R5rA0Gi5F2 /AUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695583575; x=1696188375; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c6KY3l38JJQzo0U3VJY6BsoHFoiqXvY2L3IXiGvOPS0=; b=tPVkYqxlJVyEjx18YXESRL/P2ENucH50Ml3tQ/HGCsdKrojpyrYwegnNZshfedO8CY c2gSoDSX6CYpElJNXcIcXRRDSDCZ7eO3b5dl1uoJVLJlTgWTCbNJLZiC+3N66lWLIl64 /Ngjj61koTOPuAAfrp4UoapbsbVJK4d/C8bL6Px6eoeJfs/2IZAYzQ2goFrxmG6GXyIJ JvH5h7B68ghoZeVrpEiI4cS6E1TFsdp59IvcmidzbRPBsNsUx23nuaHyD6/sEFkxRAfT oLCKobGeNOn58ins7o7lT6LCY3kJVQVTIqhyyBdxuZ4kWm9EPZUlb/f+B/nR6rQO2NDz 1uQg== X-Gm-Message-State: AOJu0Yz7T7Z9joTjU+GiCy3DejjRriZAqJTCCFK4kakI/DJOlIoZVdD7 prNqjdWpHrPTyHsCuysrDss= X-Google-Smtp-Source: AGHT+IF4uX/JM0VD6gvHTuHkWGbsMKKjWVglfewHDhBluusXbQjwKroAN2PZ5soeZgKDAFdDgJwZ1Q== X-Received: by 2002:a17:906:3010:b0:9ae:513d:de22 with SMTP id 16-20020a170906301000b009ae513dde22mr4045355ejz.56.1695583575563; Sun, 24 Sep 2023 12:26:15 -0700 (PDT) Received: from localhost.localdomain (82-149-12-148.dynamic.telemach.net. [82.149.12.148]) by smtp.gmail.com with ESMTPSA id z21-20020a1709063a1500b0099d0c0bb92bsm5317632eje.80.2023.09.24.12.26.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 12:26:15 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, wens@csie.org Subject: [PATCH 3/7] drm/sun4i: dw-hdmi: Switch to bridge functions Date: Sun, 24 Sep 2023 21:26:00 +0200 Message-ID: <20230924192604.3262187-4-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230924192604.3262187-1-jernej.skrabec@gmail.com> References: <20230924192604.3262187-1-jernej.skrabec@gmail.com> 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: samuel@sholland.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Jernej Skrabec , linux-sunxi@lists.linux.dev, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Since ddc-en property handling was moved from sun8i dw-hdmi driver to display connector driver, probe order of drivers determines if EDID is properly read at boot time or not. In order to fix this, let's switch to bridge functions which allows us to build proper chain and defer execution until all drivers are probed. Fixes: 920169041baa ("drm/sun4i: dw-hdmi: Fix ddc-en GPIO consumer conflict") Signed-off-by: Jernej Skrabec --- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 114 +++++++++++++++++++++++++- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h | 5 ++ 2 files changed, 117 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c index 8f8d3bdba5ce..93831cdf1917 100644 --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c @@ -8,14 +8,82 @@ #include #include +#include +#include #include #include #include #include +#include + #include "sun8i_dw_hdmi.h" #include "sun8i_tcon_top.h" +#define bridge_to_sun8i_dw_hdmi(x) \ + container_of(x, struct sun8i_dw_hdmi, enc_bridge) + +static int sun8i_hdmi_enc_attach(struct drm_bridge *bridge, + enum drm_bridge_attach_flags flags) +{ + struct sun8i_dw_hdmi *hdmi = bridge_to_sun8i_dw_hdmi(bridge); + + return drm_bridge_attach(&hdmi->encoder, hdmi->hdmi_bridge, + &hdmi->enc_bridge, flags); +} + +static void sun8i_hdmi_enc_detach(struct drm_bridge *bridge) +{ + struct sun8i_dw_hdmi *hdmi = bridge_to_sun8i_dw_hdmi(bridge); + + cec_notifier_conn_unregister(hdmi->cec_notifier); + hdmi->cec_notifier = NULL; +} + +static void sun8i_hdmi_enc_hpd_notify(struct drm_bridge *bridge, + enum drm_connector_status status) +{ + struct sun8i_dw_hdmi *hdmi = bridge_to_sun8i_dw_hdmi(bridge); + struct edid *edid; + + if (!hdmi->cec_notifier) + return; + + if (status == connector_status_connected) { + edid = drm_bridge_get_edid(hdmi->hdmi_bridge, hdmi->connector); + if (edid) + cec_notifier_set_phys_addr_from_edid(hdmi->cec_notifier, + edid); + } else { + cec_notifier_phys_addr_invalidate(hdmi->cec_notifier); + } +} + +static int sun8i_hdmi_enc_atomic_check(struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state) +{ + struct drm_connector_state *old_conn_state = + drm_atomic_get_old_connector_state(conn_state->state, + conn_state->connector); + + if (!drm_connector_atomic_hdr_metadata_equal(old_conn_state, conn_state)) + crtc_state->mode_changed = true; + + return 0; +} + +static const struct drm_bridge_funcs sun8i_hdmi_enc_bridge_funcs = { + .attach = sun8i_hdmi_enc_attach, + .detach = sun8i_hdmi_enc_detach, + .hpd_notify = sun8i_hdmi_enc_hpd_notify, + .atomic_check = sun8i_hdmi_enc_atomic_check, + .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, + .atomic_reset = drm_atomic_helper_bridge_reset, +}; + static void sun8i_dw_hdmi_encoder_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode, struct drm_display_mode *adj_mode) @@ -99,6 +167,8 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, { struct platform_device *pdev = to_platform_device(dev); struct dw_hdmi_plat_data *plat_data; + struct cec_connector_info conn_info; + struct drm_connector *connector; struct drm_device *drm = data; struct device_node *phy_node; struct drm_encoder *encoder; @@ -187,18 +257,57 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, plat_data->mode_valid = hdmi->quirks->mode_valid; plat_data->use_drm_infoframe = hdmi->quirks->use_drm_infoframe; + plat_data->output_port = 1; sun8i_hdmi_phy_set_ops(hdmi->phy, plat_data); platform_set_drvdata(pdev, hdmi); - hdmi->hdmi = dw_hdmi_bind(pdev, encoder, plat_data); + hdmi->hdmi = dw_hdmi_probe(pdev, plat_data); if (IS_ERR(hdmi->hdmi)) { ret = PTR_ERR(hdmi->hdmi); goto err_deinit_phy; } + hdmi->hdmi_bridge = of_drm_find_bridge(dev->of_node); + + hdmi->enc_bridge.funcs = &sun8i_hdmi_enc_bridge_funcs; + hdmi->enc_bridge.type = DRM_MODE_CONNECTOR_HDMIA; + hdmi->enc_bridge.interlace_allowed = true; + + drm_bridge_add(&hdmi->enc_bridge); + + ret = drm_bridge_attach(encoder, &hdmi->enc_bridge, NULL, + DRM_BRIDGE_ATTACH_NO_CONNECTOR); + if (ret) + goto err_remove_dw_hdmi; + + connector = drm_bridge_connector_init(drm, encoder); + if (IS_ERR(connector)) { + dev_err(dev, "Unable to create HDMI bridge connector\n"); + ret = PTR_ERR(connector); + goto err_remove_dw_hdmi; + } + + hdmi->connector = connector; + drm_connector_attach_encoder(connector, encoder); + + if (hdmi->quirks->use_drm_infoframe) + drm_connector_attach_hdr_output_metadata_property(connector); + + cec_fill_conn_info_from_drm(&conn_info, connector); + + hdmi->cec_notifier = cec_notifier_conn_register(&pdev->dev, NULL, + &conn_info); + if (!hdmi->cec_notifier) { + ret = -ENOMEM; + goto err_remove_dw_hdmi; + } + return 0; +err_remove_dw_hdmi: + drm_bridge_remove(&hdmi->enc_bridge); + dw_hdmi_remove(hdmi->hdmi); err_deinit_phy: sun8i_hdmi_phy_deinit(hdmi->phy); err_disable_clk_tmds: @@ -216,7 +325,8 @@ static void sun8i_dw_hdmi_unbind(struct device *dev, struct device *master, { struct sun8i_dw_hdmi *hdmi = dev_get_drvdata(dev); - dw_hdmi_unbind(hdmi->hdmi); + drm_bridge_remove(&hdmi->enc_bridge); + dw_hdmi_remove(hdmi->hdmi); sun8i_hdmi_phy_deinit(hdmi->phy); clk_disable_unprepare(hdmi->clk_tmds); reset_control_assert(hdmi->rst_ctrl); diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h index ab80d52a70bb..18ffc1b4841f 100644 --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h @@ -7,6 +7,7 @@ #define _SUN8I_DW_HDMI_H_ #include +#include #include #include #include @@ -178,9 +179,13 @@ struct sun8i_dw_hdmi_quirks { }; struct sun8i_dw_hdmi { + struct cec_notifier *cec_notifier; struct clk *clk_tmds; + struct drm_connector *connector; struct device *dev; + struct drm_bridge enc_bridge; struct dw_hdmi *hdmi; + struct drm_bridge *hdmi_bridge; struct drm_encoder encoder; struct sun8i_hdmi_phy *phy; struct dw_hdmi_plat_data plat_data; From patchwork Sun Sep 24 19:26:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 13397062 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 01AAFCE7A90 for ; Sun, 24 Sep 2023 19:26:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EA3C810E143; Sun, 24 Sep 2023 19:26:52 +0000 (UTC) Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3DB8E10E13B for ; Sun, 24 Sep 2023 19:26:18 +0000 (UTC) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-9a9cd066db5so674009566b.0 for ; Sun, 24 Sep 2023 12:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695583576; x=1696188376; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P67yQ9/R8vP33MNrFu8s/BR4RgUF4Oo7AxmSI7wtbGo=; b=laTA8Me7u963lXKIpwTrzdL7qT5kynTYHjA+oaz2PsNIRyEUCySsj8Y7STPx5bWrIJ XXnc6Z4w/5UiIClWbD+XXT2a2Hre7wksRgk1HjZ2uwSdpMs6PF+DCv4NiWoILU9+hQL0 iORQomhck2Ih19QbC2QYI1X6OdbV2m2GiccjUdF7Wc+b+NTXsbjUyKPf26gpsdndy2nr AVma63oqc0Jmp5YLfQewz8WWHGwyrdH3xh6gfMCOsnOqNCHr4h+DqoegjY+anhsACPM2 nL90CLsA6QndVZXthQ83qtPN4TY8se3Hx1MkhomrXutczb2gWEWiw+08S1ynOoqxxqEV E7aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695583576; x=1696188376; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P67yQ9/R8vP33MNrFu8s/BR4RgUF4Oo7AxmSI7wtbGo=; b=OE75UbJDvAT6sqYa9Um0w3RQTE3xYkRBz4hCNs99CjOmTizJKBLiseqZK4psc/mQUX WrBi+IMvbe0oYrkg59cC7MLf7000+98PznTg/7FkF6FNJgWloQ9bUi9+1f/9yaZYDrt5 p7/53q/yNjncN0R+WCoAa/7DRTv3i8wK1pw42v+fb2lxy/qV/VGMqDqB2PC0synpXRAp 85JpeLjXVW8LHZluEeRQN8VLMeMBCLV2TneVucfPtHWAVNvvqdZrgJsXdnzca+lgZchb rMVXjth+ee/asqcLgDhgcM0yZTVAU1tAM6HwCX7DcUURDvp5Qv9S6yNmW8QVrcwC1JOT OIQA== X-Gm-Message-State: AOJu0YyPWgEvlscjqDwW1DiXA1C74J0/ZIFf/NECMobdQePjpmgZ3wBw MHugrciFKeEpXuD6eKEa/98= X-Google-Smtp-Source: AGHT+IGYcIjckD309lYilHv1Z7GzrnSkK3WVyjDqrq0qtPDgxT6RI3OTizpfVXr1WSEMocNk7yTMyQ== X-Received: by 2002:a17:907:775a:b0:9b0:169b:eee2 with SMTP id kx26-20020a170907775a00b009b0169beee2mr4068950ejc.10.1695583576620; Sun, 24 Sep 2023 12:26:16 -0700 (PDT) Received: from localhost.localdomain (82-149-12-148.dynamic.telemach.net. [82.149.12.148]) by smtp.gmail.com with ESMTPSA id z21-20020a1709063a1500b0099d0c0bb92bsm5317632eje.80.2023.09.24.12.26.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 12:26:16 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, wens@csie.org Subject: [PATCH 4/7] drm/sun4i: Don't show error for deferred probes. Date: Sun, 24 Sep 2023 21:26:01 +0200 Message-ID: <20230924192604.3262187-5-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230924192604.3262187-1-jernej.skrabec@gmail.com> References: <20230924192604.3262187-1-jernej.skrabec@gmail.com> 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: samuel@sholland.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Jernej Skrabec , linux-sunxi@lists.linux.dev, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Drivers probing in display pipeline can be deferred for many reasons. Don't print error for such cases. Signed-off-by: Jernej Skrabec Acked-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c index 6a8dfc022d3c..b4816a1b0be3 100644 --- a/drivers/gpu/drm/sun4i/sun4i_drv.c +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c @@ -88,7 +88,8 @@ static int sun4i_drv_bind(struct device *dev) ret = component_bind_all(drm->dev, drm); if (ret) { - dev_err(drm->dev, "Couldn't bind all pipelines components\n"); + dev_err_probe(drm->dev, ret, + "Couldn't bind all pipelines components\n"); goto cleanup_mode_config; } From patchwork Sun Sep 24 19:26:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 13397061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 766E5CE7A8C for ; Sun, 24 Sep 2023 19:26:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A4CAB10E133; Sun, 24 Sep 2023 19:26:52 +0000 (UTC) Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 21F5710E13D for ; Sun, 24 Sep 2023 19:26:19 +0000 (UTC) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-9a64619d8fbso638000666b.0 for ; Sun, 24 Sep 2023 12:26:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695583577; x=1696188377; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MFf1cGltxf8drTRitrLUgd7Y0FznH+yCbskJSQDkt2Q=; b=LBQZV2nXrWLC2keBvZ1CqxfqUV+MPxPtMalnksr9IqCmbuJ7Y/8/plWlSNbcmMBsbS uGV5lw/Q08KGceftjh8O8qo4Z+cASBXHMbSRAJphaj9LhoPEopoGdAen9r/QzoQX/vbp g5xH4iXyUpIBsz6TnHvAkOh2T+iuZyXxJpaAr/8BoZiiyHOb32Z0VQrC7QMEhSK6I615 rQ9eAZwIlnccWCzrX+xDZ1KgUIjk2oZiiAv11m5viiPsuOLJxkrwcUqui7EBcOUR9yS1 q/AZ4k1t+KkGFxd2V+zqcv5CIbJubhFYDmLKdfLg3EN8tXBsyuOYbK1yOm0W5IkX0lsk IzGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695583577; x=1696188377; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MFf1cGltxf8drTRitrLUgd7Y0FznH+yCbskJSQDkt2Q=; b=sQFhAmjpkm6UKoThBIPq1vQ6aGH+vmKf4p2Qn8pmVp2lnsEcEuT9ixfY9RmL3UVw8x TGomfiX5ZRiqTzz3BEDRMIOwzNTAmPPsdnruSXsbnjcQHiuXY/8rhULphDkjS/jNK77P SPUtnopDtteXow5yr0r56Mh0/No5LOfttgobfb4uRSDaZvC7K4Pl8UMI0KjGluwd3Czi sWxxiwybGV41fiQiKMSRO/+mvsAxV85bpDriSl5Szu/TTzoVwgHiXgU3+ib4dFUKhV+H b7pA8CMWwObR/K/7W0idtSHdw2k6vyqbvqgQujFwz/tZak9pbMVfWUc7GMirzOujx8uy E/Ag== X-Gm-Message-State: AOJu0Yx65ukLUQE/fhJ81R4/Xlm1QMb/ijiX0SjHt5PJRg8L9i/ifcW2 y2SDuIl4roTw1B1u8X7OYxA= X-Google-Smtp-Source: AGHT+IGAhle5kDIIp4WuTj01RyhcLxUc0q31fsjC0IfkTvI/FNrLn/S5IoePIuTCGmzEdhew1ZtvcA== X-Received: by 2002:a17:906:210a:b0:9a3:c4f4:12de with SMTP id 10-20020a170906210a00b009a3c4f412demr4134394ejt.37.1695583577533; Sun, 24 Sep 2023 12:26:17 -0700 (PDT) Received: from localhost.localdomain (82-149-12-148.dynamic.telemach.net. [82.149.12.148]) by smtp.gmail.com with ESMTPSA id z21-20020a1709063a1500b0099d0c0bb92bsm5317632eje.80.2023.09.24.12.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 12:26:17 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, wens@csie.org Subject: [PATCH 5/7] drm/sun4i: dw-hdmi: Split driver registration Date: Sun, 24 Sep 2023 21:26:02 +0200 Message-ID: <20230924192604.3262187-6-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230924192604.3262187-1-jernej.skrabec@gmail.com> References: <20230924192604.3262187-1-jernej.skrabec@gmail.com> 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: samuel@sholland.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Jernej Skrabec , linux-sunxi@lists.linux.dev, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" There is no reason to register two drivers in same place. Using macro lowers amount of boilerplate code. Signed-off-by: Jernej Skrabec --- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 27 +------------------------- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h | 2 -- drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c | 3 ++- 3 files changed, 3 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c index 93831cdf1917..d93e8ff71aae 100644 --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c @@ -378,32 +378,7 @@ static struct platform_driver sun8i_dw_hdmi_pltfm_driver = { .of_match_table = sun8i_dw_hdmi_dt_ids, }, }; - -static int __init sun8i_dw_hdmi_init(void) -{ - int ret; - - ret = platform_driver_register(&sun8i_dw_hdmi_pltfm_driver); - if (ret) - return ret; - - ret = platform_driver_register(&sun8i_hdmi_phy_driver); - if (ret) { - platform_driver_unregister(&sun8i_dw_hdmi_pltfm_driver); - return ret; - } - - return ret; -} - -static void __exit sun8i_dw_hdmi_exit(void) -{ - platform_driver_unregister(&sun8i_dw_hdmi_pltfm_driver); - platform_driver_unregister(&sun8i_hdmi_phy_driver); -} - -module_init(sun8i_dw_hdmi_init); -module_exit(sun8i_dw_hdmi_exit); +module_platform_driver(sun8i_dw_hdmi_pltfm_driver); MODULE_AUTHOR("Jernej Skrabec "); MODULE_DESCRIPTION("Allwinner DW HDMI bridge"); diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h index 18ffc1b4841f..21e010deeb48 100644 --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h @@ -194,8 +194,6 @@ struct sun8i_dw_hdmi { struct reset_control *rst_ctrl; }; -extern struct platform_driver sun8i_hdmi_phy_driver; - static inline struct sun8i_dw_hdmi * encoder_to_sun8i_dw_hdmi(struct drm_encoder *encoder) { diff --git a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c index 489ea94693ff..f917a979e4a4 100644 --- a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c +++ b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c @@ -729,10 +729,11 @@ static int sun8i_hdmi_phy_probe(struct platform_device *pdev) return 0; } -struct platform_driver sun8i_hdmi_phy_driver = { +static struct platform_driver sun8i_hdmi_phy_driver = { .probe = sun8i_hdmi_phy_probe, .driver = { .name = "sun8i-hdmi-phy", .of_match_table = sun8i_hdmi_phy_of_table, }, }; +module_platform_driver(sun8i_hdmi_phy_driver); From patchwork Sun Sep 24 19:26:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 13397060 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B31C3CE7A8C for ; Sun, 24 Sep 2023 19:26:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 40C2D10E13D; Sun, 24 Sep 2023 19:26:43 +0000 (UTC) Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1EE6410E143 for ; Sun, 24 Sep 2023 19:26:20 +0000 (UTC) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-9a9d82d73f9so614701566b.3 for ; Sun, 24 Sep 2023 12:26:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695583578; x=1696188378; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LyCnYDXrBkQd8nc6ex8m6+Z4ml6K8C/rEJGtjuolnss=; b=JAJQY/JtIHgjjpqJZe0k+NAcVWudrjlTUmOU+x8FWJHIhAxFZsEpFECLeksH1AzWQp 1wUFkaH2j6DGaXTEWajSvXi8ArXiBGArnMGGcNjyjmE0U8VDD2M67iT6/MedgLerYA51 7KZ7wCO5tQIZUUIVBdsTIJ32m9+yqI/G3RNdJr7n5jLQEIXIX5fvTjY7Y+840XznQPAA 5MR7KpfJEXOOkUihIrCEivFDtTOgqT283kJ2gG2KJxL86CQvTZF45BSTqrRVKiBT1TAD Sb0uY+kjUXbyyqYpNnfoqpnC5nblrxNtHuQl+G/xLboFjVBrjyFeMt+Xl5DQbH06Ei2N 9jEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695583578; x=1696188378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LyCnYDXrBkQd8nc6ex8m6+Z4ml6K8C/rEJGtjuolnss=; b=Ns8650sFvnyC4zcPf5gTbsVT+mwNpEcCoY60fi9pnSF3CcL28zDtFO1FD8GvjTPlEc BqQUYBT3HcgddMRoUA6LA3S00gLq2fKnGanL+65VZJ32MHDpNa5RUtRGuMe8up8duu9k 5Gymmd99c9rueEUpCPeoNmWDX0RnGr6AuWhhblab4+7mOn/Qmd3ka6reg4EX9/3DfL/a nIiSI9fNjzXk59HYdeoARICo17U7cm+gOUXCSbDvOKRaKRT+cY6jVn5aMj1PApDmtfHb 86tMQFxPgckJkMuyr/9TFlKBZ7XKsAhHJikgwunf6BDTgSzd10IzvNz7sM603t4JW2gt se/Q== X-Gm-Message-State: AOJu0YwTERRSTw9KtBW09XosAmLswxvwLiEp740KTeNcQ0TM7WWPCESu 1OZy8gZtwemM7VoHb6vNKyA= X-Google-Smtp-Source: AGHT+IHCd1BgUV+vVYd3ZH8172gAFJIE1DUEWCbKCJthb4PpjhafqLcGbcOPCGbl9m5xDtLEBPKB7g== X-Received: by 2002:a17:907:7715:b0:9ae:6a8b:f8aa with SMTP id kw21-20020a170907771500b009ae6a8bf8aamr3983876ejc.26.1695583578522; Sun, 24 Sep 2023 12:26:18 -0700 (PDT) Received: from localhost.localdomain (82-149-12-148.dynamic.telemach.net. [82.149.12.148]) by smtp.gmail.com with ESMTPSA id z21-20020a1709063a1500b0099d0c0bb92bsm5317632eje.80.2023.09.24.12.26.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 12:26:18 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, wens@csie.org Subject: [PATCH 6/7] drm/sun4i: dw-hdmi: Make sun8i_hdmi_phy_get() more intuitive Date: Sun, 24 Sep 2023 21:26:03 +0200 Message-ID: <20230924192604.3262187-7-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230924192604.3262187-1-jernej.skrabec@gmail.com> References: <20230924192604.3262187-1-jernej.skrabec@gmail.com> 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: samuel@sholland.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Jernej Skrabec , linux-sunxi@lists.linux.dev, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Let's make sun8i_hdmi_phy_get() to behave more like other kernel functions and return phy pointer instead of setting field in struct. This also makes function more universal. Signed-off-by: Jernej Skrabec --- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 5 +++-- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h | 2 +- drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c | 10 ++++------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c index d93e8ff71aae..41f815a1faec 100644 --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c @@ -239,10 +239,11 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, goto err_disable_clk_tmds; } - ret = sun8i_hdmi_phy_get(hdmi, phy_node); + hdmi->phy = sun8i_hdmi_phy_get(phy_node); of_node_put(phy_node); - if (ret) { + if (IS_ERR(hdmi->phy)) { dev_err(dev, "Couldn't get the HDMI PHY\n"); + ret = PTR_ERR(hdmi->phy); goto err_disable_clk_tmds; } diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h index 21e010deeb48..748b6a4d9cdd 100644 --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h @@ -200,7 +200,7 @@ encoder_to_sun8i_dw_hdmi(struct drm_encoder *encoder) return container_of(encoder, struct sun8i_dw_hdmi, encoder); } -int sun8i_hdmi_phy_get(struct sun8i_dw_hdmi *hdmi, struct device_node *node); +struct sun8i_hdmi_phy *sun8i_hdmi_phy_get(struct device_node *node); int sun8i_hdmi_phy_init(struct sun8i_hdmi_phy *phy); void sun8i_hdmi_phy_deinit(struct sun8i_hdmi_phy *phy); diff --git a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c index f917a979e4a4..1c9bdefed35e 100644 --- a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c +++ b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c @@ -650,25 +650,23 @@ static const struct of_device_id sun8i_hdmi_phy_of_table[] = { { /* sentinel */ } }; -int sun8i_hdmi_phy_get(struct sun8i_dw_hdmi *hdmi, struct device_node *node) +struct sun8i_hdmi_phy *sun8i_hdmi_phy_get(struct device_node *node) { struct platform_device *pdev = of_find_device_by_node(node); struct sun8i_hdmi_phy *phy; if (!pdev) - return -EPROBE_DEFER; + return ERR_PTR(-EPROBE_DEFER); phy = platform_get_drvdata(pdev); if (!phy) { put_device(&pdev->dev); - return -EPROBE_DEFER; + return ERR_PTR(-EPROBE_DEFER); } - hdmi->phy = phy; - put_device(&pdev->dev); - return 0; + return phy; } static int sun8i_hdmi_phy_probe(struct platform_device *pdev) From patchwork Sun Sep 24 19:26:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 13397059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DF1E3CE7A88 for ; Sun, 24 Sep 2023 19:26:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8BCB910E13B; Sun, 24 Sep 2023 19:26:42 +0000 (UTC) Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8C2CE10E148 for ; Sun, 24 Sep 2023 19:26:21 +0000 (UTC) Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2c123eed8b2so83440671fa.0 for ; Sun, 24 Sep 2023 12:26:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695583580; x=1696188380; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8y8h3EEz9VirQFhjmojPuvqBkQuqu/oUUWDuJnG4W+c=; b=J1Spl3Tk1Wfh2VSJijxSQ3dmTGtSH9e8atY9jzfHq4qyrfJ9vCrsGIYqLdlk8qyq9s gh+jzUXViqz8Hz6zPijD6Rbjfnfl4K9rHjinn21XhD0TMtMyS3s4qPcWr8ktbdNncGtL psc4xmPuH7sUggyhfZle+0d9umYsHhD7DJndTIjv9eru5fQbWSPsIKn7KXLKKikG3Una oB8z0qO4iH68S9NiK3TMPBVturqo5PAaRueNPM7lzz6C1Akee93rIpvQapkDH/OWzcHz bwFlmx531NoswmnIExpNmlTAvTbE47l7MEUZ5BrS5XqtzwkzSBhIwRH+7oL86evWwLaR B+6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695583580; x=1696188380; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8y8h3EEz9VirQFhjmojPuvqBkQuqu/oUUWDuJnG4W+c=; b=B8fMTbK0WXGW95L2xme2/LMoK2O3F0fz+fJ9vXp2OE5NPJwgfr0o8Y22Dn8eRYqsCH +N23GPNRAynG4LlywGSHCc1XQ5uqTKgr2IjBJC7eyvo6YPF2Ak5FojRBiDWnPFFfcNp8 zEQceteqA7GMhpshB+XSO/EZsvj2A7axoEOi7gY3+DvbvlmWkqn43b/W6IISNQUyD9vu 4RhYXzTgTZbfOJwfUqGJstVDxhsOsQja3TrjFA0mhNJTCJqQCGTuXD5NpsOagEIQ/ERZ NRI7o5U2eN6vJpNhIuKysg9OFDpW8BaYEq1vQku9szaG2WI9TXDl4KvSM8GgLe6DGE3v o+CQ== X-Gm-Message-State: AOJu0Yx7cfo5Jvd8Cm0p0/aayCKScjjjArW0Ecb5TsO9Acd6sxQ2JsMc P5yFByjouZTKhsZVWJpZhHA= X-Google-Smtp-Source: AGHT+IGnY2zymlYXEbyV+5gsOUvzTU+WsC5ThrC5P4hO3P9yxgQq4BLXWnYLwnhf4fRNeIa24G6f0Q== X-Received: by 2002:a2e:2417:0:b0:2c0:2ab7:9ab5 with SMTP id k23-20020a2e2417000000b002c02ab79ab5mr4174912ljk.12.1695583579523; Sun, 24 Sep 2023 12:26:19 -0700 (PDT) Received: from localhost.localdomain (82-149-12-148.dynamic.telemach.net. [82.149.12.148]) by smtp.gmail.com with ESMTPSA id z21-20020a1709063a1500b0099d0c0bb92bsm5317632eje.80.2023.09.24.12.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 12:26:19 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, wens@csie.org Subject: [PATCH 7/7] drm/sun4i: dw-hdmi: check for phy device first Date: Sun, 24 Sep 2023 21:26:04 +0200 Message-ID: <20230924192604.3262187-8-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230924192604.3262187-1-jernej.skrabec@gmail.com> References: <20230924192604.3262187-1-jernej.skrabec@gmail.com> 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: samuel@sholland.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Jernej Skrabec , linux-sunxi@lists.linux.dev, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Let's check for phy device first. Since it uses much of the same clocks and resets it also lowers amount of possible deferred probes. While at it, don't report error for deferred phy probe. Signed-off-by: Jernej Skrabec Acked-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 35 +++++++++++++-------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c index 41f815a1faec..c1becd964326 100644 --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c @@ -173,11 +173,24 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, struct device_node *phy_node; struct drm_encoder *encoder; struct sun8i_dw_hdmi *hdmi; + struct sun8i_hdmi_phy *phy; int ret; if (!pdev->dev.of_node) return -ENODEV; + phy_node = of_parse_phandle(dev->of_node, "phys", 0); + if (!phy_node) { + dev_err(dev, "Can't find PHY phandle\n"); + return -EINVAL; + } + + phy = sun8i_hdmi_phy_get(phy_node); + of_node_put(phy_node); + if (IS_ERR(phy)) + return dev_err_probe(dev, PTR_ERR(phy), + "Couldn't get the HDMI PHY\n"); + hdmi = drmm_kzalloc(drm, sizeof(*hdmi), GFP_KERNEL); if (!hdmi) return -ENOMEM; @@ -185,6 +198,7 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, plat_data = &hdmi->plat_data; hdmi->dev = &pdev->dev; encoder = &hdmi->encoder; + hdmi->phy = phy; hdmi->quirks = of_device_get_match_data(dev); @@ -232,22 +246,7 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, goto err_assert_ctrl_reset; } - phy_node = of_parse_phandle(dev->of_node, "phys", 0); - if (!phy_node) { - dev_err(dev, "Can't found PHY phandle\n"); - ret = -EINVAL; - goto err_disable_clk_tmds; - } - - hdmi->phy = sun8i_hdmi_phy_get(phy_node); - of_node_put(phy_node); - if (IS_ERR(hdmi->phy)) { - dev_err(dev, "Couldn't get the HDMI PHY\n"); - ret = PTR_ERR(hdmi->phy); - goto err_disable_clk_tmds; - } - - ret = sun8i_hdmi_phy_init(hdmi->phy); + ret = sun8i_hdmi_phy_init(phy); if (ret) goto err_disable_clk_tmds; @@ -259,7 +258,7 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, plat_data->mode_valid = hdmi->quirks->mode_valid; plat_data->use_drm_infoframe = hdmi->quirks->use_drm_infoframe; plat_data->output_port = 1; - sun8i_hdmi_phy_set_ops(hdmi->phy, plat_data); + sun8i_hdmi_phy_set_ops(phy, plat_data); platform_set_drvdata(pdev, hdmi); @@ -310,7 +309,7 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, drm_bridge_remove(&hdmi->enc_bridge); dw_hdmi_remove(hdmi->hdmi); err_deinit_phy: - sun8i_hdmi_phy_deinit(hdmi->phy); + sun8i_hdmi_phy_deinit(phy); err_disable_clk_tmds: clk_disable_unprepare(hdmi->clk_tmds); err_assert_ctrl_reset: