tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: drvctl rescan for atabus



On Fri, Oct 02, 2009 at 09:29:31PM +0000, Jonathan A. Kollasch wrote:
> Hi,
> 
> I'm interested in feedback on and testing of a patch that implements
> rescaning of atabus.  A patch should be attached.
> 
> Usage is rather straightforward:
> 
> detach:
> drvctl -d (wdX|atapibusX)
> 
> rescan/reattach:
> drvctl -r -a ata_hl atabusX

This is a good start.

It looks to me as if one has to detach all devices attached at atabusX
before re-attaching any single device:

> +static int
> +atabus_rescan(device_t self, const char *ifattr, const int *locators)
> +{
> +     struct atabus_softc *sc = device_private(self);
> +     struct ata_channel *chp = sc->sc_chan;
> +     struct atabus_initq *initq;
> +     int i;
> +     int s;
> +
> +     /* fail if there's anything attached already */
> +
> +     if (chp->atapibus != NULL)
> +             return EBUSY;
> +
> +     for (i = 0; i < ATA_MAXDRIVES; i++) {
> +             if (chp->ata_drives[i] != NULL)
> +                     return EBUSY;
> +     }

I think the reason is that you use atabusconfig() to re-probe the bus
and attach the devices:

> @@ -384,6 +385,10 @@
>               if (chp->ch_flags & ATACH_SHUTDOWN) {
>                       break;
>               }
> +             if (chp->ch_flags & ATACH_TH_RESCAN) {
> +                     atabusconfig(sc);
> +                     chp->ch_flags &= ~ATACH_TH_RESCAN;
> +             }
>               if (chp->ch_flags & ATACH_TH_RESET) {
>                       /*
>                        * ata_reset_channel() will freeze 2 times, so

atabusconfig() assumes that neither drives nor an atapibus are attached.
I think that if you check in atabusconfig() whether there is a non-NULL
device_t at chp->atapibus or at chp->ata_drives[i] before trying to
attach a driver, then you can do without the EBUSY's above.

I think that in your drvctl(8) example above, the kernel will not convey
the interface attribute, "ata_hl", to atabusconfig().

Dave

-- 
David Young             OJC Technologies
dyoung%ojctech.com@localhost      Urbana, IL * (217) 278-3933


Home | Main Index | Thread Index | Old Index