Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Dec 2019 12:01:18 -0800
From:      Ravi Pokala <rpokala@freebsd.org>
To:        Warner Losh <imp@FreeBSD.org>, <src-committers@freebsd.org>, <svn-src-all@freebsd.org>, <svn-src-head@freebsd.org>
Subject:   Re: svn commit: r355727 - in head: share/man/man9 sys/arm/broadcom/bcm2835 sys/arm/freescale/imx sys/arm/mv sys/arm/ti sys/dev/glxiic sys/dev/ichsmb sys/dev/ow sys/kern sys/sys
Message-ID:  <A26A33EF-B705-48C7-994F-1898CD0E3C5D@panasas.com>
In-Reply-To: <201912131939.xBDJdYaB070758@repo.freebsd.org>
References:  <201912131939.xBDJdYaB070758@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Warner,

This change takes a bunch of cases of

> config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev);
> return (0)

And replaces them with a *mix* of:

> return (bus_delayed_attach_children(dev));

and

> bus_delayed_attach_children(dev);
> return (0)

Why the two different idioms?

Thanks,

Ravi (rpokala@)

=EF=BB=BF-----Original Message-----
From: <owner-src-committers@freebsd.org> on behalf of Warner Losh <imp@Free=
BSD.org>
Date: 2019-12-13, Friday at 11:39
To: <src-committers@freebsd.org>, <svn-src-all@freebsd.org>, <svn-src-head@=
freebsd.org>
Subject: svn commit: r355727 - in head: share/man/man9 sys/arm/broadcom/bcm=
2835 sys/arm/freescale/imx sys/arm/mv sys/arm/ti sys/dev/glxiic sys/dev/ichs=
mb sys/dev/ow sys/kern sys/sys

    Author: imp
    Date: Fri Dec 13 19:39:33 2019
    New Revision: 355727
    URL: https://svnweb.freebsd.org/changeset/base/355727
   =20
    Log:
      Create new wrapper function: bus_delayed_attach_children()
     =20
      Delay the attachment of children, when requested, until after interru=
tps are
      running. This is often needed to allow children to run transactions o=
n i2c or
      spi busses. It's a common enough idiom that it will be useful to have=
 its own
      wrapper.
     =20
      Reviewed by: ian
      Differential Revision: https://reviews.freebsd.org/D21465
   =20
    Added:
      head/share/man/man9/bus_delayed_attach_children.9   (contents, props =
changed)
    Modified:
      head/share/man/man9/Makefile
      head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
      head/sys/arm/freescale/imx/imx_i2c.c
      head/sys/arm/freescale/imx/imx_spi.c
      head/sys/arm/mv/a37x0_spi.c
      head/sys/arm/mv/mv_spi.c
      head/sys/arm/ti/ti_i2c.c
      head/sys/dev/glxiic/glxiic.c
      head/sys/dev/ichsmb/ichsmb.c
      head/sys/dev/ow/owc_gpiobus.c
      head/sys/kern/subr_bus.c
      head/sys/sys/bus.h
   =20
    Modified: head/share/man/man9/Makefile
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
    --- head/share/man/man9/Makefile	Fri Dec 13 19:27:51 2019	(r355726)
    +++ head/share/man/man9/Makefile	Fri Dec 13 19:39:33 2019	(r355727)
    @@ -34,6 +34,7 @@ MAN=3D	accept_filter.9 \
     	BUS_CHILD_DELETED.9 \
     	BUS_CHILD_DETACHED.9 \
     	BUS_CONFIG_INTR.9 \
    +	bus_delayed_attach_children.9 \
     	BUS_DESCRIBE_INTR.9 \
     	bus_dma.9 \
     	bus_generic_attach.9 \
   =20
    Added: head/share/man/man9/bus_delayed_attach_children.9
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
    --- /dev/null	00:00:00 1970	(empty, because file is newly added)
    +++ head/share/man/man9/bus_delayed_attach_children.9	Fri Dec 13 19:39:=
33 2019	(r355727)
    @@ -0,0 +1,55 @@
    +.\" -*- nroff -*-
    +.\"
    +.\" Copyright (c) 2019 M. Warner Losh
    +.\"
    +.\" Redistribution and use in source and binary forms, with or without
    +.\" modification, are permitted provided that the following conditions
    +.\" are met:
    +.\" 1. Redistributions of source code must retain the above copyright
    +.\"    notice, this list of conditions and the following disclaimer.
    +.\" 2. Redistributions in binary form must reproduce the above copyrig=
ht
    +.\"    notice, this list of conditions and the following disclaimer in=
 the
    +.\"    documentation and/or other materials provided with the distribu=
tion.
    +.\"
    +.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPR=
ESS OR
    +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAR=
RANTIES
    +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLA=
IMED.
    +.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIREC=
T,
    +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDIN=
G, BUT
    +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS =
OF USE,
    +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON =
ANY
    +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TOR=
T
    +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE =
USE OF
    +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    +.\"
    +.\" $FreeBSD$
    +.\"
    +.Dd August 29, 2019
    +.Dt BUS_DELAYED_ATTACH_CHILDREN 9
    +.Os
    +.Sh NAME
    +.Nm bus_delayed_attach_children
    +.Nd "request that the children be attached when interrupts are enabled=
"
    +.Sh SYNOPSIS
    +.In sys/param.h
    +.In sys/bus.h
    +.Pp
    +.Ft int
    +.Fn bus_delayed_attach_children "device_t dev"
    +.Sh DESCRIPTION
    +The
    +.Fn bus_delayed_attach_children
    +function requests that the children of this device
    +be attached when interrupts are running.
    +If interrupts are currently running, this happens immediately.
    +If interrupts aren't yet running, this happens after interrupts are en=
abled, but
    +before the system mounts root.
    +.Sh RETURN VALUES
    +A zero return value indicates success.
    +.Sh SEE ALSO
    +.Xr bus 9 ,
    +.Xr device 9 ,
    +.Xr driver 9
    +.Sh AUTHORS
    +This manual page was written by
    +.An Warner Losh Aq Mt imp@FreeBSD.org .
   =20
    Modified: head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
    --- head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c	Fri Dec 13 19:27:51 201=
9	(r355726)
    +++ head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c	Fri Dec 13 19:39:33 201=
9	(r355727)
    @@ -347,7 +347,7 @@ bcm_bsc_attach(device_t dev)
     	}
    =20
     	/* Probe and attach the iicbus when interrupts are available. */
    -	config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev);
    +	bus_delayed_attach_children(dev);
    =20
     	return (0);
     }
   =20
    Modified: head/sys/arm/freescale/imx/imx_i2c.c
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
    --- head/sys/arm/freescale/imx/imx_i2c.c	Fri Dec 13 19:27:51 2019	(r355=
726)
    +++ head/sys/arm/freescale/imx/imx_i2c.c	Fri Dec 13 19:39:33 2019	(r355=
727)
    @@ -449,8 +449,7 @@ no_recovery:
     	/* We don't do a hardware reset here because iicbus_attach() does it.=
 */
    =20
     	/* Probe and attach the iicbus when interrupts are available. */
    -	config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev);
    -	return (0);
    +	return (bus_delayed_attach_children(dev));
     }
    =20
     static int
   =20
    Modified: head/sys/arm/freescale/imx/imx_spi.c
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
    --- head/sys/arm/freescale/imx/imx_spi.c	Fri Dec 13 19:27:51 2019	(r355=
726)
    +++ head/sys/arm/freescale/imx/imx_spi.c	Fri Dec 13 19:39:33 2019	(r355=
727)
    @@ -566,9 +566,7 @@ spi_attach(device_t dev)
     	 * their attach. We can't do IO until timers and interrupts are worki=
ng.
     	 */
     	sc->spibus =3D device_add_child(dev, "spibus", -1);
    -	config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev);
    -
    -	return (0);
    +	return (bus_delayed_attach_children(dev));
     }
    =20
     static int
   =20
    Modified: head/sys/arm/mv/a37x0_spi.c
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
    --- head/sys/arm/mv/a37x0_spi.c	Fri Dec 13 19:27:51 2019	(r355726)
    +++ head/sys/arm/mv/a37x0_spi.c	Fri Dec 13 19:39:33 2019	(r355727)
    @@ -220,7 +220,7 @@ a37x0_spi_attach(device_t dev)
     	device_add_child(dev, "spibus", -1);
    =20
     	/* Probe and attach the spibus when interrupts are available. */
    -	config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev);
    +	bus_delayed_attach_children(dev);
    =20
     	return (0);
     }
   =20
    Modified: head/sys/arm/mv/mv_spi.c
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
    --- head/sys/arm/mv/mv_spi.c	Fri Dec 13 19:27:51 2019	(r355726)
    +++ head/sys/arm/mv/mv_spi.c	Fri Dec 13 19:39:33 2019	(r355727)
    @@ -174,9 +174,7 @@ mv_spi_attach(device_t dev)
     	device_add_child(dev, "spibus", -1);
    =20
     	/* Probe and attach the spibus when interrupts are available. */
    -	config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev);
    -
    -	return (0);
    +	return (bus_delayed_attach_children(dev));
     }
    =20
     static int
   =20
    Modified: head/sys/arm/ti/ti_i2c.c
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
    --- head/sys/arm/ti/ti_i2c.c	Fri Dec 13 19:27:51 2019	(r355726)
    +++ head/sys/arm/ti/ti_i2c.c	Fri Dec 13 19:39:33 2019	(r355727)
    @@ -905,7 +905,7 @@ ti_i2c_attach(device_t dev)
     	}
    =20
     	/* Probe and attach the iicbus when interrupts are available. */
    -	config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev);
    +	err =3D bus_delayed_attach_children(dev);
    =20
     out:
     	if (err) {
   =20
    Modified: head/sys/dev/glxiic/glxiic.c
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
    --- head/sys/dev/glxiic/glxiic.c	Fri Dec 13 19:27:51 2019	(r355726)
    +++ head/sys/dev/glxiic/glxiic.c	Fri Dec 13 19:39:33 2019	(r355727)
    @@ -411,8 +411,7 @@ glxiic_attach(device_t dev)
     	glxiic_smb_enable(sc, IIC_FASTEST, 0);
    =20
     	/* Probe and attach the iicbus when interrupts are available. */
    -	config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev);
    -	error =3D 0;
    +	error =3D bus_delayed_attach_children(dev);
    =20
     out:
     	if (error !=3D 0) {
   =20
    Modified: head/sys/dev/ichsmb/ichsmb.c
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
    --- head/sys/dev/ichsmb/ichsmb.c	Fri Dec 13 19:27:51 2019	(r355726)
    +++ head/sys/dev/ichsmb/ichsmb.c	Fri Dec 13 19:39:33 2019	(r355727)
    @@ -131,11 +131,8 @@ ichsmb_attach(device_t dev)
     		goto fail;
     	}
    =20
    -	/* Probe and attach the smbus when interrupts are available */
    -	config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev);
    -
    -	return (0);
    -
    +	/* Attach children when interrupts are available */
    +	return (bus_delayed_attach_children(dev));
     fail:
     	mtx_destroy(&sc->mutex);
     	return (error);
   =20
    Modified: head/sys/dev/ow/owc_gpiobus.c
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
    --- head/sys/dev/ow/owc_gpiobus.c	Fri Dec 13 19:27:51 2019	(r355726)
    +++ head/sys/dev/ow/owc_gpiobus.c	Fri Dec 13 19:39:33 2019	(r355727)
    @@ -131,7 +131,7 @@ owc_gpiobus_attach(device_t dev)
     		free(kids, M_TEMP);
     	if (nkid =3D=3D 0)
     		device_add_child(dev, "ow", -1);
    -	config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev);
    +	bus_delayed_attach_children(dev);
    =20
     	return (0);
     }
   =20
    Modified: head/sys/kern/subr_bus.c
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
    --- head/sys/kern/subr_bus.c	Fri Dec 13 19:27:51 2019	(r355726)
    +++ head/sys/kern/subr_bus.c	Fri Dec 13 19:39:33 2019	(r355727)
    @@ -3753,6 +3753,22 @@ bus_generic_attach(device_t dev)
     }
    =20
     /**
    + * @brief Helper function for delaying attaching children
    + *
    + * Many buses can't run transactions on the bus which children need to=
 probe and
    + * attach until after interrupts and/or timers are running.  This func=
tion
    + * delays their attach until interrupts and timers are enabled.
    + */
    +int
    +bus_delayed_attach_children(device_t dev)
    +{
    +	/* Probe and attach the bus children when interrupts are available */
    +	config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev);
    +
    +	return (0);
    +}
    +
    +/**
      * @brief Helper function for implementing DEVICE_DETACH()
      *
      * This function can be used to help implement the DEVICE_DETACH() for
   =20
    Modified: head/sys/sys/bus.h
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
    --- head/sys/sys/bus.h	Fri Dec 13 19:27:51 2019	(r355726)
    +++ head/sys/sys/bus.h	Fri Dec 13 19:39:33 2019	(r355727)
    @@ -567,6 +567,7 @@ int	bus_child_present(device_t child);
     int	bus_child_pnpinfo_str(device_t child, char *buf, size_t buflen);
     int	bus_child_location_str(device_t child, char *buf, size_t buflen);
     void	bus_enumerate_hinted_children(device_t bus);
    +int	bus_delayed_attach_children(device_t bus);
    =20
     static __inline struct resource *
     bus_alloc_resource_any(device_t dev, int type, int *rid, u_int flags)
   =20





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?A26A33EF-B705-48C7-994F-1898CD0E3C5D>