PERFORCE change 47817 for review
Robert Watson
rwatson at FreeBSD.org
Sat Feb 28 11:56:56 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=47817
Change 47817 by rwatson at rwatson_tislabs on 2004/02/28 11:56:32
Integrate netperf_socket forward a little more, to loop back
ip_input.c formatting changes.
Affected files ...
.. //depot/projects/netperf_socket/sys/dev/ata/ata-all.h#3 integrate
.. //depot/projects/netperf_socket/sys/dev/ata/ata-queue.c#3 integrate
.. //depot/projects/netperf_socket/sys/dev/ips/ips.c#4 integrate
.. //depot/projects/netperf_socket/sys/dev/ips/ips.h#2 integrate
.. //depot/projects/netperf_socket/sys/dev/ips/ips_commands.c#2 integrate
.. //depot/projects/netperf_socket/sys/dev/ips/ips_disk.c#3 integrate
.. //depot/projects/netperf_socket/sys/dev/ips/ips_pci.c#2 integrate
.. //depot/projects/netperf_socket/sys/dev/sound/pcm/channel.c#3 integrate
.. //depot/projects/netperf_socket/sys/dev/sound/pcm/channel.h#3 integrate
.. //depot/projects/netperf_socket/sys/dev/sound/pcm/dsp.c#3 integrate
.. //depot/projects/netperf_socket/sys/dev/sound/pcm/sound.c#3 integrate
.. //depot/projects/netperf_socket/sys/dev/sound/pcm/sound.h#3 integrate
.. //depot/projects/netperf_socket/sys/modules/acpi/acpi/Makefile#2 integrate
.. //depot/projects/netperf_socket/sys/netinet/ip_input.c#6 integrate
Differences ...
==== //depot/projects/netperf_socket/sys/dev/ata/ata-all.h#3 (text+ko) ====
@@ -25,7 +25,7 @@
* (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: src/sys/dev/ata/ata-all.h,v 1.73 2004/01/29 15:03:01 sos Exp $
+ * $FreeBSD: src/sys/dev/ata/ata-all.h,v 1.74 2004/02/28 17:47:27 sos Exp $
*/
/* ATA register defines */
@@ -156,6 +156,28 @@
#define ATA_OP_CONTINUES 0
#define ATA_OP_FINISHED 1
+/* ATAPI request sense structure */
+struct atapi_sense {
+ u_int8_t error_code :7; /* current or deferred errors */
+ u_int8_t valid :1; /* follows ATAPI spec */
+ u_int8_t segment; /* Segment number */
+ u_int8_t sense_key :4; /* sense key */
+ u_int8_t reserved2_4 :1; /* reserved */
+ u_int8_t ili :1; /* incorrect length indicator */
+ u_int8_t eom :1; /* end of medium */
+ u_int8_t filemark :1; /* filemark */
+ u_int32_t cmd_info __packed; /* cmd information */
+ u_int8_t sense_length; /* additional sense len (n-7) */
+ u_int32_t cmd_specific_info __packed; /* additional cmd spec info */
+ u_int8_t asc; /* additional sense code */
+ u_int8_t ascq; /* additional sense code qual */
+ u_int8_t replaceable_unit_code; /* replaceable unit code */
+ u_int8_t sk_specific :7; /* sense key specific */
+ u_int8_t sksv :1; /* sense key specific info OK */
+ u_int8_t sk_specific1; /* sense key specific */
+ u_int8_t sk_specific2; /* sense key specific */
+};
+
struct ata_request {
struct ata_device *device; /* ptr to device softc */
void *driver; /* driver specific */
@@ -169,6 +191,8 @@
} ata;
struct {
u_int8_t ccb[16]; /* ATAPI command block */
+ u_int8_t sense_key; /* ATAPI request sense key */
+ struct atapi_sense sense_data; /* ATAPI request sense data */
} atapi;
} u;
@@ -333,28 +357,6 @@
void *running; /* currently running request */
};
-/* ATAPI request sense structure */
-struct atapi_sense {
- u_int8_t error_code :7; /* current or deferred errors */
- u_int8_t valid :1; /* follows ATAPI spec */
- u_int8_t segment; /* Segment number */
- u_int8_t sense_key :4; /* sense key */
- u_int8_t reserved2_4 :1; /* reserved */
- u_int8_t ili :1; /* incorrect length indicator */
- u_int8_t eom :1; /* end of medium */
- u_int8_t filemark :1; /* filemark */
- u_int32_t cmd_info __packed; /* cmd information */
- u_int8_t sense_length; /* additional sense len (n-7) */
- u_int32_t cmd_specific_info __packed; /* additional cmd spec info */
- u_int8_t asc; /* additional sense code */
- u_int8_t ascq; /* additional sense code qual */
- u_int8_t replaceable_unit_code; /* replaceable unit code */
- u_int8_t sk_specific :7; /* sense key specific */
- u_int8_t sksv :1; /* sense key specific info OK */
- u_int8_t sk_specific1; /* sense key specific */
- u_int8_t sk_specific2; /* sense key specific */
-};
-
/* disk bay/enclosure related */
#define ATA_LED_OFF 0x00
#define ATA_LED_RED 0x01
==== //depot/projects/netperf_socket/sys/dev/ata/ata-queue.c#3 (text+ko) ====
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ata/ata-queue.c,v 1.21 2004/02/17 19:24:11 sos Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ata/ata-queue.c,v 1.22 2004/02/28 17:47:27 sos Exp $");
#include "opt_ata.h"
#include <sys/param.h>
@@ -131,15 +131,14 @@
int count, int flags, int timeout)
{
struct ata_request *request = ata_alloc_request();
- int packet_size, error = ENOMEM;
+ int error = ENOMEM;
if (request) {
+ request->device = atadev;
if ((atadev->param->config & ATA_PROTO_MASK) == ATA_PROTO_ATAPI_12)
- packet_size = 12;
+ bcopy(ccb, request->u.atapi.ccb, 12);
else
- packet_size = 16;
- request->device = atadev;
- bcopy(ccb, request->u.atapi.ccb, packet_size);
+ bcopy(ccb, request->u.atapi.ccb, 16);
request->data = data;
request->bytecount = count;
request->transfersize = min(request->bytecount, 65534);
@@ -332,43 +331,70 @@
if (request->result)
break;
- if (request->error) {
- switch ((request->error & ATA_SK_MASK)) {
- case ATA_SK_RECOVERED_ERROR:
- ata_prtdev(request->device, "WARNING - %s recovered error\n",
- ata_cmd2str(request));
- /* FALLTHROUGH */
+ /* if we have a sensekey -> request sense from device */
+ if (request->error & ATA_SK_MASK &&
+ request->u.atapi.ccb[0] != ATAPI_REQUEST_SENSE) {
+ static u_int8_t ccb[16] = { ATAPI_REQUEST_SENSE, 0, 0, 0,
+ sizeof(struct atapi_sense),
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+ bcopy(ccb, request->u.atapi.ccb, 16);
+ request->u.atapi.sense_key = request->error;
+ request->data = (caddr_t)&request->u.atapi.sense_data;
+ request->bytecount = sizeof(struct atapi_sense);
+ request->transfersize = sizeof(struct atapi_sense);
+ request->timeout = 5;
+ request->flags =
+ ATA_R_ATAPI | ATA_R_READ | ATA_R_IMMEDIATE | ATA_R_REQUEUE;
+ ata_queue_request(request);
+ return;
+ }
+
+ switch (request->u.atapi.sense_key & ATA_SK_MASK) {
+ case ATA_SK_RECOVERED_ERROR:
+ ata_prtdev(request->device, "WARNING - %s recovered error\n",
+ ata_cmd2str(request));
+ /* FALLTHROUGH */
+
+ case ATA_SK_NO_SENSE:
+ request->result = 0;
+ break;
- case ATA_SK_NO_SENSE:
- request->result = 0;
- break;
+ case ATA_SK_NOT_READY:
+ request->result = EBUSY;
+ break;
- case ATA_SK_NOT_READY:
- request->result = EBUSY;
- break;
+ case ATA_SK_UNIT_ATTENTION:
+ request->device->flags |= ATA_D_MEDIA_CHANGED;
+ request->result = EIO;
+ break;
- case ATA_SK_UNIT_ATTENTION:
- request->device->flags |= ATA_D_MEDIA_CHANGED;
- request->result = EIO;
+ default:
+ request->result = EIO;
+ if (request->flags & ATA_R_QUIET)
break;
- default:
- if (!(request->flags & ATA_R_QUIET))
- ata_prtdev(request->device,
- "FAILURE - %s status=%b sensekey=%s error=%b\n",
- ata_cmd2str(request),
- request->status, "\20\10BUSY\7READY\6DMA"
- "\5DSC\4DRQ\3CORRECTABLE\2INDEX\1ERROR",
- ata_skey2str((request->error & ATA_SK_MASK)>>4),
- (request->error & ATA_E_MASK),
- "\20\4MEDIA_CHANGE_REQUEST\3ABORTED"
- "\2NO_MEDIA\1ILLEGAL_LENGTH");
- request->result = EIO;
- }
- if (request->error & ATA_E_MASK)
- request->result = EIO;
+ ata_prtdev(request->device,
+ "FAILURE - %s %s asc=0x%02x ascq=0x%02x ",
+ ata_cmd2str(request), ata_skey2str(
+ (request->u.atapi.sense_key & ATA_SK_MASK) >> 4),
+ request->u.atapi.sense_data.asc,
+ request->u.atapi.sense_data.ascq);
+ if (request->u.atapi.sense_data.sksv)
+ printf("sks=0x%02x 0x%02x 0x%02x ",
+ request->u.atapi.sense_data.sk_specific,
+ request->u.atapi.sense_data.sk_specific1,
+ request->u.atapi.sense_data.sk_specific2);
+ printf("status=%b error=%b\n",
+ request->status, "\20\10BUSY\7READY\6DMA"
+ "\5DSC\4DRQ\3CORRECTABLE\2INDEX\1ERROR",
+ (request->error & ATA_E_MASK),
+ "\20\4MEDIA_CHANGE_REQUEST\3ABORTED"
+ "\2NO_MEDIA\1ILLEGAL_LENGTH");
}
- break;
+
+ if (request->error & ATA_E_MASK)
+ request->result = EIO;
}
ATA_DEBUG_RQ(request, "completed callback/wakeup");
==== //depot/projects/netperf_socket/sys/dev/ips/ips.c#4 (text+ko) ====
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ips/ips.c,v 1.10 2004/02/21 21:10:43 phk Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ips/ips.c,v 1.11 2004/02/28 19:14:41 scottl Exp $");
#include <dev/ips/ips.h>
#include <sys/stat.h>
@@ -102,16 +102,23 @@
static __inline__ int ips_cmdqueue_free(ips_softc_t *sc)
{
int i, error = -1;
- intrmask_t mask = splbio();
+ ips_command_t *command;
+ intrmask_t mask;
+
+ mask = splbio();
if(!sc->used_commands){
for(i = 0; i < sc->max_cmds; i++){
- if(!(sc->commandarray[i].command_phys_addr))
+
+ command = &sc->commandarray[i];
+ sema_destroy(&command->cmd_sema);
+
+ if(command->command_phys_addr == 0)
continue;
bus_dmamap_unload(sc->command_dmatag,
- sc->commandarray[i].command_dmamap);
+ command->command_dmamap);
bus_dmamem_free(sc->command_dmatag,
- sc->commandarray[i].command_buffer,
- sc->commandarray[i].command_dmamap);
+ command->command_buffer,
+ command->command_dmamap);
}
error = 0;
sc->state |= IPS_OFFLINE;
@@ -129,13 +136,10 @@
SLIST_INIT(&sc->free_cmd_list);
STAILQ_INIT(&sc->cmd_wait_list);
for(i = 0; i < sc->max_cmds; i++){
- sc->commandarray[i].id = i;
- sc->commandarray[i].sc = sc;
- SLIST_INSERT_HEAD(&sc->free_cmd_list, &sc->commandarray[i],
- next);
- }
- for(i = 0; i < sc->max_cmds; i++){
command = &sc->commandarray[i];
+ command->id = i;
+ command->sc = sc;
+
if(bus_dmamem_alloc(sc->command_dmatag,&command->command_buffer,
BUS_DMA_NOWAIT, &command->command_dmamap))
goto error;
@@ -147,12 +151,15 @@
command->command_buffer, command->command_dmamap);
goto error;
}
+
+ sema_init(&command->cmd_sema, 0, "IPS Command Semaphore");
+ SLIST_INSERT_HEAD(&sc->free_cmd_list, command, next);
}
sc->state &= ~IPS_OFFLINE;
return 0;
error:
- ips_cmdqueue_free(sc);
- return ENOMEM;
+ ips_cmdqueue_free(sc);
+ return ENOMEM;
}
static int ips_add_waiting_command(ips_softc_t *sc, int (*callback)(ips_command_t *), void *data, unsigned long flags)
@@ -254,6 +261,10 @@
{
intrmask_t mask;
mask = splbio();
+
+ if (sema_value(&command->cmd_sema) != 0)
+ panic("ips: command returned non-zero semaphore");
+
SLIST_INSERT_HEAD(&sc->free_cmd_list, command, next);
(sc->used_commands)--;
splx(mask);
@@ -375,6 +386,7 @@
{
int i;
DEVICE_PRINTF(1,sc->dev, "initializing\n");
+
if (bus_dma_tag_create( /* parent */ sc->adapter_dmatag,
/* alignemnt */ 1,
/* boundary */ 0,
@@ -420,8 +432,6 @@
if(sc->ips_adapter_reinit(sc, 0))
goto error;
- mtx_init(&sc->cmd_mtx, "ips command mutex", NULL, MTX_DEF);
-
/* initialize ffdc values */
microtime(&sc->ffdc_resettime);
sc->ffdc_resetcount = 1;
@@ -534,8 +544,6 @@
mask = splbio();
untimeout(ips_timeout, sc, sc->timer);
splx(mask);
- if (mtx_initialized(&sc->cmd_mtx))
- mtx_destroy(&sc->cmd_mtx);
if(sc->sg_dmatag)
bus_dma_tag_destroy(sc->sg_dmatag);
==== //depot/projects/netperf_socket/sys/dev/ips/ips.h#2 (text+ko) ====
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/dev/ips/ips.h,v 1.5 2003/11/27 08:37:36 mbr Exp $
+ * $FreeBSD: src/sys/dev/ips/ips.h,v 1.6 2004/02/28 19:14:41 scottl Exp $
*/
@@ -39,6 +39,7 @@
#include <sys/bio.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
+#include <sys/sema.h>
#include <sys/time.h>
#include <machine/bus_memio.h>
@@ -376,6 +377,7 @@
bus_dmamap_t command_dmamap;
void * command_buffer;
u_int32_t command_phys_addr;/*WARNING! must be changed if 64bit addressing ever used*/
+ struct sema cmd_sema;
ips_cmd_status_t status;
SLIST_ENTRY(ips_command) next;
bus_dma_tag_t data_dmatag;
@@ -427,7 +429,9 @@
void (* ips_adapter_intr)(void *sc);
void (* ips_issue_cmd)(ips_command_t *command);
ips_copper_queue_t * copper_queue;
- struct mtx cmd_mtx;
+ struct mtx queue_mtx;
+ struct bio_queue_head queue;
+
}ips_softc_t;
/* function defines from ips_ioctl.c */
@@ -438,7 +442,7 @@
/* function defines from ips_commands.c */
extern int ips_flush_cache(ips_softc_t *sc);
-extern void ips_start_io_request(ips_softc_t *sc, struct bio *iobuf);
+extern void ips_start_io_request(ips_softc_t *sc);
extern int ips_get_drive_info(ips_softc_t *sc);
extern int ips_get_adapter_info(ips_softc_t *sc);
extern int ips_ffdc_reset(ips_softc_t *sc);
==== //depot/projects/netperf_socket/sys/dev/ips/ips_commands.c#2 (text+ko) ====
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ips/ips_commands.c,v 1.8 2004/01/01 10:22:10 mbr Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ips/ips_commands.c,v 1.9 2004/02/28 19:14:41 scottl Exp $");
#include <dev/ips/ips.h>
@@ -44,9 +44,7 @@
status->value = command->status.value;
bus_dmamap_sync(command->sc->command_dmatag, command->command_dmamap,
BUS_DMASYNC_POSTWRITE);
- mtx_lock(&command->sc->cmd_mtx);
- wakeup(status);
- mtx_unlock(&command->sc->cmd_mtx);
+ sema_post(&command->cmd_sema);
}
/* Below are a series of functions for sending an IO request
* to the adapter. The flow order is: start, send, callback, finish.
@@ -163,15 +161,24 @@
return 0;
}
-void ips_start_io_request(ips_softc_t *sc, struct bio *iobuf)
+void ips_start_io_request(ips_softc_t *sc)
{
- if(ips_get_free_cmd(sc, ips_send_io_request, iobuf, 0)){
- device_printf(sc->dev, "no mem for command slots!\n");
- iobuf->bio_flags |= BIO_ERROR;
- iobuf->bio_error = ENOMEM;
- ipsd_finish(iobuf);
+ struct bio *iobuf;
+
+ mtx_lock(&sc->queue_mtx);
+ iobuf = bioq_first(&sc->queue);
+ if(!iobuf) {
+ mtx_unlock(&sc->queue_mtx);
+ return;
+ }
+
+ if(ips_get_free_cmd(sc, ips_send_io_request, iobuf, IPS_NOWAIT_FLAG)){
+ mtx_unlock(&sc->queue_mtx);
return;
}
+
+ bioq_remove(&sc->queue, iobuf);
+ mtx_unlock(&sc->queue_mtx);
return;
}
@@ -236,15 +243,13 @@
goto exit;
}
command->callback = ips_wakeup_callback;
- mtx_lock(&sc->cmd_mtx);
bus_dmamap_load(command->data_dmatag, command->data_dmamap,
command->data_buffer,IPS_ADAPTER_INFO_LEN,
ips_adapter_info_callback, command, BUS_DMA_NOWAIT);
if ((status->value == IPS_ERROR_STATUS) ||
- (msleep(status, &sc->cmd_mtx, 0, "ips", 30*hz) == EWOULDBLOCK))
+ (sema_timedwait(&command->cmd_sema, 30*hz) == 0))
error = ETIMEDOUT;
- mtx_unlock(&sc->cmd_mtx);
if (error == 0) {
bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
@@ -343,14 +348,12 @@
goto exit;
}
command->callback = ips_wakeup_callback;
- mtx_lock(&sc->cmd_mtx);
bus_dmamap_load(command->data_dmatag, command->data_dmamap,
command->data_buffer,IPS_DRIVE_INFO_LEN,
ips_drive_info_callback, command, BUS_DMA_NOWAIT);
if ((status->value == IPS_ERROR_STATUS) ||
- (msleep(status, &sc->cmd_mtx, 0, "ips", 10*hz) == EWOULDBLOCK))
+ (sema_timedwait(&command->cmd_sema, 10*hz) == 0))
error = ETIMEDOUT;
- mtx_unlock(&sc->cmd_mtx);
if (error == 0) {
bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
@@ -406,11 +409,9 @@
command_struct->id = command->id;
bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
BUS_DMASYNC_PREWRITE);
- mtx_lock(&sc->cmd_mtx);
sc->ips_issue_cmd(command);
if (status->value != IPS_ERROR_STATUS)
- msleep(status, &sc->cmd_mtx, 0, "flush2", 0);
- mtx_unlock(&sc->cmd_mtx);
+ sema_wait(&command->cmd_sema);
ips_insert_free_cmd(sc, command);
return 0;
}
@@ -494,11 +495,9 @@
bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
BUS_DMASYNC_PREWRITE);
- mtx_lock(&sc->cmd_mtx);
sc->ips_issue_cmd(command);
if (status->value != IPS_ERROR_STATUS)
- msleep(status, &sc->cmd_mtx, 0, "ffdc", 0);
- mtx_unlock(&sc->cmd_mtx);
+ sema_wait(&command->cmd_sema);
ips_insert_free_cmd(sc, command);
return 0;
}
@@ -603,14 +602,12 @@
goto exit;
}
command->callback = ips_write_nvram;
- mtx_lock(&sc->cmd_mtx);
bus_dmamap_load(command->data_dmatag, command->data_dmamap,
command->data_buffer,IPS_NVRAM_PAGE_SIZE,
ips_read_nvram_callback, command, BUS_DMA_NOWAIT);
if ((status->value == IPS_ERROR_STATUS) ||
- (msleep(status, &sc->cmd_mtx, 0, "ips", 0) == EWOULDBLOCK))
+ (sema_timedwait(&command->cmd_sema, 30*hz) == 0))
error = ETIMEDOUT;
- mtx_unlock(&sc->cmd_mtx);
if (error == 0) {
bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
@@ -661,11 +658,9 @@
command_struct->reserve2 = IPS_POCL;
bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
BUS_DMASYNC_PREWRITE);
- mtx_lock(&sc->cmd_mtx);
sc->ips_issue_cmd(command);
if (status->value != IPS_ERROR_STATUS)
- msleep(status, &sc->cmd_mtx, 0, "ipssyn", 0);
- mtx_unlock(&sc->cmd_mtx);
+ sema_wait(&command->cmd_sema);
ips_insert_free_cmd(sc, command);
return 0;
}
@@ -684,11 +679,9 @@
command_struct->reserve2 = IPS_CSL;
bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
BUS_DMASYNC_PREWRITE);
- mtx_lock(&sc->cmd_mtx);
sc->ips_issue_cmd(command);
if (status->value != IPS_ERROR_STATUS)
- msleep(status, &sc->cmd_mtx, 0, "ipsetc", 0);
- mtx_unlock(&sc->cmd_mtx);
+ sema_wait(&command->cmd_sema);
ips_insert_free_cmd(sc, command);
return 0;
}
==== //depot/projects/netperf_socket/sys/dev/ips/ips_disk.c#3 (text+ko) ====
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ips/ips_disk.c,v 1.5 2004/02/18 21:36:52 phk Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ips/ips_disk.c,v 1.6 2004/02/28 19:14:41 scottl Exp $");
#include <dev/ips/ips.h>
#include <dev/ips/ips_disk.h>
@@ -79,6 +79,9 @@
/* ipsd_finish is called to clean up and return a completed IO request */
void ipsd_finish(struct bio *iobuf)
{
+ ipsdisk_softc_t *dsc;
+ dsc = iobuf->bio_disk->d_drv1;
+
if (iobuf->bio_flags & BIO_ERROR) {
ipsdisk_softc_t *dsc;
dsc = iobuf->bio_disk->d_drv1;
@@ -87,6 +90,7 @@
iobuf->bio_resid = 0;
biodone(iobuf);
+ ips_start_io_request(dsc->sc);
}
@@ -97,7 +101,10 @@
dsc = iobuf->bio_disk->d_drv1;
DEVICE_PRINTF(8,dsc->dev,"in strategy\n");
iobuf->bio_driver1 = (void *)(uintptr_t)dsc->sc->drives[dsc->disk_number].drivenum;
- ips_start_io_request(dsc->sc, iobuf);
+ mtx_lock(&dsc->sc->queue_mtx);
+ bioq_disksort(&dsc->sc->queue, iobuf);
+ mtx_unlock(&dsc->sc->queue_mtx);
+ ips_start_io_request(dsc->sc);
}
static int ipsd_probe(device_t dev)
@@ -161,4 +168,3 @@
disk_destroy(dsc->ipsd_disk);
return 0;
}
-
==== //depot/projects/netperf_socket/sys/dev/ips/ips_pci.c#2 (text+ko) ====
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ips/ips_pci.c,v 1.7 2003/09/11 23:30:28 ps Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ips/ips_pci.c,v 1.8 2004/02/28 19:14:41 scottl Exp $");
#include <dev/ips/ips.h>
@@ -135,6 +135,8 @@
}
sc->ips_ich.ich_func = ips_intrhook;
sc->ips_ich.ich_arg = sc;
+ mtx_init(&sc->queue_mtx, "IPS bioqueue lock", MTX_DEF, 0);
+ bioq_init(&sc->queue);
if (config_intrhook_establish(&sc->ips_ich) != 0) {
printf("IPS can't establish configuration hook\n");
goto error;
@@ -182,7 +184,7 @@
if(ips_adapter_free(sc))
return EBUSY;
ips_pci_free(sc);
- mtx_destroy(&sc->cmd_mtx);
+ bioq_flush(&sc->queue, NULL, ENXIO);
}
return 0;
}
==== //depot/projects/netperf_socket/sys/dev/sound/pcm/channel.c#3 (text+ko) ====
@@ -29,7 +29,7 @@
#include "feeder_if.h"
-SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pcm/channel.c,v 1.96 2004/02/20 01:24:57 matk Exp $");
+SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pcm/channel.c,v 1.97 2004/02/28 19:47:02 truckman Exp $");
#define MIN_CHUNK_SIZE 256 /* for uiomove etc. */
#define DMA_ALIGN_THRESHOLD 4
@@ -69,10 +69,20 @@
static void
chn_lockinit(struct pcm_channel *c, int dir)
{
- if (dir == PCMDIR_PLAY)
- c->lock = snd_chnmtxcreate(c->name, "pcm play channel");
- else
- c->lock = snd_chnmtxcreate(c->name, "pcm record channel");
+ switch(dir) {
+ case PCMDIR_PLAY:
+ c->lock = snd_mtxcreate(c->name, "pcm play channel");
+ break;
+ case PCMDIR_REC:
+ c->lock = snd_mtxcreate(c->name, "pcm record channel");
+ break;
+ case PCMDIR_VIRTUAL:
+ c->lock = snd_mtxcreate(c->name, "pcm virtual play channel");
+ break;
+ case 0:
+ c->lock = snd_mtxcreate(c->name, "pcm fake channel");
+ break;
+ }
}
static void
@@ -746,7 +756,7 @@
}
int
-chn_init(struct pcm_channel *c, void *devinfo, int dir)
+chn_init(struct pcm_channel *c, void *devinfo, int dir, int direction)
{
struct feeder_class *fc;
struct snd_dbuf *b, *bs;
@@ -791,7 +801,7 @@
ret = ENODEV;
CHN_UNLOCK(c); /* XXX - Unlock for CHANNEL_INIT() malloc() call */
- c->devinfo = CHANNEL_INIT(c->methods, devinfo, b, c, dir);
+ c->devinfo = CHANNEL_INIT(c->methods, devinfo, b, c, direction);
CHN_LOCK(c);
if (c->devinfo == NULL)
goto out;
@@ -800,7 +810,7 @@
if ((sndbuf_getsize(b) == 0) && ((c->flags & CHN_F_VIRTUAL) == 0))
goto out;
- ret = chn_setdir(c, dir);
+ ret = chn_setdir(c, direction);
if (ret)
goto out;
==== //depot/projects/netperf_socket/sys/dev/sound/pcm/channel.h#3 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/dev/sound/pcm/channel.h,v 1.29 2004/01/28 08:02:15 truckman Exp $
+ * $FreeBSD: src/sys/dev/sound/pcm/channel.h,v 1.30 2004/02/28 19:47:02 truckman Exp $
*/
struct pcmchan_children {
@@ -76,7 +76,7 @@
int chn_flush(struct pcm_channel *c);
int chn_poll(struct pcm_channel *c, int ev, struct thread *td);
-int chn_init(struct pcm_channel *c, void *devinfo, int dir);
+int chn_init(struct pcm_channel *c, void *devinfo, int dir, int direction);
int chn_kill(struct pcm_channel *c);
int chn_setdir(struct pcm_channel *c, int dir);
int chn_reset(struct pcm_channel *c, u_int32_t fmt);
==== //depot/projects/netperf_socket/sys/dev/sound/pcm/dsp.c#3 (text+ko) ====
@@ -29,7 +29,7 @@
#include <dev/sound/pcm/sound.h>
-SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pcm/dsp.c,v 1.73 2004/02/21 21:10:47 phk Exp $");
+SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pcm/dsp.c,v 1.74 2004/02/28 19:42:48 truckman Exp $");
#define OLDPCM_IOCTL
@@ -444,7 +444,7 @@
static int
dsp_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td)
{
- struct pcm_channel *wrch, *rdch;
+ struct pcm_channel *chn, *rdch, *wrch;
struct snddev_info *d;
intrmask_t s;
int kill;
@@ -477,22 +477,19 @@
if (kill & 2)
rdch = NULL;
- if (rdch != NULL)
- CHN_LOCK(rdch);
- if (wrch != NULL)
- CHN_LOCK(wrch);
-
switch(cmd) {
#ifdef OLDPCM_IOCTL
/*
* we start with the new ioctl interface.
*/
case AIONWRITE: /* how many bytes can write ? */
+ CHN_LOCK(wrch);
/*
if (wrch && wrch->bufhard.dl)
while (chn_wrfeed(wrch) == 0);
*/
*arg_i = wrch? sndbuf_getfree(wrch->bufsoft) : 0;
+ CHN_UNLOCK(wrch);
break;
case AIOSSIZE: /* set the current blocksize */
@@ -502,12 +499,16 @@
p->play_size = 0;
p->rec_size = 0;
if (wrch) {
+ CHN_LOCK(wrch);
chn_setblocksize(wrch, 2, p->play_size);
p->play_size = sndbuf_getblksz(wrch->bufsoft);
+ CHN_UNLOCK(wrch);
}
if (rdch) {
+ CHN_LOCK(rdch);
chn_setblocksize(rdch, 2, p->rec_size);
p->rec_size = sndbuf_getblksz(rdch->bufsoft);
+ CHN_UNLOCK(rdch);
}
}
break;
@@ -515,37 +516,51 @@
{
struct snd_size *p = (struct snd_size *)arg;
- if (wrch)
+ if (wrch) {
+ CHN_LOCK(wrch);
p->play_size = sndbuf_getblksz(wrch->bufsoft);
- if (rdch)
+ CHN_UNLOCK(wrch);
+ }
+ if (rdch) {
+ CHN_LOCK(rdch);
p->rec_size = sndbuf_getblksz(rdch->bufsoft);
+ CHN_UNLOCK(rdch);
+ }
}
break;
case AIOSFMT:
+ case AIOGFMT:
{
snd_chan_param *p = (snd_chan_param *)arg;
if (wrch) {
- chn_setformat(wrch, p->play_format);
- chn_setspeed(wrch, p->play_rate);
+ CHN_LOCK(wrch);
+ if (cmd == AIOSFMT) {
+ chn_setformat(wrch, p->play_format);
+ chn_setspeed(wrch, p->play_rate);
+ }
+ p->play_rate = wrch->speed;
+ p->play_format = wrch->format;
+ CHN_UNLOCK(wrch);
+ } else {
+ p->play_rate = 0;
+ p->play_format = 0;
}
if (rdch) {
- chn_setformat(rdch, p->rec_format);
- chn_setspeed(rdch, p->rec_rate);
+ CHN_LOCK(rdch);
+ if (cmd == AIOSFMT) {
+ chn_setformat(rdch, p->rec_format);
+ chn_setspeed(rdch, p->rec_rate);
+ }
+ p->rec_rate = rdch->speed;
+ p->rec_format = rdch->format;
+ CHN_UNLOCK(rdch);
+ } else {
+ p->rec_rate = 0;
+ p->rec_format = 0;
}
}
- /* FALLTHROUGH */
-
- case AIOGFMT:
- {
- snd_chan_param *p = (snd_chan_param *)arg;
-
- p->play_rate = wrch? wrch->speed : 0;
- p->rec_rate = rdch? rdch->speed : 0;
- p->play_format = wrch? wrch->format : 0;
- p->rec_format = rdch? rdch->format : 0;
- }
break;
case AIOGCAP: /* get capabilities */
@@ -554,10 +569,14 @@
struct pcmchan_caps *pcaps = NULL, *rcaps = NULL;
dev_t pdev;
- if (rdch)
+ if (rdch) {
+ CHN_LOCK(rdch);
rcaps = chn_getcaps(rdch);
- if (wrch)
+ }
+ if (wrch) {
+ CHN_LOCK(wrch);
pcaps = chn_getcaps(wrch);
+ }
p->rate_min = max(rcaps? rcaps->minspeed : 0,
pcaps? pcaps->minspeed : 0);
p->rate_max = min(rcaps? rcaps->maxspeed : 1000000,
@@ -573,15 +592,23 @@
p->mixers = 1; /* default: one mixer */
p->inputs = pdev->si_drv1? mix_getdevs(pdev->si_drv1) : 0;
p->left = p->right = 100;
+ if (rdch)
+ CHN_UNLOCK(rdch);
+ if (wrch)
+ CHN_UNLOCK(wrch);
}
break;
case AIOSTOP:
- if (*arg_i == AIOSYNC_PLAY && wrch)
+ if (*arg_i == AIOSYNC_PLAY && wrch) {
+ CHN_LOCK(wrch);
*arg_i = chn_abort(wrch);
- else if (*arg_i == AIOSYNC_CAPTURE && rdch)
+ CHN_UNLOCK(wrch);
+ } else if (*arg_i == AIOSYNC_CAPTURE && rdch) {
+ CHN_LOCK(rdch);
*arg_i = chn_abort(rdch);
- else {
+ CHN_UNLOCK(rdch);
+ } else {
printf("AIOSTOP: bad channel 0x%x\n", *arg_i);
*arg_i = 0;
}
@@ -596,9 +623,15 @@
* here follow the standard ioctls (filio.h etc.)
*/
case FIONREAD: /* get # bytes to read */
-/* if (rdch && rdch->bufhard.dl)
- while (chn_rdfeed(rdch) == 0);
-*/ *arg_i = rdch? sndbuf_getready(rdch->bufsoft) : 0;
+ if (rdch) {
+ CHN_LOCK(rdch);
+/* if (rdch && rdch->bufhard.dl)
+ while (chn_rdfeed(rdch) == 0);
+*/
+ *arg_i = sndbuf_getready(rdch->bufsoft);
+ CHN_UNLOCK(rdch);
+ } else
+ *arg_i = 0;
break;
case FIOASYNC: /*set/clear async i/o */
@@ -607,15 +640,21 @@
case SNDCTL_DSP_NONBLOCK:
case FIONBIO: /* set/clear non-blocking i/o */
- if (rdch)
- rdch->flags &= ~CHN_F_NBIO;
- if (wrch)
- wrch->flags &= ~CHN_F_NBIO;
- if (*arg_i) {
- if (rdch)
+ if (rdch) {
+ CHN_LOCK(rdch);
+ if (*arg_i)
rdch->flags |= CHN_F_NBIO;
- if (wrch)
+ else
+ rdch->flags &= ~CHN_F_NBIO;
+ CHN_UNLOCK(rdch);
+ }
+ if (wrch) {
+ CHN_LOCK(wrch);
+ if (*arg_i)
wrch->flags |= CHN_F_NBIO;
+ else
+ wrch->flags &= ~CHN_F_NBIO;
+ CHN_UNLOCK(wrch);
}
break;
@@ -625,71 +664,93 @@
#define THE_REAL_SNDCTL_DSP_GETBLKSIZE _IOWR('P', 4, int)
case THE_REAL_SNDCTL_DSP_GETBLKSIZE:
case SNDCTL_DSP_GETBLKSIZE:
- if (wrch)
- *arg_i = sndbuf_getblksz(wrch->bufsoft);
- else if (rdch)
- *arg_i = sndbuf_getblksz(rdch->bufsoft);
- else
- *arg_i = 0;
+ chn = wrch ? wrch : rdch;
+ CHN_LOCK(chn);
+ *arg_i = sndbuf_getblksz(chn->bufsoft);
+ CHN_UNLOCK(chn);
break ;
case SNDCTL_DSP_SETBLKSIZE:
RANGE(*arg_i, 16, 65536);
- if (wrch)
+ if (wrch) {
+ CHN_LOCK(wrch);
chn_setblocksize(wrch, 2, *arg_i);
- if (rdch)
+ CHN_UNLOCK(wrch);
+ }
+ if (rdch) {
+ CHN_LOCK(rdch);
chn_setblocksize(rdch, 2, *arg_i);
+ CHN_UNLOCK(rdch);
+ }
break;
case SNDCTL_DSP_RESET:
DEB(printf("dsp reset\n"));
if (wrch) {
+ CHN_LOCK(wrch);
chn_abort(wrch);
chn_resetbuf(wrch);
+ CHN_UNLOCK(wrch);
}
if (rdch) {
+ CHN_LOCK(rdch);
chn_abort(rdch);
chn_resetbuf(rdch);
+ CHN_UNLOCK(rdch);
}
break;
case SNDCTL_DSP_SYNC:
DEB(printf("dsp sync\n"));
/* chn_sync may sleep */
- if (wrch)
+ if (wrch) {
+ CHN_LOCK(wrch);
chn_sync(wrch, sndbuf_getsize(wrch->bufsoft) - 4);
+ CHN_UNLOCK(wrch);
+ }
break;
case SNDCTL_DSP_SPEED:
/* chn_setspeed may sleep */
tmp = 0;
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list