Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp319378lqo; Fri, 10 May 2024 00:12:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVOwalclS/9hGQOm4+fkHxkszcmXwPiy5E7x3MvLLShTdSkyusoLquwDcyg/2dyUB7PTsYiFzOQCkCjIDq08pjMxyWGVrlzHhhhOzgM8w== X-Google-Smtp-Source: AGHT+IEGmhzk/Zs7Nw58kyTWZElRkMsbQ7KmPz04Xrx0ZUt2uDx92ltfZH4GqHLhiKZage99e7Ut X-Received: by 2002:a50:d5c1:0:b0:572:9d22:eb8c with SMTP id 4fb4d7f45d1cf-5734d5c3154mr1417484a12.15.1715325145947; Fri, 10 May 2024 00:12:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715325145; cv=pass; d=google.com; s=arc-20160816; b=C8FFrwjfm3S0aTA+AyuS7dIKQMQL1tnOu1nKR2RuEaVn9lGHRp3YHRZjN/6/UXQWGA jfsC56dLqiJ8OWxMi637hA0ilpG/BbpiF2p1tIBY7LbzIjicbjKml19hURfgo9K9Ek5+ Wk7MmIrFxleswtkHPz/qzF1O78ivdDb+btbuCHG+JBFWha6dtYM8xWtKAY/+jhRi5Z9Z Z0T9UwhvZUDH18XiNMZocYHA4/xvsxts6Kip5Ix09WeDkN/7hGDP+AQFTIodh0zO9QYL J5by8iAcSVNDHXTO1tITm69N26KswvnUTqFwYh8HAuU4IP19BAfI4QOsyFRDoEP2z18E EAXA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=wlFIBlmbfYaR36UaypiDCAopZgGq725DcQ4HyrxaC/o=; fh=1UkrlD8RjbfPcEjCytvKsF2+DMsNoZ7VTOVVKkrBxCk=; b=kNO7DSmGd7UwSGwzZAtAVYzPzg6Q0IRlvhLCzs0bVPoIAG5hHX/hxQr3PYHZMMtLNI mTyzqwgsB52xCy32+qMAWFhGHdPKy8UQnnemGIjwKP3YmSp6it2QO1YzVQS6OKuo/CrH ZxgVN/RXlMfNW9IHrZkMt9033m/T+DrANvToS70wqG50+z9RTkZ/g5bJPP2bz2kymeKb 6N0JwlvryW06fJn0sf+7u/I8mHSGLxsQLTb7Aht6zzimh4nzHBLH3JEQKXbghRgCr8Ok Yyb/EE5zNMZ3hI+F4fZjCjNYhS1UXT9XgnSAZ7yHZEyuQrrYFOf/p/Zx4snlauZLvCeb aM5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=U80jYivW; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-175382-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175382-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c328968si1579178a12.422.2024.05.10.00.12.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 00:12:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175382-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=U80jYivW; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-175382-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175382-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AAA3C1F218CA for ; Fri, 10 May 2024 07:12:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4985715EFA6; Fri, 10 May 2024 07:11:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="U80jYivW" Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2D7715E810; Fri, 10 May 2024 07:11:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715325101; cv=none; b=JRCneFBO9nHZatPRJ2mbroAJWzV4GeEXlg9ESxYBg3yXiGLUftHbmxnALdhgzVi7D+2/HVm7FMRhCFt+T/UJtFsjtGPTyzP/qspGy3QokVNZBteLdd/eCB3JqTOA3FXArPlc7/ecDHNpZfCpewplruRWR5kynINfp8IzotTexQw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715325101; c=relaxed/simple; bh=TH0I5snS+nX/+q/jMBmzPPgG25pX283PWFV4wnyOm8w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mtdMwg1MhS/lfpVDCbysZW0lXx3+2U3JTy7md/X0runr80T9FbmhbHFGAzOTUSotWxfVLbHafGV7q6m+b/wF3y5KWejosH2zwg7yLgRrvE7xyR7N9Q29A3dRb+n3mdSbLp3rxXeXq+m69ZmUeLXDiszIU7pEHeHoHfkSmWIZFVc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=U80jYivW; arc=none smtp.client-ip=217.70.183.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 2A45C1C0007; Fri, 10 May 2024 07:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1715325097; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wlFIBlmbfYaR36UaypiDCAopZgGq725DcQ4HyrxaC/o=; b=U80jYivWaz+SXXXRRbPrJrAw9kXYaobh3XPeNGwBUHWqTlyidKJUWCfGHeYOSHk70n9o9e rdNwajnDt1ZLuVvyCtAPFyLi0cuZV1BcPh6/7n0rJy2KkUnM/f2vnKu5Rl8r3CEHJdig8K XnwL/h3+YdTI1gmyJ4VkAdlE1W+sJvLE/hmXI4bF0ToDFb27Rwc/pSEG1vOq0oAERdxMYo 6hou/qNpur9ia60UW3p/QriUIE7upcqF/igXaljcdNUjq0kL+sdax6LpnxcVepnR0gu2Pu fJUFNOsmc0XZikwm5OvruLW9Tih4to10xiv1KTOxB2rrmUVK+8p/Vn6YNhcDvA== From: Luca Ceresoli Date: Fri, 10 May 2024 09:10:39 +0200 Subject: [PATCH v2 3/5] drm/encoder: add drm_encoder_cleanup_from() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240510-hotplug-drm-bridge-v2-3-ec32f2c66d56@bootlin.com> References: <20240510-hotplug-drm-bridge-v2-0-ec32f2c66d56@bootlin.com> In-Reply-To: <20240510-hotplug-drm-bridge-v2-0-ec32f2c66d56@bootlin.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan Cc: Paul Kocialkowski , =?utf-8?q?Herv=C3=A9_Codina?= , Thomas Petazzoni , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Paul Kocialkowski , Luca Ceresoli X-Mailer: b4 0.13.0 X-GND-Sasl: luca.ceresoli@bootlin.com Supporting hardware whose final part of the DRM pipeline can be physically removed requires the ability to detach all bridges from a given point to the end of the pipeline. Introduce a variant of drm_encoder_cleanup() for this. Signed-off-by: Luca Ceresoli --- Changed in v2: - fix a typo in a comment --- drivers/gpu/drm/drm_encoder.c | 21 +++++++++++++++++++++ include/drm/drm_encoder.h | 1 + 2 files changed, 22 insertions(+) diff --git a/drivers/gpu/drm/drm_encoder.c b/drivers/gpu/drm/drm_encoder.c index 8f2bc6a28482..472dfbefe296 100644 --- a/drivers/gpu/drm/drm_encoder.c +++ b/drivers/gpu/drm/drm_encoder.c @@ -207,6 +207,27 @@ void drm_encoder_cleanup(struct drm_encoder *encoder) } EXPORT_SYMBOL(drm_encoder_cleanup); +/** + * drm_encoder_cleanup_from - remove a given bridge and all the following + * @encoder: encoder whole list of bridges shall be pruned + * @bridge: first bridge to remove + * + * Removes from an encoder all the bridges starting with a given bridge + * and until the end of the chain. + * + * This should not be used in "normal" DRM pipelines. It is only useful for + * devices whose final part of the DRM chain can be physically removed and + * later reconnected (possibly with different hardware). + */ +void drm_encoder_cleanup_from(struct drm_encoder *encoder, struct drm_bridge *bridge) +{ + struct drm_bridge *next; + + list_for_each_entry_safe_from(bridge, next, &encoder->bridge_chain, chain_node) + drm_bridge_detach(bridge); +} +EXPORT_SYMBOL(drm_encoder_cleanup_from); + static void drmm_encoder_alloc_release(struct drm_device *dev, void *ptr) { struct drm_encoder *encoder = ptr; diff --git a/include/drm/drm_encoder.h b/include/drm/drm_encoder.h index 977a9381c8ba..bafcabb24267 100644 --- a/include/drm/drm_encoder.h +++ b/include/drm/drm_encoder.h @@ -320,6 +320,7 @@ static inline struct drm_encoder *drm_encoder_find(struct drm_device *dev, } void drm_encoder_cleanup(struct drm_encoder *encoder); +void drm_encoder_cleanup_from(struct drm_encoder *encoder, struct drm_bridge *bridge); /** * drm_for_each_encoder_mask - iterate over encoders specified by bitmask -- 2.34.1