Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3454860lqp; Tue, 26 Mar 2024 09:31:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVy49IESbjrQSWbMpfrc7Y9/pFNqwMMB9nF2lOWmFOwaW1T2pW+4qcsbqRpBiPgrLsAHr/NcFfhrNhqc2KxTfqQcn6baHprBVNw2tTwdw== X-Google-Smtp-Source: AGHT+IHqAN/BxFt907tD8cQWAcRjjUF0YZO+nx7bOdrfNKqxUT04oZsH0yVLX6jRZiGYONEOofMh X-Received: by 2002:a17:902:f68a:b0:1e0:a678:5b55 with SMTP id l10-20020a170902f68a00b001e0a6785b55mr1702098plg.11.1711470668002; Tue, 26 Mar 2024 09:31:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711470667; cv=pass; d=google.com; s=arc-20160816; b=C2AV+VqftJl6kc3fJNNat0Arspiw9Me0S7HdIZp/4pnJ7IG6ziF/1+TILlN2Z5QH36 Twkpuyg7U2T/jzvWU09XNPtAOMG6/LZYcFfmf7n0Dh08aMGsfVQssaeARx1Pg4aI/Xqr shV2UgAAPvFDXh1J7npYNmYUFlog7xeaXBVjhs0f4jSrTDuV6QwxzXvIIMldlpFgcHQa PAIFqIPN7zQasfuVeH8gMIQc9zwT2ruKq37JBgGZ9JhKxTcAubl8fDBv8CPBmecr7jW8 nYtNM9YwhshRxAON2RA3srKweJDI5Fui7bG27NNwHbi6vB8IyfH8UD5+N2dJmqc1gQN0 sOpQ== 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=ElqEQwFcV4YHaCCBf2EVHYAZ/9/5OX5WYRwZoNy8qxM=; fh=5/lQOR7r8Ck3BuCEedTmMI8LwJogFIXUogeiYwjvopw=; b=bNK14LIPecVifKkR5peT0sn9Z0Z5xyR99ANJplQgPcq6c3K0Tk+ZtNmKvior5WZqC4 k6X5piK5yOLd1riGK76RIUIblEXkZqglZMnvV3EmKclFhdvoEhCEiES7znM1PrjkGRf5 aOIsfTFJnQAaB4DLxGz/t+Qf7eTPsncViqnarGaDbOnf832ihLMF3VWgvEwzBTudEEnN Sdvf78WhFI+7nGTAwvOJrOjlzZBS0Tf96snD4SHGRxXYCuYwtmSYOK864SpcAfPbNm5B wkerPDPdFrgT4bKN0lhfWqQbmrhgBQZ1uCl+ybEd7ccvY34C5YczXzdKFj+6Oy3G80IQ bfNA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=H7RHzrLp; 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-119457-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119457-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u13-20020a170903124d00b001e0af9a8545si6436491plh.571.2024.03.26.09.31.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 09:31:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119457-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=H7RHzrLp; 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-119457-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119457-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 168843268CF for ; Tue, 26 Mar 2024 16:29:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A851613CC6B; Tue, 26 Mar 2024 16:28:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="H7RHzrLp" Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 372BD13CC51; Tue, 26 Mar 2024 16:28:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711470522; cv=none; b=SJ/QsU2FkeFbZnyBLCa9b/BiwW55B2tihz5rY1aTM/v/yTCmpVzQ3itAmAHR7EK5fi4DILiZw9+Lc2Ori7l3sZLDuuJ9YSgs64ZHS+QpMU0hK/X5GZTpsMjnkp5XW01lPMXaMfLMzbfV3m8TgowCrbZwSId1DXKiF8sEVaVLufo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711470522; c=relaxed/simple; bh=V2/V9+ScTzmE+T6ph5QIRM6bSdthiHWfE8ShdVeXhSk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ikRCci/jE9+gaYcI8VS7GD7+rU+aCYnB8w+d+hDZPPLuT2R85v9qq+1TbtLkVAvxrjVgOvQLQpLtkPX0WSTjJNiV9oZj2NRx8Jh3F3u0zB+Nr/41JAoWYfsq9sjnoKWH+m8Y7Pymn7aajBpZekr7YlXfSqeQFG2qm3rAibTvVbc= 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=H7RHzrLp; arc=none smtp.client-ip=217.70.183.200 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 A4A4420012; Tue, 26 Mar 2024 16:28:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1711470518; 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=ElqEQwFcV4YHaCCBf2EVHYAZ/9/5OX5WYRwZoNy8qxM=; b=H7RHzrLpcIz1FZgjuGDrJW16xhCXRGN2tVMfDyCJqunXhhGbmrYRFpO6xcO+mmpydbQL/b CtZ4++t5g3HG4fQdJWZEgZfYer4ZgWxSlAkD2OKZl/ZEL32qSY44xO4K0rv0EIp/X9PE6M TEmc4auT8ApbB+ufHLY1dcLOpvvEqFwOdTX+EVg/x6rJ4ibJz2sIVThjXgnnW2a46RYMog Abe+NN9pwZIxFcG21dVAukmL8Us4EDjUxbbrkeW631FLQitjyRjPJommxGcS/RwLlejMU1 I3ICtMz7T8xZ6aJ/XEjRlCjClMcmbJC/2f6Nnj9/34AD5mLmHlzTwFb8q8PMBA== From: Luca Ceresoli Date: Tue, 26 Mar 2024 17:28:13 +0100 Subject: [PATCH 3/4] 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: <20240326-hotplug-drm-bridge-v1-3-4b51b5eb75d5@bootlin.com> References: <20240326-hotplug-drm-bridge-v1-0-4b51b5eb75d5@bootlin.com> In-Reply-To: <20240326-hotplug-drm-bridge-v1-0-4b51b5eb75d5@bootlin.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Paul Kocialkowski , =?utf-8?q?Herv=C3=A9_Codina?= , Thomas Petazzoni , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.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 --- 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..13149447bec8 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 bridges + * 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