From: Franco Fichtner <franco@marian.de>
To: Franco Fichtner <franco@marian.de>,
jeff@garzik.org, netdev@vger.kernel.org, linux-driver@qlogic.com
Subject: Re: [PATCH 5/8] [RFC] qlge: Add main source module qlge_main.c
Date: Fri, 12 Sep 2008 10:15:36 +0200 [thread overview]
Message-ID: <48CA2528.2010201@marian.de> (raw)
In-Reply-To: <20080912005837.GB23939@susedev.qlogic.org>
Hi Ron,
Thanks for the clarification. 4000 lines of code are just too much to
grasp at the first glance. :)
> Regarding ql_wait_idx_reg() and ql_wait_addr_reg() they provide waiting
> while gaining access for read/writes to/from a secondary set of
> registers.
These registers are once per hardware, right? Then your spinlocking
would do nothing on single CPU systems, because it won't get into the
binaries. Meaning: your registers are NOT protected the way you would
have hoped. And even with SMP systems... if another CPU hits a locked
spinlock it does nothing but wait, quite synchronously to your mdelay()
loop. So both scenarios are rather suboptimal. If that's how things are,
you're better off using a semaphore.
On non-SMP systems, you're gonna put another access on the waiting list
by using a semaphore, which in return will give you time to finish your
operations on the registers and free the semaphore. And, last but not
least, SMP systems will do work they otherwise would not be able to do.
There is just the slight problem of ql_wait_idx_reg() and
ql_wait_addr_reg() being executed from interrupt context? If that is the
case, then you can't use the standard semaphores, because sleeping isn't
allowed. I do hope that is not the case...
> To my understanding, you can't sleep while holding a
> spinlock. I tried this before and saw massive warnings. I have
> "Spinlock debugging: sleep-inside-spinlock checking" turned on in my
> kernel and perhaps that's why I saw them.
You'd normally use spinlocks in interrupt context where you just have to
make sure no other CPU mangles with your variables or hardware registers
the fastest way possible. You don't keep a spinlock forever, not even
for the course of a few function calls, which will make the code harder
to read, thus harder to understand, and thus harder to debug.
The warning messages are right, but (I think) they are intended to avoid
deadlocks as early as possible. Though, with msleep() I don't think
you'll get into any more serious problems than before, because unless
the Kernel is really not doing what it should, you should always get
back to your loop. Using schedule() and wait queues in spinlocked
scenarios is a whole other thing. (Anyone, please correct me if I'm wrong.)
> At that point I changed from msleep to mdelay.
> After reviewing your comments I've reduced and standardized the mdelay
> wait to 5ms with a count of 50.
It may help introduce defines to get rid of magic numbers inside the
code as well. Something like:
#define QLGE_TIMEOUT_COUNT 50
#define QLGE_TIMEOUT_DELAY 5
That will help maintaining code and makes it more easily readable (and
consistent as a bonus... less lines to update).
> These secondary registers are
> accessed only during open(), reset(), and a few
> netdev-API like set_multi and add_vlan_vid.
Okay, I see. But still, I get the vibe that this is already a bit too
much to justify keeping the current way of locking in the code. Sooner
or later someone else will complain about this. ;)
Franco
next prev parent reply other threads:[~2008-09-12 8:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-10 20:58 [PATCH 0/8][RFC] qlge: New Qlogic 10Gb Ethernet Driver for 2.6.28 Ron Mercer
2008-09-10 20:58 ` [PATCH 1/8] [RFC] qlge: Add license file LICENSE.qlge Ron Mercer
2008-09-10 20:58 ` [PATCH 2/8] [RFC] qlge: Additions to driver/net/Makefile and Kconfig Ron Mercer
2008-09-10 20:58 ` [PATCH 3/8] [RFC] qlge: Added drivers/net/qlge/Makefile Ron Mercer
2008-09-10 20:58 ` [PATCH 4/8] [RFC] qlge: Add main header file qlge.h Ron Mercer
2008-09-10 20:58 ` [PATCH 5/8] [RFC] qlge: Add main source module qlge_main.c Ron Mercer
2008-09-11 8:39 ` Franco Fichtner
2008-09-12 0:58 ` Ron Mercer
2008-09-12 8:15 ` Franco Fichtner [this message]
2008-09-15 18:28 ` Ron Mercer
2008-09-10 20:59 ` [PATCH 6/8] [RFC] qlge: Add mgmt port xface file qlge_mpi.c Ron Mercer
2008-09-11 8:03 ` Franco Fichtner
2008-09-11 19:06 ` Ron Mercer
2008-09-10 20:59 ` [PATCH 7/8] [RFC] qlge: Add ethtool module qlge_ethtool.c Ron Mercer
2008-09-10 20:59 ` [PATCH 8/8] [RFC] qlge: Add debug module qlge_dbg.c Ron Mercer
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=48CA2528.2010201@marian.de \
--to=franco@marian.de \
--cc=jeff@garzik.org \
--cc=linux-driver@qlogic.com \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).