lkml.org 
[lkml]   [2008]   [Aug]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [PATCH 21/25] serial: change remove NR_IRQS in 8250.c v2
    Alan Cox <alan@lxorguk.ukuu.org.uk> writes:

    >> 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.
    >
    > Like this (again not yet tested)
    >
    > 8250: Remove NR_IRQ usage
    >
    > From: Alan Cox <alan@redhat.com>

    I think we've just about got it.

    > /*
    > * Here we define the default xmit fifo size used for each type of UART.
    > @@ -1541,9 +1545,32 @@ static void serial_do_unlink(struct irq_info *i, struct
    > uart_8250_port *up)
    >
    > static int serial_link_irq_chain(struct uart_8250_port *up)
    > {
    > - struct irq_info *i = irq_lists + up->port.irq;
    > + struct hlist_head *h;
    > + struct hlist_node *n;
    > + struct irq_info *i;
    > int ret, irq_flags = up->port.flags & UPF_SHARE_IRQ ? IRQF_SHARED : 0;
    >
    > + mutex_lock(&hash_mutex);
    > +
    > + h = &irq_lists[up->port.irq % NR_IRQ_HASH];
    > +
    > + hlist_for_each(n, h) {
    > + i = hlist_entry(n, struct irq_info, node);
    > + if (i->irq == up->port.irq)
    > + break;
    > + }
    > +
    > + if (n == NULL) {
    > + i = kzalloc(sizeof(struct irq_info), GFP_KERNEL);
    > + if (i == NULL) {
    > + mutex_unlock(&hash_mutex);
    > + return -ENOMEM;
    > + }
    > + spin_lock_init(&i->lock);
    > + hlist_add_head(&i->node, h);
    > + }
    > + mutex_unlock(&hash_mutex);
    > +
    > spin_lock_irq(&i->lock);
    >
    > if (i->head) {

    Note there is also an error path that calls serial_do_unlink in serial_link_irq_chain.
    That we might want to free the entry in. Do we want move hash table entry freeing
    into serial_do_unlink or duplicate it here?

    Eric


    \
     
     \ /
      Last update: 2008-08-04 20:57    [W:0.026 / U:2.072 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site