sysfb_simplefb: adjust BOOTFB resource size to an actual PCI BAR From: Pavel Roskin This fixes a warning with stack trace when nouveau allocates iomem area on Lenovo ThinkPad W530: resource map sanity check conflict: 0xf0000000 0xf1ffffff 0xf1000000 0xf112bfff BOOTFB --- arch/x86/kernel/sysfb_simplefb.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/arch/x86/kernel/sysfb_simplefb.c b/arch/x86/kernel/sysfb_simplefb.c index 22513e9..6c2820b 100644 --- a/arch/x86/kernel/sysfb_simplefb.c +++ b/arch/x86/kernel/sysfb_simplefb.c @@ -21,12 +21,47 @@ #include #include #include +#include #include #include static const char simplefb_resname[] = "BOOTFB"; static const struct simplefb_format formats[] = SIMPLEFB_FORMATS; +#ifdef CONFIG_PCI +/* Adjust resource to a PCI BAR of a VGA device if possible */ +static __init void adjust_pci_res(struct resource *res) +{ + struct pci_dev *dev = NULL; + int i; + + for_each_pci_dev(dev) { + if ((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA) + continue; + for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { + resource_size_t start, end; + + if (!(pci_resource_flags(dev, i) & IORESOURCE_MEM)) + continue; + start = pci_resource_start(dev, i); + if (start == 0) + continue; + if (res->start < start) + continue; + end = pci_resource_end(dev, i); + if (res->end > end) + continue; + /* Found a matching resource */ + res->start = start; + res->end = end; + break; + } + } +} +#else +#define adjust_pci_res(res) +#endif + /* try parsing x86 screen_info into a simple-framebuffer mode struct */ __init bool parse_mode(const struct screen_info *si, struct simplefb_platform_data *mode) @@ -86,6 +121,8 @@ __init int create_simplefb(const struct screen_info *si, if (res.end <= res.start) return -EINVAL; + adjust_pci_res(&res); + pd = platform_device_register_resndata(NULL, "simple-framebuffer", 0, &res, 1, mode, sizeof(*mode)); if (IS_ERR(pd))