Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp184342ybi; Tue, 2 Jul 2019 18:44:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjDRUGEcfeC+AdogRgeTrmBrdAFTP0pAePFog1iDqyF3XhkmSI8IEgGnzEyECLvCa6iKch X-Received: by 2002:a17:902:760a:: with SMTP id k10mr35379052pll.83.1562118295917; Tue, 02 Jul 2019 18:44:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562118295; cv=none; d=google.com; s=arc-20160816; b=zogeRBmJTD2UGCnKXSwvHmY1fCTfoSnituv9vm+L7i421U0uo0toAfMGkinxOyioij mOTk0JUJidStVgGHJdluN9L0rjI7iOJa5Cs/3uf4JXEj1NuExdrCeMuQkFt8sBPRi5/7 j/34ID9Ml75ZCksF6j3Nd6urq9LfUGcCdEIWJ9jVjDUc4bMN2rI7PV8F/wg6ntkzIJKe 9JQeINmAoNxsZfkJAi40kLnZX2CeZ+U+NWAUSv0RTAE0XomHrx2cm4iCyxnM6XixbXv9 la4DLUGhgHkJLdkqKb4Qeb2YDniQdiF+nxW19H3/CMc4EiuithTOEBcAZcMytshQQejI H7Nw== 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=4YffUmnYIYJSGCAfaNSWP1ayns5cp2QU4CpDgCgvPRE=; b=yvxogoj+mb3s3cD3ohdfvkoEvmyW4826eBjJRhs6EIPW6/U5UKqPyUdoK3jJBCX+fL x5VLLez8xxSpkekQQpkV+JV0/IYiChjeF8EV5lXd9dZhWxeSMFHFNc5RYlZhXQw3d6Oc jB3AYM5T2iQCxx3+c4ybyQZ40VC+QZjRcLwErMk1Pxr3uX/cszagx9YBEW3TvP1aBGdK 6jiMiwzUmIjFFtdmwe+AxTEVnOMkfnVmcRd9rlqUJfpvk5wuBYI2I3/mGfY+cLL+vusv pNwZApn2ObNbqm0kYKWacJ2XEymSUWjP2Qb97M3bTvxBmP70Aoz9SdK5A+9XuKJxNKdc Fy2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=efh0X4ll; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v16si280843pjb.91.2019.07.02.18.44.40; Tue, 02 Jul 2019 18:44:55 -0700 (PDT) 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=@linaro.org header.s=google header.b=efh0X4ll; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727217AbfGCBni (ORCPT + 99 others); Tue, 2 Jul 2019 21:43:38 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:40155 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727101AbfGCBni (ORCPT ); Tue, 2 Jul 2019 21:43:38 -0400 Received: by mail-wr1-f67.google.com with SMTP id p11so773121wre.7 for ; Tue, 02 Jul 2019 18:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4YffUmnYIYJSGCAfaNSWP1ayns5cp2QU4CpDgCgvPRE=; b=efh0X4llLVWHu5Dg5iUHBFsqpiD3EAhHy0GSa4Rw1Z7MEpgWK+3Wx+qU22FGbxHH7z Adqbj+oS3WaHZfvWf6Z7S+kxCLU3wfHEVZrZXPQPnhxe3AiJcZlGG/GqThd7oay8i3Lu NEYlEK6E22/86kHuucUfo79XlxYDZKnuvzCEjbzM4HoeZPb33jKOfVMj79vrfpfqnJOk fZI6hEX5hOZEWVoKzAxYMsbE4rVMB/nB3/IY0ffXy+zFTvD1MZeGhq7oJIEsguBrXKfD uX817r4HZk99anNjIxdo0b4kaqF2C3Os/U+eWl9WkoCMVZI5nNNSfkrMJiOopDM6DQeC ns6A== 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=4YffUmnYIYJSGCAfaNSWP1ayns5cp2QU4CpDgCgvPRE=; b=gHmMfhf8Sx5SX1xvMc7jNNV24O2jfo8H0IDXkTvPIQwO4VGh2zwBNVVXGwD0DRAB9o EKVWF8NKa6PkmP8rwn6bRR0GNokJ7vn09fDKx3bS5kpBJ6mNdkVy+JnUc4yNZ9v3RMEG Xut3e+iEdsAjkeeuYw+nA8rjJw6GLModHVTBOdVU3ia2X2TL9iy85YBDWOozCK4DHlr+ 3/TklL56zuqgwWZgw4vOhEDpzVn+9K1jKu9tow6GSMY3HnipNJFRXW2AibNBinBW5oUz KO6d0AtH7/ERnPY8+7hU/9p9PZFzMlPVNsmi1RmrgTwNQmPh+0oZECnMExpcb1sktTts SO6g== X-Gm-Message-State: APjAAAVDktVP9ck1IMcJgguJL5qCBmASIfxU9etUeZnka3XLxIimC8Pa r3DDx5I7X2xUIdSxRPYM5mt6mHqwWl95zJx87kptBA== X-Received: by 2002:a5d:5589:: with SMTP id i9mr15370525wrv.198.1562099197663; Tue, 02 Jul 2019 13:26:37 -0700 (PDT) MIME-Version: 1.0 References: <20190630203614.5290-1-robdclark@gmail.com> <20190630203614.5290-3-robdclark@gmail.com> In-Reply-To: <20190630203614.5290-3-robdclark@gmail.com> From: Ard Biesheuvel Date: Tue, 2 Jul 2019 22:26:22 +0200 Message-ID: Subject: Re: [PATCH 2/4] efi/libstub: detect panel-id To: Rob Clark Cc: dri-devel , linux-arm-msm , freedreno@lists.freedesktop.org, aarch64-laptops@lists.linaro.org, Rob Clark , Ingo Molnar , Will Deacon , Leif Lindholm , Alexander Graf , Steve Capper , Lukas Wunner , Julien Thierry , linux-efi , Linux Kernel Mailing List 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 On Sun, 30 Jun 2019 at 22:36, Rob Clark wrote: > > From: Rob Clark > > On snapdragon aarch64 laptops, a 'UEFIDisplayInfo' variable is provided > to communicate some information about the display. Crutially it has the > panel-id, so the appropriate panel driver can be selected. Read this > out and stash in /chosen/panel-id so that display driver can use it to > pick the appropriate panel. > > Signed-off-by: Rob Clark Hi Rob, I understand why you are doing this, but this *really* belongs elsewhere. So we are dealing with a platform that violates the UEFI spec, since it does not bother to implement variable services at runtime (because MS let the vendor get away with this). First of all, to pass data between the EFI stub and the OS proper, we should use a configuration table rather than a DT property, since the former is ACPI/DT agnostic. Also, I'd like the consumer of the data to actually interpret it, i.e., just dump the whole opaque thing into a config table in the stub, and do the parsing in the OS proper. However, I am not thrilled at adding code to the stub that unconditionally looks for some variable with some magic name on all ARM/arm64 EFI systems, so this will need to live under a Kconfig option that depends on ARM64 (and does not default to y) > --- > drivers/firmware/efi/libstub/arm-stub.c | 49 +++++++++++++++++++++++++ > drivers/firmware/efi/libstub/efistub.h | 2 + > drivers/firmware/efi/libstub/fdt.c | 9 +++++ > 3 files changed, 60 insertions(+) > > diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c > index 04e6ecd72cd9..999813252e0d 100644 > --- a/drivers/firmware/efi/libstub/arm-stub.c > +++ b/drivers/firmware/efi/libstub/arm-stub.c > @@ -69,6 +69,53 @@ static struct screen_info *setup_graphics(efi_system_table_t *sys_table_arg) > return si; > } > > +/* > + * We (at least currently) don't care about most of the fields, just > + * panel_id: > + */ > +struct mdp_disp_info { > + u32 version_info; > + u32 pad0[9]; > + u32 panel_id; > + u32 pad1[17]; > +}; > + > +#define MDP_DISP_INFO_VERSION_MAGIC 0xaa > + > +static void get_panel_id(efi_system_table_t *sys_table_arg, > + unsigned long fdt_addr) > +{ > + efi_guid_t gop_proto = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; > + efi_status_t status; > + struct mdp_disp_info *disp_info; > + unsigned long size = 0; > + > + status = efi_call_runtime(get_variable, L"UEFIDisplayInfo", > + &gop_proto, NULL, &size, NULL); > + if (status == EFI_NOT_FOUND) > + return; > + > + status = efi_call_early(allocate_pool, EFI_LOADER_DATA, size, > + (void **)&disp_info); > + if (status != EFI_SUCCESS) > + return; > + > + status = efi_call_runtime(get_variable, L"UEFIDisplayInfo", > + &gop_proto, NULL, &size, disp_info); > + if (status != EFI_SUCCESS) > + goto cleanup; > + > + if ((disp_info->version_info >> 16) != MDP_DISP_INFO_VERSION_MAGIC) > + goto cleanup; > + > + efi_printk(sys_table_arg, "found a panel-id!\n"); > + > + set_chosen_panel_id(fdt_addr, disp_info->panel_id); > + > +cleanup: > + efi_call_early(free_pool, disp_info); > +} > + > void install_memreserve_table(efi_system_table_t *sys_table_arg) > { > struct linux_efi_memreserve *rsv; > @@ -229,6 +276,8 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table, > if (!fdt_addr) > pr_efi(sys_table, "Generating empty DTB\n"); > > + get_panel_id(sys_table, fdt_addr); > + > status = handle_cmdline_files(sys_table, image, cmdline_ptr, "initrd=", > efi_get_max_initrd_addr(dram_base, > *image_addr), > diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h > index 1b1dfcaa6fb9..8832cb9a7a40 100644 > --- a/drivers/firmware/efi/libstub/efistub.h > +++ b/drivers/firmware/efi/libstub/efistub.h > @@ -39,6 +39,8 @@ void efi_char16_printk(efi_system_table_t *, efi_char16_t *); > > unsigned long get_dram_base(efi_system_table_t *sys_table_arg); > > +void set_chosen_panel_id(unsigned long fdt_addr, unsigned panel_id); > + > efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, > void *handle, > unsigned long *new_fdt_addr, > diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c > index 5440ba17a1c5..cb6ea160a40a 100644 > --- a/drivers/firmware/efi/libstub/fdt.c > +++ b/drivers/firmware/efi/libstub/fdt.c > @@ -200,6 +200,15 @@ static efi_status_t update_fdt_memmap(void *fdt, struct efi_boot_memmap *map) > return EFI_SUCCESS; > } > > +void set_chosen_panel_id(unsigned long fdt_addr, unsigned panel_id) > +{ > + void *fdt = (void *)fdt_addr; > + int node = fdt_subnode_offset(fdt, 0, "chosen"); > + u32 fdt_val32 = cpu_to_fdt32(panel_id); > + > + fdt_setprop_var(fdt, node, "panel-id", fdt_val32); > +} > + > #ifndef EFI_FDT_ALIGN > # define EFI_FDT_ALIGN EFI_PAGE_SIZE > #endif > -- > 2.20.1 >