diff mbox

irqchip/gicv3-its: Decrease page size when needed

Message ID 1429091364-31939-1-git-send-email-Minghuan.Lian@freescale.com (mailing list archive)
State New, archived
Headers show

Commit Message

Minghuan Lian April 15, 2015, 9:49 a.m. UTC
The default page size of ITS table has been changed to 64KB,
but for some platforms the real size of allocate memory which
calculated by DEVBITS of register GITS_TYPER may smaller than
default size. In this case, psz must be decreased, otherwise,
the wrong page number will cause kernel hang.

Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com>
---
 drivers/irqchip/irq-gic-v3-its.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Jason Cooper April 15, 2015, 11:51 a.m. UTC | #1
Minghuan Lian,

On Wed, Apr 15, 2015 at 05:49:22PM +0800, Minghuan Lian wrote:
> The default page size of ITS table has been changed to 64KB,
> but for some platforms the real size of allocate memory which
> calculated by DEVBITS of register GITS_TYPER may smaller than
> default size. In this case, psz must be decreased, otherwise,
> the wrong page number will cause kernel hang.
> 
> Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com>
> ---
>  drivers/irqchip/irq-gic-v3-its.c | 3 +++
>  1 file changed, 3 insertions(+)

Please run scripts/get_maintainer.pl on your patches before sending.  This
needs to be sent to myself and Thomas Gleixner for review.

The merge window just opened, so nothing new is being added to the tree
currently.  Go ahead and resend after a few days.

thx,

Jason.
Marc Zyngier April 15, 2015, 2:17 p.m. UTC | #2
On 2015-04-15 12:51, Jason Cooper wrote:
> Minghuan Lian,
>
> On Wed, Apr 15, 2015 at 05:49:22PM +0800, Minghuan Lian wrote:
>> The default page size of ITS table has been changed to 64KB,
>> but for some platforms the real size of allocate memory which
>> calculated by DEVBITS of register GITS_TYPER may smaller than
>> default size. In this case, psz must be decreased, otherwise,
>> the wrong page number will cause kernel hang.
>>
>> Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com>
>> ---
>>  drivers/irqchip/irq-gic-v3-its.c | 3 +++
>>  1 file changed, 3 insertions(+)
>
> Please run scripts/get_maintainer.pl on your patches before sending.  
> This
> needs to be sent to myself and Thomas Gleixner for review.

Please also CC me on anything that touches GICv3 or the ITS code.

Thanks,

         M.
Marc Zyngier April 15, 2015, 4:31 p.m. UTC | #3
On Wed, 15 Apr 2015 17:49:22 +0800
Minghuan Lian <Minghuan.Lian@freescale.com> wrote:

[adding Jason and Thomas to the party, since they shoud be cc'd the
first place]

> The default page size of ITS table has been changed to 64KB,
> but for some platforms the real size of allocate memory which
> calculated by DEVBITS of register GITS_TYPER may smaller than
> default size. In this case, psz must be decreased, otherwise,
> the wrong page number will cause kernel hang.
> 
> Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com>
> ---
>  drivers/irqchip/irq-gic-v3-its.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
> index 596b0a9..d0374a6 100644
> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -844,6 +844,9 @@ static int its_alloc_tables(struct its_node *its)
>  
>  		its->tables[i] = base;
>  
> +		while (alloc_size < psz)
> +			psz = psz >> 1;
> +
>  retry_baser:
>  		val = (virt_to_phys(base) 				 |
>  		       (type << GITS_BASER_TYPE_SHIFT)			 |

This doesn't make sense to me. psz is the page size that your HW
supports, not necessarily something that you can actually change as you
wish (some, if not most, ITSs only support one page size). Also, you
now have to psz go via unsupported page sizes (like 32K and 8K), and
you may end up programming junk in the registers. Good job! ;-)

So making it vary to accommodate your allocation size is slightly
doomed. If your allocation is smaller than your ITS page size, it is
the allocation that has to be bumped up, not the page size that has to
be reduced.

So overall, this is a NAK. Please come up with a better fix.

Thanks,

	M.
Minghuan Lian April 16, 2015, 1:15 a.m. UTC | #4
Hi Marc,

OK, I will follow your comment.

Thanks,
Minghuan

> -----Original Message-----
> From: Marc Zyngier [mailto:marc.zyngier@arm.com]
> Sent: Wednesday, April 15, 2015 10:17 PM
> To: Jason Cooper; Lian Minghuan-B31939
> Cc: Arnd Bergmann; linux-pci@vger.kernel.org; Hu Mingkai-B21284; Zang
> Roy-R61911; Yoder Stuart-B08248; Wood Scott-B07421; Bjorn Helgaas; linux-
> arm-kernel@lists.infradead.org
> Subject: Re: [PATCH] irqchip/gicv3-its: Decrease page size when needed
> 
> On 2015-04-15 12:51, Jason Cooper wrote:
> > Minghuan Lian,
> >
> > On Wed, Apr 15, 2015 at 05:49:22PM +0800, Minghuan Lian wrote:
> >> The default page size of ITS table has been changed to 64KB, but for
> >> some platforms the real size of allocate memory which calculated by
> >> DEVBITS of register GITS_TYPER may smaller than default size. In this
> >> case, psz must be decreased, otherwise, the wrong page number will
> >> cause kernel hang.
> >>
> >> Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com>
> >> ---
> >>  drivers/irqchip/irq-gic-v3-its.c | 3 +++
> >>  1 file changed, 3 insertions(+)
> >
> > Please run scripts/get_maintainer.pl on your patches before sending.
> > This
> > needs to be sent to myself and Thomas Gleixner for review.
> 
> Please also CC me on anything that touches GICv3 or the ITS code.
> 
> Thanks,
> 
>          M.
> --
> Fast, cheap, reliable. Pick two.
diff mbox

Patch

diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 596b0a9..d0374a6 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -844,6 +844,9 @@  static int its_alloc_tables(struct its_node *its)
 
 		its->tables[i] = base;
 
+		while (alloc_size < psz)
+			psz = psz >> 1;
+
 retry_baser:
 		val = (virt_to_phys(base) 				 |
 		       (type << GITS_BASER_TYPE_SHIFT)			 |