Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6259571pxb; Mon, 14 Feb 2022 20:42:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxiZ9sHo4P/Fr37vqIi5p3dwxLess6Wg1gAOh4tIDzRFz9EvuZ6RJid0acRfLoCMmim2z1U X-Received: by 2002:a63:14b:: with SMTP id 72mr2038941pgb.444.1644900123786; Mon, 14 Feb 2022 20:42:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644900123; cv=none; d=google.com; s=arc-20160816; b=ru4se6kjghTN0SbvYFKLTetFAdYDW/8NhGt1XQtIVyA9PjIeQWIwBRZ1dfyCQoP6jV 7xlhYcq/1fkq320P/Yaz3FX7aOhLw6kB7pcoLopAqxHmL9HUdCyu6XiOUrTd8VnzxtJw jZV0PJ7uCKVd1MYXnGaVBG8evAv2crOQYHK+HQmeqh5aWnl5ArNQ8upxyjZTJDBDouxa aXdqVR0HvVhgtGRjhR6YtJ/aIh7AQMKkXiqGfk8fQjMrD7Kflg9O8yrBTp4DbZnIjfZe nardgtVHzGxglyDvsZDF3BEskXPkzmrdvqVajcK/25zn3KcQz0FiGNxyjg4k5tEIHx+w TAeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=ZIiaY20pBaneULKov1ZcMBkny7tiPsPZsShhqv21aGk=; b=JZfKpFQmYw93RvRlKa2qQeolSPrr+Y1H8k4qfqlEaBc9/SijwYSMBJ5XnrlqKpDi89 XUZvwG5iG4N6GIGF+r6y+WgxbLAsGL/zcCTXqIhJhruHEcBk7PX17RuQ9glaWXXOpFAe jICY9w2dIod0QbtsEUJeS1e4SnXLrZmZrn2ntoXDRqckCT0WqVyq7YPSTMV+5vUFKw/m 2iHsCgjDKWiihhMR3lYsTMMs9oi9uoXyb0ChAuey7ePmtff149t3t/yAHGdBV0D4EvNS y+Be1K0G9+tTb5y4YFOvT6vt/CZ/ycqDZeUzxi/6auicgeODLVHRRtOSOqEuRrkzwXyo RyTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=HAWv1GWk; 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=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i36si1646695pgb.658.2022.02.14.20.41.44; Mon, 14 Feb 2022 20:42:03 -0800 (PST) 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=@collabora.com header.s=mail header.b=HAWv1GWk; 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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233010AbiBOBRN (ORCPT + 99 others); Mon, 14 Feb 2022 20:17:13 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231664AbiBOBRM (ORCPT ); Mon, 14 Feb 2022 20:17:12 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E7BB97BB8; Mon, 14 Feb 2022 17:17:03 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 23E821F43839 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1644887821; bh=z+Pkjj4FCBWwphTASrycJ+DSyiPQpio9khcfraStadg=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=HAWv1GWk79QOFTN1XRGwER8IeQYSu+lF/EGQF2nZDTedBqNrkhG7xPrRYOUAtZAdo abUnkEPUAjC2K1ibW0LmXH7mduwUhIVTXAoGqr3uSC3mUWKulcQppQji8tX0BvFlw7 amoDp6LQsvGVLTvIq3LgXyvHBbh3g5FEuhx4dDtmEOATvWiqOXMJeHOb0IoAf9ysme VaDslraajxiKEbP5m/iLYi3QSmPewPf6sQisKIWo1FoZ1Ho8/CqgYWPm+coIUbQsF8 JLs1qIdVs/NEz4GvkrCTJvJuEdt/6XG4TiXnEsa5lDLL/4/uuWcwBnIXpIQwBn7Cp/ ySE5zSpd49vYg== From: Gabriel Krisman Bertazi To: Hsin-Yi Wang Cc: dri-devel@lists.freedesktop.org, David Airlie , Daniel Vetter , amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Chun-Kuang Hu , Sean Paul , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , linux-kernel@vger.kernel.org, Rob Herring , Matthias Brugger , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Simon Ser , Harry Wentland , Alex Deucher , Jani Nikula Subject: Re: [PATCH v8 1/3] gpu: drm: separate panel orientation property creating and value setting References: <20220208084234.1684930-1-hsinyi@chromium.org> Date: Mon, 14 Feb 2022 20:16:56 -0500 In-Reply-To: <20220208084234.1684930-1-hsinyi@chromium.org> (Hsin-Yi Wang's message of "Tue, 8 Feb 2022 16:42:32 +0800") Message-ID: <87leydhqt3.fsf@collabora.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY 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 Hsin-Yi Wang writes: > drm_dev_register() sets connector->registration_state to > DRM_CONNECTOR_REGISTERED and dev->registered to true. If > drm_connector_set_panel_orientation() is first called after > drm_dev_register(), it will fail several checks and results in following > warning. Hi, I stumbled upon this when investigating the same WARN_ON on amdgpu. Thanks for the patch :) > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c > index a50c82bc2b2fec..572ead7ac10690 100644 > --- a/drivers/gpu/drm/drm_connector.c > +++ b/drivers/gpu/drm/drm_connector.c > @@ -1252,7 +1252,7 @@ static const struct drm_prop_enum_list dp_colorspaces[] = { > * INPUT_PROP_DIRECT) will still map 1:1 to the actual LCD panel > * coordinates, so if userspace rotates the picture to adjust for > * the orientation it must also apply the same transformation to the > - * touchscreen input coordinates. This property is initialized by calling > + * touchscreen input coordinates. This property value is set by calling > * drm_connector_set_panel_orientation() or > * drm_connector_set_panel_orientation_with_quirk() > * > @@ -2341,8 +2341,8 @@ EXPORT_SYMBOL(drm_connector_set_vrr_capable_property); > * @connector: connector for which to set the panel-orientation property. > * @panel_orientation: drm_panel_orientation value to set > * > - * This function sets the connector's panel_orientation and attaches > - * a "panel orientation" property to the connector. > + * This function sets the connector's panel_orientation value. If the property > + * doesn't exist, it will try to create one. > * > * Calling this function on a connector where the panel_orientation has > * already been set is a no-op (e.g. the orientation has been overridden with > @@ -2373,19 +2373,12 @@ int drm_connector_set_panel_orientation( > info->panel_orientation = panel_orientation; > > prop = dev->mode_config.panel_orientation_property; > - if (!prop) { > - prop = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE, > - "panel orientation", > - drm_panel_orientation_enum_list, > - ARRAY_SIZE(drm_panel_orientation_enum_list)); > - if (!prop) > - return -ENOMEM; > - > - dev->mode_config.panel_orientation_property = prop; > - } > + if (!prop && > + drm_connector_init_panel_orientation_property(connector) < 0) > + return -ENOMEM; > In the case where the property has not been created beforehand, you forgot to reinitialize prop here, after calling drm_connector_init_panel_orientation_property(). This means drm_object_property_set_value() will be called with a NULL second argument and Oops the kernel. > - drm_object_attach_property(&connector->base, prop, > - info->panel_orientation); > + drm_object_property_set_value(&connector->base, prop, > + info->panel_orientation); -- Gabriel Krisman Bertazi