Re: [PATCH 21/25] serial: change remove NR_IRQS in 8250.c v2

From: Eric W. Biederman
Date: Sun Aug 03 2008 - 16:03:21 EST


Alan Cox <alan@xxxxxxxxxxxxxxxxxxx> writes:

> On Sat, 2 Aug 2008 19:59:21 -0700
> Yinghai Lu <yhlu.kernel@xxxxxxxxx> wrote:
>
>> use small array with index to handle irq locking for serial port
>> hope 32 slot is enough
>
>
> Untested alternative approach

I like it.

Good catch on the m68k serial driver.


> 8250: Remove NR_IRQ usage
>
> From: Alan Cox <alan@xxxxxxxxxx>

Now to pick a few nits ;)

You are short a definition of NR_IRQ_HASH that is trivial.

>
> drivers/serial/68328serial.c | 11 ++---------
> drivers/serial/8250.c | 41 ++++++++++++++++++++++++++++++++++-------
> 2 files changed, 36 insertions(+), 16 deletions(-)


> diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
> index a97f1ae..7165e88 100644
> --- a/drivers/serial/8250.c
> +++ b/drivers/serial/8250.c
> @@ -145,11 +145,14 @@ struct uart_8250_port {
> };
>
> struct irq_info {
> - spinlock_t lock;
> + struct irq_info *next;
struct hlist_node hchain;
Would allow us to use the generic hash table code.
> + int irq;
> + spinlock_t lock; /* Protects list not the hash */
> struct list_head *head;
> };
>
> -static struct irq_info irq_lists[NR_IRQS];
> +static struct irq_info *irq_lists[NR_IRQ_HASH];
> +static DEFINE_SPINLOCK(hash_lock); /* Used to walk the hash */
static DEFINE_MUTEX(hash_mutex);

kzalloc sleeps....

Looks like we can also tweak serial_do_unlink to free irq_info when
the list goes empty, so we don't have a leak if the driver is ever
unloaded.

Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/