From: Jeff Garzik <jeff@garzik.org>
To: Matthew Wilcox <matthew@wil.cx>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 3/21] advansys: Convert to pci_register_driver interface
Date: Fri, 27 Jul 2007 09:48:34 -0400 [thread overview]
Message-ID: <46A9F7B2.3090604@garzik.org> (raw)
In-Reply-To: <20070726204915.GS19275@parisc-linux.org>
Matthew Wilcox wrote:
> On Thu, Jul 26, 2007 at 03:31:21PM -0400, Jeff Garzik wrote:
>> 2) you dropped the check for pci_resource_start() returning zero (look
>> for 'iop == 0' in original code)
>
> That's not actually something that could happen through that path.
Er, huh? It's a value returned from the PCI device. Of course it can
happen on that path. That's the first time you look at the PCI BAR values.
>> 3) what happened to PCI BAR #1 ? shouldn't you move that call here too?
>> it gets ioremapped (look at 'pci_memory_address' in old code, right
>> next to pci_resource_start call)
>
> That'll move later, once I'm on the iomap path. We don't have the
> structure to stash the result in at this point.
If you follow other PCI drivers, you should check it in pci_driver::probe().
>> 4) it is often wise to add sanity checks that ensure that PCI BAR #0 ==
>> IORESOURCE_IO and PCI BAR #1 == IORESOURCE_MEM
>
> Why is that? There's no danger of advansys producing any more cards ;-)
Granted it is far less important than checking pci_resource_start()==0
and pci_resource_len()==0 -- which happens often enough to care about
it. Firmware or kernel PCI allocation routines or even PCI quirks can
affect this.
Generally this is not about new cards but about misconfiguration, or
even protection from users trying to see if adding a PCI ID works for them.
But overall, it's sane to check that the resource is memory before
passing it to ioremap, so that you catch the error at the correct time.
This is standard stuff that all PCI drivers should do.
>> 5) call pci_set_drvdata(pdev, NULL) as with other PCI drivers
>
> Why?
So that you don't leave a dangling pointer to an object that has already
been destroyed.
Again, this is standard PCI driver practice.
>> 7) bug: don't unregister, if pci_register_driver() failed during init
>
> I assumed that pci_unregister_driver handled that, for the same reason that
> kfree(NULL) works. Otherwise I have to keep track of that in the driver
> somewhere.
Well either verify your assumption or keep track of it :)
>>> + for (i = 0; i < asc_board_count; i++) {
>>> + struct Scsi_Host *host = asc_host[i];
>>> + if (!host)
>>> + continue;
>>> + scsi_remove_host(host);
>>> + advansys_release(host);
>>> + asc_host[i] = NULL;
>> this last line of code is rather pointless, isn't it?
>
> No ... see advansys_interrupt. Yes, that needs to be cleaned up *too*,
> but I can't fix everything at once. Eventually, the asc_host array will
> disappear.
Look at scsi_module.c: it is sane practice to have two loops for code
like this: the first loop calls scsi_remove_host() for all hosts, and
the second loop does the rest of the cleanup. IMO this is more
conservative, as you know the SCSI layer will not be passing anything to
any port on your card, when you start shutting it down. Makes it harder
to trigger races and bugs.
Of course, when everything is converted to EISA/PCI hotplug API, you
cannot do this anymore.
But I find it sane practice for older buses, especially.
Jeff
next prev parent reply other threads:[~2007-07-27 13:48 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-26 17:11 Advansys driver Matthew Wilcox
2007-07-26 17:22 ` [PATCH 1/21] advansys: Clean up proc_info implementation Matthew Wilcox
2007-07-26 18:51 ` Jeff Garzik
2007-07-26 19:05 ` Matthew Wilcox
2007-07-26 17:22 ` [PATCH 2/21] advansys: version, copyright, etc Matthew Wilcox
2007-07-26 18:56 ` Jeff Garzik
2007-07-26 19:03 ` Matthew Wilcox
2007-07-26 19:08 ` Jeff Garzik
2007-07-26 19:16 ` Matthew Wilcox
2007-07-26 19:25 ` Christer Weinigel
2007-07-26 17:22 ` [PATCH 3/21] advansys: Convert to pci_register_driver interface Matthew Wilcox
2007-07-26 19:05 ` Jeff Garzik
2007-07-26 19:31 ` Jeff Garzik
2007-07-26 20:49 ` Matthew Wilcox
2007-07-26 21:21 ` Jeff Garzik
2007-07-27 13:48 ` Jeff Garzik [this message]
2007-07-26 17:22 ` [PATCH 4/21] advansys: restructure error handling in advansys_board_found Matthew Wilcox
2007-07-26 17:22 ` [PATCH 5/21] advansys: split advansys_init_wide_chip() out of advansys_board_found() Matthew Wilcox
2007-07-26 17:22 ` [PATCH 6/21] advansys: Move to scsi hotplug initialisation model Matthew Wilcox
2007-07-26 18:01 ` Christoph Hellwig
2007-07-26 18:04 ` Matthew Wilcox
2007-07-26 18:06 ` Matthew Wilcox
2007-07-26 18:16 ` Jeff Garzik
2007-07-26 18:29 ` Matthew Wilcox
2007-07-26 18:13 ` Jeff Garzik
2007-07-26 19:19 ` Jeff Garzik
2007-07-26 17:22 ` [PATCH 7/21] advansys: Convert to EISA driver model Matthew Wilcox
2007-07-26 19:38 ` Jeff Garzik
2007-07-26 20:37 ` Matthew Wilcox
2007-07-27 13:50 ` Jeff Garzik
2007-07-27 14:16 ` Matthew Wilcox
2007-07-27 14:55 ` Jeff Garzik
2007-07-26 17:22 ` [PATCH 8/21] advansys: Rewrite resource management Matthew Wilcox
2007-07-26 19:41 ` Jeff Garzik
2007-07-26 17:22 ` [PATCH 9/21] advansys: More PCI cleanups Matthew Wilcox
2007-07-26 19:43 ` Jeff Garzik
2007-07-26 19:50 ` Matthew Wilcox
2007-07-26 19:55 ` Jeff Garzik
2007-07-26 17:22 ` [PATCH 10/21] advansys: remove AscCompareString() Matthew Wilcox
2007-07-26 17:22 ` [PATCH 11/21] Add QUANTUM XP34301 to the blacklist Matthew Wilcox
2007-07-26 17:22 ` [PATCH 12/21] advansys: remove INQUIRY sniffing Matthew Wilcox
2007-07-26 17:22 ` [PATCH 13/21] advansys: misc reformatting Matthew Wilcox
2007-07-26 17:22 ` [PATCH 14/21] advansys: delete AscGetChipBusType Matthew Wilcox
2007-07-26 17:22 ` [PATCH 15/21] advansys: ioremap no longer needs page-aligned addresses Matthew Wilcox
2007-07-26 17:22 ` [PATCH 16/21] advansys: Stop using n_io_port in Scsi_Host structure Matthew Wilcox
2007-07-26 17:22 ` [PATCH 17/21] advansys: remove detect_called Matthew Wilcox
2007-07-26 19:48 ` Jeff Garzik
2007-07-26 17:22 ` [PATCH 18/21] advansys: Move struct device out of the cfg structures Matthew Wilcox
2007-07-26 19:49 ` Jeff Garzik
2007-07-26 20:26 ` Matthew Wilcox
2007-07-26 17:22 ` [PATCH 19/21] advansys: Remove library-style callback routines Matthew Wilcox
2007-07-26 17:22 ` [PATCH 20/21] advansys: Remove pci_slot_info Matthew Wilcox
2007-07-26 17:22 ` [PATCH 21/21] advansys: use memcpy instead of open-coded loop Matthew Wilcox
2007-07-26 19:50 ` Jeff Garzik
2007-07-27 4:58 ` Matthew Wilcox
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=46A9F7B2.3090604@garzik.org \
--to=jeff@garzik.org \
--cc=linux-scsi@vger.kernel.org \
--cc=matthew@wil.cx \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.