From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Intel graphics driver community testing & development
<intel-gfx@lists.freedesktop.org>
Cc: x86@kernel.org, Ingo Molnar <mingo@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Mika Kuoppala <mika.kuoppala@intel.com>
Subject: Re: [PATCH v2 2/2] drm/i915: Function per early graphics quirk
Date: Wed, 27 Apr 2016 13:52:18 +0300 [thread overview]
Message-ID: <1461754338.3986.31.camel@linux.intel.com> (raw)
In-Reply-To: <1461328105-13212-2-git-send-email-joonas.lahtinen@linux.intel.com>
Hi,
Adding x86 maintainers as CC as they were missing from the original
patch due to some confusion in best practices.
This patch was merged to the drm-intel.git after reviewing and testing.
Regards, Joonas
On pe, 2016-04-22 at 15:28 +0300, Joonas Lahtinen wrote:
> Move graphics stolen memory related early quirk into a function to
> allow easy adding of other graphics quirks to fix memory maps on
> machines running old BIOS versions.
>
> While at it;
> - _funcs -> _ops to follow de facto naming
> - make the iteration code tad more readable
> - remove unused variables
>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> ---
> arch/x86/kernel/early-quirks.c | 187 +++++++++++++++++++++--------------------
> 1 file changed, 98 insertions(+), 89 deletions(-)
>
> diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
> index 70e0ab6..d2f75b4 100644
> --- a/arch/x86/kernel/early-quirks.c
> +++ b/arch/x86/kernel/early-quirks.c
> @@ -423,11 +423,6 @@ static size_t __init chv_stolen_size(int num, int slot, int func)
> return (size_t)(gms - 0x17 + 9) * MB(4);
> }
>
> -struct intel_stolen_funcs {
> - size_t (*size)(int num, int slot, int func);
> - phys_addr_t (*base)(int num, int slot, int func, size_t size);
> -};
> -
> static size_t __init gen9_stolen_size(int num, int slot, int func)
> {
> u16 gmch_ctrl;
> @@ -444,115 +439,129 @@ static size_t __init gen9_stolen_size(int num, int slot, int func)
> return (size_t)(gms - 0xf0 + 1) * MB(4);
> }
>
> -typedef size_t (*stolen_size_fn)(int num, int slot, int func);
> +struct intel_early_ops {
> + size_t (*stolen_size)(int num, int slot, int func);
> + phys_addr_t (*stolen_base)(int num, int slot, int func, size_t size);
> +};
>
> -static const struct intel_stolen_funcs i830_stolen_funcs __initconst = {
> - .base = i830_stolen_base,
> - .size = i830_stolen_size,
> +static const struct intel_early_ops i830_early_ops __initconst = {
> + .stolen_base = i830_stolen_base,
> + .stolen_size = i830_stolen_size,
> };
>
> -static const struct intel_stolen_funcs i845_stolen_funcs __initconst = {
> - .base = i845_stolen_base,
> - .size = i830_stolen_size,
> +static const struct intel_early_ops i845_early_ops __initconst = {
> + .stolen_base = i845_stolen_base,
> + .stolen_size = i830_stolen_size,
> };
>
> -static const struct intel_stolen_funcs i85x_stolen_funcs __initconst = {
> - .base = i85x_stolen_base,
> - .size = gen3_stolen_size,
> +static const struct intel_early_ops i85x_early_ops __initconst = {
> + .stolen_base = i85x_stolen_base,
> + .stolen_size = gen3_stolen_size,
> };
>
> -static const struct intel_stolen_funcs i865_stolen_funcs __initconst = {
> - .base = i865_stolen_base,
> - .size = gen3_stolen_size,
> +static const struct intel_early_ops i865_early_ops __initconst = {
> + .stolen_base = i865_stolen_base,
> + .stolen_size = gen3_stolen_size,
> };
>
> -static const struct intel_stolen_funcs gen3_stolen_funcs __initconst = {
> - .base = gen3_stolen_base,
> - .size = gen3_stolen_size,
> +static const struct intel_early_ops gen3_early_ops __initconst = {
> + .stolen_base = gen3_stolen_base,
> + .stolen_size = gen3_stolen_size,
> };
>
> -static const struct intel_stolen_funcs gen6_stolen_funcs __initconst = {
> - .base = gen3_stolen_base,
> - .size = gen6_stolen_size,
> +static const struct intel_early_ops gen6_early_ops __initconst = {
> + .stolen_base = gen3_stolen_base,
> + .stolen_size = gen6_stolen_size,
> };
>
> -static const struct intel_stolen_funcs gen8_stolen_funcs __initconst = {
> - .base = gen3_stolen_base,
> - .size = gen8_stolen_size,
> +static const struct intel_early_ops gen8_early_ops __initconst = {
> + .stolen_base = gen3_stolen_base,
> + .stolen_size = gen8_stolen_size,
> };
>
> -static const struct intel_stolen_funcs gen9_stolen_funcs __initconst = {
> - .base = gen3_stolen_base,
> - .size = gen9_stolen_size,
> +static const struct intel_early_ops gen9_early_ops __initconst = {
> + .stolen_base = gen3_stolen_base,
> + .stolen_size = gen9_stolen_size,
> };
>
> -static const struct intel_stolen_funcs chv_stolen_funcs __initconst = {
> - .base = gen3_stolen_base,
> - .size = chv_stolen_size,
> +static const struct intel_early_ops chv_early_ops __initconst = {
> + .stolen_base = gen3_stolen_base,
> + .stolen_size = chv_stolen_size,
> };
>
> -static const struct pci_device_id intel_stolen_ids[] __initconst = {
> - INTEL_I830_IDS(&i830_stolen_funcs),
> - INTEL_I845G_IDS(&i845_stolen_funcs),
> - INTEL_I85X_IDS(&i85x_stolen_funcs),
> - INTEL_I865G_IDS(&i865_stolen_funcs),
> - INTEL_I915G_IDS(&gen3_stolen_funcs),
> - INTEL_I915GM_IDS(&gen3_stolen_funcs),
> - INTEL_I945G_IDS(&gen3_stolen_funcs),
> - INTEL_I945GM_IDS(&gen3_stolen_funcs),
> - INTEL_VLV_M_IDS(&gen6_stolen_funcs),
> - INTEL_VLV_D_IDS(&gen6_stolen_funcs),
> - INTEL_PINEVIEW_IDS(&gen3_stolen_funcs),
> - INTEL_I965G_IDS(&gen3_stolen_funcs),
> - INTEL_G33_IDS(&gen3_stolen_funcs),
> - INTEL_I965GM_IDS(&gen3_stolen_funcs),
> - INTEL_GM45_IDS(&gen3_stolen_funcs),
> - INTEL_G45_IDS(&gen3_stolen_funcs),
> - INTEL_IRONLAKE_D_IDS(&gen3_stolen_funcs),
> - INTEL_IRONLAKE_M_IDS(&gen3_stolen_funcs),
> - INTEL_SNB_D_IDS(&gen6_stolen_funcs),
> - INTEL_SNB_M_IDS(&gen6_stolen_funcs),
> - INTEL_IVB_M_IDS(&gen6_stolen_funcs),
> - INTEL_IVB_D_IDS(&gen6_stolen_funcs),
> - INTEL_HSW_D_IDS(&gen6_stolen_funcs),
> - INTEL_HSW_M_IDS(&gen6_stolen_funcs),
> - INTEL_BDW_M_IDS(&gen8_stolen_funcs),
> - INTEL_BDW_D_IDS(&gen8_stolen_funcs),
> - INTEL_CHV_IDS(&chv_stolen_funcs),
> - INTEL_SKL_IDS(&gen9_stolen_funcs),
> - INTEL_BXT_IDS(&gen9_stolen_funcs),
> - INTEL_KBL_IDS(&gen9_stolen_funcs),
> +static const struct pci_device_id intel_early_ids[] __initconst = {
> + INTEL_I830_IDS(&i830_early_ops),
> + INTEL_I845G_IDS(&i845_early_ops),
> + INTEL_I85X_IDS(&i85x_early_ops),
> + INTEL_I865G_IDS(&i865_early_ops),
> + INTEL_I915G_IDS(&gen3_early_ops),
> + INTEL_I915GM_IDS(&gen3_early_ops),
> + INTEL_I945G_IDS(&gen3_early_ops),
> + INTEL_I945GM_IDS(&gen3_early_ops),
> + INTEL_VLV_M_IDS(&gen6_early_ops),
> + INTEL_VLV_D_IDS(&gen6_early_ops),
> + INTEL_PINEVIEW_IDS(&gen3_early_ops),
> + INTEL_I965G_IDS(&gen3_early_ops),
> + INTEL_G33_IDS(&gen3_early_ops),
> + INTEL_I965GM_IDS(&gen3_early_ops),
> + INTEL_GM45_IDS(&gen3_early_ops),
> + INTEL_G45_IDS(&gen3_early_ops),
> + INTEL_IRONLAKE_D_IDS(&gen3_early_ops),
> + INTEL_IRONLAKE_M_IDS(&gen3_early_ops),
> + INTEL_SNB_D_IDS(&gen6_early_ops),
> + INTEL_SNB_M_IDS(&gen6_early_ops),
> + INTEL_IVB_M_IDS(&gen6_early_ops),
> + INTEL_IVB_D_IDS(&gen6_early_ops),
> + INTEL_HSW_D_IDS(&gen6_early_ops),
> + INTEL_HSW_M_IDS(&gen6_early_ops),
> + INTEL_BDW_M_IDS(&gen8_early_ops),
> + INTEL_BDW_D_IDS(&gen8_early_ops),
> + INTEL_CHV_IDS(&chv_early_ops),
> + INTEL_SKL_IDS(&gen9_early_ops),
> + INTEL_BXT_IDS(&gen9_early_ops),
> + INTEL_KBL_IDS(&gen9_early_ops),
> };
>
> -static void __init intel_graphics_stolen(int num, int slot, int func)
> +static void __init
> +intel_graphics_stolen(int num, int slot, int func,
> + const struct intel_early_ops *early_ops)
> {
> + phys_addr_t base;
> size_t size;
> +
> + size = early_ops->stolen_size(num, slot, func);
> + base = early_ops->stolen_base(num, slot, func, size);
> +
> + if (!size || !base)
> + return;
> +
> + printk(KERN_INFO "Reserving Intel graphics stolen memory at "
> + "0x%llx-0x%llx\n", base, base + size - 1);
> +
> + /* Mark this space as reserved */
> + e820_add_region(base, size, E820_RESERVED);
> + sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
> +}
> +
> +static void __init intel_graphics_quirks(int num, int slot, int func)
> +{
> + const struct intel_early_ops *early_ops;
> + u16 device;
> int i;
> - phys_addr_t start;
> - u16 device, subvendor, subdevice;
>
> device = read_pci_config_16(num, slot, func, PCI_DEVICE_ID);
> - subvendor = read_pci_config_16(num, slot, func,
> - PCI_SUBSYSTEM_VENDOR_ID);
> - subdevice = read_pci_config_16(num, slot, func, PCI_SUBSYSTEM_ID);
> -
> - for (i = 0; i < ARRAY_SIZE(intel_stolen_ids); i++) {
> - if (intel_stolen_ids[i].device == device) {
> - const struct intel_stolen_funcs *stolen_funcs =
> - (const struct intel_stolen_funcs *)intel_stolen_ids[i].driver_data;
> - size = stolen_funcs->size(num, slot, func);
> - start = stolen_funcs->base(num, slot, func, size);
> - if (size && start) {
> - printk(KERN_INFO "Reserving Intel graphics stolen memory at 0x%llx-0x%llx\n",
> - start, start + size - 1);
> - /* Mark this space as reserved */
> - e820_add_region(start, size, E820_RESERVED);
> - sanitize_e820_map(e820.map,
> - ARRAY_SIZE(e820.map),
> - &e820.nr_map);
> - }
> - return;
> - }
> +
> + for (i = 0; i < ARRAY_SIZE(intel_early_ids); i++) {
> + kernel_ulong_t driver_data = intel_early_ids[i].driver_data;
> +
> + if (intel_early_ids[i].device != device)
> + continue;
> +
> + early_ops = (typeof(early_ops))driver_data;
> +
> + intel_graphics_stolen(num, slot, func, early_ops);
> +
> + return;
> }
> }
>
> @@ -601,7 +610,7 @@ static struct chipset early_qrk[] __initdata = {
> { PCI_VENDOR_ID_INTEL, 0x3406, PCI_CLASS_BRIDGE_HOST,
> PCI_BASE_CLASS_BRIDGE, 0, intel_remapping_check },
> { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA, PCI_ANY_ID,
> - QFLAG_APPLY_ONCE, intel_graphics_stolen },
> + QFLAG_APPLY_ONCE, intel_graphics_quirks },
> /*
> * HPET on the current version of the Baytrail platform has accuracy
> * problems: it will halt in deep idle state - so we disable it.
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-04-27 10:50 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-22 11:25 Cleanup of early quirks Joonas Lahtinen
2016-04-22 11:25 ` [PATCH 1/2] drm/i915: Canonicalize stolen memory calculations Joonas Lahtinen
2016-04-22 11:48 ` Chris Wilson
2016-04-27 10:50 ` Joonas Lahtinen
2016-04-22 11:25 ` [PATCH 2/2] drm/i915: Function per early graphics quirk Joonas Lahtinen
2016-04-22 11:55 ` Chris Wilson
2016-04-22 12:07 ` Joonas Lahtinen
2016-04-22 12:17 ` Chris Wilson
2016-04-22 12:28 ` [PATCH v2 1/2] drm/i915: Canonicalize stolen memory calculations Joonas Lahtinen
2016-04-22 12:28 ` [PATCH v2 2/2] drm/i915: Function per early graphics quirk Joonas Lahtinen
2016-04-27 10:52 ` Joonas Lahtinen [this message]
2016-04-22 13:32 ` ✗ Fi.CI.BAT: warning for series starting with [1/2] drm/i915: Canonicalize stolen memory calculations (rev2) Patchwork
2016-04-24 7:53 ` Patchwork
2016-04-25 8:54 ` Joonas Lahtinen
2016-04-25 9:23 ` Tvrtko Ursulin
2016-04-25 10:35 ` Joonas Lahtinen
2016-04-25 10:49 ` Mika Kuoppala
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1461754338.3986.31.camel@linux.intel.com \
--to=joonas.lahtinen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=mika.kuoppala@intel.com \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.