linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf/arm-cmn: fix compilation issue
@ 2023-05-15  1:29 liming.wu
  2023-05-15  6:20 ` Bagas Sanjaya
  2023-05-15  8:31 ` Mark Rutland
  0 siblings, 2 replies; 5+ messages in thread
From: liming.wu @ 2023-05-15  1:29 UTC (permalink / raw)
  To: will
  Cc: mark.rutland, linux-arm-kernel, linux-kernel, robin.murphy, Liming Wu

From: Liming Wu <liming.wu@jaguarmicro.com>

This patch is used to fix following compilation issue with legacy gcc
and define variables at the beginning of the function

error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
2098 |                 for (int p = 0; p < CMN_MAX_PORTS; p++)

Signed-off-by: Liming Wu <liming.wu@jaguarmicro.com>
---
 drivers/perf/arm-cmn.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
index 47d359f72957..2299fcde5b4a 100644
--- a/drivers/perf/arm-cmn.c
+++ b/drivers/perf/arm-cmn.c
@@ -2009,8 +2009,11 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
 	u16 child_count, child_poff;
 	u32 xp_offset[CMN_MAX_XPS];
 	u64 reg;
-	int i, j;
+	int i, j, p;
 	size_t sz;
+	void __iomem *xp_region;
+	struct arm_cmn_node *xp;
+	unsigned int xp_ports;
 
 	arm_cmn_init_node_info(cmn, rgn_offset, &cfg);
 	if (cfg.type != CMN_TYPE_CFG)
@@ -2067,9 +2070,9 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
 	cmn->dns = dn;
 	cmn->dtms = dtm;
 	for (i = 0; i < cmn->num_xps; i++) {
-		void __iomem *xp_region = cmn->base + xp_offset[i];
-		struct arm_cmn_node *xp = dn++;
-		unsigned int xp_ports = 0;
+		xp_region = cmn->base + xp_offset[i];
+		xp = dn++;
+		xp_ports = 0;
 
 		arm_cmn_init_node_info(cmn, xp_offset[i], xp);
 		/*
@@ -2095,7 +2098,7 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
 		 * from this, since in that case we will see at least one XP
 		 * with port 2 connected, for the HN-D.
 		 */
-		for (int p = 0; p < CMN_MAX_PORTS; p++)
+		for (p = 0; p < CMN_MAX_PORTS; p++)
 			if (arm_cmn_device_connect_info(cmn, xp, p))
 				xp_ports |= BIT(p);
 
-- 
2.25.1


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

* Re: [PATCH] perf/arm-cmn: fix compilation issue
  2023-05-15  1:29 [PATCH] perf/arm-cmn: fix compilation issue liming.wu
@ 2023-05-15  6:20 ` Bagas Sanjaya
  2023-05-15  8:31 ` Mark Rutland
  1 sibling, 0 replies; 5+ messages in thread
From: Bagas Sanjaya @ 2023-05-15  6:20 UTC (permalink / raw)
  To: liming.wu, will
  Cc: mark.rutland, linux-arm-kernel, linux-kernel, robin.murphy

[-- Attachment #1: Type: text/plain, Size: 2163 bytes --]

On Mon, May 15, 2023 at 09:29:30AM +0800, liming.wu@jaguarmicro.com wrote:
> From: Liming Wu <liming.wu@jaguarmicro.com>
> 
> This patch is used to fix following compilation issue with legacy gcc
> and define variables at the beginning of the function

What GCC version?

> 
> error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
> 2098 |                 for (int p = 0; p < CMN_MAX_PORTS; p++)
> 
> Signed-off-by: Liming Wu <liming.wu@jaguarmicro.com>
> ---
>  drivers/perf/arm-cmn.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
> index 47d359f72957..2299fcde5b4a 100644
> --- a/drivers/perf/arm-cmn.c
> +++ b/drivers/perf/arm-cmn.c
> @@ -2009,8 +2009,11 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
>  	u16 child_count, child_poff;
>  	u32 xp_offset[CMN_MAX_XPS];
>  	u64 reg;
> -	int i, j;
> +	int i, j, p;
>  	size_t sz;
> +	void __iomem *xp_region;
> +	struct arm_cmn_node *xp;
> +	unsigned int xp_ports;
>  
>  	arm_cmn_init_node_info(cmn, rgn_offset, &cfg);
>  	if (cfg.type != CMN_TYPE_CFG)
> @@ -2067,9 +2070,9 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
>  	cmn->dns = dn;
>  	cmn->dtms = dtm;
>  	for (i = 0; i < cmn->num_xps; i++) {
> -		void __iomem *xp_region = cmn->base + xp_offset[i];
> -		struct arm_cmn_node *xp = dn++;
> -		unsigned int xp_ports = 0;
> +		xp_region = cmn->base + xp_offset[i];
> +		xp = dn++;
> +		xp_ports = 0;
>  
>  		arm_cmn_init_node_info(cmn, xp_offset[i], xp);
>  		/*
> @@ -2095,7 +2098,7 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
>  		 * from this, since in that case we will see at least one XP
>  		 * with port 2 connected, for the HN-D.
>  		 */
> -		for (int p = 0; p < CMN_MAX_PORTS; p++)
> +		for (p = 0; p < CMN_MAX_PORTS; p++)
>  			if (arm_cmn_device_connect_info(cmn, xp, p))
>  				xp_ports |= BIT(p);
>  

Is above manually tracking xp* variables?

I'm confused...

-- 
An old man doll... just what I always wanted! - Clara

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH] perf/arm-cmn: fix compilation issue
  2023-05-15  1:29 [PATCH] perf/arm-cmn: fix compilation issue liming.wu
  2023-05-15  6:20 ` Bagas Sanjaya
@ 2023-05-15  8:31 ` Mark Rutland
  2023-05-15  8:35   ` Liming Wu
  1 sibling, 1 reply; 5+ messages in thread
From: Mark Rutland @ 2023-05-15  8:31 UTC (permalink / raw)
  To: liming.wu; +Cc: will, linux-arm-kernel, linux-kernel, robin.murphy

On Mon, May 15, 2023 at 09:29:30AM +0800, liming.wu@jaguarmicro.com wrote:
> From: Liming Wu <liming.wu@jaguarmicro.com>
> 
> This patch is used to fix following compilation issue with legacy gcc
> and define variables at the beginning of the function
> 
> error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
> 2098 |                 for (int p = 0; p < CMN_MAX_PORTS; p++)

The kernel builds as gnu11 (i.e. C11 + GNU extensions) since commit:

  e8c07082a810fbb9 ("Kbuild: move to -std=gnu11")

... so that warning shouldn't be happenning.

How are you triggering this? Have you modified KBUILD_CFLAGS?

> Signed-off-by: Liming Wu <liming.wu@jaguarmicro.com>
> ---
>  drivers/perf/arm-cmn.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
> index 47d359f72957..2299fcde5b4a 100644
> --- a/drivers/perf/arm-cmn.c
> +++ b/drivers/perf/arm-cmn.c
> @@ -2009,8 +2009,11 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
>  	u16 child_count, child_poff;
>  	u32 xp_offset[CMN_MAX_XPS];
>  	u64 reg;
> -	int i, j;
> +	int i, j, p;
>  	size_t sz;
> +	void __iomem *xp_region;
> +	struct arm_cmn_node *xp;
> +	unsigned int xp_ports;
>  
>  	arm_cmn_init_node_info(cmn, rgn_offset, &cfg);
>  	if (cfg.type != CMN_TYPE_CFG)
> @@ -2067,9 +2070,9 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
>  	cmn->dns = dn;
>  	cmn->dtms = dtm;
>  	for (i = 0; i < cmn->num_xps; i++) {
> -		void __iomem *xp_region = cmn->base + xp_offset[i];
> -		struct arm_cmn_node *xp = dn++;
> -		unsigned int xp_ports = 0;
> +		xp_region = cmn->base + xp_offset[i];
> +		xp = dn++;
> +		xp_ports = 0;

None of these are for loop initial declarations. Even if we wanted to avoid the
warning, there's no need for these to change.

>  
>  		arm_cmn_init_node_info(cmn, xp_offset[i], xp);
>  		/*
> @@ -2095,7 +2098,7 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
>  		 * from this, since in that case we will see at least one XP
>  		 * with port 2 connected, for the HN-D.
>  		 */
> -		for (int p = 0; p < CMN_MAX_PORTS; p++)
> +		for (p = 0; p < CMN_MAX_PORTS; p++)

This shouldn't be necessary given the jernel builds as gnu11.

Thanks,
Mark.

>  			if (arm_cmn_device_connect_info(cmn, xp, p))
>  				xp_ports |= BIT(p);
>  
> -- 
> 2.25.1
> 

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

* RE: [PATCH] perf/arm-cmn: fix compilation issue
  2023-05-15  8:31 ` Mark Rutland
@ 2023-05-15  8:35   ` Liming Wu
  2023-05-15 12:29     ` Robin Murphy
  0 siblings, 1 reply; 5+ messages in thread
From: Liming Wu @ 2023-05-15  8:35 UTC (permalink / raw)
  To: Mark Rutland; +Cc: will, linux-arm-kernel, linux-kernel, robin.murphy

> The kernel builds as gnu11 (i.e. C11 + GNU extensions) since commit:
> 
>   e8c07082a810fbb9 ("Kbuild: move to -std=gnu11")
> 
> ... so that warning shouldn't be happenning.
> 
> How are you triggering this? Have you modified KBUILD_CFLAGS?

Thanks for reply.
This error occurs for I compiled the arn-cmn module separately.

> -----Original Message-----
> From: Mark Rutland <mark.rutland@arm.com>
> Sent: Monday, May 15, 2023 4:31 PM
> To: Liming Wu <liming.wu@jaguarmicro.com>
> Cc: will@kernel.org; linux-arm-kernel@lists.infradead.org; linux-
> kernel@vger.kernel.org; robin.murphy@arm.com
> Subject: Re: [PATCH] perf/arm-cmn: fix compilation issue
> 
> On Mon, May 15, 2023 at 09:29:30AM +0800, liming.wu@jaguarmicro.com
> wrote:
> > From: Liming Wu <liming.wu@jaguarmicro.com>
> >
> > This patch is used to fix following compilation issue with legacy gcc
> > and define variables at the beginning of the function
> >
> > error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
> > 2098 |                 for (int p = 0; p < CMN_MAX_PORTS; p++)
> 
> The kernel builds as gnu11 (i.e. C11 + GNU extensions) since commit:
> 
>   e8c07082a810fbb9 ("Kbuild: move to -std=gnu11")
> 
> ... so that warning shouldn't be happenning.
> 
> How are you triggering this? Have you modified KBUILD_CFLAGS?
> 
> > Signed-off-by: Liming Wu <liming.wu@jaguarmicro.com>
> > ---
> >  drivers/perf/arm-cmn.c | 13 ++++++++-----
> >  1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c index
> > 47d359f72957..2299fcde5b4a 100644
> > --- a/drivers/perf/arm-cmn.c
> > +++ b/drivers/perf/arm-cmn.c
> > @@ -2009,8 +2009,11 @@ static int arm_cmn_discover(struct arm_cmn *cmn,
> unsigned int rgn_offset)
> >  	u16 child_count, child_poff;
> >  	u32 xp_offset[CMN_MAX_XPS];
> >  	u64 reg;
> > -	int i, j;
> > +	int i, j, p;
> >  	size_t sz;
> > +	void __iomem *xp_region;
> > +	struct arm_cmn_node *xp;
> > +	unsigned int xp_ports;
> >
> >  	arm_cmn_init_node_info(cmn, rgn_offset, &cfg);
> >  	if (cfg.type != CMN_TYPE_CFG)
> > @@ -2067,9 +2070,9 @@ static int arm_cmn_discover(struct arm_cmn *cmn,
> unsigned int rgn_offset)
> >  	cmn->dns = dn;
> >  	cmn->dtms = dtm;
> >  	for (i = 0; i < cmn->num_xps; i++) {
> > -		void __iomem *xp_region = cmn->base + xp_offset[i];
> > -		struct arm_cmn_node *xp = dn++;
> > -		unsigned int xp_ports = 0;
> > +		xp_region = cmn->base + xp_offset[i];
> > +		xp = dn++;
> > +		xp_ports = 0;
> 
> None of these are for loop initial declarations. Even if we wanted to avoid the
> warning, there's no need for these to change.
> 
> >
> >  		arm_cmn_init_node_info(cmn, xp_offset[i], xp);
> >  		/*
> > @@ -2095,7 +2098,7 @@ static int arm_cmn_discover(struct arm_cmn *cmn,
> unsigned int rgn_offset)
> >  		 * from this, since in that case we will see at least one XP
> >  		 * with port 2 connected, for the HN-D.
> >  		 */
> > -		for (int p = 0; p < CMN_MAX_PORTS; p++)
> > +		for (p = 0; p < CMN_MAX_PORTS; p++)
> 
> This shouldn't be necessary given the jernel builds as gnu11.
> 
> Thanks,
> Mark.
> 
> >  			if (arm_cmn_device_connect_info(cmn, xp, p))
> >  				xp_ports |= BIT(p);
> >
> > --
> > 2.25.1
> >

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

* Re: [PATCH] perf/arm-cmn: fix compilation issue
  2023-05-15  8:35   ` Liming Wu
@ 2023-05-15 12:29     ` Robin Murphy
  0 siblings, 0 replies; 5+ messages in thread
From: Robin Murphy @ 2023-05-15 12:29 UTC (permalink / raw)
  To: Liming Wu, Mark Rutland; +Cc: will, linux-arm-kernel, linux-kernel

On 2023-05-15 09:35, Liming Wu wrote:
>> The kernel builds as gnu11 (i.e. C11 + GNU extensions) since commit:
>>
>>    e8c07082a810fbb9 ("Kbuild: move to -std=gnu11")
>>
>> ... so that warning shouldn't be happenning.
>>
>> How are you triggering this? Have you modified KBUILD_CFLAGS?
> 
> Thanks for reply.
> This error occurs for I compiled the arn-cmn module separately.

You're free to build bits of mainline against older kernels if you want 
to and can make it work, but understand that what you're doing in that 
case is a backport. It can be expected that some things need adjusting 
when backporting, and this happens to be one of them; go back far enough 
and the irq_set_affinity() call would be another, IIRC.

The code in mainline here is correct for the mainline kernel, so there 
is nothing to fix.

Thanks,
Robin.

>> -----Original Message-----
>> From: Mark Rutland <mark.rutland@arm.com>
>> Sent: Monday, May 15, 2023 4:31 PM
>> To: Liming Wu <liming.wu@jaguarmicro.com>
>> Cc: will@kernel.org; linux-arm-kernel@lists.infradead.org; linux-
>> kernel@vger.kernel.org; robin.murphy@arm.com
>> Subject: Re: [PATCH] perf/arm-cmn: fix compilation issue
>>
>> On Mon, May 15, 2023 at 09:29:30AM +0800, liming.wu@jaguarmicro.com
>> wrote:
>>> From: Liming Wu <liming.wu@jaguarmicro.com>
>>>
>>> This patch is used to fix following compilation issue with legacy gcc
>>> and define variables at the beginning of the function
>>>
>>> error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
>>> 2098 |                 for (int p = 0; p < CMN_MAX_PORTS; p++)
>>
>> The kernel builds as gnu11 (i.e. C11 + GNU extensions) since commit:
>>
>>    e8c07082a810fbb9 ("Kbuild: move to -std=gnu11")
>>
>> ... so that warning shouldn't be happenning.
>>
>> How are you triggering this? Have you modified KBUILD_CFLAGS?
>>
>>> Signed-off-by: Liming Wu <liming.wu@jaguarmicro.com>
>>> ---
>>>   drivers/perf/arm-cmn.c | 13 ++++++++-----
>>>   1 file changed, 8 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c index
>>> 47d359f72957..2299fcde5b4a 100644
>>> --- a/drivers/perf/arm-cmn.c
>>> +++ b/drivers/perf/arm-cmn.c
>>> @@ -2009,8 +2009,11 @@ static int arm_cmn_discover(struct arm_cmn *cmn,
>> unsigned int rgn_offset)
>>>   	u16 child_count, child_poff;
>>>   	u32 xp_offset[CMN_MAX_XPS];
>>>   	u64 reg;
>>> -	int i, j;
>>> +	int i, j, p;
>>>   	size_t sz;
>>> +	void __iomem *xp_region;
>>> +	struct arm_cmn_node *xp;
>>> +	unsigned int xp_ports;
>>>
>>>   	arm_cmn_init_node_info(cmn, rgn_offset, &cfg);
>>>   	if (cfg.type != CMN_TYPE_CFG)
>>> @@ -2067,9 +2070,9 @@ static int arm_cmn_discover(struct arm_cmn *cmn,
>> unsigned int rgn_offset)
>>>   	cmn->dns = dn;
>>>   	cmn->dtms = dtm;
>>>   	for (i = 0; i < cmn->num_xps; i++) {
>>> -		void __iomem *xp_region = cmn->base + xp_offset[i];
>>> -		struct arm_cmn_node *xp = dn++;
>>> -		unsigned int xp_ports = 0;
>>> +		xp_region = cmn->base + xp_offset[i];
>>> +		xp = dn++;
>>> +		xp_ports = 0;
>>
>> None of these are for loop initial declarations. Even if we wanted to avoid the
>> warning, there's no need for these to change.
>>
>>>
>>>   		arm_cmn_init_node_info(cmn, xp_offset[i], xp);
>>>   		/*
>>> @@ -2095,7 +2098,7 @@ static int arm_cmn_discover(struct arm_cmn *cmn,
>> unsigned int rgn_offset)
>>>   		 * from this, since in that case we will see at least one XP
>>>   		 * with port 2 connected, for the HN-D.
>>>   		 */
>>> -		for (int p = 0; p < CMN_MAX_PORTS; p++)
>>> +		for (p = 0; p < CMN_MAX_PORTS; p++)
>>
>> This shouldn't be necessary given the jernel builds as gnu11.
>>
>> Thanks,
>> Mark.
>>
>>>   			if (arm_cmn_device_connect_info(cmn, xp, p))
>>>   				xp_ports |= BIT(p);
>>>
>>> --
>>> 2.25.1
>>>

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

end of thread, other threads:[~2023-05-15 12:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-15  1:29 [PATCH] perf/arm-cmn: fix compilation issue liming.wu
2023-05-15  6:20 ` Bagas Sanjaya
2023-05-15  8:31 ` Mark Rutland
2023-05-15  8:35   ` Liming Wu
2023-05-15 12:29     ` Robin Murphy

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).