Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp904487rdd; Wed, 10 Jan 2024 03:11:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IG2tMS+CI/tp8jTFOTQ5CI8Nm+V4QRtFbeQxAQlSToSJPXyuvcq6dHJB0rpYQ6V+56ju63r X-Received: by 2002:a17:906:c7ca:b0:a27:f6aa:c7b0 with SMTP id dc10-20020a170906c7ca00b00a27f6aac7b0mr513453ejb.11.1704885069236; Wed, 10 Jan 2024 03:11:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704885069; cv=none; d=google.com; s=arc-20160816; b=lvshvgyl7Sto87eyB3eswnAFzzHo+nRGMYnsNo3gzX4vbChLyOavcldtCo7NTjWeoK niWhlbDW/aijhAyuqt1Cu5kmThjX5XXSpBz3lAT8e+Ta86qmB5RGuyds1ZXQokgJFwE7 yNMIJSX4XZgEOvhCciPNk74cwZLRc/73m6a5r4dSjwH5e8rgw5zkes40cQ/Ykm9WUOe1 28HJSbiHWMoJV9h2k1FxFK9bNqwFrpyIx81PZgVsIq+ndBANSDNGnNSyntXAIToT4bqM KlyTmwE+P9xFKdkfKRRzQdN8Zk98mfvzfz+fwPMpIeTLWXWzDvkLtaUB7mcGNc4XUuaT EIQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=3QlF0rRTBRD1E5jWA0kISaH2vZgtmpP2AfnIty3q4TQ=; fh=BiiF6Ca9HWjXy+abw+2YpqjmERP0+tNSIv8PRDGgFbY=; b=HbAxqpNMSwnJhg4+mKXk0Inqnf8opdtEldxBiPx7r9mGw0ukQGseaVdXAvN87+s9w3 0TAw1X+JIWjtDXEXD0LJwnC85vltEKeVD/wuqponkB8MC1YRP83ZGz6jn0ZEdl81vAMR wOb5XVNNdmLkh2nfBHF57yq7EeZPqzKK1lK6UQLiLqFcMeto6et1tUWs9cWEdIhEK9up wdPlU1k12EIZVtFqpuOLjunqybK4bMe/39EmDu2uC2bZMw3CkSxtt7G5DcQiZzzkDmHN xIBGA2lMgvVJ0bI8sfbPB8MFVh0J/HZ0z9XMiUPwHVpsRAcDnLbwIrzsANdLA/RPEDYZ qsZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=Zic2V0Wi; spf=pass (google.com: domain of linux-kernel+bounces-22045-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22045-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id kt11-20020a170906aacb00b00a234963fc8csi1714942ejb.691.2024.01.10.03.11.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 03:11:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22045-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=@ffwll.ch header.s=google header.b=Zic2V0Wi; spf=pass (google.com: domain of linux-kernel+bounces-22045-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22045-linux.lists.archive=gmail.com@vger.kernel.org" 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 C7C801F2179F for ; Wed, 10 Jan 2024 11:11:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 48E1F47A47; Wed, 10 Jan 2024 11:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="Zic2V0Wi" Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFAF247795 for ; Wed, 10 Jan 2024 11:10:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ffwll.ch Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a28cfca3c45so101984466b.1 for ; Wed, 10 Jan 2024 03:10:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; t=1704885049; x=1705489849; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=3QlF0rRTBRD1E5jWA0kISaH2vZgtmpP2AfnIty3q4TQ=; b=Zic2V0Wiuaq4gTl+N44n1XUP4UA1b65X7cROPZrdK7Gqx47g5fLdSzeGowGK2w0ltl uTESACfTbt+JNpPh9ddtNWuMI73YHi5io0MAfsmKunlxPRRwTNRSp2bYVyDrMF7fMGpL RoqKUlYthJIDIg9/RPtT8+1Qn54W2C18gvfU0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704885049; x=1705489849; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3QlF0rRTBRD1E5jWA0kISaH2vZgtmpP2AfnIty3q4TQ=; b=CtNNoOA4iUSuyP8wqVyQ8jcMUK+RsR0zRn3D5AmkJMjnNtt8oW7KPelJF3Sb+6hfxQ Abj2Gf7S3m7kf5nB4lSvUh6z+knHvDjw+YiLG/JRSXGbmVJ6u3qd6NAMllZ9zfwk/nEx l1DkGDJi6Oy8r/Q3eIzD20qmR0m7tN9r9FbERXU5bGSepFAk+NpCOv/Vr6NyNMqy3wD8 L7D4FR5FXKiFQr7WETSx2+QJ2c7vwrzgOMRNPX7pr2FPmK2zfMChV32Ot5fWR7jMKWjI BD0jK58KRTcN0pqFjIUBZcGgkN9m1aQQeUZeYMAQbKASr8vcKV/e3sFjWDeYj/WGO90g 2a2w== X-Gm-Message-State: AOJu0YyBtrwxyPQUgoqiqlAUdHspZ+KA3aI6zORrbvZK91ANpTMtHqgU gu6VoFMQPnJNUAPkfNpeEynJBxQzKc9T0Q== X-Received: by 2002:a17:907:9445:b0:a27:7701:f16 with SMTP id dl5-20020a170907944500b00a2777010f16mr1131131ejc.7.1704885048816; Wed, 10 Jan 2024 03:10:48 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id m27-20020a1709062adb00b00a269f8e8869sm1976817eje.128.2024.01.10.03.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 03:10:48 -0800 (PST) Date: Wed, 10 Jan 2024 12:10:46 +0100 From: Daniel Vetter To: Andri Yngvason Cc: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , Christian =?iso-8859-1?Q?K=F6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, Simon Ser , Werner Sembach Subject: Re: [PATCH 3/7] drm/amd/display: Add handling for new "active color format" property Message-ID: Mail-Followup-To: Andri Yngvason , Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , Christian =?iso-8859-1?Q?K=F6nig?= , "Pan, Xinhui" , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, Simon Ser , Werner Sembach References: <20240109181104.1670304-1-andri@yngvason.is> <20240109181104.1670304-4-andri@yngvason.is> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240109181104.1670304-4-andri@yngvason.is> X-Operating-System: Linux phenom 6.5.0-4-amd64 On Tue, Jan 09, 2024 at 06:11:00PM +0000, Andri Yngvason wrote: > From: Werner Sembach > > This commit implements the "active color format" drm property for the AMD > GPU driver. > > Signed-off-by: Werner Sembach > Signed-off-by: Andri Yngvason > Tested-by: Andri Yngvason > --- > .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 42 ++++++++++++++++++- > .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 4 ++ > 2 files changed, 45 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > index 10e041a3b2545..b44d06c3b1706 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > @@ -6882,6 +6882,24 @@ int convert_dc_color_depth_into_bpc(enum dc_color_depth display_color_depth) > return 0; > } > > +static int convert_dc_pixel_encoding_into_drm_color_format( > + enum dc_pixel_encoding display_pixel_encoding) > +{ > + switch (display_pixel_encoding) { > + case PIXEL_ENCODING_RGB: > + return DRM_COLOR_FORMAT_RGB444; > + case PIXEL_ENCODING_YCBCR422: > + return DRM_COLOR_FORMAT_YCBCR422; > + case PIXEL_ENCODING_YCBCR444: > + return DRM_COLOR_FORMAT_YCBCR444; > + case PIXEL_ENCODING_YCBCR420: > + return DRM_COLOR_FORMAT_YCBCR420; > + default: > + break; > + } > + return 0; > +} > + > static int dm_encoder_helper_atomic_check(struct drm_encoder *encoder, > struct drm_crtc_state *crtc_state, > struct drm_connector_state *conn_state) > @@ -7436,8 +7454,10 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm, > adev->mode_info.underscan_vborder_property, > 0); > > - if (!aconnector->mst_root) > + if (!aconnector->mst_root) { > drm_connector_attach_max_bpc_property(&aconnector->base, 8, 16); > + drm_connector_attach_active_color_format_property(&aconnector->base); > + } > > aconnector->base.state->max_bpc = 16; > aconnector->base.state->max_requested_bpc = aconnector->base.state->max_bpc; > @@ -8969,6 +8989,26 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) > kfree(dummy_updates); > } > > + /* Extract information from crtc to communicate it to userspace as connector properties */ > + for_each_new_connector_in_state(state, connector, new_con_state, i) { > + struct drm_crtc *crtc = new_con_state->crtc; > + struct dc_stream_state *stream; > + > + if (crtc) { > + new_crtc_state = drm_atomic_get_new_crtc_state(state, crtc); > + dm_new_crtc_state = to_dm_crtc_state(new_crtc_state); > + stream = dm_new_crtc_state->stream; > + > + if (stream) { > + drm_connector_set_active_color_format_property(connector, > + convert_dc_pixel_encoding_into_drm_color_format( > + dm_new_crtc_state->stream->timing.pixel_encoding)); > + } > + } else { > + drm_connector_set_active_color_format_property(connector, 0); Just realized an even bigger reason why your current design doesn't work: You don't have locking here. And you cannot grab the required lock, which is drm_dev->mode_config.mutex, because that would result in deadlocks. So this really needs to use the atomic state based design I've described. A bit a tanget, but it would be really good to add a lockdep assert into drm_object_property_set_value, that at least for atomic drivers and connectors the above lock must be held for changing property values. But it will be quite a bit of audit to make sure all current users obey that rule. Cheers, Sima > + } > + } > + > /** > * Enable interrupts for CRTCs that are newly enabled or went through > * a modeset. It was intentionally deferred until after the front end > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c > index 11da0eebee6c4..a4d1b3ea8f81c 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c > @@ -600,6 +600,10 @@ dm_dp_add_mst_connector(struct drm_dp_mst_topology_mgr *mgr, > if (connector->max_bpc_property) > drm_connector_attach_max_bpc_property(connector, 8, 16); > > + connector->active_color_format_property = master->base.active_color_format_property; > + if (connector->active_color_format_property) > + drm_connector_attach_active_color_format_property(&aconnector->base); > + > connector->vrr_capable_property = master->base.vrr_capable_property; > if (connector->vrr_capable_property) > drm_connector_attach_vrr_capable_property(connector); > -- > 2.43.0 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch