Deleted Added
full compact
usb_busdma.c (193074) usb_busdma.c (194227)
1/* $FreeBSD: head/sys/dev/usb/usb_busdma.c 193074 2009-05-30 00:22:57Z thompsa $ */
1/* $FreeBSD: head/sys/dev/usb/usb_busdma.c 194227 2009-06-15 00:33:18Z thompsa $ */
2/*-
3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

--- 430 unchanged lines hidden (view full) ---

440 owned = mtx_owned(uptag->mtx);
441 if (!owned)
442 mtx_lock(uptag->mtx);
443
444 uptag->dma_error = (error ? 1 : 0);
445 if (isload) {
446 (uptag->func) (uptag);
447 } else {
2/*-
3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

--- 430 unchanged lines hidden (view full) ---

440 owned = mtx_owned(uptag->mtx);
441 if (!owned)
442 mtx_lock(uptag->mtx);
443
444 uptag->dma_error = (error ? 1 : 0);
445 if (isload) {
446 (uptag->func) (uptag);
447 } else {
448 usb2_cv_broadcast(uptag->cv);
448 cv_broadcast(uptag->cv);
449 }
450 if (!owned)
451 mtx_unlock(uptag->mtx);
452}
453
454/*------------------------------------------------------------------------*
455 * usb2_pc_alloc_mem - allocate DMA'able memory
456 *

--- 69 unchanged lines hidden (view full) ---

526 mtx_lock(uptag->mtx);
527
528 /* load memory into DMA */
529 err = bus_dmamap_load(
530 utag->tag, map, ptr, size, &usb2_pc_alloc_mem_cb,
531 pc, (BUS_DMA_WAITOK | BUS_DMA_COHERENT));
532
533 if (err == EINPROGRESS) {
449 }
450 if (!owned)
451 mtx_unlock(uptag->mtx);
452}
453
454/*------------------------------------------------------------------------*
455 * usb2_pc_alloc_mem - allocate DMA'able memory
456 *

--- 69 unchanged lines hidden (view full) ---

526 mtx_lock(uptag->mtx);
527
528 /* load memory into DMA */
529 err = bus_dmamap_load(
530 utag->tag, map, ptr, size, &usb2_pc_alloc_mem_cb,
531 pc, (BUS_DMA_WAITOK | BUS_DMA_COHERENT));
532
533 if (err == EINPROGRESS) {
534 usb2_cv_wait(uptag->cv, uptag->mtx);
534 cv_wait(uptag->cv, uptag->mtx);
535 err = 0;
536 }
537 mtx_unlock(uptag->mtx);
538
539 if (err || uptag->dma_error) {
540 bus_dmamem_free(utag->tag, ptr, map);
541 goto error;
542 }

--- 64 unchanged lines hidden (view full) ---

607
608 /*
609 * Try to load memory into DMA.
610 */
611 err = bus_dmamap_load(
612 pc->tag, pc->map, pc->buffer, size,
613 &usb2_pc_alloc_mem_cb, pc, BUS_DMA_WAITOK);
614 if (err == EINPROGRESS) {
535 err = 0;
536 }
537 mtx_unlock(uptag->mtx);
538
539 if (err || uptag->dma_error) {
540 bus_dmamem_free(utag->tag, ptr, map);
541 goto error;
542 }

--- 64 unchanged lines hidden (view full) ---

607
608 /*
609 * Try to load memory into DMA.
610 */
611 err = bus_dmamap_load(
612 pc->tag, pc->map, pc->buffer, size,
613 &usb2_pc_alloc_mem_cb, pc, BUS_DMA_WAITOK);
614 if (err == EINPROGRESS) {
615 usb2_cv_wait(uptag->cv, uptag->mtx);
615 cv_wait(uptag->cv, uptag->mtx);
616 err = 0;
617 }
618 if (err || uptag->dma_error) {
619 return (1);
620 }
621 } else {
622
623 /*

--- 153 unchanged lines hidden (view full) ---

777 /* sanity checking */
778 if ((nudt == 0) ||
779 (ndmabits == 0) ||
780 (mtx == NULL)) {
781 /* something is corrupt */
782 return;
783 }
784 /* initialise condition variable */
616 err = 0;
617 }
618 if (err || uptag->dma_error) {
619 return (1);
620 }
621 } else {
622
623 /*

--- 153 unchanged lines hidden (view full) ---

777 /* sanity checking */
778 if ((nudt == 0) ||
779 (ndmabits == 0) ||
780 (mtx == NULL)) {
781 /* something is corrupt */
782 return;
783 }
784 /* initialise condition variable */
785 usb2_cv_init(udpt->cv, "USB DMA CV");
785 cv_init(udpt->cv, "USB DMA CV");
786
787 /* store some information */
788 udpt->mtx = mtx;
789 udpt->func = func;
790 udpt->tag = dmat;
791 udpt->utag_first = udt;
792 udpt->utag_max = nudt;
793 udpt->dma_bits = ndmabits;

--- 24 unchanged lines hidden (view full) ---

818 usb2_dma_tag_destroy(udt);
819 udt->align = 0;
820 }
821 udt++;
822 }
823
824 if (udpt->utag_max) {
825 /* destroy the condition variable */
786
787 /* store some information */
788 udpt->mtx = mtx;
789 udpt->func = func;
790 udpt->tag = dmat;
791 udpt->utag_first = udt;
792 udpt->utag_max = nudt;
793 udpt->dma_bits = ndmabits;

--- 24 unchanged lines hidden (view full) ---

818 usb2_dma_tag_destroy(udt);
819 udt->align = 0;
820 }
821 udt++;
822 }
823
824 if (udpt->utag_max) {
825 /* destroy the condition variable */
826 usb2_cv_destroy(udpt->cv);
826 cv_destroy(udpt->cv);
827 }
828}
829
830/*------------------------------------------------------------------------*
831 * usb2_bdma_work_loop
832 *
833 * This function handles loading of virtual buffers into DMA and is
834 * only called when "dma_refcount" is zero.

--- 209 unchanged lines hidden ---
827 }
828}
829
830/*------------------------------------------------------------------------*
831 * usb2_bdma_work_loop
832 *
833 * This function handles loading of virtual buffers into DMA and is
834 * only called when "dma_refcount" is zero.

--- 209 unchanged lines hidden ---