From gd78059@sac.sfbay.sun.com Tue Dec 22 13:22:38 2009
Received: from sunmail6brm.central.sun.com (sunmail6brm.Central.Sun.COM [129.147.4.169])
	by sac.sfbay.sun.com (8.13.8+Sun/8.13.8) with ESMTP id nBMLMcWi027921
	for <psarc-ext@sac.sfbay.sun.com>; Tue, 22 Dec 2009 13:22:38 -0800 (PST)
Received: from nwk-avmta-1.SFBay.Sun.COM (nwk-avmta-1.SFBay.Sun.COM [129.146.11.74])
	by sunmail6brm.central.sun.com (8.13.8+Sun/8.13.8/ENSMAIL,v2.4) with ESMTP id nBMLMbaL027164;
	Tue, 22 Dec 2009 15:22:37 -0600 (CST)
Received: from pmxchannel-daemon.nwk-avmta-1.sfbay.Sun.COM by
 nwk-avmta-1.sfbay.Sun.COM
 (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005))
 id <0KV200J01OPPQU00@nwk-avmta-1.sfbay.Sun.COM>; Tue,
 22 Dec 2009 13:22:37 -0800 (PST)
Received: from dm-sfbay-01.sfbay.sun.com ([129.145.155.118])
 by nwk-avmta-1.sfbay.Sun.COM
 (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005))
 with ESMTP id <0KV2004IKOPOVFA0@nwk-avmta-1.sfbay.Sun.COM>; Tue,
 22 Dec 2009 13:22:36 -0800 (PST)
Received: from sac.sfbay.sun.com (sac.SFBay.Sun.COM [129.146.226.132])
	by dm-sfbay-01.sfbay.sun.com (8.13.8+Sun/8.13.8/ENSMAIL,v2.4)
 with ESMTP id nBMLMZQx003684; Tue, 22 Dec 2009 13:22:35 -0800 (PST)
Received: from sac.sfbay.sun.com (localhost [127.0.0.1])
	by sac.sfbay.sun.com (8.13.8+Sun/8.13.8) with ESMTP id nBMLMVWh027916; Tue,
 22 Dec 2009 13:22:31 -0800 (PST)
Received: (from gd78059@localhost)
	by sac.sfbay.sun.com (8.13.8+Sun/8.13.8/Submit) id nBMLMV3H027912; Tue,
 22 Dec 2009 13:22:31 -0800 (PST)
Date: Tue, 22 Dec 2009 13:22:31 -0800 (PST)
From: "Garrett D'Amore - sun microsystems" <gd78059@sac.sfbay.sun.com>
Subject: Audio DDI Simplifications [PSARC/2009/689 FastTrack timeout 01/05/2009]
To: PSARC-ext@sun.com
Cc: audio-oss-ext@sun.com
Message-id: <200912222122.nBMLMV3H027912@sac.sfbay.sun.com>
Content-transfer-encoding: 7BIT
X-PMX-Version: 5.4.1.325704
Status: RO
Content-Length: 4773


Template Version: @(#)sac_nextcase 1.68 02/23/09 SMI
This information is Copyright 2009 Sun Microsystems
1. Introduction
    1.1. Project/Component Working Name:
	 Audio DDI Simplifications
    1.2. Name of Document Author/Supplier:
	 Author:  Garrett D'Amore
    1.3  Date of This Document:
	22 December, 2009
4. Technical Description

PROBLEM

Since Boomer (PSARC 2008/318) has integrated, we've gotten quite a bit of
experience with audio drivers.  As part of the work to move to an
interrupt-free design (PSARC 2009/674), we found that most drivers were
still retaining a fair bit of complexity simply to support to suspend/resume.
Yet, since the framework had to suspend and resume the devices properly anyway
(in order to prevent underruns) outside of the normal DDI suspend/resume
framework for devices, this complexity seemed largely redundant.


SOLUTION (SUMMARY)

We therefore have come up with some changes to the audio DDI which will
facilitate a number of changes, and another set of significant
reductions in complexity for audio device drivers.  (Indeed, in our work,
these changes allow drivers like audiots and audio810 to run completely
without any need for synchronization primitives, and with very little in
the way of explicit code to support suspend/resume.)


DETAILS

We propose to add the following two functions:

	void audio_dev_suspend(audio_dev_t *);
	void audio_dev_resume(audio_dev_t *);

The driver shall call these during DDI_SUSPEND and DDI_RESUME handling,
respectively.  The framework guarantees not to call any of the driver's
entry points (either for controls or for engines) after audio_dev_suspend()
returns, or before the driver calls audio_dev_resume().

Additionally, the framework guarantees all audio engines will be be properly
stopped during audio_dev_suspend(), and (if appropriate) restarted during
audio_dev_resume().   (This is done using the audio_engine_t's entry points.)

Furthermore, all audio controls will have their values saved and restored
by these functions, provided that they are both readable and writable.

Note that the driver must not be holding any locks while calling these
suspend/resume functions, since they will call back into the driver.

There is also a semantic requirement made of audio engines.  Specifically
it is now assumed that an audio_engine_t will perform a full reset of the
engine (including resetting the processing index in the buffer to zero).
The master count returned by audio_engine_count() must _not_, however,
be reset.  (Although it must stop incrementing between the calls to
audio_engine_stop() and audio_engine_start(), as before.)

As a consequence of these requirements, we are able to remove the exported
audio_engine_reset() interface, as drivers no longer need to call it.  (Its
action is performed implicitly by the framework as part of audio_dev_resume()
processing before the engine is restarted.)

Additionally, the framework makes the following additional guarantees:

1. Each engine's entry points will be serialized.  That is, no entry point
   for an audio_engine_t will be executed by the framework when any other
   entry point for the same audio_engine_t is active.

2. No entry point for an audio_ctrl_t on a given device (audio_dev_t)
   will be executed while any other entry points for audio_ctrl_t's on
   the same device are active.

Ultimately, this means that if a device driver has no other need for an
interrupt routine or asynchronous handling, and has separate state and
registers for each of its engines (and collectively for its controls),
the device can operate without any locks or explicit checks for suspended
state on its hot code paths.


AC'97 CHANGES

With the above, we can also remove a lot of complexity from the AC'97 code
which had explicit awareness and support for suspend/resume and concurrency.

We therefore are removing the following two functions:

	ac97_suspend()
	ac97_resume()

However, drivers which use AC'97 codecs must still perform a low-level
reinitialization of the codec during DDI_RESUME handling.  Previously
this was performed by ac97_resume().  Instead, we now require the drivers
to call ac97_reset(), which already existed.


INTERFACE TABLES

audio_dev_suspend()	Cons. Private		New function
audio_dev_resume()	 "	"		 "	"
audio_engine_reset()	REMOVED			REMOVED
ac97_suspend()		REMOVED			REMOVED
ac97_resume()		REMOVED			REMOVED
ac97_reset()		Cons. Private		No change
Synchronous guarantees	Cons. Private		New semantics
audio_engine_start()	Cons. Private		New semantics
audio_engine_stop()	Cons. Private		New semantics


6. Resources and Schedule
    6.4. Steering Committee requested information
   	6.4.1. Consolidation C-team Name:
		ON
    6.5. ARC review type: FastTrack
    6.6. ARC Exposure: open


From gdamore@sun.com Tue Dec 22 22:41:11 2009
Received: from newsunmail1brm.central.sun.com (newsunmail1brm.Central.Sun.COM [129.147.62.245])
	by sac.sfbay.sun.com (8.13.8+Sun/8.13.8) with ESMTP id nBN6fA4R019720
	for <psarc-ext@sac.sfbay.sun.com>; Tue, 22 Dec 2009 22:41:11 -0800 (PST)
Received: from nwk-avmta-2.sfbay.sun.com (nwk-avmta-2.SFBay.Sun.COM [129.145.155.6])
	by newsunmail1brm.central.sun.com (8.13.7+Sun/8.13.7/ENSMAIL,v2.4) with ESMTP id nBN6f9PT040442;
	Tue, 22 Dec 2009 23:41:10 -0700 (MST)
Received: from pmxchannel-daemon.nwk-avmta-2.sfbay.sun.com by
 nwk-avmta-2.sfbay.sun.com
 (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005))
 id <0KV300B0HEKMI600@nwk-avmta-2.sfbay.sun.com>; Tue,
 22 Dec 2009 22:41:10 -0800 (PST)
Received: from sca-es-mail-1.sun.com ([192.18.43.132])
 by nwk-avmta-2.sfbay.sun.com
 (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005))
 with ESMTP id <0KV300KOJEKLHJ90@nwk-avmta-2.sfbay.sun.com>; Tue,
 22 Dec 2009 22:41:09 -0800 (PST)
Received: from fe-sfbay-10.sun.com ([192.18.43.129])
	by sca-es-mail-1.sun.com (8.13.7+Sun/8.12.9) with ESMTP id nBN6f90H012491;
 Tue, 22 Dec 2009 22:41:09 -0800 (PST)
Received: from conversion-daemon.fe-sfbay-10.sun.com by fe-sfbay-10.sun.com
 (Sun Java(tm) System Messaging Server 7u2-7.04 64bit (built Jul  2 2009))
 id <0KV300I00EJZ1Z00@fe-sfbay-10.sun.com>; Tue,
 22 Dec 2009 22:41:09 -0800 (PST)
Received: from [192.168.251.11] ([unknown] [76.93.15.33])
 by fe-sfbay-10.sun.com
 (Sun Java(tm) System Messaging Server 7u2-7.04 64bit (built Jul  2 2009))
 with ESMTPSA id <0KV3005NAEKL3IC0@fe-sfbay-10.sun.com>; Tue,
 22 Dec 2009 22:41:09 -0800 (PST)
Date: Tue, 22 Dec 2009 22:41:09 -0800
From: "Garrett D'Amore" <gdamore@sun.com>
Subject: Re: Audio DDI Simplifications [PSARC/2009/689 FastTrack timeout
 01/05/2009]
In-reply-to: <200912222122.nBMLMV3H027912@sac.sfbay.sun.com>
Sender: Garrett.Damore@sun.com
To: "Garrett D'Amore - sun microsystems" <gd78059@sac.sfbay.sun.com>
Cc: PSARC-ext@sun.com, audio-oss-ext@sun.com
Message-id: <4B31BB85.1060404@sun.com>
MIME-version: 1.0
Content-type: text/plain; CHARSET=US-ASCII; format=flowed
Content-transfer-encoding: 7BIT
X-PMX-Version: 5.4.1.325704
References: <200912222122.nBMLMV3H027912@sac.sfbay.sun.com>
User-Agent: Thunderbird 2.0.0.23 (X11/20091013)
Status: RO
Content-Length: 5800

A few other guarantees that the audio framework makes, that I forgot to 
mention:

1) audio_engine_open() will only be called for an engine that is not 
already opened
2) audio_engine_start() will only be called for an engine that is open, 
but not started
3) audio_engine_stop() will only be called for an engine that is open, 
and started
4) audio_engine_count() will only be called for an open, started engine
5) audio_engine_close() will only be called for an engine that is open 
but not started

Basically, there is a state machine which one can pretty easily imagine 
makes sense from the above.  I won't offend your vision by trying to 
draw the state diagram here in ASCII art, but I _think_ its pretty much 
what you would expect given the above.

    - Garrett

Garrett D'Amore - sun microsystems wrote:
> Template Version: @(#)sac_nextcase 1.68 02/23/09 SMI
> This information is Copyright 2009 Sun Microsystems
> 1. Introduction
>     1.1. Project/Component Working Name:
> 	 Audio DDI Simplifications
>     1.2. Name of Document Author/Supplier:
> 	 Author:  Garrett D'Amore
>     1.3  Date of This Document:
> 	22 December, 2009
> 4. Technical Description
>
> PROBLEM
>
> Since Boomer (PSARC 2008/318) has integrated, we've gotten quite a bit of
> experience with audio drivers.  As part of the work to move to an
> interrupt-free design (PSARC 2009/674), we found that most drivers were
> still retaining a fair bit of complexity simply to support to suspend/resume.
> Yet, since the framework had to suspend and resume the devices properly anyway
> (in order to prevent underruns) outside of the normal DDI suspend/resume
> framework for devices, this complexity seemed largely redundant.
>
>
> SOLUTION (SUMMARY)
>
> We therefore have come up with some changes to the audio DDI which will
> facilitate a number of changes, and another set of significant
> reductions in complexity for audio device drivers.  (Indeed, in our work,
> these changes allow drivers like audiots and audio810 to run completely
> without any need for synchronization primitives, and with very little in
> the way of explicit code to support suspend/resume.)
>
>
> DETAILS
>
> We propose to add the following two functions:
>
> 	void audio_dev_suspend(audio_dev_t *);
> 	void audio_dev_resume(audio_dev_t *);
>
> The driver shall call these during DDI_SUSPEND and DDI_RESUME handling,
> respectively.  The framework guarantees not to call any of the driver's
> entry points (either for controls or for engines) after audio_dev_suspend()
> returns, or before the driver calls audio_dev_resume().
>
> Additionally, the framework guarantees all audio engines will be be properly
> stopped during audio_dev_suspend(), and (if appropriate) restarted during
> audio_dev_resume().   (This is done using the audio_engine_t's entry points.)
>
> Furthermore, all audio controls will have their values saved and restored
> by these functions, provided that they are both readable and writable.
>
> Note that the driver must not be holding any locks while calling these
> suspend/resume functions, since they will call back into the driver.
>
> There is also a semantic requirement made of audio engines.  Specifically
> it is now assumed that an audio_engine_t will perform a full reset of the
> engine (including resetting the processing index in the buffer to zero).
> The master count returned by audio_engine_count() must _not_, however,
> be reset.  (Although it must stop incrementing between the calls to
> audio_engine_stop() and audio_engine_start(), as before.)
>
> As a consequence of these requirements, we are able to remove the exported
> audio_engine_reset() interface, as drivers no longer need to call it.  (Its
> action is performed implicitly by the framework as part of audio_dev_resume()
> processing before the engine is restarted.)
>
> Additionally, the framework makes the following additional guarantees:
>
> 1. Each engine's entry points will be serialized.  That is, no entry point
>    for an audio_engine_t will be executed by the framework when any other
>    entry point for the same audio_engine_t is active.
>
> 2. No entry point for an audio_ctrl_t on a given device (audio_dev_t)
>    will be executed while any other entry points for audio_ctrl_t's on
>    the same device are active.
>
> Ultimately, this means that if a device driver has no other need for an
> interrupt routine or asynchronous handling, and has separate state and
> registers for each of its engines (and collectively for its controls),
> the device can operate without any locks or explicit checks for suspended
> state on its hot code paths.
>
>
> AC'97 CHANGES
>
> With the above, we can also remove a lot of complexity from the AC'97 code
> which had explicit awareness and support for suspend/resume and concurrency.
>
> We therefore are removing the following two functions:
>
> 	ac97_suspend()
> 	ac97_resume()
>
> However, drivers which use AC'97 codecs must still perform a low-level
> reinitialization of the codec during DDI_RESUME handling.  Previously
> this was performed by ac97_resume().  Instead, we now require the drivers
> to call ac97_reset(), which already existed.
>
>
> INTERFACE TABLES
>
> audio_dev_suspend()	Cons. Private		New function
> audio_dev_resume()	 "	"		 "	"
> audio_engine_reset()	REMOVED			REMOVED
> ac97_suspend()		REMOVED			REMOVED
> ac97_resume()		REMOVED			REMOVED
> ac97_reset()		Cons. Private		No change
> Synchronous guarantees	Cons. Private		New semantics
> audio_engine_start()	Cons. Private		New semantics
> audio_engine_stop()	Cons. Private		New semantics
>
>
> 6. Resources and Schedule
>     6.4. Steering Committee requested information
>    	6.4.1. Consolidation C-team Name:
> 		ON
>     6.5. ARC review type: FastTrack
>     6.6. ARC Exposure: open
>
>   


From Sebastien.Roy@sun.com Thu Jan 14 12:26:56 2010
Received: from sunmail3mpk.sfbay.sun.com (sunmail3mpk.SFBay.Sun.COM [129.146.11.52])
	by sac.sfbay.sun.com (8.13.8+Sun/8.13.8) with ESMTP id o0EKQuBn004879
	for <psarc-ext@sac.sfbay.sun.com>; Thu, 14 Jan 2010 12:26:56 -0800 (PST)
Received: from brm-avmta-1.central.sun.com (brm-avmta-1.Central.Sun.COM [129.147.4.11])
	by sunmail3mpk.sfbay.sun.com (8.13.8+Sun/8.13.8/ENSMAIL,v2.4) with ESMTP id o0EKQqDQ009191;
	Thu, 14 Jan 2010 12:26:56 -0800 (PST)
Received: from pmxchannel-daemon.brm-avmta-1.central.sun.com by
 brm-avmta-1.central.sun.com
 (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005))
 id <0KW900C177GWRO00@brm-avmta-1.central.sun.com>; Thu,
 14 Jan 2010 13:26:56 -0700 (MST)
Received: from brmea-mail-4.sun.com ([192.18.98.36])
 by brm-avmta-1.central.sun.com
 (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005))
 with ESMTP id <0KW900H0F7GVYED0@brm-avmta-1.central.sun.com>; Thu,
 14 Jan 2010 13:26:55 -0700 (MST)
Received: from fe-amer-10.sun.com ([192.18.109.80])
	by brmea-mail-4.sun.com (8.13.6+Sun/8.12.9) with ESMTP id o0EKQtta020864; Thu,
 14 Jan 2010 20:26:55 +0000 (GMT)
Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com
 (Sun Java(tm) System Messaging Server 7u2-7.04 64bit (built Jul  2 2009))
 id <0KW90030070A8D00@mail-amer.sun.com>; Thu, 14 Jan 2010 13:26:55 -0700 (MST)
Received: from [192.168.1.5] ([unknown] [173.76.16.34])
 by mail-amer.sun.com (Sun Java(tm) System Messaging Server 7u2-7.04 64bit
 (built Jul  2 2009)) with ESMTPSA id <0KW900JXG7GMMXB0@mail-amer.sun.com>; Thu,
 14 Jan 2010 13:26:46 -0700 (MST)
Date: Thu, 14 Jan 2010 15:26:45 -0500
From: Sebastien Roy <Sebastien.Roy@sun.com>
Subject: Re: Audio DDI Simplifications [PSARC/2009/689 FastTrack timeout
 01/05/2009]
In-reply-to: <200912222122.nBMLMV3H027912@sac.sfbay.sun.com>
Sender: Sebastien.Roy@sun.com
To: "Garrett D'Amore - sun microsystems" <gd78059@sac.sfbay.sun.com>
Cc: PSARC-ext@sun.com, audio-oss-ext@sun.com
Message-id: <1263500805.14312.84.camel@seb>
Organization: Sun Microsystems
MIME-version: 1.0
Content-type: text/plain; CHARSET=US-ASCII
Content-transfer-encoding: 7BIT
X-PMX-Version: 5.4.1.325704
References: <200912222122.nBMLMV3H027912@sac.sfbay.sun.com>
Status: RO
Content-Length: 9

+1
-Seb


From gdamore@sun.com Wed Jan 20 19:35:23 2010
Received: from sunmail6brm.central.sun.com (sunmail6brm.Central.Sun.COM [129.147.4.169])
	by sac.sfbay.sun.com (8.13.8+Sun/8.13.8) with ESMTP id o0L3ZNPf002536
	for <psarc-ext@sac.sfbay.sun.com>; Wed, 20 Jan 2010 19:35:23 -0800 (PST)
Received: from nwk-avmta-1.SFBay.Sun.COM (nwk-avmta-1.SFBay.Sun.COM [129.146.11.74])
	by sunmail6brm.central.sun.com (8.13.8+Sun/8.13.8/ENSMAIL,v2.4) with ESMTP id o0L3ZM7N016563
	for <@sunmail2sca.sfbay.sun.com:PSARC-ext@sun.com>; Wed, 20 Jan 2010 21:35:23 -0600 (CST)
Received: from pmxchannel-daemon.nwk-avmta-1.sfbay.Sun.COM by
 nwk-avmta-1.sfbay.Sun.COM
 (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005))
 id <0KWK00405VAYG300@nwk-avmta-1.sfbay.Sun.COM> for PSARC-ext@sun.com
 (ORCPT PSARC-ext@sun.com); Wed, 20 Jan 2010 19:35:22 -0800 (PST)
Received: from sca-es-mail-2.sun.com ([192.18.43.133])
 by nwk-avmta-1.sfbay.Sun.COM
 (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005))
 with ESMTP id <0KWK0031LVAY2L10@nwk-avmta-1.sfbay.Sun.COM> for
 PSARC-ext@sun.com (ORCPT PSARC-ext@sun.com); Wed,
 20 Jan 2010 19:35:22 -0800 (PST)
Received: from fe-sfbay-09.sun.com ([192.18.43.129])
	by sca-es-mail-2.sun.com (8.13.7+Sun/8.12.9) with ESMTP id o0L3ZMGC010100	for
 <PSARC-ext@sun.com>; Wed, 20 Jan 2010 19:35:22 -0800 (PST)
Received: from conversion-daemon.fe-sfbay-09.sun.com by fe-sfbay-09.sun.com
 (Sun Java(tm) System Messaging Server 7u2-7.04 64bit (built Jul  2 2009))
 id <0KWK00800UZSVT00@fe-sfbay-09.sun.com> for PSARC-ext@sun.com
 (ORCPT PSARC-ext@sun.com); Wed, 20 Jan 2010 19:35:22 -0800 (PST)
Received: from [192.168.251.11] ([unknown] [76.93.15.33])
 by fe-sfbay-09.sun.com
 (Sun Java(tm) System Messaging Server 7u2-7.04 64bit (built Jul  2 2009))
 with ESMTPSA id <0KWK00HJUVAYQG60@fe-sfbay-09.sun.com> for PSARC-ext@sun.com
 (ORCPT PSARC-ext@sun.com); Wed, 20 Jan 2010 19:35:22 -0800 (PST)
Date: Wed, 20 Jan 2010 19:35:21 -0800
From: "Garrett D'Amore" <gdamore@sun.com>
Subject: PSARC 2009/689 Audio DDI simplifications
Sender: Garrett.Damore@sun.com
To: PSARC-ext <PSARC-ext@sun.com>
Message-id: <4B57CB79.1030004@sun.com>
MIME-version: 1.0
Content-type: text/plain; CHARSET=US-ASCII; format=flowed
Content-transfer-encoding: 7BIT
X-PMX-Version: 5.4.1.325704
User-Agent: Thunderbird 2.0.0.23 (X11/20091013)
Status: RO
Content-Length: 55

This case was approved at PSARC today.

    - Garrett


