LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] hpt366: fix section mismatch warnings
@ 2008-02-22 19:46 Sam Ravnborg
  2008-02-22 19:53 ` Sergei Shtylyov
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Sam Ravnborg @ 2008-02-22 19:46 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz, Sergei Shtylyov, LKML, linux-ide

hpt366: fix section mismatch warnings

Fix following warnings:
WARNING: o-sparc64/vmlinux.o(.data+0x195a38): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt370
WARNING: o-sparc64/vmlinux.o(.data+0x195a40): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt370a
WARNING: o-sparc64/vmlinux.o(.data+0x195a48): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt372
WARNING: o-sparc64/vmlinux.o(.data+0x195a50): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt372n

Replace a static array with a small switch resulting in
more readable code.
Be consistent in use of __devinitconst for const data
to avoid section type conflicts.
Mark the pci table __devinitconst.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
---
Only build tested but looks obviously correct.
I saw this doing a sparc64 build - dunno whit it did not
surface when I sweeped over an x86 64 bit allyesconfig.

	Sam

diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index d0f7bb8..9911584 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -513,7 +513,7 @@ static struct hpt_timings hpt37x_timings = {
 	}
 };
 
-static const struct hpt_info hpt36x __devinitdata = {
+static const struct hpt_info hpt36x __devinitconst = {
 	.chip_name	= "HPT36x",
 	.chip_type	= HPT36x,
 	.udma_mask	= HPT366_ALLOW_ATA66_3 ? (HPT366_ALLOW_ATA66_4 ? ATA_UDMA4 : ATA_UDMA3) : ATA_UDMA2,
@@ -521,7 +521,7 @@ static const struct hpt_info hpt36x __devinitdata = {
 	.timings	= &hpt36x_timings
 };
 
-static const struct hpt_info hpt370 __devinitdata = {
+static const struct hpt_info hpt370 __devinitconst = {
 	.chip_name	= "HPT370",
 	.chip_type	= HPT370,
 	.udma_mask	= HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4,
@@ -529,7 +529,7 @@ static const struct hpt_info hpt370 __devinitdata = {
 	.timings	= &hpt37x_timings
 };
 
-static const struct hpt_info hpt370a __devinitdata = {
+static const struct hpt_info hpt370a __devinitconst = {
 	.chip_name	= "HPT370A",
 	.chip_type	= HPT370A,
 	.udma_mask	= HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4,
@@ -537,7 +537,7 @@ static const struct hpt_info hpt370a __devinitdata = {
 	.timings	= &hpt37x_timings
 };
 
-static const struct hpt_info hpt374 __devinitdata = {
+static const struct hpt_info hpt374 __devinitconst = {
 	.chip_name	= "HPT374",
 	.chip_type	= HPT374,
 	.udma_mask	= ATA_UDMA5,
@@ -545,7 +545,7 @@ static const struct hpt_info hpt374 __devinitdata = {
 	.timings	= &hpt37x_timings
 };
 
-static const struct hpt_info hpt372 __devinitdata = {
+static const struct hpt_info hpt372 __devinitconst = {
 	.chip_name	= "HPT372",
 	.chip_type	= HPT372,
 	.udma_mask	= HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
@@ -553,7 +553,7 @@ static const struct hpt_info hpt372 __devinitdata = {
 	.timings	= &hpt37x_timings
 };
 
-static const struct hpt_info hpt372a __devinitdata = {
+static const struct hpt_info hpt372a __devinitconst = {
 	.chip_name	= "HPT372A",
 	.chip_type	= HPT372A,
 	.udma_mask	= HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
@@ -561,7 +561,7 @@ static const struct hpt_info hpt372a __devinitdata = {
 	.timings	= &hpt37x_timings
 };
 
-static const struct hpt_info hpt302 __devinitdata = {
+static const struct hpt_info hpt302 __devinitconst = {
 	.chip_name	= "HPT302",
 	.chip_type	= HPT302,
 	.udma_mask	= HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
@@ -569,7 +569,7 @@ static const struct hpt_info hpt302 __devinitdata = {
 	.timings	= &hpt37x_timings
 };
 
-static const struct hpt_info hpt371 __devinitdata = {
+static const struct hpt_info hpt371 __devinitconst = {
 	.chip_name	= "HPT371",
 	.chip_type	= HPT371,
 	.udma_mask	= HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
@@ -577,7 +577,7 @@ static const struct hpt_info hpt371 __devinitdata = {
 	.timings	= &hpt37x_timings
 };
 
-static const struct hpt_info hpt372n __devinitdata = {
+static const struct hpt_info hpt372n __devinitconst = {
 	.chip_name	= "HPT372N",
 	.chip_type	= HPT372N,
 	.udma_mask	= HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
@@ -585,7 +585,7 @@ static const struct hpt_info hpt372n __devinitdata = {
 	.timings	= &hpt37x_timings
 };
 
-static const struct hpt_info hpt302n __devinitdata = {
+static const struct hpt_info hpt302n __devinitconst = {
 	.chip_name	= "HPT302N",
 	.chip_type	= HPT302N,
 	.udma_mask	= HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
@@ -593,7 +593,7 @@ static const struct hpt_info hpt302n __devinitdata = {
 	.timings	= &hpt37x_timings
 };
 
-static const struct hpt_info hpt371n __devinitdata = {
+static const struct hpt_info hpt371n __devinitconst = {
 	.chip_name	= "HPT371N",
 	.chip_type	= HPT371N,
 	.udma_mask	= HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
@@ -1475,7 +1475,7 @@ static int __devinit hpt36x_init(struct pci_dev *dev, struct pci_dev *dev2)
 	 IDE_HFLAG_ABUSE_SET_DMA_MODE | \
 	 IDE_HFLAG_OFF_BOARD)
 
-static const struct ide_port_info hpt366_chipsets[] __devinitdata = {
+static const struct ide_port_info hpt366_chipsets[] __devinitconst = {
 	{	/* 0 */
 		.name		= "HPT36x",
 		.init_chipset	= init_chipset_hpt366,
@@ -1570,11 +1570,13 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic
 		if (rev < 3)
 			info = &hpt36x;
 		else {
-			static const struct hpt_info *hpt37x_info[] =
-				{ &hpt370, &hpt370a, &hpt372, &hpt372n };
-
-			info = hpt37x_info[min_t(u8, rev, 6) - 3];
-			idx++;
+			switch (min_t(u8, rev, 6) - 3) {
+			case 0: info = &hpt370;  break;
+			case 1: info = &hpt370a; break;
+			case 2: info = &hpt372;  break;
+			case 3: info = &hpt372n; break;
+			}
+		idx++;
 		}
 		break;
 	case 1:
@@ -1626,7 +1628,7 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic
 	return ide_setup_pci_device(dev, &d);
 }
 
-static const struct pci_device_id hpt366_pci_tbl[] = {
+static const struct pci_device_id hpt366_pci_tbl[] __devinitconst = {
 	{ PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT366),  0 },
 	{ PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT372),  1 },
 	{ PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT302),  2 },

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] hpt366: fix section mismatch warnings
  2008-02-22 19:46 [PATCH] hpt366: fix section mismatch warnings Sam Ravnborg
@ 2008-02-22 19:53 ` Sergei Shtylyov
  2008-02-22 20:57   ` Bartlomiej Zolnierkiewicz
  2008-02-22 20:43 ` Sam Ravnborg
  2008-02-23 21:22 ` [Fixed PATCH] " Sam Ravnborg
  2 siblings, 1 reply; 7+ messages in thread
From: Sergei Shtylyov @ 2008-02-22 19:53 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: Sam Ravnborg, LKML, linux-ide

Sam Ravnborg wrote:

> hpt366: fix section mismatch warnings

> Fix following warnings:
> WARNING: o-sparc64/vmlinux.o(.data+0x195a38): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt370
> WARNING: o-sparc64/vmlinux.o(.data+0x195a40): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt370a
> WARNING: o-sparc64/vmlinux.o(.data+0x195a48): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt372
> WARNING: o-sparc64/vmlinux.o(.data+0x195a50): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt372n

> Replace a static array with a small switch resulting in
> more readable code.
> Be consistent in use of __devinitconst for const data
> to avoid section type conflicts.
> Mark the pci table __devinitconst.

> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

MBR, Sergei

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] hpt366: fix section mismatch warnings
  2008-02-22 19:46 [PATCH] hpt366: fix section mismatch warnings Sam Ravnborg
  2008-02-22 19:53 ` Sergei Shtylyov
@ 2008-02-22 20:43 ` Sam Ravnborg
  2008-02-23 21:22 ` [Fixed PATCH] " Sam Ravnborg
  2 siblings, 0 replies; 7+ messages in thread
From: Sam Ravnborg @ 2008-02-22 20:43 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz, Sergei Shtylyov, LKML, linux-ide

> @@ -1570,11 +1570,13 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic
>  		if (rev < 3)
>  			info = &hpt36x;
>  		else {
> -			static const struct hpt_info *hpt37x_info[] =
> -				{ &hpt370, &hpt370a, &hpt372, &hpt372n };
> -
> -			info = hpt37x_info[min_t(u8, rev, 6) - 3];
> -			idx++;
> +			switch (min_t(u8, rev, 6) - 3) {
> +			case 0: info = &hpt370;  break;
> +			case 1: info = &hpt370a; break;
> +			case 2: info = &hpt372;  break;
> +			case 3: info = &hpt372n; break;
> +			}
> +		idx++;
>  		}

I kept the calculation as it was before but the '- 3'
is not needed. So it could be fixed and the case N:
should then be updated.
[Thanks to Sergei to not this]

Another note: The warnings were seen with a
make CONFIG_DEBUG_SECTION_MISMATCH=y build so they most likely
does not show up duing a typical build due to the inlining performed
by gcc.

	Sam

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] hpt366: fix section mismatch warnings
  2008-02-22 19:53 ` Sergei Shtylyov
@ 2008-02-22 20:57   ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 7+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-02-22 20:57 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: Sam Ravnborg, LKML, linux-ide

On Friday 22 February 2008, Sergei Shtylyov wrote:
> Sam Ravnborg wrote:
> 
> > hpt366: fix section mismatch warnings
> 
> > Fix following warnings:
> > WARNING: o-sparc64/vmlinux.o(.data+0x195a38): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt370
> > WARNING: o-sparc64/vmlinux.o(.data+0x195a40): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt370a
> > WARNING: o-sparc64/vmlinux.o(.data+0x195a48): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt372
> > WARNING: o-sparc64/vmlinux.o(.data+0x195a50): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt372n
> 
> > Replace a static array with a small switch resulting in
> > more readable code.
> > Be consistent in use of __devinitconst for const data
> > to avoid section type conflicts.
> > Mark the pci table __devinitconst.
> 
> > Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> 
> Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

applied

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Fixed PATCH] hpt366: fix section mismatch warnings
  2008-02-22 19:46 [PATCH] hpt366: fix section mismatch warnings Sam Ravnborg
  2008-02-22 19:53 ` Sergei Shtylyov
  2008-02-22 20:43 ` Sam Ravnborg
@ 2008-02-23 21:22 ` Sam Ravnborg
  2008-02-24 14:33   ` Bartlomiej Zolnierkiewicz
  2 siblings, 1 reply; 7+ messages in thread
From: Sam Ravnborg @ 2008-02-23 21:22 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz, Sergei Shtylyov, LKML, linux-ide

hpt366: fix section mismatch warnings

Fix following warnings:
WARNING: o-sparc64/vmlinux.o(.data+0x195a38): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt370
WARNING: o-sparc64/vmlinux.o(.data+0x195a40): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt370a
WARNING: o-sparc64/vmlinux.o(.data+0x195a48): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt372
WARNING: o-sparc64/vmlinux.o(.data+0x195a50): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt372n

Replace a static array with a small switch resulting in
more readable code.
Mark the pci table __devinitconst.

A lot of variables are const but annotated __devinitdata.
Annotating them __devinitconst would cause a section type
conflict error when build for 64 bit powerpc.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
---

The first patch I posted caused a section type conflict when
build for 64 bit powerpc. The actual cause of this is know and unavoidable
when we start to declare variables const.
The patch attached is much simpler as the transition from __devinitdata
to __devinitconst turned out to be bogus.

I also took the opportunity to simplify the switch as suggested by
Sergei.

	Sam

diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index d0f7bb8..a5eeb6b 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -1570,11 +1570,13 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic
 		if (rev < 3)
 			info = &hpt36x;
 		else {
-			static const struct hpt_info *hpt37x_info[] =
-				{ &hpt370, &hpt370a, &hpt372, &hpt372n };
-
-			info = hpt37x_info[min_t(u8, rev, 6) - 3];
-			idx++;
+			switch (min_t(u8, rev, 6)) {
+			case 3: info = &hpt370;  break;
+			case 4: info = &hpt370a; break;
+			case 5: info = &hpt372;  break;
+			case 6: info = &hpt372n; break;
+			}
+		idx++;
 		}
 		break;
 	case 1:
@@ -1626,7 +1628,7 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic
 	return ide_setup_pci_device(dev, &d);
 }
 
-static const struct pci_device_id hpt366_pci_tbl[] = {
+static const struct pci_device_id hpt366_pci_tbl[] __devinitconst = {
 	{ PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT366),  0 },
 	{ PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT372),  1 },
 	{ PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT302),  2 },

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Fixed PATCH] hpt366: fix section mismatch warnings
  2008-02-23 21:22 ` [Fixed PATCH] " Sam Ravnborg
@ 2008-02-24 14:33   ` Bartlomiej Zolnierkiewicz
  2008-02-24 17:53     ` Sam Ravnborg
  0 siblings, 1 reply; 7+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-02-24 14:33 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Sergei Shtylyov, LKML, linux-ide

On Saturday 23 February 2008, Sam Ravnborg wrote:
> hpt366: fix section mismatch warnings
> 
> Fix following warnings:
> WARNING: o-sparc64/vmlinux.o(.data+0x195a38): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt370
> WARNING: o-sparc64/vmlinux.o(.data+0x195a40): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt370a
> WARNING: o-sparc64/vmlinux.o(.data+0x195a48): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt372
> WARNING: o-sparc64/vmlinux.o(.data+0x195a50): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt372n
> 
> Replace a static array with a small switch resulting in
> more readable code.
> Mark the pci table __devinitconst.
> 
> A lot of variables are const but annotated __devinitdata.
> Annotating them __devinitconst would cause a section type
> conflict error when build for 64 bit powerpc.
> 
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
> ---

thanks, applied

> The first patch I posted caused a section type conflict when
> build for 64 bit powerpc. The actual cause of this is know and unavoidable
> when we start to declare variables const.
> The patch attached is much simpler as the transition from __devinitdata
> to __devinitconst turned out to be bogus.

Weird, I thought that the main purpose of __devinitconst was to replace
const + __devinitdata?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Fixed PATCH] hpt366: fix section mismatch warnings
  2008-02-24 14:33   ` Bartlomiej Zolnierkiewicz
@ 2008-02-24 17:53     ` Sam Ravnborg
  0 siblings, 0 replies; 7+ messages in thread
From: Sam Ravnborg @ 2008-02-24 17:53 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: Sergei Shtylyov, LKML, linux-ide

On Sun, Feb 24, 2008 at 03:33:51PM +0100, Bartlomiej Zolnierkiewicz wrote:
> On Saturday 23 February 2008, Sam Ravnborg wrote:
> > hpt366: fix section mismatch warnings
> > 
> > Fix following warnings:
> > WARNING: o-sparc64/vmlinux.o(.data+0x195a38): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt370
> > WARNING: o-sparc64/vmlinux.o(.data+0x195a40): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt370a
> > WARNING: o-sparc64/vmlinux.o(.data+0x195a48): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt372
> > WARNING: o-sparc64/vmlinux.o(.data+0x195a50): Section mismatch in reference from the variable hpt37x_info.0 to the variable .devinit.data:hpt372n
> > 
> > Replace a static array with a small switch resulting in
> > more readable code.
> > Mark the pci table __devinitconst.
> > 
> > A lot of variables are const but annotated __devinitdata.
> > Annotating them __devinitconst would cause a section type
> > conflict error when build for 64 bit powerpc.
> > 
> > Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> > Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> > Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
> > ---
> 
> thanks, applied
> 
> > The first patch I posted caused a section type conflict when
> > build for 64 bit powerpc. The actual cause of this is know and unavoidable
> > when we start to declare variables const.
> > The patch attached is much simpler as the transition from __devinitdata
> > to __devinitconst turned out to be bogus.
> 
> Weird, I thought that the main purpose of __devinitconst was to replace
> const + __devinitdata?

The problem we face is that gcc in some cases mark the
destination section READ-ONLY and in other cases not.
So if we annotate two variables to go into the same
section and gcc only annotate one of them READ-ONLY them
we will have a section type conflict.

gcc is not consistent across architectures what to mark
READ-ONLY and not. And what we saw here was a combination
where on x86 the destinatin section were marked equal
(READ-ONLY or not READ-ONLY) but on powerpc were marked
different. One was marked READ-ONLY the other was not.

So when playing with const it is improtant to try out with
a 64 bit gcc for powerpc to see if it causes any section
type conflict. Note: 32 bit gcc does not have this
issue.

	Sam


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-02-24 17:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-22 19:46 [PATCH] hpt366: fix section mismatch warnings Sam Ravnborg
2008-02-22 19:53 ` Sergei Shtylyov
2008-02-22 20:57   ` Bartlomiej Zolnierkiewicz
2008-02-22 20:43 ` Sam Ravnborg
2008-02-23 21:22 ` [Fixed PATCH] " Sam Ravnborg
2008-02-24 14:33   ` Bartlomiej Zolnierkiewicz
2008-02-24 17:53     ` Sam Ravnborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).