Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: Huacai Chen <chenhc@lemote.com>
Cc: John Crispin <john@phrozen.org>,
	"Steven J. Hill" <Steven.Hill@imgtec.com>,
	Aurelien Jarno <aurelien@aurel32.net>,
	linux-mips@linux-mips.org, Fuxin Zhang <zhangfx@lemote.com>,
	Zhangjin Wu <wuzhangjin@gmail.com>,
	Hongliang Tao <taohl@lemote.com>, Hua Yan <yanh@lemote.com>
Subject: Re: [PATCH V19 07/13] MIPS: Loongson 3: Add IRQ init and dispatch support
Date: Tue, 18 Mar 2014 15:59:11 +0100	[thread overview]
Message-ID: <20140318145911.GE17197@linux-mips.org> (raw)
In-Reply-To: <1392537690-5961-8-git-send-email-chenhc@lemote.com>

On Sun, Feb 16, 2014 at 04:01:24PM +0800, Huacai Chen wrote:

> +#define LOONGSON_HT1_INT_VECTOR_BASE	(LOONGSON_HT1_CFG_BASE + 0x80)
> +#define LOONGSON_HT1_INT_EN_BASE	(LOONGSON_HT1_CFG_BASE + 0xa0)
> +#define LOONGSON_HT1_INT_VECTOR(n)	\
> +		LOONGSON3_REG32(LOONGSON_HT1_INT_VECTOR_BASE, 4 * n)
> +#define LOONGSON_HT1_INTN_EN(n)		\
> +		LOONGSON3_REG32(LOONGSON_HT1_INT_EN_BASE, 4 * n)

Doing math on macro arguments without parenthesis is dangerous,  please
use (n) instead.

> +
> +#define LOONGSON_INT_ROUTER_OFFSET	0x1400
> +#define LOONGSON_INT_ROUTER_INTEN	\
> +	  LOONGSON3_REG32(LOONGSON3_REG_BASE, LOONGSON_INT_ROUTER_OFFSET + 0x24)
> +#define LOONGSON_INT_ROUTER_INTENSET	\
> +	  LOONGSON3_REG32(LOONGSON3_REG_BASE, LOONGSON_INT_ROUTER_OFFSET + 0x28)
> +#define LOONGSON_INT_ROUTER_INTENCLR	\
> +	  LOONGSON3_REG32(LOONGSON3_REG_BASE, LOONGSON_INT_ROUTER_OFFSET + 0x2c)
> +#define LOONGSON_INT_ROUTER_ENTRY(n)	\
> +	  LOONGSON3_REG8(LOONGSON3_REG_BASE, LOONGSON_INT_ROUTER_OFFSET + n)
> +#define LOONGSON_INT_ROUTER_LPC		LOONGSON_INT_ROUTER_ENTRY(0x0a)
> +#define LOONGSON_INT_ROUTER_HT1(n)	LOONGSON_INT_ROUTER_ENTRY(n + 0x18)

These two also.

> +static void ht_irqdispatch(void)
> +{
> +	unsigned int i, irq;
> +	unsigned int ht_irq[] = {1, 3, 4, 5, 6, 7, 8, 12, 14, 15};
> +
> +	irq = LOONGSON_HT1_INT_VECTOR(0);
> +	LOONGSON_HT1_INT_VECTOR(0) = irq; /* Acknowledge the IRQs */
> +
> +	for (i = 0; i < ARRAY_SIZE(ht_irq); i++) {
> +		if (irq & (0x1 << ht_irq[i]))
> +			do_IRQ(ht_irq[i]);
> +	}
> +}

Ouch.

Initializing an array like this in C will generate code which at runtime
initializes the ht_irq[] array each time ht_irqdispatch is invoked
and slowing this function to a crawl.

You want to make either move the definition of this array out of the
function body or make it "static const unsigned int ht_irq[] ..." to
avoid this.

  Ralf

  reply	other threads:[~2014-03-18 14:59 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-16  8:01 [PATCH V19 00/13] MIPS: Add Loongson-3 based machines support Huacai Chen
2014-02-16  8:01 ` [PATCH V19 01/13] MIPS: Loongson: Rename PRID_IMP_LOONGSON1 and PRID_IMP_LOONGSON2 Huacai Chen
2014-03-18 12:13   ` Ralf Baechle
2014-02-16  8:01 ` [PATCH V19 02/13] MIPS: Loongson: Add basic Loongson-3 definition Huacai Chen
2014-03-18 14:04   ` Ralf Baechle
2014-03-19  1:14     ` "陈华才"
2014-02-16  8:01 ` [PATCH V19 03/13] MIPS: Loongson: Add basic Loongson-3 CPU support Huacai Chen
2014-03-18 14:05   ` Ralf Baechle
2014-02-16  8:01 ` [PATCH V19 04/13] MIPS: Loongson 3: Add Lemote-3A machtypes definition Huacai Chen
2014-02-16  8:01 ` [PATCH V19 05/13] MIPS: Loongson: Add UEFI-like firmware interface (LEFI) support Huacai Chen
2014-02-16 21:12   ` Aurelien Jarno
2014-02-17  5:15     ` "陈华才"
2014-02-16  8:01 ` [PATCH V19 06/13] MIPS: Loongson 3: Add HT-linked PCI support Huacai Chen
2014-02-16  8:01 ` [PATCH V19 07/13] MIPS: Loongson 3: Add IRQ init and dispatch support Huacai Chen
2014-03-18 14:59   ` Ralf Baechle [this message]
2014-03-19  3:05     ` "陈华才"
2014-03-19 16:49       ` Ralf Baechle
2014-02-16  8:01 ` [PATCH V19 08/13] MIPS: Loongson 3: Add serial port support Huacai Chen
2014-02-16  8:01 ` [PATCH V19 09/13] MIPS: Loongson: Add swiotlb to support All-Memory DMA Huacai Chen
2014-02-16 21:12   ` Aurelien Jarno
2014-02-17  5:41     ` "陈华才"
2014-02-19 21:39       ` Aurelien Jarno
2014-02-20  1:00         ` "陈华才"
2014-02-16  8:01 ` [PATCH V19 10/13] MIPS: Loongson: Add Loongson-3 Kconfig options Huacai Chen
2014-02-16  8:01 ` [PATCH V19 11/13] MIPS: Loongson 3: Add Loongson-3 SMP support Huacai Chen
2014-03-18 15:52   ` Ralf Baechle
2014-02-16  8:01 ` [PATCH V19 12/13] MIPS: Loongson 3: Add CPU hotplug support Huacai Chen
2014-03-18 17:20   ` Ralf Baechle
2014-02-16  8:01 ` [PATCH V19 13/13] MIPS: Loongson: Add a Loongson-3 default config file Huacai Chen
2014-02-16 22:26 ` [PATCH V19 00/13] MIPS: Add Loongson-3 based machines support Andreas Barth
2014-03-06 10:30 ` Andreas Barth
2014-03-06 13:22   ` Huacai Chen
     [not found]   ` <532076A7.1040606@phrozen.org>
2014-03-12 23:31     ` Andreas Barth
2014-03-12 17:21 ` Aurelien Jarno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140318145911.GE17197@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=Steven.Hill@imgtec.com \
    --cc=aurelien@aurel32.net \
    --cc=chenhc@lemote.com \
    --cc=john@phrozen.org \
    --cc=linux-mips@linux-mips.org \
    --cc=taohl@lemote.com \
    --cc=wuzhangjin@gmail.com \
    --cc=yanh@lemote.com \
    --cc=zhangfx@lemote.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox