Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp118520pxb; Tue, 15 Feb 2022 06:42:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJz3syiFn4V+naTWoSP6fu0mUb/nMu1NMSeuKlEInzJyalUjp/GwlONRKls2Q6nIqdoA2jlV X-Received: by 2002:a17:907:1c26:: with SMTP id nc38mr1891879ejc.557.1644936173469; Tue, 15 Feb 2022 06:42:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644936173; cv=none; d=google.com; s=arc-20160816; b=XVZ8YtBP0yMNQd7T5s1ALa0kSp7REg65XbR+2ZOgaN524z1pN37oQiRzPwE/n6LXB2 Ov9vcxxkADTkiBvHh42F9QtZhJfo0NYH+2gOiKipBF00QeIdaDACAsiXr/wFf6jj2n77 lRdzXJR5vVnBSFt92tKGRD1z5RVS2dVgWReNzBj0MbBDXdJ3G1k9F5TuzhTRU72riZ8z +NnSTQv+7lqNaArCOT7cw7zqjfwRajym2CKLh7iFBM5s9qvaPz8sAG7L4agg06epF9ym P2XnTd/hUHA3yPdY18pA0xodzENFgNJ041FMyf5kuzFgwwAFUzlCAAcdETu70miJQwqj zvOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=h8vn3ZFW8UjLnMLsgl86dcA80MaxOlksJ/pmKV8vWGU=; b=c0MLyZlDKUIJ4yMM6a+rGtZ39K5zzF3j6tH0Dq96HxMEpkAhfdlrWBFTtO17zYa2aO XSZPPPJ/PEyynerl+0my2ITyjP8YVQGeNGnib0pBVfHeN0937Ty3OJatiYGfZzrbW0El bGVb0bR3dKPQMXJmkkXE4SDkooRCGtw8JFb1V7uN/+3weIfrlah22MhLcNq4S3lxzRFZ NF43ziM2Afh00Cf8PESAAKrW4mc2ChsMrpnp/E4h7MILQb+NjN1q7DtgfKg5M6xdod9F 0I25AbBaOgzdZlvoqF8HKsP5oQX4u9iCMh3PfFl0hZGPuol+IE5a8FjOcnqCpLbg7fjI P0ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Xw6MjLP9; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b20si25826172edd.177.2022.02.15.06.42.30; Tue, 15 Feb 2022 06:42:53 -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=@chromium.org header.s=google header.b=Xw6MjLP9; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238113AbiBONIz (ORCPT + 99 others); Tue, 15 Feb 2022 08:08:55 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238115AbiBONIx (ORCPT ); Tue, 15 Feb 2022 08:08:53 -0500 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDB7BC24A1 for ; Tue, 15 Feb 2022 05:08:42 -0800 (PST) Received: by mail-il1-x134.google.com with SMTP id h11so14731229ilq.9 for ; Tue, 15 Feb 2022 05:08:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=h8vn3ZFW8UjLnMLsgl86dcA80MaxOlksJ/pmKV8vWGU=; b=Xw6MjLP9Kt6wH/XPSkTrQGGvUPWDpKraFYxM4d6yH3RKbYA/YECy72aCJttKSuP587 10FtshqY75bNZ0wPI428PCyMW2OAb6yh/TT1o8uOiXl/AYRQtBPDYcnJeIpx7cQYKuhp wqae+oOmMT9dVZpOYgXDUMAKab0DYkhYdVNJ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=h8vn3ZFW8UjLnMLsgl86dcA80MaxOlksJ/pmKV8vWGU=; b=E6gcQVIAfk1BqwwzUhSqXj6J93KCHv7N/x+NBPh8U+++xuqrJnpArqzioWr15DjVZ9 9xMEHge5ZFmS6uoxgNL5DsllwsmJzt/A69jQd2UCopgmDaYjn6tGyST2ObzIlNnoRn5A O1qwehUn3n5XyxyGE0re0lSyDGnwjeyh/DlNt9nk369wacNOCooePFk2Yp+ttrgf5ouH EWv8M4ncjSNUDPNzpz9Z2/YNNrJ08Z9m+vw8bGSXF+YNCovWFNd0yACmdCQentAShaY3 8tpluZ3FT+A0zfnBLeu+yp3YEISJnfi/nlyDONAJ0knkMFKIpKs9J+6IuO3WguEeB/r6 jrNQ== X-Gm-Message-State: AOAM531J9+O88/duHbFLifh71WQHqDqHk7mjIWL+2Ohrnxxzi1tzF93v 7Moh83L2RJJ1tXqDaDx3lz4N80171hvyBM61TZplUg== X-Received: by 2002:a05:6e02:18c6:: with SMTP id s6mr2544341ilu.230.1644930522121; Tue, 15 Feb 2022 05:08:42 -0800 (PST) MIME-Version: 1.0 References: <20220208084234.1684930-1-hsinyi@chromium.org> <87leydhqt3.fsf@collabora.com> <87czjoixno.fsf@collabora.com> In-Reply-To: <87czjoixno.fsf@collabora.com> From: Hsin-Yi Wang Date: Tue, 15 Feb 2022 21:08:16 +0800 Message-ID: Subject: Re: [PATCH v8 1/3] gpu: drm: separate panel orientation property creating and value setting To: Gabriel Krisman Bertazi 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Tue, Feb 15, 2022 at 12:03 PM Gabriel Krisman Bertazi wrote: > > Hsin-Yi Wang writes: > > > On Tue, Feb 15, 2022 at 9:17 AM Gabriel Krisman Bertazi > > wrote: > >> > >> 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 > > hi Gabriel, > > > > drm_connector_init_panel_orientation_property() will create prop if > > it's null. If prop fails to be created there, it will return -ENOMEM. > > Yes. But *after the property is successfully created*, the prop variable is still > NULL. And then you call the following, using prop, which is still NULL: > > >> > + drm_object_property_set_value(&connector->base, prop, > >> > + info->panel_orientation); > > This will do property->dev right on the first line of code, and dereference the > null prop pointer. Ah, right. Sorry that I totally missed this. I'll fix it in the next version if the idea of this patch is accepted. There might be another preferred solution for this. > > You must do > > prop = dev->mode_config.panel_orientation_property; > > again after drm_connector_init_panel_orientation_property successfully > returns, or call drm_object_property_set_value using > dev->mode_config.panel_orientation_property directly: > > drm_object_property_set_value(&connector->base, > dev->mode_config.panel_orientation_property > info->panel_orientation); > > -- > Gabriel Krisman Bertazi