Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Oct 2009 09:53:16 +0200
From:      Hans Petter Selasky <hselasky@c2i.net>
To:        freebsd-current@freebsd.org
Subject:   Re: [PATCH] Fix for USB media not found at boot
Message-ID:  <200910030953.17359.hselasky@c2i.net>
In-Reply-To: <20091002150931.K35591@pooker.samsco.org>
References:  <20091002150931.K35591@pooker.samsco.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 02 October 2009 23:11:21 Scott Long wrote:
> All,
>
> I have a candidate patch to fix the problem with USB boot media not being
> found in time at boot, leading to the "mountroot" prompt instead of a
> booting system.  Please apply both patches below and let me know if it
> works for you.

Hi,

Your patch looks OK. Some checkpoints however:

Does your patch work if ehci/ohci/uhci is kldloaded after system startup?

Does your patch work if CAM is not in the kernel?

I have a simple imporovement to your patch:

I would just add a synchronously blocking call to the end of "usb_bus_attach".

Something like:

#ifdef USB_HAVE_CAM
static void
usb_cam_wait_cb(void *arg)
{
	struct usb_bus *bus = *(struct usb_bus **)arg;

    USB_BUS_LOCK(bus);
    *(struct usb_bus **)arg = NULL;
	wakeup(arg);
    USB_BUS_UNLOCK(bus);
}

static void
usb_wait_cam(struct usb_bus *bus)
{
    struct intr_config_hook *hook;
    void *temp = bus;
    hook = malloc(sizeof(*hook), M_TEMP, M_ZERO);
    hook->ich_func = usb_wait_cam_cb;
    hook->ich_arg = &temp;

	config_intrhook_establish(hook);

    USB_BUS_LOCK(bus);
    if (temp != NULL)
		mtx_sleep(&temp, &bus->bus_mtx, 0, "WCAM", 0);
    USB_BUS_UNLOCK(bus);
}
#endif

That way makes the code more simple and avoids a race with the CAM callback 
being called after that the hardware is detached. For example if the Host 
Controller resides on a removable device.

There are some more USB_HAVE_XXX in sys/dev/usb/usb_freebsd.h .

--HPS




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200910030953.17359.hselasky>