RE: [PATCH] isci: reformulate for_each_isci_host macro to fix anoops
From: Dorau, Lukasz
Date: Mon Jan 20 2014 - 08:47:04 EST
On Thursday, January 16, 2014 2:16 PM Lukasz Dorau <lukasz.dorau@xxxxxxxxx> wrote:
> The loop 'for' in macro 'for_each_isci_host' (drivers/scsi/isci/init.c:717)
> is executed more times than it can be. Regardless the condition:
> 'id < ARRAY_SIZE(to_pci_info(pdev)->hosts)' (drivers/scsi/isci/host.h:315)
> it is executed when id equals ARRAY_SIZE(to_pci_info(pdev)->hosts) too.
> (Remark: ARRAY_SIZE(to_pci_info(pdev)->hosts) always equals
> SCI_MAX_CONTROLLERS = 2)
> It sounds crazy, but it is truth. I have checked it in the following way:
> I have added the line:
> printk(KERN_ERR ">>> (%d < %d) == %d \n", \
> i, SCI_MAX_CONTROLLERS, (i < SCI_MAX_CONTROLLERS));
> after the 'for_each_isci_host' macro in drivers/scsi/isci/init.c:701
> and received the following output:
> >>> (0 < 2) == 1
> >>> (1 < 2) == 1
> >>> (2 < 2) == 1
> after issuing 'modprobe isci' command on platform with two SCU controllers
> (Patsburg D or T chipset required).
> The kernel was compiled using gcc version 4.8.2.
Please disregard this patch.
It turned to be a GCC 4.8 bug:
I will write a new patch.