Lukas Wunner
2020-Aug-08 22:11 UTC
[Nouveau] [PATCH 1/4] drm: retrieve EDID via ACPI _DDC method
On Mon, Jul 27, 2020 at 03:53:54PM -0500, Daniel Dadap wrote:> --- a/drivers/gpu/drm/drm_edid.c > +++ b/drivers/gpu/drm/drm_edid.c > @@ -34,6 +34,7 @@ > #include <linux/module.h> > #include <linux/slab.h> > #include <linux/vga_switcheroo.h> > +#include <linux/pci.h>Nit: Alphabetic ordering.> +static u64 *get_dod_entries(acpi_handle handle, int *count) > +{ > + acpi_status status; > + struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL }; > + union acpi_object *dod; > + int i; > + u64 *ret = NULL;Nits: Reverse christmas tree. "ret" is a poor name, I'd suggest "entries" or something like that. The spec says that _DOD is a list of 32-bit values, not 64-bit.> + status = acpi_evaluate_object(handle, "_DOD", NULL, &buf); > + > + if (ACPI_FAILURE(status)) > + return NULL;Nit: No blank line between function invocation and error check.> + dod = buf.pointer; > + > + if (dod == NULL || dod->type != ACPI_TYPE_PACKAGE) > + goto done;Same.> + ret = kmalloc_array(dod->package.count, sizeof(*ret), GFP_KERNEL); > + if (ret == NULL) > + goto done;Nit: Usually we use "if (!ret)" or "if (ret)".> + list_for_each_safe(node, next, &device->children) {No, that's not safe because the ACPI namespace may change concurrently, e.g. because a DSDT patch is applied by the user via sysfs. Use acpi_walk_namespace() with a depth of 1 instead.> + for (i = 0; i < num_dod_entries; i++) { > + if (adr == dod_entries[i]) { > + ret = do_acpi_ddc(child->handle); > + > + if (ret != NULL) > + goto done;I guess ideally we'd want to correlate the display objects with drm_connectors or at least constrain the search to Display Type "Internal/Integrated Digital Flat Panel" instead of picking the first EDID found. Otherwise we might erroneously use the DDC for an externally attached display.> +struct edid *drm_get_edid_acpi(void) > +{ > +#if defined(CONFIG_ACPI) && defined(CONFIG_PCI)No, put an empty inline stub in the header file instead of using #ifdef, see: https://www.kernel.org/doc/html/latest/process/coding-style.html#conditional-compilation Patches 2, 3 and 4 need a "drm/" prefix in the Subject, e.g. "drm/i915: ". Please cc all ACPI-related patches to linux-acpi. Thanks, Lukas
Daniel Dadap
2020-Aug-12 22:37 UTC
[Nouveau] [PATCH 1/4] drm: retrieve EDID via ACPI _DDC method
Thanks, Lukas. I've incorporated your feedback into my local tree, but will wait for additional feedback from the individual DRM driver maintainers before sending out a series v2. On 8/8/20 5:11 PM, Lukas Wunner wrote:> On Mon, Jul 27, 2020 at 03:53:54PM -0500, Daniel Dadap wrote: >> + for (i = 0; i < num_dod_entries; i++) { >> + if (adr == dod_entries[i]) { >> + ret = do_acpi_ddc(child->handle); >> + >> + if (ret != NULL) >> + goto done; > I guess ideally we'd want to correlate the display objects with > drm_connectors or at least constrain the search to Display Type > "Internal/Integrated Digital Flat Panel" instead of picking the > first EDID found. Otherwise we might erroneously use the DDC > for an externally attached display.Yes, we'd definitely need a way to do this if this functionality ever needs to be extended to systems with more than one _DDC method. Unfortunately, this will be much easier said than done, since I'm not aware of any way to reliably do map _DOD entries to connectors in a GPU driver, especially when we're talking about possibly correlating connectors on multiple GPUs which mux to the same internal display or external connector. All systems which I am aware of that implement ACPI _DDC do so for a single internal panel. I don't believe there's any reason to ever retrieve an EDID via ACPI _DDC for an external panel, but a hypothetical design with multiple internal panels, more than one of which needs to retrieve an EDID via ACPI _DDC, would certainly be problematic. On at least the system I'm working with for the various switcheroo and platform-x86 driver patches I've recently sent off, the dGPU has an ACPI _DOD table and one _DDC method corresponding to one of the _DOD entries, but the iGPU has neither a _DOD table nor a _DDC method. Either GPU can be connected to the internal panel via the dynamically switchable mux, and the internal panel's EDID is available via _DDC to allow a disconnected GPU to read the EDID. Since only the DGPU has _DOD and _DDC, and there's no obvious way to associate connectors on the iGPU with connectors on the dGPU, I've implemented the ACPI _DDC EDID retrieval with the "first available" implementation you see here. I'm open to other ideas if you have them, but didn't see a good way to search for the "right" _DDC implementation should there be more than one. As for preventing the ACPI EDID retrieval from being used for external panels, I've done this in the individual DRM drivers that call into the new drm_edid_acpi() API since it seemed that each DRM driver had its own way of distinguishing display connector types. If there's a good way to filter for internal panels in DRM core, I'd be happy to do that instead.
Alex Deucher
2020-Aug-13 03:05 UTC
[Nouveau] [PATCH 1/4] drm: retrieve EDID via ACPI _DDC method
On Wed, Aug 12, 2020 at 10:31 PM Daniel Dadap <ddadap at nvidia.com> wrote:> > Thanks, Lukas. I've incorporated your feedback into my local tree, but > will wait for additional feedback from the individual DRM driver > maintainers before sending out a series v2. > > On 8/8/20 5:11 PM, Lukas Wunner wrote: > > On Mon, Jul 27, 2020 at 03:53:54PM -0500, Daniel Dadap wrote: > >> + for (i = 0; i < num_dod_entries; i++) { > >> + if (adr == dod_entries[i]) { > >> + ret = do_acpi_ddc(child->handle); > >> + > >> + if (ret != NULL) > >> + goto done; > > I guess ideally we'd want to correlate the display objects with > > drm_connectors or at least constrain the search to Display Type > > "Internal/Integrated Digital Flat Panel" instead of picking the > > first EDID found. Otherwise we might erroneously use the DDC > > for an externally attached display. > > > Yes, we'd definitely need a way to do this if this functionality ever > needs to be extended to systems with more than one _DDC method. > Unfortunately, this will be much easier said than done, since I'm not > aware of any way to reliably do map _DOD entries to connectors in a GPU > driver, especially when we're talking about possibly correlating > connectors on multiple GPUs which mux to the same internal display or > external connector. All systems which I am aware of that implement ACPI > _DDC do so for a single internal panel. I don't believe there's any > reason to ever retrieve an EDID via ACPI _DDC for an external panel, but > a hypothetical design with multiple internal panels, more than one of > which needs to retrieve an EDID via ACPI _DDC, would certainly be > problematic. > > > On at least the system I'm working with for the various switcheroo and > platform-x86 driver patches I've recently sent off, the dGPU has an ACPI > _DOD table and one _DDC method corresponding to one of the _DOD entries, > but the iGPU has neither a _DOD table nor a _DDC method. Either GPU can > be connected to the internal panel via the dynamically switchable mux, > and the internal panel's EDID is available via _DDC to allow a > disconnected GPU to read the EDID. Since only the DGPU has _DOD and > _DDC, and there's no obvious way to associate connectors on the iGPU > with connectors on the dGPU, I've implemented the ACPI _DDC EDID > retrieval with the "first available" implementation you see here. I'm > open to other ideas if you have them, but didn't see a good way to > search for the "right" _DDC implementation should there be more than one. > > > As for preventing the ACPI EDID retrieval from being used for external > panels, I've done this in the individual DRM drivers that call into the > new drm_edid_acpi() API since it seemed that each DRM driver had its own > way of distinguishing display connector types. If there's a good way to > filter for internal panels in DRM core, I'd be happy to do that instead.I can double check with our ACPI and vbios teams, but I'm not sure that we ever used the _DDC method on any AMD platforms. Even if we did, the driver is still able to get the integrated panel's mode info via other means. In general, external connectors would always get the EDID via i2c or aux. The only use case we ever had to hardcoding an EDID was for some really old server chips so they would always think something was connected if you wanted to attach a crash cart. That EDID was stored in the vbios, not ACPI. As for enumerating which displays were muxed or not and the local mappings to acpi ids, etc., we had a whole set of ATPX methods to do that if anyone is interested: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/amd/include/amd_acpi.h Alex
Seemingly Similar Threads
- [PATCH 1/4] drm: retrieve EDID via ACPI _DDC method
- [PATCH 1/4] drm: retrieve EDID via ACPI _DDC method
- [PATCH 0/4] drm: add support for retrieving EDID via ACPI _DDC
- [PATCH 4/4] radeon: fall back to ACPI EDID retrieval
- [PATCH 4/4] radeon: fall back to ACPI EDID retrieval