From patchwork Wed Jun 29 16:05:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 12900354 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 AE59DC43334 for ; Wed, 29 Jun 2022 16:06:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1878910E3E8; Wed, 29 Jun 2022 16:06:06 +0000 (UTC) Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by gabe.freedesktop.org (Postfix) with ESMTPS id E516210E2FE for ; Wed, 29 Jun 2022 16:06:02 +0000 (UTC) Received: by mail-pg1-x535.google.com with SMTP id x8so11135499pgj.13 for ; Wed, 29 Jun 2022 09:06:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=notPBC4MnqP3/2b0DoBP3luF+le6LrZ0so+pTM6prWs=; b=NlCjvaxetubf24Z+sQZfc332yDLW4QSIKdokM9O2OcMgf3swcWTSFE70+NvWJG6RH6 5KUa8cDpnS2Hlxm/E0AcW2EQ44MaKor8CzE1Rr8OUrOHZuWX9ucpten1Ll5u54CY07Jf iP/Ts5khXRN5mvLnEikY481Wpob2eMYx85b90= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=notPBC4MnqP3/2b0DoBP3luF+le6LrZ0so+pTM6prWs=; b=LMq5M8TMLR2RnWkvTCWZnPiMpJx9ibWF6VJj66fvvy1xxJIDAh9qOy4dWvJ64fx54t bD8itWCEGz3LYrMYSKHYEfbjUQo6CcfmFug4h8GxiQ9jZzvXq9gti0KraUZUrHC0old8 qCIhch1ZB4U0HPtHphSKCAAFgWb3zyw/t/v9+vZSZBLvqLvnIYSd9yMrsMERZk51U4rn wi3oSugZGFLV7MP3ZqURw0vKHcAo/CxhTg7EGfUqRcfULjJY5DcAuBrK9w8piCoWfFHp UDEXT22RaBN3PDHMJnFo+P2moV0yM4UpnOW+K20g0NqwGmfCddERU3MDRKFnwaYmVmhS wHZw== X-Gm-Message-State: AJIora+x116UelyJP++OPXQ5DMIHk3GPs+m2lMdLUcTBOhndFrtsc3Fp FIbmvVazssCmUE4uCIxwsbWBsA== X-Google-Smtp-Source: AGRyM1vg6eF7pHecOpH49930sygS1lu8vE8q9/o+9+HVT9Nz4uVBZw2Pt0NdQ0HZB4n2QPKkcQX5Og== X-Received: by 2002:a05:6a00:22cb:b0:525:ba83:559a with SMTP id f11-20020a056a0022cb00b00525ba83559amr10977364pfj.54.1656518762463; Wed, 29 Jun 2022 09:06:02 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:9841:721:7d8b:4502]) by smtp.gmail.com with ESMTPSA id r19-20020a170902e3d300b00163f8ddf160sm11495350ple.161.2022.06.29.09.05.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 09:06:02 -0700 (PDT) From: Hsin-Yi Wang To: Robert Foss , Xin Ji Subject: [PATCH 1/4] drm/bridge: anx7625: Convert to devm_i2c_new_dummy_device() Date: Thu, 30 Jun 2022 00:05:47 +0800 Message-Id: <20220629160550.433980-2-hsinyi@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220629160550.433980-1-hsinyi@chromium.org> References: <20220629160550.433980-1-hsinyi@chromium.org> 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: Jonas Karlman , David Airlie , Thomas Zimmermann , dri-devel@lists.freedesktop.org, Neil Armstrong , linux-kernel@vger.kernel.org, Jernej Skrabec , Laurent Pinchart , Andrzej Hajda , Sam Ravnborg , Maxime Ripard Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Simplify the resource management. Signed-off-by: Hsin-Yi Wang Reviewed-by: Xin Ji --- drivers/gpu/drm/bridge/analogix/anx7625.c | 96 +++++++---------------- 1 file changed, 27 insertions(+), 69 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c index 3710fa9ee0acd..f89e8151475f7 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -2436,82 +2436,44 @@ static const struct drm_bridge_funcs anx7625_bridge_funcs = { static int anx7625_register_i2c_dummy_clients(struct anx7625_data *ctx, struct i2c_client *client) { - int err = 0; + struct device *dev = &ctx->client->dev; - ctx->i2c.tx_p0_client = i2c_new_dummy_device(client->adapter, - TX_P0_ADDR >> 1); + ctx->i2c.tx_p0_client = devm_i2c_new_dummy_device(dev, client->adapter, + TX_P0_ADDR >> 1); if (IS_ERR(ctx->i2c.tx_p0_client)) return PTR_ERR(ctx->i2c.tx_p0_client); - ctx->i2c.tx_p1_client = i2c_new_dummy_device(client->adapter, - TX_P1_ADDR >> 1); - if (IS_ERR(ctx->i2c.tx_p1_client)) { - err = PTR_ERR(ctx->i2c.tx_p1_client); - goto free_tx_p0; - } + ctx->i2c.tx_p1_client = devm_i2c_new_dummy_device(dev, client->adapter, + TX_P1_ADDR >> 1); + if (IS_ERR(ctx->i2c.tx_p1_client)) + return PTR_ERR(ctx->i2c.tx_p1_client); - ctx->i2c.tx_p2_client = i2c_new_dummy_device(client->adapter, - TX_P2_ADDR >> 1); - if (IS_ERR(ctx->i2c.tx_p2_client)) { - err = PTR_ERR(ctx->i2c.tx_p2_client); - goto free_tx_p1; - } + ctx->i2c.tx_p2_client = devm_i2c_new_dummy_device(dev, client->adapter, + TX_P2_ADDR >> 1); + if (IS_ERR(ctx->i2c.tx_p2_client)) + return PTR_ERR(ctx->i2c.tx_p2_client); - ctx->i2c.rx_p0_client = i2c_new_dummy_device(client->adapter, - RX_P0_ADDR >> 1); - if (IS_ERR(ctx->i2c.rx_p0_client)) { - err = PTR_ERR(ctx->i2c.rx_p0_client); - goto free_tx_p2; - } + ctx->i2c.rx_p0_client = devm_i2c_new_dummy_device(dev, client->adapter, + RX_P0_ADDR >> 1); + if (IS_ERR(ctx->i2c.rx_p0_client)) + return PTR_ERR(ctx->i2c.rx_p0_client); - ctx->i2c.rx_p1_client = i2c_new_dummy_device(client->adapter, - RX_P1_ADDR >> 1); - if (IS_ERR(ctx->i2c.rx_p1_client)) { - err = PTR_ERR(ctx->i2c.rx_p1_client); - goto free_rx_p0; - } + ctx->i2c.rx_p1_client = devm_i2c_new_dummy_device(dev, client->adapter, + RX_P1_ADDR >> 1); + if (IS_ERR(ctx->i2c.rx_p1_client)) + return PTR_ERR(ctx->i2c.rx_p1_client); - ctx->i2c.rx_p2_client = i2c_new_dummy_device(client->adapter, - RX_P2_ADDR >> 1); - if (IS_ERR(ctx->i2c.rx_p2_client)) { - err = PTR_ERR(ctx->i2c.rx_p2_client); - goto free_rx_p1; - } + ctx->i2c.rx_p2_client = devm_i2c_new_dummy_device(dev, client->adapter, + RX_P2_ADDR >> 1); + if (IS_ERR(ctx->i2c.rx_p2_client)) + return PTR_ERR(ctx->i2c.rx_p2_client); - ctx->i2c.tcpc_client = i2c_new_dummy_device(client->adapter, - TCPC_INTERFACE_ADDR >> 1); - if (IS_ERR(ctx->i2c.tcpc_client)) { - err = PTR_ERR(ctx->i2c.tcpc_client); - goto free_rx_p2; - } + ctx->i2c.tcpc_client = devm_i2c_new_dummy_device(dev, client->adapter, + TCPC_INTERFACE_ADDR >> 1); + if (IS_ERR(ctx->i2c.tcpc_client)) + return PTR_ERR(ctx->i2c.tcpc_client); return 0; - -free_rx_p2: - i2c_unregister_device(ctx->i2c.rx_p2_client); -free_rx_p1: - i2c_unregister_device(ctx->i2c.rx_p1_client); -free_rx_p0: - i2c_unregister_device(ctx->i2c.rx_p0_client); -free_tx_p2: - i2c_unregister_device(ctx->i2c.tx_p2_client); -free_tx_p1: - i2c_unregister_device(ctx->i2c.tx_p1_client); -free_tx_p0: - i2c_unregister_device(ctx->i2c.tx_p0_client); - - return err; -} - -static void anx7625_unregister_i2c_dummy_clients(struct anx7625_data *ctx) -{ - i2c_unregister_device(ctx->i2c.tx_p0_client); - i2c_unregister_device(ctx->i2c.tx_p1_client); - i2c_unregister_device(ctx->i2c.tx_p2_client); - i2c_unregister_device(ctx->i2c.rx_p0_client); - i2c_unregister_device(ctx->i2c.rx_p1_client); - i2c_unregister_device(ctx->i2c.rx_p2_client); - i2c_unregister_device(ctx->i2c.tcpc_client); } static int __maybe_unused anx7625_runtime_pm_suspend(struct device *dev) @@ -2723,8 +2685,6 @@ static int anx7625_i2c_probe(struct i2c_client *client, if (!platform->pdata.low_power_mode) pm_runtime_put_sync_suspend(&client->dev); - anx7625_unregister_i2c_dummy_clients(platform); - free_wq: if (platform->workqueue) destroy_workqueue(platform->workqueue); @@ -2754,8 +2714,6 @@ static int anx7625_i2c_remove(struct i2c_client *client) if (!platform->pdata.low_power_mode) pm_runtime_put_sync_suspend(&client->dev); - anx7625_unregister_i2c_dummy_clients(platform); - if (platform->pdata.audio_en) anx7625_unregister_audio(platform); From patchwork Wed Jun 29 16:05:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 12900356 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 51FFCC433EF for ; Wed, 29 Jun 2022 16:06:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7096A10E52A; Wed, 29 Jun 2022 16:06:14 +0000 (UTC) Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by gabe.freedesktop.org (Postfix) with ESMTPS id CC0C910E3E8 for ; Wed, 29 Jun 2022 16:06:05 +0000 (UTC) Received: by mail-pj1-x102f.google.com with SMTP id d14so16123359pjs.3 for ; Wed, 29 Jun 2022 09:06:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=egURh53ld+NhXDS1wdCdA08O6R9LPjRpDFkoMid42Z0=; b=OSUkiwyuskUf+Byr0SuVvncCH4Lzu8K/kheg/bLfzzOv9U5BElk+a7IkIR+OjNTcHM iXFdbBJNlc09zCigO4KRlLz54n0cFDGu0DzFnbh+XATA//Bv3VoM7/dkXOM8/xR0gOhD DIeg1AciRPbBxiRCRbWd/Lh2svnORZXpz5cto= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=egURh53ld+NhXDS1wdCdA08O6R9LPjRpDFkoMid42Z0=; b=mZDDvqp5cAQs70R8IWPePy3Kpkmon/vMnqY0OlZBvR5v5VZKtxCR3g7iZFNX9FvreJ KapwqVduoqGMwVGYpFAkBu8cfhMQCjJVnmVc9sRYb8GaPrH/jROD8mydlaynroUFk3iZ 4QUmRjSwgq2Gsfbka91z0WylyD1bR9jWnxqzGmWFh/iVVundhTgrN6IQKIxFHIrooIOY w0KFVW3jt1C8YXTYaq/Ng1N6ZvStOmCwYss7GjQ75izLqvxLidIdNyC7Xz6uUzFqIMZG aB1Ic/Up1BSGh9XmS3TEjQ78eeRvwk0dV/FXn+Y/wsqKPpRfi5eIFXUPmqEqPj5Ioyrd gPhA== X-Gm-Message-State: AJIora/ZDXsrtvViBSCON5E1+dUAx0k2Dbxmgd5gb5oTevaQUaivH2+j f0/LrXwQcbMFdVcdFaR39qSWeu6TOXK2ig== X-Google-Smtp-Source: AGRyM1v0n9Yujom0ChKMec4x+DMXG77s3nGIWQJwoZbRjQyXCrugCj4jmNVrznO8yxMBPKzwSGF+LA== X-Received: by 2002:a17:90b:1d09:b0:1ec:bb51:9396 with SMTP id on9-20020a17090b1d0900b001ecbb519396mr6573335pjb.192.1656518765408; Wed, 29 Jun 2022 09:06:05 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:9841:721:7d8b:4502]) by smtp.gmail.com with ESMTPSA id r19-20020a170902e3d300b00163f8ddf160sm11495350ple.161.2022.06.29.09.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 09:06:04 -0700 (PDT) From: Hsin-Yi Wang To: Robert Foss , Xin Ji Subject: [PATCH 2/4] drm/bridge: anx7625: Use pm_runtime_force_suspend(resume) Date: Thu, 30 Jun 2022 00:05:48 +0800 Message-Id: <20220629160550.433980-3-hsinyi@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220629160550.433980-1-hsinyi@chromium.org> References: <20220629160550.433980-1-hsinyi@chromium.org> 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: Jonas Karlman , David Airlie , Thomas Zimmermann , dri-devel@lists.freedesktop.org, Neil Armstrong , linux-kernel@vger.kernel.org, Jernej Skrabec , Laurent Pinchart , Andrzej Hajda , Sam Ravnborg , Maxime Ripard Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" There's no need to check for IRQ or disable it in suspend. Use pm_runtime_force_suspend(resume) to make sure anx7625 is powered off correctly. Make the system suspend/resume and pm runtime suspend/resume more consistant. Signed-off-by: Hsin-Yi Wang Reviewed-by: Xin Ji --- drivers/gpu/drm/bridge/analogix/anx7625.c | 33 ++--------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c index f89e8151475f7..478f5af381c7d 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -2504,38 +2504,9 @@ static int __maybe_unused anx7625_runtime_pm_resume(struct device *dev) return 0; } -static int __maybe_unused anx7625_resume(struct device *dev) -{ - struct anx7625_data *ctx = dev_get_drvdata(dev); - - if (!ctx->pdata.intp_irq) - return 0; - - if (!pm_runtime_enabled(dev) || !pm_runtime_suspended(dev)) { - enable_irq(ctx->pdata.intp_irq); - anx7625_runtime_pm_resume(dev); - } - - return 0; -} - -static int __maybe_unused anx7625_suspend(struct device *dev) -{ - struct anx7625_data *ctx = dev_get_drvdata(dev); - - if (!ctx->pdata.intp_irq) - return 0; - - if (!pm_runtime_enabled(dev) || !pm_runtime_suspended(dev)) { - anx7625_runtime_pm_suspend(dev); - disable_irq(ctx->pdata.intp_irq); - } - - return 0; -} - static const struct dev_pm_ops anx7625_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(anx7625_suspend, anx7625_resume) + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) SET_RUNTIME_PM_OPS(anx7625_runtime_pm_suspend, anx7625_runtime_pm_resume, NULL) }; From patchwork Wed Jun 29 16:05:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 12900355 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 1152ECCA47C for ; Wed, 29 Jun 2022 16:06:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6F72910E45A; Wed, 29 Jun 2022 16:06:09 +0000 (UTC) Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by gabe.freedesktop.org (Postfix) with ESMTPS id B64A410E52A for ; Wed, 29 Jun 2022 16:06:08 +0000 (UTC) Received: by mail-pg1-x52f.google.com with SMTP id 68so15729620pgb.10 for ; Wed, 29 Jun 2022 09:06:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LwimkmoBK2vJGij8UUnRV6t0uOjwq6dnkWSCt3UmvOg=; b=BC5StwdHRdfpkrXcfq8wY3aIGaAhCJid7IBMUYBfsZOf8zWHOeEV0BSDhwzF/NrkbI SFlILCqtdZyXrtspikiixxiWQLdx4BK6wpQqysFkp6JaD0MAJma06YXNl9bbG7aOFAH/ Od9MGSrXh/UJ4SM7eHK/kp2xn4FhNKJUFQQ7g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LwimkmoBK2vJGij8UUnRV6t0uOjwq6dnkWSCt3UmvOg=; b=2a1fFwwraNo/m45JOPpJvQ2beDD4/W6RQ9v5SL76gGuFPej7ucd8rbbF2aQJ1cp377 PqzTJRBDs1s8eIz+HSnjqBM7fZ1KwfMStTWvD+Fy+PO/85q5oH3Kh7OkM1Md/ltakVT1 Qm4fyq6U/EhOIgPK9cSU0YT9tLJbScEEf0ZYKCw1wj+v+QkCj8Po8/bZ4VpkspYMo97p bcr3JpyztxyC1mgnpQL9NrDIIxjXirytaY5vCl6Ia0WhuBGbmiZwNnwMLX1IPJOnY2C9 5CTmWkZOFmEfw6FxdZzaDJZgp3Vym+LCqUw/zlI25uNhuLLTEXZWuKwkvMce0m0KIDiW YC6g== X-Gm-Message-State: AJIora82gjANXeGOzpYe3woQJRWo0oJZVZpw+UwsGM8ccmMHkQsPB+7/ h5YrgtF2PW3ttXDC8oUlHOyd7A== X-Google-Smtp-Source: AGRyM1tYJfwH/bSAlF+6S8zoDJUYsVl0BO11qvOxodSG+nzG1h/rZYNyVFyxZf87MyrFiLdtW/8Nlg== X-Received: by 2002:a05:6a00:1f94:b0:527:a8f4:9811 with SMTP id bg20-20020a056a001f9400b00527a8f49811mr9529367pfb.71.1656518768201; Wed, 29 Jun 2022 09:06:08 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:9841:721:7d8b:4502]) by smtp.gmail.com with ESMTPSA id r19-20020a170902e3d300b00163f8ddf160sm11495350ple.161.2022.06.29.09.06.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 09:06:07 -0700 (PDT) From: Hsin-Yi Wang To: Robert Foss , Xin Ji Subject: [PATCH 3/4] drm/bridge: anx7625: Fix NULL pointer crash when using edp-panel Date: Thu, 30 Jun 2022 00:05:49 +0800 Message-Id: <20220629160550.433980-4-hsinyi@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220629160550.433980-1-hsinyi@chromium.org> References: <20220629160550.433980-1-hsinyi@chromium.org> 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: Jonas Karlman , David Airlie , Thomas Zimmermann , dri-devel@lists.freedesktop.org, Neil Armstrong , linux-kernel@vger.kernel.org, Jernej Skrabec , Laurent Pinchart , Andrzej Hajda , Sam Ravnborg , Maxime Ripard Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Move devm_of_dp_aux_populate_ep_devices() after pm runtime and i2c setup to avoid NULL pointer crash. edp-panel probe (generic_edp_panel_probe) calls pm_runtime_get_sync() to read EDID. At this time, bridge should have pm runtime enabled and i2c clients ready. Fixes: adca62ec370c ("drm/bridge: anx7625: Support reading edid through aux channel") Signed-off-by: Hsin-Yi Wang Reviewed-by: Xin Ji --- drivers/gpu/drm/bridge/analogix/anx7625.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c index 478f5af381c7d..59ddeba33652b 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -2590,14 +2590,6 @@ static int anx7625_i2c_probe(struct i2c_client *client, platform->aux.dev = dev; platform->aux.transfer = anx7625_aux_transfer; drm_dp_aux_init(&platform->aux); - devm_of_dp_aux_populate_ep_devices(&platform->aux); - - ret = anx7625_parse_dt(dev, pdata); - if (ret) { - if (ret != -EPROBE_DEFER) - DRM_DEV_ERROR(dev, "fail to parse DT : %d\n", ret); - goto free_wq; - } if (anx7625_register_i2c_dummy_clients(platform, client) != 0) { ret = -ENOMEM; @@ -2613,6 +2605,15 @@ static int anx7625_i2c_probe(struct i2c_client *client, if (ret) goto free_wq; + devm_of_dp_aux_populate_ep_devices(&platform->aux); + + ret = anx7625_parse_dt(dev, pdata); + if (ret) { + if (ret != -EPROBE_DEFER) + DRM_DEV_ERROR(dev, "fail to parse DT : %d\n", ret); + goto free_wq; + } + if (!platform->pdata.low_power_mode) { anx7625_disable_pd_protocol(platform); pm_runtime_get_sync(dev); From patchwork Wed Jun 29 16:05:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 12900357 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 B13A7C43334 for ; Wed, 29 Jun 2022 16:06:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1D8F610E2FE; Wed, 29 Jun 2022 16:06:18 +0000 (UTC) Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8A5FE10E52A for ; Wed, 29 Jun 2022 16:06:11 +0000 (UTC) Received: by mail-pj1-x1030.google.com with SMTP id g16-20020a17090a7d1000b001ea9f820449so19898365pjl.5 for ; Wed, 29 Jun 2022 09:06:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jjoZa4oRghyRXFlLw4DClOAhKTZMl2uJvOPWFlMMk24=; b=ci6b5plqfpyMOn/13KVzANy4B4Rw1UFEP8CVEpPlw6wBopmzuXQme/cGfxNlpgxG1f mmTB4kdLCSpAEwAyqVvM0ReKyOuCbetN6Vtc9KdptUPJJU3JAorOKZ1fODsDgpTR3Hsh jFFDXR3iw4NZEsFlRNgMcRZUd3+U9jjmD8dz4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jjoZa4oRghyRXFlLw4DClOAhKTZMl2uJvOPWFlMMk24=; b=pBLrXfCvI/doqgOAZAhVUAu+jiwM/1b8rZwKQT91+4uXLZkcKcrsoT6j62dS+kcQyf ho1k/sQzgbV0o1Qw4i9C2sQwwO1VPXjfcOMzdJUNKUenjc8Ws7t5FQXCW4B6CK6GqwCR WKcEjQdu3tEv8s5ixX8IT+suWoWRCKOPmfBatrSbJbKmGBApTATl2o1EXxUgdZQHiLvv QoUy31/u3X6mOiFKn+d6Em+qccUnG1yVgg0WdOlz6ILJ2JC0eU8G79jXLRYOzMjrokX1 h+0EZuI13yiA4/Apn6xnmBiRyWIycyXYryo4hikdXU0/Ug313igWj8r7setuoEcZin3X AI8g== X-Gm-Message-State: AJIora+8FhdBYH7wYCfjDvEdXuiYhF8RWK2xjcz25Din2nBL0KTTHvr6 QyDSjQUXPIwecI8rOZQScf8Ymf/uJ+6o4g== X-Google-Smtp-Source: AGRyM1u+U191CnPQy0WhIfImTsCFkxYOpxdbN26rcYsm/FPVqX/YPldsedf3YCIavcqiQsWlmZY2xg== X-Received: by 2002:a17:902:ef46:b0:168:bac3:2fd4 with SMTP id e6-20020a170902ef4600b00168bac32fd4mr11007834plx.132.1656518771029; Wed, 29 Jun 2022 09:06:11 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:9841:721:7d8b:4502]) by smtp.gmail.com with ESMTPSA id r19-20020a170902e3d300b00163f8ddf160sm11495350ple.161.2022.06.29.09.06.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 09:06:10 -0700 (PDT) From: Hsin-Yi Wang To: Robert Foss , Xin Ji Subject: [PATCH 4/4] drm/bridge: anx7625: Add wait_hpd_asserted() callback Date: Thu, 30 Jun 2022 00:05:50 +0800 Message-Id: <20220629160550.433980-5-hsinyi@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220629160550.433980-1-hsinyi@chromium.org> References: <20220629160550.433980-1-hsinyi@chromium.org> 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: Jonas Karlman , David Airlie , Thomas Zimmermann , dri-devel@lists.freedesktop.org, Neil Armstrong , linux-kernel@vger.kernel.org, Jernej Skrabec , Laurent Pinchart , Andrzej Hajda , Sam Ravnborg , Maxime Ripard Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Move hpd polling check into wait_hpd_asserted() callback. For the cases that aux transfer function wasn't used, do hpd polling check after pm runtime resume, which will power on the bridge. Signed-off-by: Hsin-Yi Wang Reviewed-by: Xin Ji --- drivers/gpu/drm/bridge/analogix/anx7625.c | 33 ++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c index 59ddeba33652b..ea5a0b86fe52a 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -1443,23 +1443,24 @@ static int anx7625_read_hpd_status_p0(struct anx7625_data *ctx) return anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, SYSTEM_STSTUS); } -static void anx7625_hpd_polling(struct anx7625_data *ctx) +static int _anx7625_hpd_polling(struct anx7625_data *ctx, + unsigned long wait_us) { int ret, val; struct device *dev = &ctx->client->dev; /* Interrupt mode, no need poll HPD status, just return */ if (ctx->pdata.intp_irq) - return; + return 0; ret = readx_poll_timeout(anx7625_read_hpd_status_p0, ctx, val, ((val & HPD_STATUS) || (val < 0)), - 5000, - 5000 * 100); + wait_us / 100, + wait_us); if (ret) { DRM_DEV_ERROR(dev, "no hpd.\n"); - return; + return ret; } DRM_DEV_DEBUG_DRIVER(dev, "system status: 0x%x. HPD raise up.\n", val); @@ -1472,6 +1473,23 @@ static void anx7625_hpd_polling(struct anx7625_data *ctx) if (!ctx->pdata.panel_bridge && ctx->bridge_attached) drm_helper_hpd_irq_event(ctx->bridge.dev); + + return 0; +} + +static int anx7625_wait_hpd_asserted(struct drm_dp_aux *aux, + unsigned long wait_us) +{ + struct anx7625_data *ctx = container_of(aux, struct anx7625_data, aux); + struct device *dev = &ctx->client->dev; + int ret; + + pm_runtime_get_sync(dev); + ret = _anx7625_hpd_polling(ctx, wait_us); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + + return ret; } static void anx7625_remove_edid(struct anx7625_data *ctx) @@ -1741,6 +1759,7 @@ static struct edid *anx7625_get_edid(struct anx7625_data *ctx) } pm_runtime_get_sync(dev); + _anx7625_hpd_polling(ctx, 5000 * 100); edid_num = sp_tx_edid_read(ctx, p_edid->edid_raw_data); pm_runtime_put_sync(dev); @@ -2378,6 +2397,7 @@ static void anx7625_bridge_atomic_enable(struct drm_bridge *bridge, ctx->connector = connector; pm_runtime_get_sync(dev); + _anx7625_hpd_polling(ctx, 5000 * 100); anx7625_dp_start(ctx); } @@ -2497,7 +2517,6 @@ static int __maybe_unused anx7625_runtime_pm_resume(struct device *dev) mutex_lock(&ctx->lock); anx7625_power_on_init(ctx); - anx7625_hpd_polling(ctx); mutex_unlock(&ctx->lock); @@ -2589,6 +2608,7 @@ static int anx7625_i2c_probe(struct i2c_client *client, platform->aux.name = "anx7625-aux"; platform->aux.dev = dev; platform->aux.transfer = anx7625_aux_transfer; + platform->aux.wait_hpd_asserted = anx7625_wait_hpd_asserted; drm_dp_aux_init(&platform->aux); if (anx7625_register_i2c_dummy_clients(platform, client) != 0) { @@ -2617,6 +2637,7 @@ static int anx7625_i2c_probe(struct i2c_client *client, if (!platform->pdata.low_power_mode) { anx7625_disable_pd_protocol(platform); pm_runtime_get_sync(dev); + _anx7625_hpd_polling(platform, 5000 * 100); } /* Add work function */