Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Nov 2010 16:31:44 -0500
From:      Attilio Rao <attilio@freebsd.org>
To:        John Baldwin <jhb@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Jung-uk Kim <jkim@freebsd.org>
Subject:   Re: svn commit: r215544 - head/sys/kern
Message-ID:  <AANLkTimzP7hNYFqsYgFW4Vzuj-cOWO%2Bq9nU4vFMTJ3R=@mail.gmail.com>
In-Reply-To: <201011191621.25520.jhb@freebsd.org>
References:  <201011191943.oAJJhv3i087205@svn.freebsd.org> <201011191609.31308.jkim@FreeBSD.org> <201011191621.25520.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
2010/11/19 John Baldwin <jhb@freebsd.org>:
> On Friday, November 19, 2010 4:09:28 pm Jung-uk Kim wrote:
>> On Friday 19 November 2010 02:43 pm, Attilio Rao wrote:
>> > Author: attilio
>> > Date: Fri Nov 19 19:43:56 2010
>> > New Revision: 215544
>> > URL: http://svn.freebsd.org/changeset/base/215544
>> >
>> > Log:
>> > =C2=A0 Scan the list in reverse order for the shutdown handlers of
>> > loaded modules. This way, when there is a dependency between two
>> > modules, the handler of the latter probed runs first.
>> >
>> > =C2=A0 This is a similar approach as the modules are unloaded in the
>> > same linkerfile.
>> >
>> > =C2=A0 Sponsored by: =C2=A0 =C2=A0 Sandvine Incorporated
>> > =C2=A0 Submitted by: =C2=A0 =C2=A0 Nima Misaghian <nmisaghian at sandv=
ine dot com>
>> > =C2=A0 MFC after: =C2=A0 =C2=A0 =C2=A0 =C2=A01 week
>>
>> Hmm... =C2=A0It is not directly related but I was thinking about doing
>> similar things for sys/kern/subr_bus.c. =C2=A0What do you think about th=
e
>> attached patch?
>
> Hmm, the patches for suspend and resume that I had for this took the oppo=
site
> order, they did suspend in forward order, but resume in backwards order.
> Like so:
>
> --- //depot/vendor/freebsd/src/sys/kern/subr_bus.c =C2=A0 =C2=A0 =C2=A020=
10-11-17 22:30:24.000000000 0000
> +++ //depot/user/jhb/acpipci/kern/subr_bus.c =C2=A0 =C2=A02010-11-19 17:1=
9:02.000000000 00
> @@ -3426,9 +3429,9 @@
> =C2=A0 =C2=A0 =C2=A0 =C2=A0TAILQ_FOREACH(child, &dev->children, link) {
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0error =3D DEVICE_S=
USPEND(child);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (error) {
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 for (child2 =3D TAILQ_FIRST(&dev->children);
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0child2 && child2 !=3D child;
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0child2 =3D TAILQ_NEXT(child2, link))
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 for (child2 =3D TAILQ_PREV(child, device_list, link);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0child2 !=3D NULL;
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0child2 =3D TAILQ_PREV(child2, device_list, link)=
)
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0DEVICE_RESUME(child2);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0return (error);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> @@ -3447,7 +3450,7 @@
> =C2=A0{
> =C2=A0 =C2=A0 =C2=A0 =C2=A0device_t =C2=A0 =C2=A0 =C2=A0 =C2=A0child;
>
> - =C2=A0 =C2=A0 =C2=A0 TAILQ_FOREACH(child, &dev->children, link) {
> + =C2=A0 =C2=A0 =C2=A0 TAILQ_FOREACH_REVERSE(child, &dev->children, devic=
e_list, link) {
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0DEVICE_RESUME(chil=
d);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* if resume fails=
, there's nothing we can usefully do... */
> =C2=A0 =C2=A0 =C2=A0 =C2=A0}
>
> (Likely mangled whitespace.)
>
> I couldn't convince myself which order was "more" correct for suspend and=
 resume.

Considering loading in starting point, I think suspend should go in
reverse logic and resume in the same module load logic.
So that dependent modules are suspended first and resumed after.
Don't you agree?

Attilio


--=20
Peace can only be achieved by understanding - A. Einstein



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTimzP7hNYFqsYgFW4Vzuj-cOWO%2Bq9nU4vFMTJ3R=>