Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp746920pxp; Fri, 11 Mar 2022 14:04:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJyR/IsdmFvQhd0lkmdSyhpFQAyap2EsHKuXiYkUxemO/8WuxacnVg2MXmFXTsmYzwP8Fkfs X-Received: by 2002:a17:903:4055:b0:153:2250:c18b with SMTP id n21-20020a170903405500b001532250c18bmr9518882pla.25.1647036247714; Fri, 11 Mar 2022 14:04:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647036247; cv=none; d=google.com; s=arc-20160816; b=SApbYJ8b1uiysqkbKN1mLXjnd7JWQrUF1w81YEijkwLqdJAQKhxLWKYjo37sLzTth0 SIDA00o/2fSl8kxW6ta8yhI9vd+e9fRkEFJq1XhdolFIroe+q1OeEJ0qsOEWHkvAI7RR N1clF1G7qGxkHBwai9K0Id29XVdFLL5RPDXZsObpKnxmdibS6DuSXlWVvthyf3bGucN7 ArajgEA0KQgj73LuSxxmtY33h8EZJHQoGn6Zr+rqqWh9TjcaZpPMbnTrDavOh4ChlfmZ xJUIiZ58dJc1vkvDK86Ov7UiIybrjfSXUBRCtI27DIGBxfwDqAF7YcRXLfDI0+vUvDfI TcKQ== 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=cuGvTjXrj43oXF9BXLz7NoLb5a9wIURT+ASyVkaNEto=; b=vQSN66K37wpULK/UGDMYB0BYWmZ69Jh582aQnHRlwjanCXT9sbuKz77URY5YuBn9+v 7g0XgaeMDSqxiYNd44JPrb5wx2Lw/Y8iUqszwA5ydkghIZgDP19USOFY6/V2MMe/2gaw lVZRhxV0w5SKDhXEsXk0V9RY10aKCNFeQULGYX9VsmD2XCBNIK84dwjK2AjkprJ1IXWB bYvZ8WuPhKcPSFD8K+32jxjHmD8yqXY9e1YxSn/EkrBjFILBWDqrPjVfvLYB68NF6SMv 8IaneNpspyA+P+XBDAIbeXykEoswW2T+6CJaIjWjlL9dG6hvnUTn96haMlQ1RexDjax6 CBIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=gD8SJkWP; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id p6-20020a1709028a8600b0014fb0a5a6aasi8506508plo.53.2022.03.11.14.04.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 14:04:07 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=gD8SJkWP; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D7C0F28D864; Fri, 11 Mar 2022 13:19:20 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347579AbiCKJfp (ORCPT + 99 others); Fri, 11 Mar 2022 04:35:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347553AbiCKJfl (ORCPT ); Fri, 11 Mar 2022 04:35:41 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E76089F3B2 for ; Fri, 11 Mar 2022 01:34:38 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: rcn) with ESMTPSA id E511A1F4649E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1646991277; bh=6IuTiAPuhKDYgNwCLKRyc4SunUJTB6ruZFYFsOvvpvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gD8SJkWPQ7AVcDYe+nWxXfobtI4INoYCVxW2ZB+Ymm9w2+8CaNz1q4SOTOz0LYPjz hGE5rXOAurREVi3IW7YQ+311vbeuCvhAZEtGwT1UQ6JGNN4jw9I5SVByaHfedUpRgk 8tl6I1ycOfeVe6h3U6FpZHRJQ4a08lXbIc0faRsAqCq1QccSYUlhyRTPdgqB7lD/KD nlgN6VZ5BncUXMpaEJHhVlgNMh78y/7kD8lLHl4E8MWn0XAm+B4cW/SdglvOY5S+SS JRf3BVt9wetOW7qBA0Od2XtzFbiAg08uBp+EtWKh8s9Wzyz3ipXIE1sm44716SVvX1 7EEsvho0zxjdg== From: =?UTF-8?q?Ricardo=20Ca=C3=B1uelo?= To: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, kernel@collabora.com, andrzej.hajda@intel.com, narmstrong@baylibre.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org Subject: [PATCH 2/2 RESEND] drm/bridge: Add extra checks in pre_enable and post_enable Date: Fri, 11 Mar 2022 10:34:06 +0100 Message-Id: <20220311093406.4068019-3-ricardo.canuelo@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220311093406.4068019-1-ricardo.canuelo@collabora.com> References: <20220311093406.4068019-1-ricardo.canuelo@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=no 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 Depending on the bridge code, certain userspace events during a driver teardown (such as a DRM ioctl call) might cause a race condition where the drm_bridge_chain_pre_enable() and drm_bridge_chain_post_enable() functions could be called for a bridge that has just been detached and removed from the bridge chain of an encoder. This change makes these functions a bit more robust by bailing out if the bridge has already been detached. Tested on an Acer Chromebook R13 (Elm, MT8173) with Debian Sid. Signed-off-by: Ricardo CaƱuelo --- drivers/gpu/drm/drm_bridge.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index c96847fc0ebc..e074aa456dd1 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -529,7 +529,7 @@ void drm_bridge_chain_post_disable(struct drm_bridge *bridge) { struct drm_encoder *encoder; - if (!bridge) + if (!bridge || !bridge->dev) return; encoder = bridge->encoder; @@ -585,7 +585,7 @@ void drm_bridge_chain_pre_enable(struct drm_bridge *bridge) struct drm_encoder *encoder; struct drm_bridge *iter; - if (!bridge) + if (!bridge || !bridge->dev) return; encoder = bridge->encoder; -- 2.25.1