Changeset 2e8a01b in mainline


Ignore:
Timestamp:
2011-07-10T21:17:38Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1f6eb7d
Parents:
1ecc5de
Message:

OHCI: Use the new way of generating IRQ code

Use bogus read to force kernel to create mapping (perhaps a flag could be added and used by pio_enable, to avoid this)

Location:
uspace/drv/bus/usb/ohci
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/hc.c

    r1ecc5de r2e8a01b  
    177177         * and accepts physical addresses in IRQ code.
    178178         * TODO: remove */
    179         void *registers;
    180         const int ret = pio_enable((void*)regs, reg_size, &registers);
     179        ohci_regs_t *registers;
     180        const int ret = pio_enable((void*)regs, reg_size, (void**)&registers);
     181
     182        /* Some bogus access to force create mapping. DO NOT remove,
     183         * unless whole virtual addresses in irq is replaced */
     184        registers->revision;
    181185
    182186        if (ret != EOK)
     
    185189        memcpy(cmds, ohci_irq_commands, sizeof(ohci_irq_commands));
    186190
    187         void *address = (void*)&(((ohci_regs_t*)registers)->interrupt_status);
     191        void *address = (void*)&registers->interrupt_status;
    188192        cmds[0].addr = address;
    189193        cmds[3].addr = address;
  • uspace/drv/bus/usb/ohci/ohci.c

    r1ecc5de r2e8a01b  
    194194            (void *) reg_base, reg_size, irq);
    195195
     196        const size_t cmd_count = hc_irq_cmd_count();
     197        irq_cmd_t irq_cmds[cmd_count];
     198        ret =
     199            hc_get_irq_commands(irq_cmds, sizeof(irq_cmds), reg_base, reg_size);
     200        CHECK_RET_DEST_FREE_RETURN(ret,
     201            "Failed to generate IRQ code: %s.\n", str_error(ret));
     202
     203        irq_code_t irq_code = { .cmdcount = cmd_count, .cmds = irq_cmds };
     204
     205        /* Register handler to avoid interrupt lockup */
     206        ret = register_interrupt_handler(device, irq, irq_handler,
     207            &irq_code);
     208        CHECK_RET_DEST_FREE_RETURN(ret,
     209            "Failed(%d) to register interrupt handler.\n", ret);
     210
     211        /* Try to enable interrupts */
    196212        bool interrupts = false;
    197 #ifdef CONFIG_USBHC_NO_INTERRUPTS
    198         usb_log_warning("Interrupts disabled in OS config, "
    199             "falling back to polling.\n");
    200 #else
    201213        ret = pci_enable_interrupts(device);
    202214        if (ret != EOK) {
    203                 usb_log_warning("Failed to enable interrupts: %s.\n",
    204                     str_error(ret));
    205                 usb_log_info("HW interrupts not available, "
    206                     "falling back to polling.\n");
     215                usb_log_warning("Failed to enable interrupts: %s."
     216                    "Falling back to pollling\n", str_error(ret));
     217                /* We don't need that handler */
     218                unregister_interrupt_handler(device, irq);
    207219        } else {
    208220                usb_log_debug("Hw interrupts enabled.\n");
    209221                interrupts = true;
    210222        }
    211 #endif
    212223
    213224        ret = hc_init(&instance->hc, reg_base, reg_size, interrupts);
     
    216227#define CHECK_RET_FINI_RETURN(ret, message...) \
    217228if (ret != EOK) { \
     229        unregister_interrupt_handler(device, irq); \
    218230        hc_fini(&instance->hc); \
    219231        CHECK_RET_DEST_FREE_RETURN(ret, message); \
    220232} else (void)0
    221233
    222         /* It does no harm if we register this on polling */
    223         ret = register_interrupt_handler(device, irq, irq_handler,
    224             &instance->hc.interrupt_code);
    225         CHECK_RET_FINI_RETURN(ret,
    226             "Failed(%d) to register interrupt handler.\n", ret);
    227234
    228235        ret = ddf_fun_bind(instance->hc_fun);
Note: See TracChangeset for help on using the changeset viewer.