Changeset eb5a42f6 in rtems


Ignore:
Timestamp:
Mar 23, 2016, 9:45:26 AM (3 years ago)
Author:
Daniel Hellstrom <daniel@…>
Branches:
master
Children:
1ef9caa2
Parents:
36c3fbbd
git-author:
Daniel Hellstrom <daniel@…> (03/23/16 09:45:26)
git-committer:
Daniel Hellstrom <daniel@…> (03/06/17 06:54:55)
Message:

leon, grspw_pkt: fixed device/dma closing

The user is now responsible to stop and close the DMA channels
before closing the device. To prevent complicated situations and
blocking the caller of grspw_close and grspw_dma_close a return
code was added to indicate to the user that the DMA may not have
been stopped or that blocked tasks are still active within the
driver for the specified device.

Location:
c/src/lib/libbsp/sparc/shared
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/sparc/shared/include/grspw_pkt.h

    r36c3fbbd reb5a42f6  
    313313extern int grspw_dev_count(void);
    314314extern void *grspw_open(int dev_no);
    315 extern void grspw_close(void *d);
     315extern int grspw_close(void *d);
    316316extern void grspw_hw_support(void *d, struct grspw_hw_sup *hw);
    317317extern void grspw_stats_read(void *d, struct grspw_core_stats *sts);
     
    423423/*** DMA Interface ***/
    424424extern void *grspw_dma_open(void *d, int chan_no);
    425 extern void grspw_dma_close(void *c);
     425extern int grspw_dma_close(void *c);
    426426
    427427extern int grspw_dma_start(void *c);
  • c/src/lib/libbsp/sparc/shared/spw/grspw_pkt.c

    r36c3fbbd reb5a42f6  
    624624}
    625625
    626 void grspw_close(void *d)
     626int grspw_close(void *d)
    627627{
    628628        struct grspw_priv *priv = d;
     
    632632        if (rtems_semaphore_obtain(grspw_sem, RTEMS_WAIT, RTEMS_NO_TIMEOUT)
    633633            != RTEMS_SUCCESSFUL)
    634                 return;
    635 
    636         /* Stop Hardware from doing DMA, put HW into "startup-state",
    637          * Stop hardware from generating IRQ.
     634                return -1;
     635
     636        /* Check that user has stopped and closed all DMA channels
     637         * appropriately. At this point the Hardware shall not be doing DMA
     638         * or generating Interrupts. We want HW in a "startup-state".
    638639         */
    639         for (i=0; i<priv->hwsup.ndma_chans; i++)
    640                 grspw_dma_close(&priv->dma[i]);
     640        for (i=0; i<priv->hwsup.ndma_chans; i++) {
     641                if (priv->dma[i].open) {
     642                        rtems_semaphore_release(grspw_sem);
     643                        return 1;
     644                }
     645        }
    641646        grspw_hw_stop(priv);
    642647
    643648        /* Mark not open */
    644649        priv->open = 0;
    645 
    646650        rtems_semaphore_release(grspw_sem);
    647 
    648         /* Check that all threads are out? */
     651        return 0;
    649652}
    650653
     
    17521755}
    17531756
    1754 void grspw_dma_close(void *c)
     1757int grspw_dma_close(void *c)
    17551758{
    17561759        struct grspw_dma_priv *dma = c;
    17571760
    17581761        if (!dma->open)
    1759                 return;
     1762                return 0;
    17601763
    17611764        /* Take device lock - Wait until we get semaphore */
    17621765        if (rtems_semaphore_obtain(dma->sem_dma, RTEMS_WAIT, RTEMS_NO_TIMEOUT)
    17631766            != RTEMS_SUCCESSFUL)
    1764                 return;
    1765 
    1766         grspw_dma_stop_locked(dma);
     1767                return -1;
     1768
     1769        /* Can not close active DMA channel. User must stop DMA and make sure
     1770         * no threads are active/blocked within driver.
     1771         */
     1772        if (dma->started || dma->rx_wait.waiting || dma->tx_wait.waiting) {
     1773                rtems_semaphore_release(dma->sem_dma);
     1774                return 1;
     1775        }
    17671776
    17681777        /* Free resources */
     
    17801789
    17811790        dma->open = 0;
     1791        return 0;
    17821792}
    17831793
     
    23992409        struct grspw_dma_priv *dma = c;
    24002410
     2411        /* If DMA channel is closed we should not access the semaphore */
     2412        if (!dma->open)
     2413                return;
     2414
    24012415        /* Take DMA Channel lock */
    24022416        if (rtems_semaphore_obtain(dma->sem_dma, RTEMS_WAIT, RTEMS_NO_TIMEOUT)
     
    24292443        unsigned int ctrl;
    24302444        IRQFLAGS_TYPE irqflags;
     2445
     2446        /* If DMA channel is closed we should not access the semaphore */
     2447        if (dma->open == 0)
     2448                return;
    24312449
    24322450        rx_cond_true = 0;
Note: See TracChangeset for help on using the changeset viewer.