Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6341492rwn; Tue, 13 Sep 2022 02:49:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR6QB5Qr7/veSOnzUUAK8jtpEebdFzcqVMJ1oi0a59SeEoAXwOBEDHWcyABUXk1WJPxSR+b9 X-Received: by 2002:a17:907:7b93:b0:770:1d4f:4de9 with SMTP id ne19-20020a1709077b9300b007701d4f4de9mr21507744ejc.201.1663062561323; Tue, 13 Sep 2022 02:49:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663062561; cv=none; d=google.com; s=arc-20160816; b=BdrfSeIDZuknfBuwbhre6E/OgKKg4y/CRshJuGa4y04S82uG23m8rjU+lA4KPiOJ9r P3GNr83rJv5sarSg/Ur9uynYTx6eYeO+WmUgJzbmB5S7tABlYck0p1LMbG4boFxy/tx+ WtkPXQ5nGSLJTDAl62Ouk3j23eyq2xCcYiQEoSA+ib2PPXq5m+V/6KT8WpeHYxpxiBzK 6dKp22rg/yWLbCuoUB2gDC4AwfJ9m3zySapNLN/SHp20kdR6Z4jZJSPCbRcodm+ECTe8 r3mDVm2YpQK9RkTgF9TkGQE89UtWIw0OoU81um6e5hyceDnox2Aawl1KOwbaHVNO74wW N0/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xiFzvw2NzYCrrYdm3f5bWhvYTVl0U3ltacZLq6wB5g4=; b=ECcdLnuQSJVQqHZKow7Ze4kTbyis4yj6ZPtOAnVCXm1wB9QEqixesQPf/12R9HmwQi 9TNLb2OIgf2jB1gASg5lFA6g1zmkj6Rs1V4rvQyFGZDmhQY7/uhrsng66HFat/TwGzV+ NOm7vKZo3bnUEDLpmNCns1Pxskn/AkZ6MfDtjWmRdCN9v/SY5UP9modOkH/nI2CNCUO8 2I35DBhQUXDr9EGlyJnE4SAYAzVJhBU0uyThn+sAM2Sr9Q+9W7hlomt/30t1hfMiJB8k +4a2NBpMm1oMHGv7/36GkrKWgADs8A/iEuOoOY44YZnwg5t/AUg9QvUDknzjRgEL3Gje 6Ekg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sTS3FNdE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt3-20020a170907728300b00730983c4646si8408246ejc.508.2022.09.13.02.48.55; Tue, 13 Sep 2022 02:49:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sTS3FNdE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231532AbiIMI7F (ORCPT + 99 others); Tue, 13 Sep 2022 04:59:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231488AbiIMI6Y (ORCPT ); Tue, 13 Sep 2022 04:58:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 094565A2C7; Tue, 13 Sep 2022 01:58:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7F300B80E40; Tue, 13 Sep 2022 08:58:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B18A0C43148; Tue, 13 Sep 2022 08:58:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663059499; bh=ZcIqc1knQDBLZsYiRURyGWfkmlLHu5K+oQ6ruURZbro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sTS3FNdE+EXltnMNa9h3t5HHxPDAV3FkjYxZXZzxxwatDqjnDieL8UI0YWbk3+iRb BYy/ihxt8Axd+nQdQEB01mz3/qyk45lVZObDGOXWKYcwU+RlPwzG9oEWcWwa/CwNaP VabYvOC67nBvjxScVUlui7LW43A71MqP2oFx6GcjJNtedJ+8fyXxPgDtxp3trnLsj0 BS//ga8N7p+JuouJuIItXfONiqKN1QPnvwrIbM6xViGfA/7mkq4NiQtlmJjA8DM77T DGSMD2iNG+tKarvowIoAkyZ6TfXzN1jeaD0S4evUL+kPlMaYQXK3IKbPa1qv4d83Zb 6lY2Bo2+YYUGQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oY1kI-0002HE-TH; Tue, 13 Sep 2022 10:58:18 +0200 From: Johan Hovold To: Douglas Anderson , Dmitry Baryshkov , Rob Clark , Abhinav Kumar Cc: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Daniel Vetter , Sean Paul , Stephen Boyd , Bjorn Andersson , Manivannan Sadhasivam , Kuogee Hsieh , Steev Klimaszewski , dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH v2 07/10] drm/msm/dp: fix bridge lifetime Date: Tue, 13 Sep 2022 10:53:17 +0200 Message-Id: <20220913085320.8577-8-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220913085320.8577-1-johan+linaro@kernel.org> References: <20220913085320.8577-1-johan+linaro@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Device-managed resources allocated post component bind must be tied to the lifetime of the aggregate DRM device or they will not necessarily be released when binding of the aggregate device is deferred. This can lead resource leaks or failure to bind the aggregate device when binding is later retried and a second attempt to allocate the resources is made. For the DP bridges, previously allocated bridges will leak on probe deferral. Fix this by amending the DP parser interface and tying the lifetime of the bridge device to the DRM device rather than DP platform device. Fixes: c3bf8e21b38a ("drm/msm/dp: Add eDP support via aux_bus") Cc: stable@vger.kernel.org # 5.19 Reviewed-by: Dmitry Baryshkov Signed-off-by: Johan Hovold --- drivers/gpu/drm/msm/dp/dp_display.c | 2 +- drivers/gpu/drm/msm/dp/dp_parser.c | 6 +++--- drivers/gpu/drm/msm/dp/dp_parser.h | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index 4b0a2d4bb61e..808a516e84c5 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -1586,7 +1586,7 @@ static int dp_display_get_next_bridge(struct msm_dp *dp) * For DisplayPort interfaces external bridges are optional, so * silently ignore an error if one is not present (-ENODEV). */ - rc = dp_parser_find_next_bridge(dp_priv->parser); + rc = devm_dp_parser_find_next_bridge(dp->drm_dev->dev, dp_priv->parser); if (!dp->is_edp && rc == -ENODEV) return 0; diff --git a/drivers/gpu/drm/msm/dp/dp_parser.c b/drivers/gpu/drm/msm/dp/dp_parser.c index dd732215d55b..dcbe893d66d7 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.c +++ b/drivers/gpu/drm/msm/dp/dp_parser.c @@ -240,12 +240,12 @@ static int dp_parser_clock(struct dp_parser *parser) return 0; } -int dp_parser_find_next_bridge(struct dp_parser *parser) +int devm_dp_parser_find_next_bridge(struct device *dev, struct dp_parser *parser) { - struct device *dev = &parser->pdev->dev; + struct platform_device *pdev = parser->pdev; struct drm_bridge *bridge; - bridge = devm_drm_of_get_bridge(dev, dev->of_node, 1, 0); + bridge = devm_drm_of_get_bridge(dev, pdev->dev.of_node, 1, 0); if (IS_ERR(bridge)) return PTR_ERR(bridge); diff --git a/drivers/gpu/drm/msm/dp/dp_parser.h b/drivers/gpu/drm/msm/dp/dp_parser.h index 866c1a82bf1a..d30ab773db46 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.h +++ b/drivers/gpu/drm/msm/dp/dp_parser.h @@ -138,8 +138,9 @@ struct dp_parser { struct dp_parser *dp_parser_get(struct platform_device *pdev); /** - * dp_parser_find_next_bridge() - find an additional bridge to DP + * devm_dp_parser_find_next_bridge() - find an additional bridge to DP * + * @dev: device to tie bridge lifetime to * @parser: dp_parser data from client * * This function is used to find any additional bridge attached to @@ -147,6 +148,6 @@ struct dp_parser *dp_parser_get(struct platform_device *pdev); * * Return: 0 if able to get the bridge, otherwise negative errno for failure. */ -int dp_parser_find_next_bridge(struct dp_parser *parser); +int devm_dp_parser_find_next_bridge(struct device *dev, struct dp_parser *parser); #endif -- 2.35.1