Changeset 1e77a45 in rtems-libbsd


Ignore:
Timestamp:
Oct 4, 2018, 10:06:44 AM (7 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
647dd08ae2aa69b935c2847ea450fb824322ecae, c6261f97870562d4c797cfb1ff1ba0affb85a916
Children:
f949b43
Parents:
f9d4e1d
git-author:
Sebastian Huber <sebastian.huber@…> (10/04/18 10:06:44)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/04/18 12:14:51)
Message:

saf1761_otg: Use real interrupt handler

The USB_BUS_SPIN_LOCK() is only used internally to the bus driver.
Replace the mutex with an interrupt disable/enable section. Execute the
interrupt filter in a real interrupt context and forward the interrupt
handler to the interrupt server if necessary.

Location:
freebsd/sys/dev/usb/controller
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • freebsd/sys/dev/usb/controller/saf1761_otg.c

    rf9d4e1d r1e77a45  
    8989#include <bsp/pin-config.h>
    9090#endif /* LIBBSP_ARM_ATSAM_BSP_H */
     91#undef  USB_BUS_SPIN_LOCK
     92#undef  USB_BUS_SPIN_UNLOCK
     93#define USB_BUS_SPIN_LOCK(_b) \
     94    do { \
     95        rtems_interrupt_level usb_bus_spin_lock; \
     96        rtems_interrupt_disable(usb_bus_spin_lock)
     97#define USB_BUS_SPIN_UNLOCK(_b) \
     98        rtems_interrupt_enable(usb_bus_spin_lock); \
     99    } while (0)
    91100#endif /* __rtems__ */
    92101
     
    16691678        struct saf1761_otg_softc *sc = arg;
    16701679        uint32_t status;
     1680        bool xfer_complete;
    16711681
    16721682        USB_BUS_LOCK(&sc->sc_bus);
     
    17361746        }
    17371747
    1738         if (sc->sc_xfer_complete != 0) {
     1748        xfer_complete = (sc->sc_xfer_complete != 0);
     1749        if (xfer_complete)
    17391750                sc->sc_xfer_complete = 0;
    17401751
     1752        USB_BUS_SPIN_UNLOCK(&sc->sc_bus);
     1753
     1754        if (xfer_complete)
    17411755                /* complete FIFOs, if any */
    17421756                saf1761_otg_interrupt_complete_locked(sc);
    1743         }
    1744         USB_BUS_SPIN_UNLOCK(&sc->sc_bus);
     1757
    17451758        USB_BUS_UNLOCK(&sc->sc_bus);
    17461759}
     
    22332246        }
    22342247
     2248        USB_BUS_SPIN_UNLOCK(&sc->sc_bus);
     2249
    22352250        /* dequeue transfer and start next transfer */
    22362251        usbd_transfer_done(xfer, error);
    2237 
    2238         USB_BUS_SPIN_UNLOCK(&sc->sc_bus);
    22392252}
    22402253
     
    26012614        USB_BUS_SPIN_LOCK(&sc->sc_bus);
    26022615        saf1761_otg_interrupt_poll_locked(sc);
     2616        USB_BUS_SPIN_UNLOCK(&sc->sc_bus);
    26032617        saf1761_otg_interrupt_complete_locked(sc);
    2604         USB_BUS_SPIN_UNLOCK(&sc->sc_bus);
    26052618        USB_BUS_UNLOCK(&sc->sc_bus);
    26062619}
  • freebsd/sys/dev/usb/controller/saf1761_otg.h

    rf9d4e1d r1e77a45  
    3333#define _SAF1761_OTG_H_
    3434
     35#ifdef __rtems__
     36#include <rtems/irq-extension.h>
     37#endif /* __rtems__ */
    3538#define SOTG_MAX_DEVICES MIN(USB_MAX_DEVICES, 32)
    3639#define SOTG_FS_MAX_PACKET_SIZE 64
     
    164167
    165168        struct saf1761_otg_flags sc_flags;
     169#ifdef __rtems__
     170        rtems_interrupt_server_request sc_irq_srv_req;
     171#endif /* __rtems__ */
    166172};
    167173
  • freebsd/sys/dev/usb/controller/saf1761_otg_fdt.c

    rf9d4e1d r1e77a45  
    136136}
    137137
     138#ifdef __rtems__
     139static void
     140saf1761_otg_filter_interrupt_wrapper(void *arg)
     141{
     142        struct saf1761_otg_softc *sc = arg;
     143        int status;
     144
     145        status = saf1761_otg_filter_interrupt(sc);
     146        if ((status & FILTER_SCHEDULE_THREAD) != 0) {
     147                rtems_interrupt_server_request_submit(&sc->sc_irq_srv_req);
     148        }
     149}
     150#endif /* __rtems__ */
    138151static int
    139152saf1761_otg_fdt_attach(device_t dev)
     
    143156        int err;
    144157        int rid;
     158#ifdef __rtems__
     159        rtems_status_code status;
     160#endif /* __rtems__ */
    145161
    146162#ifndef __rtems__
     
    244260#endif /* LIBBSP_ARM_ATSAM_BSP_H */
    245261#endif /* __rtems__ */
     262#ifndef __rtems__
    246263        err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_TTY | INTR_MPSAFE,
    247264            &saf1761_otg_filter_interrupt, &saf1761_otg_interrupt, sc, &sc->sc_intr_hdl);
     265#else /* __rtems__ */
     266        rtems_interrupt_server_request_initialize(
     267            RTEMS_INTERRUPT_SERVER_DEFAULT, &sc->sc_irq_srv_req,
     268            saf1761_otg_interrupt, sc);
     269        rtems_interrupt_server_request_set_vector(&sc->sc_irq_srv_req,
     270            rman_get_start(sc->sc_irq_res));
     271        status = rtems_interrupt_handler_install(
     272            rman_get_start(sc->sc_irq_res), device_get_nameunit(dev),
     273            RTEMS_INTERRUPT_SHARED, saf1761_otg_filter_interrupt_wrapper, sc);
     274        err = (status == RTEMS_SUCCESSFUL) ? 0 : EINVAL;
     275#endif /* __rtems__ */
    248276        if (err) {
    249277                sc->sc_intr_hdl = NULL;
Note: See TracChangeset for help on using the changeset viewer.