warning: "EDID_LENGTH" redefined (was Re: [PATCH v4] Fix loading of module radeonfb on PowerMac)

2018-02-04 Thread Mathieu Malaterre
Hi Dave,

Since I am not very familiar with the drm vs fbdev architecture, could
you please suggest a patch for the following [*].

Reference:
f453ba0460742 (Dave Airlie 2008-11-07 14:05:41 -0800  32)
#define EDID_LENGTH 128


Thanks

[*]
On Sat, Feb 3, 2018 at 3:39 AM, kbuild test robot  wrote:
> Hi Mathieu,
>
> Thank you for the patch! Perhaps something to improve:
>
> [auto build test WARNING on linus/master]
> [also build test WARNING on v4.15 next-20180202]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
>
> url:
> https://github.com/0day-ci/linux/commits/Mathieu-Malaterre/Fix-loading-of-module-radeonfb-on-PowerMac/20180203-085907
> config: x86_64-randconfig-x009-201804 (attached as .config)
> compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=x86_64
>
> All warnings (new ones prefixed by >>):
>
>In file included from drivers/video/fbdev/aty/radeon_base.c:91:0:
>>> drivers/video/fbdev/aty/../edid.h:21:0: warning: "EDID_LENGTH" redefined
> #define EDID_LENGTH0x80
>
>In file included from include/drm/drm_crtc.h:44:0,
> from include/drm/drm_fb_helper.h:35,
> from drivers/video/fbdev/aty/radeon_base.c:73:
>include/drm/drm_edid.h:32:0: note: this is the location of the previous 
> definition
> #define EDID_LENGTH 128
>
>Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:fls64
>Cyclomatic Complexity 1 include/linux/log2.h:__ilog2_u64
>Cyclomatic Complexity 1 include/asm-generic/getorder.h:__get_order
>Cyclomatic Complexity 1 include/linux/string.h:strnlen
>Cyclomatic Complexity 4 include/linux/string.h:strlen
>Cyclomatic Complexity 6 include/linux/string.h:strlcpy
>Cyclomatic Complexity 4 include/linux/string.h:memcpy
>Cyclomatic Complexity 1 
> arch/x86/include/asm/paravirt.h:arch_local_irq_disable
>Cyclomatic Complexity 1 
> arch/x86/include/asm/paravirt.h:arch_local_irq_enable
>Cyclomatic Complexity 1 include/linux/spinlock.h:spinlock_check
>Cyclomatic Complexity 1 include/linux/spinlock.h:spin_unlock_irqrestore
>Cyclomatic Complexity 1 include/linux/jiffies.h:_msecs_to_jiffies
>Cyclomatic Complexity 3 include/linux/jiffies.h:msecs_to_jiffies
>Cyclomatic Complexity 1 arch/x86/include/asm/io.h:readb
>Cyclomatic Complexity 1 arch/x86/include/asm/io.h:readw
>Cyclomatic Complexity 1 arch/x86/include/asm/io.h:readl
>Cyclomatic Complexity 1 arch/x86/include/asm/io.h:writeb
>Cyclomatic Complexity 1 arch/x86/include/asm/io.h:writel
>Cyclomatic Complexity 1 arch/x86/include/asm/io.h:ioremap
>Cyclomatic Complexity 1 include/linux/kobject.h:kobject_name
>Cyclomatic Complexity 2 include/linux/device.h:dev_name
>Cyclomatic Complexity 1 include/linux/device.h:dev_get_drvdata
>Cyclomatic Complexity 1 include/linux/device.h:dev_set_drvdata
>Cyclomatic Complexity 1 include/linux/io.h:arch_phys_wc_add
>Cyclomatic Complexity 1 include/linux/io.h:arch_phys_wc_del
>Cyclomatic Complexity 68 include/linux/slab.h:kmalloc_large
>Cyclomatic Complexity 3 include/linux/slab.h:kmalloc
>Cyclomatic Complexity 1 include/linux/slab.h:kzalloc
>Cyclomatic Complexity 1 include/linux/pci.h:pci_get_drvdata
>Cyclomatic Complexity 1 include/linux/pci.h:pci_set_drvdata
>Cyclomatic Complexity 1 include/linux/pci.h:pci_name
>Cyclomatic Complexity 2 include/linux/fb.h:alloc_apertures
>Cyclomatic Complexity 2 
> drivers/video/fbdev/aty/radeonfb.h:radeon_pll_errata_after_index
>Cyclomatic Complexity 2 
> drivers/video/fbdev/aty/radeonfb.h:radeon_pll_errata_after_data
>Cyclomatic Complexity 1 drivers/video/fbdev/aty/radeonfb.h:round_div
>Cyclomatic Complexity 3 drivers/video/fbdev/aty/radeonfb.h:var_to_depth
>Cyclomatic Complexity 5 
> drivers/video/fbdev/aty/radeonfb.h:radeon_get_dstbpp
>Cyclomatic Complexity 1 drivers/video/fbdev/aty/radeonfb.h:radeonfb_bl_init
>Cyclomatic Complexity 1 drivers/video/fbdev/aty/radeonfb.h:radeonfb_bl_exit
>Cyclomatic Complexity 1 
> include/drm/drm_fb_helper.h:drm_fb_helper_remove_conflicting_framebuffers
>Cyclomatic Complexity 21 
> drivers/video/fbdev/aty/radeon_base.c:radeon_calc_pll_regs
>Cyclomatic Complexity 1 drivers/video/fbdev/aty/radeon_base.c:radeonfb_exit
>Cyclomatic Complexity 6 
> drivers/video/fbdev/aty/radeon_base.c:radeon_find_mem_vbios
>Cyclomatic Complexity 4 
> drivers/video/fbdev/aty/radeon_base.c:radeon_kick_out_firmware_fb
>Cyclomatic Complexity 5 
> drivers/video/fbdev/aty/radeon_base.c:radeonfb_pci_unregister
>Cyclomatic Complexity 1 
> drivers/video/fbdev/aty/radeon_base.c:radeon_show_one_edid
>Cyclomatic Complexity 3 
> drivers/video/fbdev/aty/radeon_base.c:radeon_show_edid2
>Cyclomatic Complexity 3 
> drivers/video/fbdev/aty/radeon_base.c:radeon_show_edid1
>Cyclomatic Complexit

Re: [PATCH v4] Fix loading of module radeonfb on PowerMac

2018-02-02 Thread kbuild test robot
Hi Mathieu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.15 next-20180202]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Mathieu-Malaterre/Fix-loading-of-module-radeonfb-on-PowerMac/20180203-085907
config: x86_64-randconfig-x009-201804 (attached as .config)
compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from drivers/video/fbdev/aty/radeon_base.c:91:0:
>> drivers/video/fbdev/aty/../edid.h:21:0: warning: "EDID_LENGTH" redefined
#define EDID_LENGTH0x80

   In file included from include/drm/drm_crtc.h:44:0,
from include/drm/drm_fb_helper.h:35,
from drivers/video/fbdev/aty/radeon_base.c:73:
   include/drm/drm_edid.h:32:0: note: this is the location of the previous 
definition
#define EDID_LENGTH 128

   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:fls64
   Cyclomatic Complexity 1 include/linux/log2.h:__ilog2_u64
   Cyclomatic Complexity 1 include/asm-generic/getorder.h:__get_order
   Cyclomatic Complexity 1 include/linux/string.h:strnlen
   Cyclomatic Complexity 4 include/linux/string.h:strlen
   Cyclomatic Complexity 6 include/linux/string.h:strlcpy
   Cyclomatic Complexity 4 include/linux/string.h:memcpy
   Cyclomatic Complexity 1 
arch/x86/include/asm/paravirt.h:arch_local_irq_disable
   Cyclomatic Complexity 1 arch/x86/include/asm/paravirt.h:arch_local_irq_enable
   Cyclomatic Complexity 1 include/linux/spinlock.h:spinlock_check
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_unlock_irqrestore
   Cyclomatic Complexity 1 include/linux/jiffies.h:_msecs_to_jiffies
   Cyclomatic Complexity 3 include/linux/jiffies.h:msecs_to_jiffies
   Cyclomatic Complexity 1 arch/x86/include/asm/io.h:readb
   Cyclomatic Complexity 1 arch/x86/include/asm/io.h:readw
   Cyclomatic Complexity 1 arch/x86/include/asm/io.h:readl
   Cyclomatic Complexity 1 arch/x86/include/asm/io.h:writeb
   Cyclomatic Complexity 1 arch/x86/include/asm/io.h:writel
   Cyclomatic Complexity 1 arch/x86/include/asm/io.h:ioremap
   Cyclomatic Complexity 1 include/linux/kobject.h:kobject_name
   Cyclomatic Complexity 2 include/linux/device.h:dev_name
   Cyclomatic Complexity 1 include/linux/device.h:dev_get_drvdata
   Cyclomatic Complexity 1 include/linux/device.h:dev_set_drvdata
   Cyclomatic Complexity 1 include/linux/io.h:arch_phys_wc_add
   Cyclomatic Complexity 1 include/linux/io.h:arch_phys_wc_del
   Cyclomatic Complexity 68 include/linux/slab.h:kmalloc_large
   Cyclomatic Complexity 3 include/linux/slab.h:kmalloc
   Cyclomatic Complexity 1 include/linux/slab.h:kzalloc
   Cyclomatic Complexity 1 include/linux/pci.h:pci_get_drvdata
   Cyclomatic Complexity 1 include/linux/pci.h:pci_set_drvdata
   Cyclomatic Complexity 1 include/linux/pci.h:pci_name
   Cyclomatic Complexity 2 include/linux/fb.h:alloc_apertures
   Cyclomatic Complexity 2 
drivers/video/fbdev/aty/radeonfb.h:radeon_pll_errata_after_index
   Cyclomatic Complexity 2 
drivers/video/fbdev/aty/radeonfb.h:radeon_pll_errata_after_data
   Cyclomatic Complexity 1 drivers/video/fbdev/aty/radeonfb.h:round_div
   Cyclomatic Complexity 3 drivers/video/fbdev/aty/radeonfb.h:var_to_depth
   Cyclomatic Complexity 5 drivers/video/fbdev/aty/radeonfb.h:radeon_get_dstbpp
   Cyclomatic Complexity 1 drivers/video/fbdev/aty/radeonfb.h:radeonfb_bl_init
   Cyclomatic Complexity 1 drivers/video/fbdev/aty/radeonfb.h:radeonfb_bl_exit
   Cyclomatic Complexity 1 
include/drm/drm_fb_helper.h:drm_fb_helper_remove_conflicting_framebuffers
   Cyclomatic Complexity 21 
drivers/video/fbdev/aty/radeon_base.c:radeon_calc_pll_regs
   Cyclomatic Complexity 1 drivers/video/fbdev/aty/radeon_base.c:radeonfb_exit
   Cyclomatic Complexity 6 
drivers/video/fbdev/aty/radeon_base.c:radeon_find_mem_vbios
   Cyclomatic Complexity 4 
drivers/video/fbdev/aty/radeon_base.c:radeon_kick_out_firmware_fb
   Cyclomatic Complexity 5 
drivers/video/fbdev/aty/radeon_base.c:radeonfb_pci_unregister
   Cyclomatic Complexity 1 
drivers/video/fbdev/aty/radeon_base.c:radeon_show_one_edid
   Cyclomatic Complexity 3 
drivers/video/fbdev/aty/radeon_base.c:radeon_show_edid2
   Cyclomatic Complexity 3 
drivers/video/fbdev/aty/radeon_base.c:radeon_show_edid1
   Cyclomatic Complexity 2 
drivers/video/fbdev/aty/radeon_base.c:radeon_set_fbinfo
   Cyclomatic Complexity 18 
drivers/video/fbdev/aty/radeon_base.c:radeonfb_check_var
   Cyclomatic Complexity 2 
drivers/video/fbdev/aty/radeon_base.c:radeon_unmap_ROM
   Cyclomatic Complexity 7 drivers/video/fbdev/aty/radeon_base.c:radeon_map_ROM
   Cyclomatic Complexity 16 drivers/video/fbdev/aty/radeon_base.c:radeonfb_setup
   Cyclomatic Complexity 2 drivers/video/fbdev/aty/radeon_base.c:radeonfb_init
   C

[PATCH v4] Fix loading of module radeonfb on PowerMac

2018-01-31 Thread Mathieu Malaterre
When the linux kernel is build with (typical kernel ship with Debian
installer):

CONFIG_FB_OF=y
CONFIG_VT_HW_CONSOLE_BINDING=y
CONFIG_FB_RADEON=m

The offb driver takes precedence over module radeonfb. It is then
impossible to load the module, error reported is:

[   96.551486] radeonfb :00:10.0: enabling device (0006 -> 0007)
[   96.551526] radeonfb :00:10.0: BAR 0: can't reserve [mem 
0x9800-0x9fff pref]
[   96.551531] radeonfb (:00:10.0): cannot request region 0.
[   96.551545] radeonfb: probe of :00:10.0 failed with error -16

This patch reproduce the behavior of the module radeon, so as to make it
possible to load radeonfb when offb is first loaded, see commit a56f7428d753
("drm/radeon: Add early unregister of firmware fb's").

It should be noticed that `offb_destroy` is never called which explain the
need to skip error detection on the radeon side.

Signed-off-by: Mathieu Malaterre 
Link: https://bugs.debian.org/826629#57
Link: https://bugzilla.kernel.org/show_bug.cgi?id=119741
Suggested-by: Lennart Sorensen 
Cc: Bartlomiej Zolnierkiewicz 
Cc: Benjamin Herrenschmidt 
Cc: Tomi Valkeinen 
---
v2: Only fails when CONFIG_PCC is not set
v3: Only fails when CONFIG_FB_OF is not set, CONFIG_PCC was too broad. Since 
the conflicts in region is due to OFfb explicitly refers to it.
v4: Use drm_fb_helper_remove_conflicting_framebuffers from drm_fb_helper

 drivers/video/fbdev/aty/radeon_base.c | 28 
 1 file changed, 28 insertions(+)

diff --git a/drivers/video/fbdev/aty/radeon_base.c 
b/drivers/video/fbdev/aty/radeon_base.c
index 4d77daeecf99..ae669f424537 100644
--- a/drivers/video/fbdev/aty/radeon_base.c
+++ b/drivers/video/fbdev/aty/radeon_base.c
@@ -70,6 +70,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -2259,6 +2260,23 @@ static const struct bin_attribute edid2_attr = {
.read   = radeon_show_edid2,
 };
 
+static int radeon_kick_out_firmware_fb(struct pci_dev *pdev)
+{
+   struct apertures_struct *ap;
+
+   ap = alloc_apertures(1);
+   if (!ap)
+   return -ENOMEM;
+
+   ap->ranges[0].base = pci_resource_start(pdev, 0);
+   ap->ranges[0].size = pci_resource_len(pdev, 0);
+
+   drm_fb_helper_remove_conflicting_framebuffers(ap, KBUILD_MODNAME, 
false);
+
+   kfree(ap);
+
+   return 0;
+}
 
 static int radeonfb_pci_register(struct pci_dev *pdev,
 const struct pci_device_id *ent)
@@ -2312,19 +2330,27 @@ static int radeonfb_pci_register(struct pci_dev *pdev,
rinfo->fb_base_phys = pci_resource_start (pdev, 0);
rinfo->mmio_base_phys = pci_resource_start (pdev, 2);
 
+   ret = radeon_kick_out_firmware_fb(pdev);
+   if (ret)
+   return ret;
+
/* request the mem regions */
ret = pci_request_region(pdev, 0, "radeonfb framebuffer");
if (ret < 0) {
+#ifndef CONFIG_FB_OF
printk( KERN_ERR "radeonfb (%s): cannot request region 0.\n",
pci_name(rinfo->pdev));
goto err_release_fb;
+#endif
}
 
ret = pci_request_region(pdev, 2, "radeonfb mmio");
if (ret < 0) {
+#ifndef CONFIG_FB_OF
printk( KERN_ERR "radeonfb (%s): cannot request region 2.\n",
pci_name(rinfo->pdev));
goto err_release_pci0;
+#endif
}
 
/* map the regions */
@@ -2509,10 +2535,12 @@ static int radeonfb_pci_register(struct pci_dev *pdev,
iounmap(rinfo->mmio_base);
 err_release_pci2:
pci_release_region(pdev, 2);
+#ifndef CONFIG_FB_OF
 err_release_pci0:
pci_release_region(pdev, 0);
 err_release_fb:
 framebuffer_release(info);
+#endif
 err_disable:
 err_out:
return ret;
-- 
2.11.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel