Re: GETOSPACE in Sound DMA handler, mmap [hack patch]

Jason T. Collins (dark@ksu.edu)
Mon, 20 Apr 1998 22:09:55 -0500


This is a multi-part message in MIME format.
--------------29A72350CC61EEFC6034794E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


--------------29A72350CC61EEFC6034794E
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Message-ID: <353C0D9B.4F46213B@ksu.edu>
Date: Mon, 20 Apr 1998 22:08:11 -0500
From: "Jason T. Collins" <dark@ksu.edu>
X-Mailer: Mozilla 4.05 [en] (X11; I; Linux 2.1.97 i586)
MIME-Version: 1.0
To: "James M." <dart@ncn.net>
Subject: Re: GETOSPACE in Sound DMA handler, mmap [hack patch]
References: <3539B0B1.670BDD89@ncn.net>
Content-Type: multipart/mixed; boundary="------------D7883C0F919F55D8A44F1351"

This is a multi-part message in MIME format.
--------------D7883C0F919F55D8A44F1351
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

James M. wrote:

> Xanim--no messages--plays perfectly-(music video from CD)
> Quake2--"Um, Can't do GETOSPACE?" -- "/dev/dsp: Bad file number" and
> "could not reset /dev/dsp"
> Play--/usr/bin/play: /dev/audio: Device or resource busy
> Cat--no messages--works
> Xplaycd--works

I've already posted this, but I'm going to do it again in hopes that
someone on the Linux sound/mm people will answer my question below:

This is due to a little change in the ioctl for SNDCTL_DSP_GETOSPACE
that makes it impossible to use the function when memory mapped DMA
buffers are in use (like Quake 2 uses). You can discover this from
using strace, but Quake2 doesn't exactly handle the error with the
greatest of ease.

To fix it, you can apply the attached patch to drivers/sound/audio.c.
This patch worked as recently as 2.1.95, on 2.1.97 now I am getting mmap
errors when trying to map the DMA buffer, which is a different but
possibly related problem.

My question is this: why was this condition added? Until recently it
didn't seem to do anything except break Quake 2. Now Quake 2 is
breaking on my machine on the mmap call to allocate the sound buffer:

mmap(0 ,65536, PROT_WRITE, MAP_SHARED, 5, 0) = -1 -EIO (Input/output
error)

Any ideas, anyone?

Jason T. Collins
--------------D7883C0F919F55D8A44F1351
Content-Type: text/plain; charset=us-ascii; name="audio.c.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="audio.c.diff"

*** audio.c.orig Mon Apr 20 22:00:03 1998
--- audio.c Fri Apr 17 22:00:33 1998
***************
*** 731,737 ****
if (cmd == SNDCTL_DSP_GETISPACE && audio_devs[dev]->flags & DMA_DUPLEX)
dmap = dmap_in;
if (dmap->mapping_flags & DMA_MAP_MAPPED)
! return -EINVAL;
if (!(dmap->flags & DMA_ALLOC_DONE))
reorganize_buffers(dev, dmap, (cmd == SNDCTL_DSP_GETISPACE));
info.fragstotal = dmap->nbufs;
--- 731,738 ----
if (cmd == SNDCTL_DSP_GETISPACE && audio_devs[dev]->flags & DMA_DUPLEX)
dmap = dmap_in;
if (dmap->mapping_flags & DMA_MAP_MAPPED)
! printk(KERN_DEBUG "GETOSPACE: DMA_MAP_MAPPED set\n");
! /*return -EINVAL;*/
if (!(dmap->flags & DMA_ALLOC_DONE))
reorganize_buffers(dev, dmap, (cmd == SNDCTL_DSP_GETISPACE));
info.fragstotal = dmap->nbufs;

--------------D7883C0F919F55D8A44F1351--

--------------29A72350CC61EEFC6034794E--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu