From: Andrew Morton <akpm@osdl.org>
To: Li Shaohua <shaohua.li@intel.com>
Cc: linux-kernel@vger.kernel.org, Jeff Garzik <jgarzik@pobox.com>
Subject: Re: hotplug e1000 failed after 32 times
Date: Thu, 16 Sep 2004 22:14:06 -0700 [thread overview]
Message-ID: <20040916221406.1f3764e0.akpm@osdl.org> (raw)
In-Reply-To: <1095396793.10407.9.camel@sli10-desk.sh.intel.com>
Li Shaohua <shaohua.li@intel.com> wrote:
>
> I'm testing a hotplug driver. In my test, I will hot add/remove an e1000
> NIC frequently. The result is my hot add failed after 32 times hotadd.
> After looking at the code of e1000 driver, I found
> e1000_adapter->bd_number has maxium limitation of 32, and it increased
> one every hot add. Looks like the remove driver routine didn't free the
> 'bd_number', so hot add failed after 32 times. Below patch fixes this
> issue.
Yeah. I think you'll find that damn near every net driver in the kernel
has this problem. I think it would be better to create a little suite of
library functions in net/core/dev.c to handle this situation.
Maybe something like
struct net_boards {
struct idr idr;
int max_boards;
}
void net_boards_init(struct net_boards *net_boards, int max_boards);
int net_board_alloc(struct net_boards *net_boards);
int net_boards_free(struct net_boards *net_boards, int board_no);
(I wonder where the locking should be performed?)
This is a pretty thin wrapper around the idr code and actually is quite
generic and has nothing to do with networking so you might end up deciding
to rename things and to move the code into idr.c
> - adapter->bd_number = cards_found;
> + adapter->bd_number = e1000_alloc_bd_number();;
Extra semicolon.
> + TxDescriptors[bd_number] =
> + RxDescriptors[bd_number] =
> + Speed[bd_number] =
> + Duplex[bd_number] =
> + AutoNeg[bd_number] =
> + FlowControl[bd_number] =
> + XsumRX[bd_number] =
> + TxIntDelay[bd_number] =
> + TxAbsIntDelay[bd_number] =
> + RxIntDelay[bd_number] =
> + RxAbsIntDelay[bd_number] =
> + InterruptThrottleRate[bd_number] = OPTION_UNSET;
Unpopular coding style. Please just do
RxAbsIntDelay[bd_number] = OPTION_UNSET;
InterruptThrottleRate[bd_number] = OPTION_UNSET;
etc.
next prev parent reply other threads:[~2004-09-17 5:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-17 4:53 Li Shaohua
2004-09-17 5:14 ` Andrew Morton [this message]
2004-09-17 5:48 ` Li Shaohua
2004-09-17 9:05 ` Li Shaohua
2004-09-17 23:19 ` Andrew Morton
2004-09-17 23:34 ` Jeff Garzik
2004-09-19 16:04 ` Jonathan Lundell
2004-09-19 16:50 ` Dr. David Alan Gilbert
2004-09-20 0:30 ` Jonathan Lundell
2004-09-20 0:51 ` Li Shaohua
2004-09-20 2:55 ` Jeff Garzik
2004-09-20 4:15 ` Chris Leech
2004-09-20 4:35 ` Li Shaohua
2004-09-17 9:06 ` Li Shaohua
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=20040916221406.1f3764e0.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=jgarzik@pobox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=shaohua.li@intel.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
all inboxes | Powered by JetHome®