Commit Graph

83 Commits

Author SHA1 Message Date
mrg 90a7d6260e - check sc->dying after sleeping in several more places, and
convert it into EIO error where necessary.
- remove a wrong additional mutex_exit() call.
- make sure to check sc->dying under the device lock.
2014-12-30 07:28:34 +00:00
mrg 55e0969cef various clean ups for midi and sequencer:
midi specific:
- add reference counting for midi operations, and ensure that
  detach waits for other threads to complete before tearing
  down the device completely.
- in detach, halt midi callouts before destroying them
- re-check sc->dying after sleeping in midiread()
- in real_writebytes(), make sure we're open and not dying
- make sure we drop the interrupt lock before calling any code
  that may want to check thread locks.  this is now safe due to
  the above changes.

sequencer specific:
- avoid caching the midi softc in the sequencer softc.  instead,
  every time we want to use it, look it up again and make sure
  it still exists.


this fixes various crashes i've seen in the usb midi code when
detaching the umidi while it is active.
2014-12-22 07:02:22 +00:00
dholland f9228f4225 Add d_discard to all struct cdevsw instances I could find.
All have been set to "nodiscard"; some should get a real implementation.
2014-07-25 08:10:31 +00:00
dholland a68f9396b6 Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
2014-03-16 05:20:22 +00:00
martin 83301d9000 Quell a few "unused variable" warnings (where the variables are generated
by macros)
2013-09-14 21:02:36 +00:00
plunky 1687854c43 Tidy up a little, the way that midi attachment code works
- change midi_attach() to omit the 'parent' arg (there are
  only two callers of this and it is not used)

- change midisyn_attach() to midisyn_init(), so not needing a midi_softc,
  and fix the midi_pcppi driver to set hw_if and hw_hdl directly in
  its midi_softc before calling midi_attach()

- add a device_t to opl_softc structure, change opl drivers to store
  the device 'self' in opl_softc and fix opl_attach() to use this
  opl_softc->dev field directly rather than a field in an otherwise
  unused midi_softc

- remove unnecessary midi_softc from opl and cms drivers (child device
  provides that)

reviewed by mrg
2012-04-09 10:18:16 +00:00
plunky 490bfa094b midi_attach() does not actually ever use the parent device
pointer, so no need to store it in sc_dev. Further, remove
the sc_dev field entirely since it is easily confused with
the dev field, which is the 'self' device pointer. Fix the
comment.
2012-04-05 20:25:53 +00:00
plunky 6948556de5 move the pmf_device_register() for midi.c and midi_pcppi.c to midi_attach()
for symmetry, since it is removed in midi detach code

and don't need to call device_pmf_is_registered() before registering it
2012-04-05 20:13:34 +00:00
njoly 7da60f53d8 Call aprint_naive for quiet boot message. 2012-01-10 17:53:51 +00:00
mrg efcb2059eb set hwif_softc around midi_attach()s call to ->getinfo(), like the old
code, so that midi_register_hw_if_ext() works.  add a mutex for this
to avoid multiple midi_attach()s fighting over it.

XXX: this is an ugly interface
2011-11-24 02:54:32 +00:00
jmcneill 8a962f23f2 Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

  Add MP locking to the audio drivers.

  Making the audio drivers MP safe is necessary before efforts
  can be made to make the VM system MP safe.

  The are two locks per device instance, an ISR lock and
  a character device lock. The ISR lock replaces calls to
  splaudio()/splx(), and will be held across calls to device
  methods which were called at splaudio() before (e.g.
  trigger_output). The character device lock is held across
  calls to nearly all of the methods, excluding some only
  used for initialization, e.g. get_locks.

Welcome to 5.99.57.
2011-11-23 23:07:28 +00:00
jakllsch 5da0f05200 printf() size_t with 'z' format modifier in debug code. 2010-07-27 14:34:33 +00:00
dyoung 4075f812e7 Simplify these device-activation hooks using the following semantic
patch.

XXX sc_dying must die.

@@
type device_t;

identifier act, midi_softc, midiactivate, sc, self;
@@

int
midiactivate(device_t self, enum devact act)
{
(
	struct midi_softc *sc = device_private(self);
|
-	struct midi_softc *sc;
+	struct midi_softc *sc = device_private(self);
...
-	sc = device_private(self);
)
...
	switch (act) {
-	case DVACT_ACTIVATE:
-		return (EOPNOTSUPP);
-
	case DVACT_DEACTIVATE:
(
	sc->dying
|
	sc->sc_dying
)
		=
(
	1
|
	true
)
		;
-		break;
+		return 0;
+	default:
+		return EOPNOTSUPP;
	}
-	return (0);
}
2009-12-06 22:42:48 +00:00
jmcneill 6224dc462d I'm not so sure this is actually CPU-intensive in 2009, so don't print it. 2009-08-23 15:56:07 +00:00
dyoung 6a72962b6c Cosmetic: in a debug statement, use "%s", __func__ instead of a
misspelling of the detach routine's name.
2009-04-07 17:54:58 +00:00
cegger b22a26144d use device_lookup to get device_t 2008-06-12 22:29:41 +00:00
cegger fc8fd752ef device_private(device_lookup()) -> device_lookup_private()
ok cube@
2008-06-10 22:53:08 +00:00
ad 1498ad220e Make various bits of debug code compile again. 2008-04-30 14:07:13 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ad 6d70f903e6 Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
  be sent from a hardware interrupt handler. Signal activity must be
  deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
  and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
2008-04-24 15:35:27 +00:00
cube df77590f4c Fix fallout from midi(4)'s softc split. 2008-03-05 10:48:48 +00:00
tnn 150b74d8b7 Include sys/device.h for device_t 2008-03-05 00:45:40 +00:00
cube 14218c181b Split device_t/softc for midi(4), and other related cosmetic changes. 2008-03-04 21:56:11 +00:00
rmind c6186face4 Welcome to 4.99.55:
- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call.  It will
  indicate which event (POLL_IN, POLL_OUT, etc) happen.  If unknown,
  zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
2008-03-01 14:16:49 +00:00
christos f54e064ee9 add null pmf handlers. 2007-12-16 19:01:35 +00:00
pooka 4e38160d4d Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.
2007-12-05 17:19:46 +00:00
jmcneill 490542edae aprintify, on behalf of xtraeme 2007-12-01 23:40:28 +00:00
ad 46ed8f7d77 Use the softint API. 2007-10-08 16:18:02 +00:00
ad 88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
pavel 54cbd184a2 Correct format strings for ptrdiff_t and size_t arguments in DPRINTFs,
so that a kernel with AUDIO_DEBUG builds.
2007-06-16 10:25:03 +00:00
christos 53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
ad 9db0a17503 Defer wakeup() to the soft interrupt also. 2007-02-15 18:12:05 +00:00
ad b07ec3fc38 Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
christos 168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
thorpej 6cd7a64f41 Add __unused as necessary. 2006-10-12 04:32:34 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
christos a91b63349c add missing initializer 2006-09-02 07:04:46 +00:00
wiz bd3700fe4c Uppercase CPU. 2006-07-02 01:33:55 +00:00
chap 8576d4b377 Correct build failures when MIDI is not enabled (the idea!).
Specifically eap but no midi, which makes sense if you want sound,
and umidi but no midi, which makes little sense but shouldn't fail the
build.

Suggest changing the evbarm conf files containing umidi but #midi
to comment out umidi as well (even though this fix should let them build).
2006-07-01 15:22:06 +00:00
chap 710af63468 Ankh-Morpork, we have a MIDI driver....
Merge from chap-midi branch, after
~month for review
Comments by thorpej@ drochner@ and Alexandre Ratchov

Incorporated: points by thorpej@ drochner@; preliminary support for
a stats-collecting ioctl suggested by martin@ from comments by A.R.

PR kern/32441 kern/32442 kern/32567 kern/32588 kern/32694 kern/33590
kern/33614 and one instance of kern/32651

ok martin@
2006-06-30 13:56:25 +00:00
thorpej 39cd836ee1 Use device_unit(). 2006-03-28 17:38:24 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
ws 9d78e0cf36 PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.
2005-06-21 14:01:11 +00:00
christos 2c91ca8bd0 - add const
- avoid variable shadowing.
2005-05-29 22:18:25 +00:00
perry f31bd063e9 nuke trailing whitespace 2005-02-27 00:26:58 +00:00
yamt 18f717bb90 constify audio_hw_if, midi_hw_if, and radio_hw_if. 2004-10-29 12:57:15 +00:00
keihan b8702f530b netbsd.org -> NetBSD.org
This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean".  Thanks for the patiance, and sorry for all the commits.
2003-12-04 13:57:30 +00:00
gson 3187c34fa2 Make the raw midi device pass through received system exclusive
messages rather than discard them.
2003-11-23 01:25:59 +00:00
gson 159f73f5c9 Some possible MIDI input byte streams could cause sc->in_msg[]
to be overrun, causing a crash.
2003-11-02 11:56:36 +00:00
fvdl d5aece61d6 Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
2003-06-29 22:28:00 +00:00