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: 13397065 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 894B7CE7A88 for ; Sun, 24 Sep 2023 19:26:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sHQhhCc8sr6wKtYEjVXrTVsynopSNFCCsQdfSyhUaSQ=; b=bjaCXd3Spbglgv ppicu9SNMe/riylSDL9rRIY2BJrik01cTcQozRRfNQxV29cmt1ZahVreG7+5Kuv6/LFbYfmmv2Ff4 A1ZlCxSexewPTxxs1ZOL5OL3XkhHsqord0qA58dr031STdX3EVQCDrH3yBzXYBeNIznLWCYzb1o9u qq4NnkRLnLVWRQgvJA8enbJAO3t3q9LZZQ7f5Y0PnLLwB/T00sE/LmVcD8KI7Xahf9l/a28fFvTPT aNnJ1xLnupAtE02x92Qh37LBFckwH6AyVRtweD0gRynx8ota0hVZzRbvKm60/lXSwNLhm5Z8jD/HQ B78Z++MLi6bDBifSDtig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qkUkJ-00CgXq-2u; Sun, 24 Sep 2023 19:26:23 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qkUkB-00CgTa-1o for linux-arm-kernel@lists.infradead.org; Sun, 24 Sep 2023 19:26:17 +0000 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-9adb9fa7200so1197794366b.0 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.infradead.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=SnRC5k2qZdx9yRGg8jZJRqrpwyTtkLw12rlEZb+N8TQQ4eWSoPRn4IW0AQ0OQedOP/ HmPoBrbeWWetwOz9E1KhLofNdyz0CeAECJbespsizmPYZt1AJ1rf+tciuyNOSuj37aEY Cpx3SWIgUqYiNXFGWcKKBD4CE+De+02dECsjzfVIIGCWEz2KJInSOJV2DjDBtM6z+CEG 9CdrWIzAL1kc3LFLXemLRVLPWTxYqKZ5pU2LTHv1BfcHxouuCIsBevXIvGdOXsvZ1AG7 IfXblQPkv4FyO+JmmyBHDqErStioIUi/9S3uw4JAS44qA3h7pGvCzkwa/vKNJ+tpTBNg zzww== 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=t79Ttf2IDO6kg4WYEE5sAJxH+KGF8sxKFX8alLO7wH2Oi5kez13olwdKJUoZ3+HpHQ gbHJeijyWlSQKDlBHfSXy7St2EI8HWgwPEWRF8EcPS2Ud3CG/VFnQLjt4AdWB4S2Z6lh Fy+5/yDYhGBOngmpW1zerbBo8Rr7P79p5NSF9/cDnrHAAsGmZLWBxx1xpdJm5cRcmzxj EAv0FL8MZxaJafa20CBjpy8RtzbB8sWItDtV5hkV4sRChSilqx2YgsIZIXemwTAwRxNY 8nOcCMODgaXRfdyh//S9YWC7IzoBiwYiv5/9E4VnhiBz4wo0bT/qdwNibZKlDZdlta6y UqGg== X-Gm-Message-State: AOJu0Ywu+FY962SUmuWfyxJf/pf14rYC3dX7hoY9GoXo/jwFp0MurIKD 6qNzNHgDZZDPKuIMiosEq0I= 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 Cc: airlied@gmail.com, daniel@ffwll.ch, samuel@sholland.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230924_122615_598740_26EA6758 X-CRM114-Status: GOOD ( 10.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 13397069 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 47CFCCE7A8F for ; Sun, 24 Sep 2023 19:26:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yq3gJgLu1OOhreK8oy/D70jDO+UgAwg8b0nK5nlx/ME=; b=IUkqNZdG299KuL N8LjsZq5imDNNa44xHBmu67XTpUeqdKWj6zPv/Xgyu91aucmfg2ToJJ/rSJjBKZSFbPI4nBHtg2qx 91k5r893SRlmhLpZAsHkm+Li4hv1M7vywCmAiGryM28aFTFgk3Zm0mn3ZkGgnd5taaER8PACIzQmy aH4hUTZKnVQce+U27RHMh6rNP/E5+fSfdNv4oi+nxWkUEgaLgPh/4JjyQGxC/OWLGcBKNjEFZOeHR +CrW0HxyEk6LweQX6VYXf4/vvKn2XqvplI7Mn+aiLqfO1QHXW5ZqXbxtqmtfPwTwbXCTmqc23U8JC XAh2XgHebhi6iy9US55A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qkUkK-00CgYA-1M; Sun, 24 Sep 2023 19:26:24 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qkUkB-00CgTu-3A for linux-arm-kernel@lists.infradead.org; Sun, 24 Sep 2023 19:26:17 +0000 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-9b275afb6abso281653766b.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=1695583575; x=1696188375; darn=lists.infradead.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=ZNfcFMQvOn+R3g6xLUmmB3PeiCvh6jSeVySyKNM88hmZlF5YSWn3KzH/J1CWqg8UcL Gk12xPeJJiR+BDKfSAEb29ldjMuEZt5rtCWqyfjy7esJrJcqmISXeCwnt0T8St1BDgYQ i8UjW6x2sahY5NWywIflfT/squ3sOKwL34sjdFely8nwp9TK7i0qQ4xqZ4l93R6b21T0 4NH3cStdDTNN4TS91tmOmOA5bzvkGMJESBi9WcTCabye/29FhyQ+3/ediqZU1vhgk444 0tKdNc0yCfwUl6wxa3KN9cOPEycCKIXmppIoRMzGg4VYVtQN24pQ68R6faZq3zW10IA0 tkXw== 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=OcWXf4zmhqTwFCeR7dECMvBSSd9znIcJw4y1/MRszo4kQh9+kTePxaBbCil7hlVmkE EHGKFBDAVJdTf3Q92nvR5Z6/vGO9q4vRFKCo2nnEojy2d2K/HUVb4UvNfUR9WRReB2ft 2yy4sTjUk7QLEjQdA+ZWU01O9YHCIL5Wcl0gqP0tEHaSQKkEqoS22kcbB5s6vPWu5blR xYm2hViLh4y6wj5KPwsyCl5vIXi2Xvcprv4hyURXxohx3glNtE1O8QsXfTK7dEi7HwQy fS/5ikNPgq0V3M3NyTCJxo0NCqE0pebmGapJagRS4epi7K9ewqIzcEsLp3RYzx0D8UTT bX0w== X-Gm-Message-State: AOJu0YzjYB/UX8SKVm1Od4UgwFTgRItgC2YQx3ZQz/Gz8a0koQN2cRiq zberVLAK/rEL8P9ZuDFPgEq+LFSWGz6iPg== 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 Cc: airlied@gmail.com, daniel@ffwll.ch, samuel@sholland.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230924_122616_022769_224C2A8F X-CRM114-Status: GOOD ( 15.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 13397066 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 2CA49CE7A8E for ; Sun, 24 Sep 2023 19:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UWsI/x3y7mu64HGDQ//Tkvslrubri5ogM5mf7qjK4XU=; b=jQMsRif5p8V1Wb Ek05i7rQYBTd0dqFDOy89NzKjPtyLtzkbNILJfnWTJJIuQs0DMXLi+4pS/DJJ7Wx+zZWOCLRMyCxu fazx8xtpPi+MZ4iCRSfhu3EtBcFFhTCVLmn+EE4bV1HKKs4msvd2aUz5So9/V323w7/pvslzJhcO/ TVAjwTQN9bWARirx9vIqCoMtZBZhac/rorRrewxnadEsCNq+9+ZdK1vUcYUKJYSpGMx9HqnOs0zrm a/Fc7rg6GMuA1Ues1tcJOaIHBQEgsnq4DNo0RLEwJna64sN+B8aTr3e2CiM1wStxETVh7tj0KHXaD lWuS4BpuVLrIzf8FOV/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qkUkK-00CgYQ-36; Sun, 24 Sep 2023 19:26:24 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qkUkD-00CgUh-0G for linux-arm-kernel@lists.infradead.org; Sun, 24 Sep 2023 19:26:18 +0000 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-9ad810be221so635096266b.2 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.infradead.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=Wx2B6AG/SC+9QIIYYHSDHsUVJdZJfHTGXYulGvBoFZl1EX6AaUsKIvWe8LZZ5Rr6X/ mbAUVLzkK/0p1YYIefJtRzkfEPzWnXH/QYEVQk3FAF1vdrdKQINuIb9jgaYIcrcuOAcR 0R+Nq0el4vSgmdXs8eXPsK3RfFQaRTJeEJSgf5yaSO0DAPZKPVJ6XvECzBdaai+s+gMV FkVQhGffWLOTlhel+dzDD6gDVdq1FvXQX7y6WbqZvn4Pa0Cv8FbwVpORGf0T1UYIz3ZM eQ7GODdkVDMXw36AfrYJxmTdrYxG+d+4eD6eBz55pVaogEI47lGMifH/H85PB8XJ0SRi rhiA== 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=kYuazjXx2B5Do7yygxipKRLfArJ9qgZU+r4KFetd4cjzUYD+1QoXh61ouWkHbBuquk Qu/rqIrHzr+r7pKjCCdXL8f3fZmx04vBOflleKQyHH2zj1rcUGPF7tWO6nL1CEjRoaAc zY9Qiy5eBgiHlDgfrdqR4/jnQt7Z7km2HumT46IXH+qm5D329B5I8O8RlHNXf5wShjOQ Sq1aCqds9n5HX+21jGNvcQUslOssFWDoj9iQ4ioShEfhtRUNg9qSMzaWJa6XiZeiPydn UUnRXE29Z/XYKiYFcfksthG5dyhIkUJegYLE6XoQbwwvbg/6T3Ywahx8WHdjfo8LJcAG 85NQ== X-Gm-Message-State: AOJu0YzsxmYqHDzt2nzXNwPESLAzukipZOQZ52fFs0JFS4MN0eX/ltQ1 YHkhMagE9Xdgsw6NMo5iu5JXr7YQHOhb7Q== 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 Cc: airlied@gmail.com, daniel@ffwll.ch, samuel@sholland.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230924_122617_121317_F00F4F1A X-CRM114-Status: GOOD ( 20.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 13397071 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 C97F8CE7A91 for ; Sun, 24 Sep 2023 19:26:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=F8RaJKmrk1QfcfeomX+PqTP0rvqBSoSGexqEhRj6mjM=; b=qlL+vyO01AMP1l Tw/RTnTIAQ6AblouepS1hLKHvDEeSotU97wLzWiVKq4iJwDkpddTqWKz2yHzQO12ZPZVl7YA4ZR6S Ap7HkMcoAz5nAa/yz5HSz0XtT0OAo7thdFXJH3kd+L5Br1jgnF3kpabxKSSEYvTdM35lHeyG9h3SA o+WhHSuodtpnLfgfn5DsxAyJUKfIOv7/zUi8G2siSb9UXb/7Rig4TNHaFHRehIYZ2xJ1HnaKgKfXD BoobByjmOGPpH9r9w8K5VxkJlLmS4RSwNT+P47S+jhVG7jmDYeExC6i61AH0XkRMurMLdc4BPQlMx p8AKqPny4rhMaVgxx/Xg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qkUkL-00CgYl-1e; Sun, 24 Sep 2023 19:26:25 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qkUkE-00CgV0-1D for linux-arm-kernel@lists.infradead.org; Sun, 24 Sep 2023 19:26:19 +0000 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-9a648f9d8e3so672055966b.1 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=1695583576; x=1696188376; darn=lists.infradead.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=LP6ZO9TXV35e9J88wnyYt3kpgEU9W491Dv/uoHw2dN0NavZIvElJKWlQfHbFNdevFb qKmltdkYmCXRQOPK76aeL6Z0B/oEy0fNG6E4b8RM+0a1ykvPSLS7oqRHz/hEe7DiJiox K6inz2QhVAcRhORPKOzp7xVESpXyC5pzSsivSZ8bYbZYaese7RbGSLQYwG+yrWnCYKqD wzg49xcf08rs+HCKwPpvCyI9lUJ6gs2/Eh0Zo0SIm8Ij4aJZHjuoHWJI/+SdUC0ymlAu U4rfea05sBl6vZu7f6A3PyIqrH4e9t5Ksp2zjo9Z8xtRUipGdstQqhBdilYXMQGI2jqC cy8w== 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=RfyNs1+7vCHdZf1BIEtmJGfrwLIjw2wso/iGklj+F4QPe1EQEpYF0TVGQXslZVWbr8 rzMWRdajI8zi+R7h3hQgJsZcNJ3MhkU2Wg6xh65MXb7YUYdXVt+U78t64FI8J/3EL5bn viHoXd81PxpgrMFnBJeiSmx4ZF/K/srfFQjEZfmSAvkD0/jRtF6jvL8thmptJugMNpql h2eBytPlDRcJNfvVmX+yTf8dlnl+zQBuDhwp50hDUYOaM5OqmSJL7M8mD4GSP8SFOwL7 njfN3RZTB6RcJYDI7KgHwl03LPE46u3su/ahMbtkeSMih4sfAbVFxUd0T1hFuridd/Er OjAQ== X-Gm-Message-State: AOJu0Yy6BiBZqS8MsZFRsiUh7gWiCFWmxm6Apx0orRXFAqy+ep1a2iLO OmpXHVODBULKY+ateJS+Y8E= 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 Cc: airlied@gmail.com, daniel@ffwll.ch, samuel@sholland.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230924_122618_417065_25E94B32 X-CRM114-Status: GOOD ( 10.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 13397070 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 2870FCE7A8E for ; Sun, 24 Sep 2023 19:26:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=87HUBFzA7HiOOQSv9OmP8GTfzvueqV1k85OSyVRDsTo=; b=sIMfhHgZL3Dg1D ZzRrNDpB3Cz2iilmGYnE/PPe9LtXpZzQsgFy7sFB7HvUTwzBSfnW6AphCDtsvMIhwZtK7q/EXrhQh oNYdLH3GS9oEbj9gerVszIrhqjvPqSfpOjYfiKJtaRovCXonMWOg6jXnzemDRppDV9eQ5R62ag5lY pA9AkiKzHng2gQjNwkHElRb6T0yi3nYKnJttxcbyt0oDjkIqqWGc0gy463NFye7MK+Nl3bX+gFSX+ rlelZklEiM7mJ/BAR/kPeXlINAWtK1RayH5SjARvTWSMq1ZfuaaliSULtZfa6ZKZRo8AHoxDKdJg+ y12bgAAsfmN30dMieSMw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qkUkM-00CgZ3-08; Sun, 24 Sep 2023 19:26:26 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qkUkE-00CgVb-2a for linux-arm-kernel@lists.infradead.org; Sun, 24 Sep 2023 19:26:20 +0000 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-9ad8bf9bfabso636086066b.3 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=1695583577; x=1696188377; darn=lists.infradead.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=Cgt+QrrXtFqFddL89nx2reS0A0dunJ856MXPoR77C+ECUucFGcrX4MlKtzDgc3bL4T RebScD3Q2RA1bCngL+3oktxNOWj7hADlhTdK/ZfUlJ/eyfN/j2Y3D7NNS374z7GbsEk9 cDSuqCbcI3+mPobHcUos0hDjRc9j76dc6pzznZerda5xA89GaSSLzV8akA5mDQ4ZYgQs cWWW9FNFzVPE4BQe4AykTb7nYE3kCd8mz8Z38G5q1FyzseByr6AasZ8OLJ0IcQ5R4AGY XNTFNMyYh5LTTuaJmL57BDRUYd9x6RX+E2SsSwb+y1fijUDMLlmJrGRKgq6my1CsA2BZ 18Pw== 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=OmQqBgACrFst4AK/XbNSin0riOopWbwQy86yX5scvkxOkRoa9NLPr39urqYvJkb+jJ PpxDa/3hAiesQA5y513LIaVFxJ+ZJJyIi97Ak4PNN8rLWBjToCbO3AvkQnOq57G90QgA Jg5axK7TxbLPoc1z6dQ7K3UDamZFi7OpwUUNTgL7qMyfVvPXU3zplno3KoEF3FViRZUl DO8FO1kLrCXRgFoZ4BPtxPXXei917mC8yZ1o3RISrYnwuVdK+9aQdXVPkO/H9yRFZdm1 3Be4NgIXnOX+Jun0Yey7k2qACFq9fEHRwMtP+poxt3zv5FOTwySyyQXi1nwyiRW5abrb 33pQ== X-Gm-Message-State: AOJu0YyO76uP8nbYZjVQjRUzDydJ3S91ZAm6OfRCTfo3pQovm2w7Mz73 UiK+54P24+3XJduzmaLC5yg= 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 Cc: airlied@gmail.com, daniel@ffwll.ch, samuel@sholland.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230924_122618_840580_E7DC0D63 X-CRM114-Status: GOOD ( 15.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 13397068 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 39EFBCE7A8A for ; Sun, 24 Sep 2023 19:26:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ry6e+a3ZWPOexne2HoYMv3TrOyBPWKKu8YC7hYKNkeY=; b=eoX7ZfjHc0qpzE 77lFp7g8kyWxC+VOmTtt5NUuW0DdqWAavbKOzHdkX5Qic+aK/bQ5PjX4owW61i6NGF14yRzWW+F5s RjXu6H352eP3WKyNLIUB/DDxZfvcYcwZVQuRygOaptU7ipzXN3Ovkj/4LleLHoWmQQpXYKX3ueQMw CAfuWmeaYq7QkVtlYawfFqu40mY2Jdhd80hjFYlUR3dB5GH/8t96YLGi+edYc5r5PZ3KJQNF543Xr VwBoJxcP1DECoKeuxfo/4vMPUOe7Ytw+rqZ5GuU/UQW/XqEDikuhibVf317nL9KmlZ97Mce06rij3 acDT21/Y3551nsr8VrQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qkUkM-00CgZP-1x; Sun, 24 Sep 2023 19:26:26 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qkUkG-00CgWK-2w for linux-arm-kernel@lists.infradead.org; Sun, 24 Sep 2023 19:26:22 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-9ad8d47ef2fso617119066b.1 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=1695583578; x=1696188378; darn=lists.infradead.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=DvISNWQXGsGH15tbX/2WFOm5LoHYneOvluvUuNAgvCdFD6AQedCyGnLyI4eoG4+B7W +zJ+UtiwnAJyaCZHBCIuLkAuxF1YGdOGjfucgRrdwGH+W/+GLmf0LLq9IgrqZGbT9tW5 BcwLYQAQQWWNC6iDwtwTiMGDrMhBDws02ePT4hviE5GqOe8PwWlid84DOoGBwOm7tYne crSdW1cTpXp6zRi/eSPlPc3tnGw/GuH3nS1zNEFAFeEVMd94fb1yY+joaJMpwuF+2pPm XBll/Oq6AjFfBFnpGxweGIiGhYkRHJwE0sfgJRABSj1YOfk7WvgW3nVO6p0amGVHzqvG 8RYw== 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=NWF7WAJOF/ps5H7BRo1FxBrGQQhy7AE4Xf/Ds7ucbr/GzU8M3bRG207gjbypzQQR3i I1rGn3zkq1Tsx8YHkhnyG6Sx29WFhIUpo6NROWWI2P2R2TbZGCT03qTTfmWR/Gw3Mldx RFA/ZWDSKjgzZc0wRO6HK6MCSchB28h+WSFfPvu7GUN4hRNI9KXJj9G+kp3byggm6oes 51j0huZKxCpo5EN5vIiLmM57/MZfXodkaK9SCoyW/Wfe2R+hA9gW3Ja3SiEwt0nV639L 7WX8zIc/UhU4myPxL04/JeQ4PWf99NCRSp5b1SakZpfCH8yBJPS30MfPFKTxeh1ZNdFj jABg== X-Gm-Message-State: AOJu0YzUOkk2Qa1/x2epKy4/L1vpvNw4cH8e3WNnbQphtZpEqGTc1W1o 8hFAxvAMPX+9FUhBXBgy6RU= 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 Cc: airlied@gmail.com, daniel@ffwll.ch, samuel@sholland.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230924_122620_946178_74592816 X-CRM114-Status: GOOD ( 16.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 13397067 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 695BBCE7A88 for ; Sun, 24 Sep 2023 19:26:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0pYbGLeDOt7ruY9D6Nudl3XyYY+/KrODPNxnPJCoUy0=; b=wCZn8iq2tjHDhu 4PDVQDxWAGzSSy03ljjAbOYOYZCNOMasTmeXFFcnz6IMRXY264xHpZbctQaeuW/hK2otbXLDOWEnG bMiGBOZWwLBgmL+l/UydsIubPxdUJcdp0oHEkT5xHKdNXwoOZtbGg9S9QVarPP8PBWFjl34XpIQox yS/8TEE8gqTguiNQThd/IhmvBHhvgdlASsm6oy1ktMZDirHBsmeuKi0d1VYWlVhhYeomtsHsT5OzP D8hDQAzPF4LynZCGWkvD5d5+rJu/abFj9CAztDCgd3/DzUSwKJYKYazXcSWr2qcQdwUdcaHJkff1d AEvlUur6LF9+TdiA2YxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qkUkN-00CgZl-0a; Sun, 24 Sep 2023 19:26:27 +0000 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qkUkI-00CgWf-0E for linux-arm-kernel@lists.infradead.org; Sun, 24 Sep 2023 19:26:23 +0000 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2c00df105f8so83035191fa.2 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.infradead.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=ibCrceIclt7VPdx/5ZNMXR9CJbQWKdoBpcvv389AUzJHPUrH2sJMz7cvyDfVMHPnTW Flv+fxMA7nZ4QrfBZVZ+VM+PQqQSTQVi7kopBf5mlooNa8FAYDPOGfWY6JLPSf1sAPhn vE4kvNVZmoT2Nm2p2jupayj7WuHnB3lhObJBoKGfxNLTeXzGAGz5dmmTWu02f7w5UiGj O9RBjjklpTBX65kvC881LM1NZE/yKi+0w/5VXBRQ7u8Z9AlQE+gC9Xa/nxLAg4qFAde9 Rj1lanIuoyRnDqOeFMY4G5X6fctTDr9T11AI6S7KGAKZcgwZ/iFxDdVnjFEQpUgketwU czag== 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=lwunAazVRDJ3fiezqFP5p1C+LEgNj+bagt+KKX/L+eUVWtWiYQoweDT+ZbtDVzS4TH Zs8KQXwc5O0wV8xgUEWSLXxMJwKphNLIlGEfjFQZyq5t80kT7HhTnOwJfJUvAS1PBxOL OEZ4UX7ZRgfRXbKA/Ui9tsv9NNoX8pa23ntiL6N3FCgjItRN65EUJQgq5YeE5kaRRQB2 +TjrxOtfFdMIl+eY1AGL/ZplyoVKdgYV+EAQQWrM+B6cyPqupOPniKs3sycl6ZXuciIA Us9pyQOHQqsyqeDFH+530OlXlECPY3TiBiLfvC7obheOOn7pzhRwlUH/nQrJngYI53CM p0Jg== X-Gm-Message-State: AOJu0Yzx8PHM7MXmUPePC8rkXSfDu5GHOZgwOQ7w9RvUVZapMwnEmXLt iI4QfdHR0ccccbnJHm1sfok= 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 Cc: airlied@gmail.com, daniel@ffwll.ch, samuel@sholland.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230924_122622_108261_64ACB3C1 X-CRM114-Status: GOOD ( 13.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: