Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp976825ybl; Fri, 24 Jan 2020 13:03:41 -0800 (PST) X-Google-Smtp-Source: APXvYqzSrJG83zIgTfiXxUAG76S30nn4q0pknxJEXo/hzMgMmyReGzB9JKQ1BW0vO6urr+enqxCY X-Received: by 2002:a9d:7:: with SMTP id 7mr4004592ota.26.1579899821109; Fri, 24 Jan 2020 13:03:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579899821; cv=none; d=google.com; s=arc-20160816; b=NxK+F0WDmFlOPsEg6fDI0MOP6okZjdQ4MEki7FiHZzZ7qrhCf75ZP2ZBGKxCIB34Se +he3vp8d0F9UNltx2iCoefw5QFLxmrlfsNHvE8k6UbaqvxAmfxfuw0W1tLbIeS1LOCDo VVV0M9HNYAJ9sdQl5mJ7mGEPY8/63toPScX4AT4OdcLX9UfaqEa3t43fmY04F20PBnFQ 2Hwrmbb3fgZM0kHhj//N9KFxB9tGO48HlVmXr5rfn6fJUcXOC4w8mwEMwSk18mn0FSgO 3UiyJQzIgBdUookeQcD+QEyrDVaWxzu4AI2/YJI7hUkUUKbnfs6/2Jh7o2ORxVam9N27 iobQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=eibpFJ/dL/po7h/5lUN6b9t7vGqoq6edRosDwybFErA=; b=kJAfgjnYE5Z0Zs27WYgRGQSM1xgsejGDhz52OEV6qw61Gb/ZKk9jiYV7gZbFmAIKlK TioJZEsLgMJmkM0PnNShlZ20E40w0ec9HBQudPztNcGH0nFBdmtjFSaLQunfOz76u+7i kt/JMsJWfFOszuH9rW5LilWO2rpr+TvoKKxrI4ah4M83FWAKjgeB96+mLcxG20i1Am8A rahxk7qc4oWz545mQSGb/JEZm+Eqwp9t0OwJymEwIpwsTEMuCjp9JL0dDXD97HN4RGnW 2hZXza3yv3MK8YA3PpmAuDDv3i4+D1n5UrqlQDZZuELRGTSVIs/MG6p+B5OcSvHBHohR ES2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=THXVTwko; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u62si366530oig.29.2020.01.24.13.03.27; Fri, 24 Jan 2020 13:03:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=THXVTwko; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388442AbgAXUXl (ORCPT + 99 others); Fri, 24 Jan 2020 15:23:41 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:32931 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387480AbgAXUXk (ORCPT ); Fri, 24 Jan 2020 15:23:40 -0500 Received: by mail-lf1-f67.google.com with SMTP id n25so2027007lfl.0 for ; Fri, 24 Jan 2020 12:23:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eibpFJ/dL/po7h/5lUN6b9t7vGqoq6edRosDwybFErA=; b=THXVTwkodkl4NV0lthJq64T8BkB+kb+ffvrbOIIER8YxEvQBCT2o/7LDw2RGVsJRL2 uXOqDAz/tYlhLLwyQPSbMtBDwZfl9wCyed52H+MSR+Bhx3i7TtCEQ5VJU92oS91V0RFM ZV5jHG9CroKc3T7vN4hYoBeavgcbdaIhntw1I43u67p8jWEleo+IoYekee0/fKj5k0q5 j7pVKy/aHd/X5lwcOmIBtCfUfiW1DfPSHtSfw5MX86ChFkP7YXD5BEfd29Jxxk9IAv24 S4NJIPiBbOExUxqQNGmNrCJhRl4iIoj27x5+BxRyuAPtp8XZPn0qsKyzOjcH1s/aC3Lz SQow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eibpFJ/dL/po7h/5lUN6b9t7vGqoq6edRosDwybFErA=; b=TWQMKuRuxu8EjnHrpDiJA7ev/9JW7LH01yZFXb2xnMDM+MqSG2N9jYPVfuARw0Inpi IcV8246CtPGu+ai57vU+5GTIfl+Vl25EK3SSdIVxHTpXitXTeoCmbAuxrufw0YN4mJYC IjaO1HsoJekpBIirRIJP+cHsbIAYs26ado6zWGYvomzBeCYKp4n0j1ohPxhKFHD19dho 0ZzWvlWd5Ym479cACUnMpKjwG852U7YcRLi8Lc1Ssy+yQjWQkROIdNmDkfY3DMWORF3Q W2fmVqIWC6yMCQI66gtP6rbYEfzMZKGunbtTKn1tJ2eNRof92jkc5y/tzMr7h2Y68849 1cwQ== X-Gm-Message-State: APjAAAUx+mtyXJGghUUgfJBbRQIPqrBPafkd6kMDz/2bsRFeEE3sprSI JXGtm+LLVXMC+0v8whldcii+z9is9TPi1qF81kpThg== X-Received: by 2002:a19:4208:: with SMTP id p8mr2257984lfa.160.1579897417530; Fri, 24 Jan 2020 12:23:37 -0800 (PST) MIME-Version: 1.0 References: <20191220200353.252399-1-rajatja@google.com> <20191220200353.252399-2-rajatja@google.com> <87v9p1gk4z.fsf@intel.com> In-Reply-To: <87v9p1gk4z.fsf@intel.com> From: Rajat Jain Date: Fri, 24 Jan 2020 12:23:00 -0800 Message-ID: Subject: Re: [PATCH v5 2/3] drm/i915: Lookup and attach ACPI device node for connectors To: Jani Nikula Cc: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , Joonas Lahtinen , Rodrigo Vivi , =?UTF-8?B?VmlsbGUgU3lyasOkbMOk?= , Chris Wilson , Imre Deak , =?UTF-8?Q?Jos=C3=A9_Roberto_de_Souza?= , Linux Kernel Mailing List , dri-devel , intel-gfx@lists.freedesktop.org, Greg Kroah-Hartman , Mat King , Daniel Thompson , Jonathan Corbet , Pavel Machek , Sean Paul , Duncan Laurie , Jesse Barnes , Thierry Reding , Rajat Jain Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jani, Thank you for the review. Please see inline. On Fri, Jan 24, 2020 at 3:37 AM Jani Nikula wrote: > > On Fri, 20 Dec 2019, Rajat Jain wrote: > > Lookup and attach ACPI nodes for intel connectors. The lookup is done > > in compliance with ACPI Spec 6.3 > > https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf > > (Ref: Pages 1119 - 1123). > > > > This can be useful for any connector specific platform properties. (This > > will be used for privacy screen in next patch). > > > > Signed-off-by: Rajat Jain > > --- > > v5: same as v4 > > v4: Same as v3 > > v3: fold the code into existing acpi_device_id_update() function > > v2: formed by splitting the original patch into ACPI lookup, and privacy > > screen property. Also move it into i915 now that I found existing code > > in i915 that can be re-used. > > > > drivers/gpu/drm/i915/display/intel_acpi.c | 24 +++++++++++++++++++ > > .../drm/i915/display/intel_display_types.h | 3 +++ > > drivers/gpu/drm/i915/display/intel_dp.c | 3 +++ > > 3 files changed, 30 insertions(+) > > > > diff --git a/drivers/gpu/drm/i915/display/intel_acpi.c b/drivers/gpu/drm/i915/display/intel_acpi.c > > index e21fb14d5e07..101a56c08996 100644 > > --- a/drivers/gpu/drm/i915/display/intel_acpi.c > > +++ b/drivers/gpu/drm/i915/display/intel_acpi.c > > @@ -222,11 +222,23 @@ static u32 acpi_display_type(struct intel_connector *connector) > > return display_type; > > } > > > > +/* > > + * Ref: ACPI Spec 6.3 > > + * https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf > > + * Pages 1119 - 1123 describe, what I believe, a standard way of > > + * identifying / addressing "display panels" in the ACPI. It provides > > + * a way for the ACPI to define devices for the display panels attached > > + * to the system. It thus provides a way for the BIOS to export any panel > > + * specific properties to the system via ACPI (like device trees). > > + */ > > void intel_acpi_device_id_update(struct drm_i915_private *dev_priv) > > { > > struct drm_device *drm_dev = &dev_priv->drm; > > struct intel_connector *connector; > > struct drm_connector_list_iter conn_iter; > > + struct device *dev = &drm_dev->pdev->dev; > > Hmm, already pushed patch 1 with the unfortunate "drm_dev" local. We use > "dev" for struct drm_device * and almost never use struct device. Sorry, I did not know. I'll send an independent fixup patch for patch 1 on top of drm-intel-next-queued (or let me know if you want to handle it). I will also change this patch to rename the variable. > > > + struct acpi_device *conn_dev; > > + u64 conn_addr; > > u8 display_index[16] = {}; > > > > /* Populate the ACPI IDs for all connectors for a given drm_device */ > > @@ -242,6 +254,18 @@ void intel_acpi_device_id_update(struct drm_i915_private *dev_priv) > > device_id |= display_index[type]++ << ACPI_DISPLAY_INDEX_SHIFT; > > > > connector->acpi_device_id = device_id; > > + > > + /* Build the _ADR to look for */ > > + conn_addr = device_id | ACPI_DEVICE_ID_SCHEME | > > + ACPI_BIOS_CAN_DETECT; > > + > > + DRM_DEV_INFO(dev, "Checking connector ACPI node at _ADR=%llX\n", > > + conn_addr); > > This is more than a little verbose. One line of INFO level dmesg for > every connector at boot and at resume. > > Please use the new drm_dbg_kms() macro for this. Will do. > > > + > > + /* Look up the connector device, under the PCI device */ > > + conn_dev = acpi_find_child_device(ACPI_COMPANION(dev), > > + conn_addr, false); > > + connector->acpi_handle = conn_dev ? conn_dev->handle : NULL; > > acpi_device_handle(conn_dev) > Will do. > > } > > drm_connector_list_iter_end(&conn_iter); > > } > > diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h > > index 1a7334dbe802..0a4a04116091 100644 > > --- a/drivers/gpu/drm/i915/display/intel_display_types.h > > +++ b/drivers/gpu/drm/i915/display/intel_display_types.h > > @@ -407,6 +407,9 @@ struct intel_connector { > > /* ACPI device id for ACPI and driver cooperation */ > > u32 acpi_device_id; > > > > + /* ACPI handle corresponding to this connector display, if found */ > > + void *acpi_handle; > > + > > The type is acpi_handle. It's none of our business to know what the > underlying type is. Will do. > > > /* Reads out the current hw, returning true if the connector is enabled > > * and active (i.e. dpms ON state). */ > > bool (*get_hw_state)(struct intel_connector *); > > diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c > > index b05b2191b919..93cece8e2516 100644 > > --- a/drivers/gpu/drm/i915/display/intel_dp.c > > +++ b/drivers/gpu/drm/i915/display/intel_dp.c > > @@ -45,6 +45,7 @@ > > #include "i915_debugfs.h" > > #include "i915_drv.h" > > #include "i915_trace.h" > > +#include "intel_acpi.h" > > #include "intel_atomic.h" > > #include "intel_audio.h" > > #include "intel_connector.h" > > @@ -6623,6 +6624,8 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect > > > > connector->state->scaling_mode = DRM_MODE_SCALE_ASPECT; > > > > + /* Lookup the ACPI node corresponding to the connector */ > > + intel_acpi_device_id_update(dev_priv); > > Auch, this is problematic. It iterates all connectors, for every DP > connector being added. In the middle of registering all connectors. > > From the POV of this patch alone, this is also unnecessary. This gets > called via intel_opregion_register() after all connectors have been > registered. > > I am aware it's not enough for your next patch, because it will need the > acpi handle right here. > > I'm wondering if we need to maintain display_index[] in struct > drm_i915_private, and update that as connectors get added instead of all > at once in the end. Sure, I can do that. > connector->acpi_device_id never changes, does it, > even though we keep updating it? This is the part I am not so sure about - I hypothesized that theory because of the current behavior in code (i.e. it is getting updated in intel_opregion_resume() path). May be it does not change, I was not sure, so I did not want to create any regression in the intel_opregion code that I did not understand. I tried on my system and as far as I could experiment, I did not see it changing. Please let me know if you would like me to change my code to: 1) Maintain drm_i915_private->display_index[] and update it as connectors are added. 2) Remove the code to update it on every resume and while registering the connector. Thanks & Best Regards, Rajat > > BR, > Jani. > > > > } > > } > > -- > Jani Nikula, Intel Open Source Graphics Center