From patchwork Sun May 16 15:46:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 99977 X-Patchwork-Delegate: omar.ramirez@ti.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4GFkbgO025340 for ; Sun, 16 May 2010 15:46:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753816Ab0EPPqg (ORCPT ); Sun, 16 May 2010 11:46:36 -0400 Received: from fg-out-1718.google.com ([72.14.220.159]:5081 "EHLO fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753628Ab0EPPqf (ORCPT ); Sun, 16 May 2010 11:46:35 -0400 Received: by fg-out-1718.google.com with SMTP id d23so2359940fga.1 for ; Sun, 16 May 2010 08:46:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=gqVH3lPjsZrfCEaNoFkcNU+rlKxquKuVVNdcaVtIHc4=; b=K/j1zMi6X5fWbcvJHx7hGzxQe3Msh4eOJt/fnjHwbC46LqP+ukCCt2iywRwHsizmFr nhilhpVGHVhuTJV3X77HUfGDKQ0zxdPjLNVPsiBcFDGq+dT3i6w3qT3ZwebRuhZ6cvzC 85lrKRuP03epnwY0fC1M5TEuWJMtsMOsrycDw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=abTDq38Nf3LWZhMHtzODjsnRN7LEHxl0MlyTHhNbKH2dfJyYIdl09umsvEDjBg6sbd bYQrGG6Yv4+DZGzX3u3zaCrujG6JT3VYXVD1QoJhWO/G0G+9+B5A66NkXPeg4GUxypIm dObACK7SpJ70hF46N5JU+XyPlI+qYHxwTp36w= Received: by 10.87.45.15 with SMTP id x15mr6772987fgj.42.1274024794773; Sun, 16 May 2010 08:46:34 -0700 (PDT) Received: from localhost (a91-153-253-80.elisa-laajakaista.fi [91.153.253.80]) by mx.google.com with ESMTPS id 4sm11597158fgg.27.2010.05.16.08.46.33 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 16 May 2010 08:46:34 -0700 (PDT) From: Felipe Contreras To: linux-omap Cc: Omar Ramirez Luna , Fernando Guzman Lugo , Felipe Contreras Subject: [PATCH 13/14] dspbridge: deh: tidying up Date: Sun, 16 May 2010 18:46:04 +0300 Message-Id: <1274024765-21076-14-git-send-email-felipe.contreras@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1274024765-21076-1-git-send-email-felipe.contreras@gmail.com> References: <1274024765-21076-1-git-send-email-felipe.contreras@gmail.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sun, 16 May 2010 15:46:37 +0000 (UTC) diff --git a/arch/arm/plat-omap/include/dspbridge/dspdeh.h b/arch/arm/plat-omap/include/dspbridge/dspdeh.h index 4c4d577..e5e83b4 100644 --- a/arch/arm/plat-omap/include/dspbridge/dspdeh.h +++ b/arch/arm/plat-omap/include/dspbridge/dspdeh.h @@ -23,21 +23,20 @@ #ifndef DSPDEH_ #define DSPDEH_ -#include +struct deh_mgr; +struct dev_object; +struct dsp_notification; -#include - -extern dsp_status bridge_deh_create(struct deh_mgr **ret_deh_mgr, +int bridge_deh_create(struct deh_mgr **ret_deh, struct dev_object *hdev_obj); -extern dsp_status bridge_deh_destroy(struct deh_mgr *deh_mgr); +int bridge_deh_destroy(struct deh_mgr *deh); -extern dsp_status bridge_deh_register_notify(struct deh_mgr *deh_mgr, +int bridge_deh_register_notify(struct deh_mgr *deh, u32 event_mask, u32 notify_type, struct dsp_notification *hnotification); -extern void bridge_deh_notify(struct deh_mgr *deh_mgr, - u32 ulEventMask, u32 dwErrInfo); +void bridge_deh_notify(struct deh_mgr *deh, int event, int info); #endif /* DSPDEH_ */ diff --git a/drivers/dsp/bridge/core/_deh.h b/drivers/dsp/bridge/core/_deh.h index 32b84f3..9fb727b 100644 --- a/drivers/dsp/bridge/core/_deh.h +++ b/drivers/dsp/bridge/core/_deh.h @@ -26,7 +26,6 @@ struct deh_mgr { struct bridge_dev_context *hbridge_context; /* Bridge context. */ struct ntfy_object *ntfy_obj; /* NTFY object */ - u32 fault_addr; /* MMU Fault DPC */ struct tasklet_struct dpc_tasklet; diff --git a/drivers/dsp/bridge/core/ue_deh.c b/drivers/dsp/bridge/core/ue_deh.c index d44c895..6ff73a2 100644 --- a/drivers/dsp/bridge/core/ue_deh.c +++ b/drivers/dsp/bridge/core/ue_deh.c @@ -16,41 +16,19 @@ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -/* ----------------------------------- Host OS */ -#include +#include +#include #include -/* ----------------------------------- DSP/BIOS Bridge */ -#include #include -#include - -/* ----------------------------------- Trace & Debug */ -#include - -/* ----------------------------------- OS Adaptation Layer */ -#include -#include -#include - -/* ----------------------------------- Link Driver */ #include - -/* ----------------------------------- Platform Manager */ #include -#include -#include - -/* ------------------------------------ Hardware Abstraction Layer */ -#include -#include - -/* ----------------------------------- This */ #include "_tiomap.h" #include "_deh.h" -#include "_tiomap_mmu.h" -#include "_tiomap_pwr.h" + #include +#include +#include /* GP Timer number to trigger interrupt for MMU-fault ISR on DSP */ #define GPTIMER_FOR_DSP_MMU_FAULT 8 @@ -60,44 +38,45 @@ #define GPTIMER_IRQ_WAIT_MAX_CNT 1000 static struct omap_dm_timer *timer; +static u32 fault_addr; static void mmu_fault_dpc(unsigned long data) { - struct deh_mgr *hdeh_mgr = (void *)data; + struct deh_mgr *deh = (void *)data; - if (!hdeh_mgr) + if (!deh) return; - bridge_deh_notify(hdeh_mgr, DSP_MMUFAULT, 0); + bridge_deh_notify(deh, DSP_MMUFAULT, 0); } static irqreturn_t mmu_fault_isr(int irq, void *data) { - struct deh_mgr *deh_mgr_obj = data; + struct deh_mgr *deh = data; struct cfg_hostres *resources; - u32 dmmu_event_mask; + u32 event; - if (!deh_mgr_obj) + if (!deh) return IRQ_HANDLED; - resources = deh_mgr_obj->hbridge_context->resources; + resources = deh->hbridge_context->resources; if (!resources) { dev_dbg(bridge, "%s: Failed to get Host Resources\n", __func__); return IRQ_HANDLED; } - hw_mmu_event_status(resources->dw_dmmu_base, &dmmu_event_mask); - if (dmmu_event_mask == HW_MMU_TRANSLATION_FAULT) { - hw_mmu_fault_addr_read(resources->dw_dmmu_base, &deh_mgr_obj->fault_addr); - dev_info(bridge, "%s: status=0x%x, fault_addr=0x%x\n", __func__, - dmmu_event_mask, deh_mgr_obj->fault_addr); + hw_mmu_event_status(resources->dw_dmmu_base, &event); + if (event == HW_MMU_TRANSLATION_FAULT) { + hw_mmu_fault_addr_read(resources->dw_dmmu_base, &fault_addr); + dev_dbg(bridge, "%s: event=0x%x, fault_addr=0x%x\n", __func__, + event, fault_addr); /* * Schedule a DPC directly. In the future, it may be * necessary to check if DSP MMU fault is intended for * Bridge. */ - tasklet_schedule(&deh_mgr_obj->dpc_tasklet); + tasklet_schedule(&deh->dpc_tasklet); /* Disable the MMU events, else once we clear it will * start to raise INTs again */ @@ -110,11 +89,11 @@ static irqreturn_t mmu_fault_isr(int irq, void *data) return IRQ_HANDLED; } -dsp_status bridge_deh_create(struct deh_mgr **ret_deh_mgr, +int bridge_deh_create(struct deh_mgr **ret_deh, struct dev_object *hdev_obj) { - dsp_status status; - struct deh_mgr *deh_mgr; + int status; + struct deh_mgr *deh; struct bridge_dev_context *hbridge_context = NULL; /* Message manager will be created when a file is loaded, since @@ -123,29 +102,29 @@ dsp_status bridge_deh_create(struct deh_mgr **ret_deh_mgr, /* Get WMD context info. */ dev_get_bridge_context(hdev_obj, &hbridge_context); /* Allocate IO manager object: */ - deh_mgr = kzalloc(sizeof(struct deh_mgr), GFP_KERNEL); - if (!deh_mgr) { + deh = kzalloc(sizeof(*deh), GFP_KERNEL); + if (!deh) { status = -ENOMEM; goto err; } /* Create an NTFY object to manage notifications */ - deh_mgr->ntfy_obj = kmalloc(sizeof(struct ntfy_object), GFP_KERNEL); - if (!deh_mgr->ntfy_obj) { + deh->ntfy_obj = kmalloc(sizeof(struct ntfy_object), GFP_KERNEL); + if (!deh->ntfy_obj) { status = -ENOMEM; goto err; } - ntfy_init(deh_mgr->ntfy_obj); + ntfy_init(deh->ntfy_obj); /* Create a MMUfault DPC */ - tasklet_init(&deh_mgr->dpc_tasklet, mmu_fault_dpc, (u32) deh_mgr); + tasklet_init(&deh->dpc_tasklet, mmu_fault_dpc, (u32) deh); /* Fill in context structure */ - deh_mgr->hbridge_context = hbridge_context; + deh->hbridge_context = hbridge_context; /* Install ISR function for DSP MMU fault */ status = request_irq(INT_DSP_MMU_IRQ, mmu_fault_isr, 0, - "DspBridge\tiommu fault", deh_mgr); + "DspBridge\tiommu fault", deh); if (status < 0) goto err; @@ -157,33 +136,33 @@ dsp_status bridge_deh_create(struct deh_mgr **ret_deh_mgr, } omap_dm_timer_disable(timer); - *ret_deh_mgr = deh_mgr; + *ret_deh = deh; return 0; err: - bridge_deh_destroy(deh_mgr); - *ret_deh_mgr = NULL; + bridge_deh_destroy(deh); + *ret_deh = NULL; return status; } -dsp_status bridge_deh_destroy(struct deh_mgr *deh_mgr) +int bridge_deh_destroy(struct deh_mgr *deh) { - if (!deh_mgr) + if (!deh) return -EFAULT; /* If notification object exists, delete it */ - if (deh_mgr->ntfy_obj) { - ntfy_delete(deh_mgr->ntfy_obj); - kfree(deh_mgr->ntfy_obj); + if (deh->ntfy_obj) { + ntfy_delete(deh->ntfy_obj); + kfree(deh->ntfy_obj); } /* Disable DSP MMU fault */ - free_irq(INT_DSP_MMU_IRQ, deh_mgr); + free_irq(INT_DSP_MMU_IRQ, deh); /* Free DPC object */ - tasklet_kill(&deh_mgr->dpc_tasklet); + tasklet_kill(&deh->dpc_tasklet); /* Deallocate the DEH manager object */ - kfree(deh_mgr); + kfree(deh); /* The GPTimer is no longer needed */ omap_dm_timer_free(timer); @@ -192,18 +171,18 @@ dsp_status bridge_deh_destroy(struct deh_mgr *deh_mgr) return 0; } -dsp_status bridge_deh_register_notify(struct deh_mgr *deh_mgr, u32 event_mask, +int bridge_deh_register_notify(struct deh_mgr *deh, u32 event_mask, u32 notify_type, struct dsp_notification *hnotification) { - if (!deh_mgr) + if (!deh) return -EFAULT; if (event_mask) - return ntfy_register(deh_mgr->ntfy_obj, hnotification, + return ntfy_register(deh->ntfy_obj, hnotification, event_mask, notify_type); else - return ntfy_unregister(deh_mgr->ntfy_obj, hnotification); + return ntfy_unregister(deh->ntfy_obj, hnotification); } static void wait_for_timer(void) @@ -233,8 +212,7 @@ static void wait_for_timer(void) omap_dm_timer_disable(timer); } -static void mmu_fault_print_stack(struct bridge_dev_context *dev_context, - u32 fault_addr) +static void mmu_fault_print_stack(struct bridge_dev_context *dev_context) { struct cfg_hostres *resources; struct hw_mmu_map_attrs_t map_attrs = { @@ -270,51 +248,50 @@ static void mmu_fault_print_stack(struct bridge_dev_context *dev_context, free_page((unsigned long)dummy_va_addr); } -void bridge_deh_notify(struct deh_mgr *deh_mgr, u32 ulEventMask, u32 dwErrInfo) +static inline const char *event_to_string(int event) +{ + switch (event) { + case DSP_SYSERROR: return "DSP_SYSERROR"; break; + case DSP_MMUFAULT: return "DSP_MMUFAULT"; break; + case DSP_PWRERROR: return "DSP_PWRERROR"; break; + case DSP_WDTOVERFLOW: return "DSP_WDTOVERFLOW"; break; + default: return "unkown event"; break; + } +} + +void bridge_deh_notify(struct deh_mgr *deh, int event, int info) { struct bridge_dev_context *dev_context; + const char *str = event_to_string(event); - if (!deh_mgr) + if (!deh) return; - dev_info(bridge, "%s: device exception\n", __func__); - dev_context = deh_mgr->hbridge_context; + dev_dbg(bridge, "%s: device exception", __func__); + dev_context = deh->hbridge_context; - switch (ulEventMask) { + switch (event) { case DSP_SYSERROR: - dev_err(bridge, "%s: %s, err_info = 0x%x\n", - __func__, "DSP_SYSERROR", dwErrInfo); + dev_err(bridge, "%s: %s, info=0x%x", __func__, + str, info); dump_dl_modules(dev_context); dump_dsp_stack(dev_context); break; case DSP_MMUFAULT: - dev_err(bridge, "%s: %s, err_info = 0x%x\n", - __func__, "DSP_MMUFAULT", dwErrInfo); - dev_info(bridge, "%s: %s, fault=0x%x\n", __func__, "DSP_MMUFAULT", - deh_mgr->fault_addr); - + dev_err(bridge, "%s: %s, addr=0x%x", __func__, + str, fault_addr); print_dsp_trace_buffer(dev_context); dump_dl_modules(dev_context); - mmu_fault_print_stack(dev_context, deh_mgr->fault_addr); - break; -#ifdef CONFIG_BRIDGE_NTFY_PWRERR - case DSP_PWRERROR: - dev_err(bridge, "%s: %s, err_info = 0x%x\n", - __func__, "DSP_PWRERROR", dwErrInfo); - break; -#endif /* CONFIG_BRIDGE_NTFY_PWRERR */ - case DSP_WDTOVERFLOW: - dev_err(bridge, "%s: DSP_WDTOVERFLOW\n", __func__); + mmu_fault_print_stack(dev_context); break; default: - dev_dbg(bridge, "%s: Unknown Error, err_info = 0x%x\n", - __func__, dwErrInfo); + dev_err(bridge, "%s: %s", __func__, str); break; } /* Filter subsequent notifications when an error occurs */ if (dev_context->dw_brd_state != BRD_ERROR) { - ntfy_notify(deh_mgr->ntfy_obj, ulEventMask); + ntfy_notify(deh->ntfy_obj, event); #ifdef CONFIG_BRIDGE_RECOVERY bridge_recover_schedule(); #endif