Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp607291pxb; Tue, 15 Feb 2022 23:36:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5KpsXT/WAC6wrG1Vw4gRbSbZe8DWn7iKDrJre//NXl5E38JbjO9WHTG89QF6QFd88zHp3 X-Received: by 2002:a62:7e06:0:b0:4e0:f0f8:9b86 with SMTP id z6-20020a627e06000000b004e0f0f89b86mr1509904pfc.26.1644996974346; Tue, 15 Feb 2022 23:36:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644996974; cv=none; d=google.com; s=arc-20160816; b=Z5sI2tRhfP4XTsPKoCNpe3LEbbHcFFR8rGmI0GT4gctO8lJIvU0N5+uCvzuaQ1f3NH JwgzcCAtp50F1hK7f4MlkPZuVnqlTWsxZcVsKxujohwejp36lxw1bCX0hHRq/0ahgk4W FlWjLjgGU1WBMvPRENQQQPnPlrYK5Lp45xZrAvKIHZTSvRR9cwKFW5I2KERVlQoFauoT 5VcvkGWfQPonlrDzTx9dzA88re5poyhN/MZEdN4ktG76BLcZytw1JvZ8pOc8rG9d1VR4 qPqmW9dnJYmfFsRZGLPVYFy2OOU0gZQzvzlPXIQbQA8einxo9GgMYqYY+VQW8dO5frKQ hEKA== 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=PaZVevCVWnJLVjvrHlW/dnI5NADyeCbLBAp7MlyZJEs=; b=ON0ZP7Rbexn1RisreK92936FxNF77LpzFNw9Pe8KgA9FqM0Ch1mXNXVPC38QPw859b chC//m/J5OOOmMyJJMn5qNp0lG6+kNChuEXbV9JvRSxv5Nwu7lRwnPkWPLi8kLm64kXI 7ly+fBiOzXFSL9V3o3I/+bRGJmaPHVsIUcUHAJ7Zk/bhQeeI9tXiH4wwuQr6kWu4X0+I yACco2jumIM6ZZQZx1s0KVnAVGe/sdM0EBZnMD/ZIQdgNmvoSdhJHAAJLH7fs+dTC3iL EL7q8wWiBnmtczaWW6FQuPvCi4Au1KDYlJuV71iNA/UDuIcpAhUkgE+1/uiBdTqoEZXH MXYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TDZSGSZD; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id qe11si5249856pjb.170.2022.02.15.23.36.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 23:36:14 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TDZSGSZD; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5B3A82B0B03; Tue, 15 Feb 2022 23:01:56 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230129AbiBONFw (ORCPT + 99 others); Tue, 15 Feb 2022 08:05:52 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238067AbiBONFq (ORCPT ); Tue, 15 Feb 2022 08:05:46 -0500 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE67AA0BC9 for ; Tue, 15 Feb 2022 05:05:34 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id i62so23714470ioa.1 for ; Tue, 15 Feb 2022 05:05:34 -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=PaZVevCVWnJLVjvrHlW/dnI5NADyeCbLBAp7MlyZJEs=; b=TDZSGSZDOR6tESGKMffWCPAQg0pmlp4Qd/GfZoTuMP4o9VEdBnDeiiE6GGqWBPQsgN qd+VnUyyPezL+pBRqSdBPDVYO2zc+Rl12fctv8JMQmtfQHTIFV1VisAraOidRtzcv7az h+RdY2hixZ3rguGFXADmEsNVOk97TpExpsPCM= 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=PaZVevCVWnJLVjvrHlW/dnI5NADyeCbLBAp7MlyZJEs=; b=ryJc2hh9aBhvDYSrXysOrwYIKuoWhi3cuhkvefq0HPGA9WwQQFbIEiVTaC9l9xLYbW /a95w1/SyA+sMZl+qiTGFvYABNteLSpaq++KIeiVgYjIAjpfknJsYcTlgoyOePwBr9X3 4gb9UoyPas8EwuZuWGbU3oRsWX8eK5cmFZyaF3hfyTepjgvu/JnaDsp/gYcdT/SqFlcN fkJpH3lgHDyQRfdBsa/rnVvccqg4V19n5dQnW65WyeeXdjGMIe5eyiXAYobQ2TzyOi+y 8gEjoZOoZrVIBM/NXYDCWjlM2mUMAx2i5dMv5Bh7Pf46m0JYtOg1T4q4iQPz92sxLbOT mcVQ== X-Gm-Message-State: AOAM532mWCHhBkq8drv4DjQyEz3mXExxSHm1IEJVUxk+CYtJV59LxBYY TtyUCKjG+N4nbVeQ8yWInQ64BFlLYqHaGsLAq/OzNg== X-Received: by 2002:a05:6638:3785:: with SMTP id w5mr2736567jal.210.1644930334003; Tue, 15 Feb 2022 05:05:34 -0800 (PST) MIME-Version: 1.0 References: <20220208084234.1684930-1-hsinyi@chromium.org> In-Reply-To: From: Hsin-Yi Wang Date: Tue, 15 Feb 2022 21:05:08 +0800 Message-ID: Subject: Re: [Intel-gfx] [PATCH v8 1/3] gpu: drm: separate panel orientation property creating and value setting To: Emil Velikov Cc: ML dri-devel , David Airlie , Daniel Vetter , amd-gfx mailing list , Intel Graphics Development , Chun-Kuang Hu , devicetree , Simon Ser , "Linux-Kernel@Vger. Kernel. Org" , Maxime Ripard , Alex Deucher , Rob Herring , linux-mediatek@lists.infradead.org, Thomas Zimmermann , Harry Wentland , Matthias Brugger , LAKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 8:04 PM Emil Velikov wrote: > > Greetings everyone, > > Padron for joining in so late o/ > > On Tue, 8 Feb 2022 at 08:42, Hsin-Yi Wang wrote: > > > > 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. > > > > Add a function to create panel orientation property and set default value > > to UNKNOWN, so drivers can call this function to init the property earlier > > , and let the panel set the real value later. > > > > The warning illustrates a genuine race condition, where userspace will > read the old/invalid property value/state. So this patch masks away > the WARNING without addressing the actual issue. > Instead can we fix the respective drivers, so that no properties are > created after drm_dev_register()? > 1. How about the proposal in previous version: v7 https://patchwork.kernel.org/project/linux-mediatek/patch/20220208073714.1540390-1-hsinyi@chromium.org/ we separate property creation (drm_connector_init_panel_orientation_property) and value setting (drm_connector_set_panel_orientation). This is also similar to some of other optional properties are created, eg. vrr_capable. And drm drivers have to make sure that if they want to use this property, they have to create it before drm_dev_register(). For example, in the 2nd patch, mtk_drm sets the property before calling drm_dev_register(). 2. I'm not sure how to handle the case that if user space tries to read the property before the proper value is set. Currently drm creates this property and the panels[1] will set the correct value parsed from DT. If userspace calls before the panel sets the correct value, it will get unknown (similar to the illustration you mentioned below). Do you think that the drm should be responsible for parsing the value if the panel provides it? In this way it's guaranteed that the value is set when the property is created. [1] https://elixir.bootlin.com/linux/latest/A/ident/drm_connector_set_panel_orientation > Longer version: > As we look into drm_dev_register() it's in charge of creating the > dev/sysfs nodes (et al). Note that connectors cannot disappear at > runtime. > For panel orientation, we are creating an immutable connector > properly, meaning that as soon as drm_dev_register() is called we must > ensure that the property is available (if applicable) and set to the > correct value. > > For illustration, consider the following scenario: > - DRM modules are loaded late - are not built-in and not part of > initrd (or there's no initrd) > - kernel boots > - plymouth/similar user-space component kicks in before the > driver/module is loaded > - module gets loaded, drm_dev_register() kicks in populating /dev/dri/card0 > - plymouth opens the dev node and reads DRM_MODE_PANEL_ORIENTATION_UNKNOWN > - module updates the orientation property > > Thanks > Emil