From patchwork Wed Mar 18 01:26:43 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12731 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2I1Qw0V029250 for ; Wed, 18 Mar 2009 01:26:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754626AbZCRB06 (ORCPT ); Tue, 17 Mar 2009 21:26:58 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754438AbZCRB06 (ORCPT ); Tue, 17 Mar 2009 21:26:58 -0400 Received: from mail-fx0-f158.google.com ([209.85.220.158]:41202 "EHLO mail-fx0-f158.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754110AbZCRB05 (ORCPT ); Tue, 17 Mar 2009 21:26:57 -0400 Received: by fxm2 with SMTP id 2so304748fxm.37 for ; Tue, 17 Mar 2009 18:26:54 -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=Y5a4YupRPZI7QbdYOX7P8DPg9vUgMtYJDFSkK/wJ5Ks=; b=kKZFLJjZWvJ6Eio7wtXw4d7MgBo+3IEwy4j0Kd8xdG/hO6bdwASQfda2Sdlx5mKaQ/ xU7m0fCbFj+21FVZ4hpRFM3KgK7EqQNS1ANKcpbqrOOd1kiXvy6CyAY5ZGCECEcxEFiD 8nhi51fBkpqLWx+olx9fLdltxXDfcvXFpqtfI= 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=CRslrDoLV15He7hR9BI7PfqGhHavEKeOz4d0RzydQYw5teJtLTAzICQNAXvU4rDreo 4qhpB48UqtF+9gzKIgx4/zUsK7CxGyVgZHJEoMQpQhKdxTM9/854fm9sbvg2HEyjUL8O rQ/jQ8uoLWULGZKmw5pO5CL9VUSyYVcQNrVSo= Received: by 10.204.118.138 with SMTP id v10mr207305bkq.182.1237339614228; Tue, 17 Mar 2009 18:26:54 -0700 (PDT) Received: from localhost (a91-153-251-222.elisa-laajakaista.fi [91.153.251.222]) by mx.google.com with ESMTPS id f31sm11208811fkf.35.2009.03.17.18.26.53 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 17 Mar 2009 18:26:53 -0700 (PDT) From: Felipe Contreras To: linux-omap@vger.kernel.org Cc: Hari Kanigeri , Hiroshi DOYU , Ameya Palande , Fernando Guzman Lugo , Felipe Contreras Subject: [PATCH B 1/3] tidspbridge: don't flood the mailbox on MemUnMap Date: Wed, 18 Mar 2009 03:26:43 +0200 Message-Id: <1237339605-20697-2-git-send-email-felipe.contreras@gmail.com> X-Mailer: git-send-email 1.6.2.1.287.g9a8be In-Reply-To: <1237339605-20697-1-git-send-email-felipe.contreras@gmail.com> References: <1237339605-20697-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 From: Felipe Contreras Impact: improves performance and reliability Check the hardware state of the DSP before sending the command to wake it up thus avoiding to flood the mailbox unnecessarily. By doing that the mailbox is free most of the time which dramatically decreases CPU usage since the check for empty slots is done in a busy loop. Also, a free mailbox means less timeouts, so now most messages are posted which improves reliability. MemMap is doing the flush properly, so this patch also refactors the code into a common flush_all function. The problem can be triggered by doing many memmap/unmaps, just like TI's OpenMAX IL implementation. Signed-off-by: Felipe Contreras --- drivers/dsp/bridge/wmd/tiomap3430.c | 42 +++++++++++++++++++--------------- 1 files changed, 23 insertions(+), 19 deletions(-) diff --git a/drivers/dsp/bridge/wmd/tiomap3430.c b/drivers/dsp/bridge/wmd/tiomap3430.c index c0f4ffc..b538ef7 100644 --- a/drivers/dsp/bridge/wmd/tiomap3430.c +++ b/drivers/dsp/bridge/wmd/tiomap3430.c @@ -235,6 +235,25 @@ static struct WMD_DRV_INTERFACE drvInterfaceFxns = { WMD_MSG_SetQueueId, }; +static inline void flush_all(struct WMD_DEV_CONTEXT *pDevContext) +{ + struct CFG_HOSTRES resources; + u32 temp = 0; + + CFG_GetHostResources((struct CFG_DEVNODE *)DRV_GetFirstDevExtension(), &resources); + HW_PWRST_IVA2RegGet(resources.dwPrmBase, &temp); + + if ((temp & HW_PWR_STATE_ON) == HW_PWR_STATE_OFF) { + /* IVA domain is not in ON state*/ + DBG_Trace(DBG_LEVEL7, "temp value is 0x%x\n", temp); + CLK_Enable(SERVICESCLK_iva2_ck); + WakeDSP(pDevContext, NULL); + HW_MMU_TLBFlushAll(pDevContext->dwDSPMmuBase); + CLK_Disable(SERVICESCLK_iva2_ck); + } else + HW_MMU_TLBFlushAll(pDevContext->dwDSPMmuBase); +} + /* * ======== WMD_DRV_Entry ======== * purpose: @@ -1283,17 +1302,14 @@ static DSP_STATUS WMD_BRD_MemMap(struct WMD_DEV_CONTEXT *hDevContext, struct WMD_DEV_CONTEXT *pDevContext = hDevContext; struct HW_MMUMapAttrs_t hwAttrs; u32 numOfActualTabEntries = 0; - u32 temp = 0; - struct CFG_HOSTRES resources; u32 *pPhysAddrPageTbl = NULL; struct vm_area_struct *vma; struct mm_struct *mm = current->mm; + u32 temp = 0; DBG_Trace(DBG_ENTER, "> WMD_BRD_MemMap hDevContext %x, pa %x, va %x, " "size %x, ulMapAttr %x\n", hDevContext, ulMpuAddr, ulVirtAddr, ulNumBytes, ulMapAttr); - status = CFG_GetHostResources( - (struct CFG_DEVNODE *)DRV_GetFirstDevExtension(), &resources); if (ulNumBytes == 0) return DSP_EINVALIDARG; @@ -1421,16 +1437,7 @@ func_cont: * This is called from here instead from PteUpdate to avoid unnecessary * repetition while mapping non-contiguous physical regions of a virtual * region */ - HW_PWRST_IVA2RegGet(resources.dwPrmBase, &temp); - if ((temp & HW_PWR_STATE_ON) == HW_PWR_STATE_OFF) { - /* IVA domain is not in ON state*/ - DBG_Trace(DBG_LEVEL7, "temp value is 0x%x\n", temp); - CLK_Enable(SERVICESCLK_iva2_ck); - WakeDSP(pDevContext, NULL); - HW_MMU_TLBFlushAll(pDevContext->dwDSPMmuBase); - CLK_Disable(SERVICESCLK_iva2_ck); - } else - HW_MMU_TLBFlushAll(pDevContext->dwDSPMmuBase); + flush_all(pDevContext); DBG_Trace(DBG_ENTER, "< WMD_BRD_MemMap status %x\n", status); return status; } @@ -1571,8 +1578,7 @@ static DSP_STATUS WMD_BRD_MemUnMap(struct WMD_DEV_CONTEXT *hDevContext, /* It is better to flush the TLB here, so that any stale old entries * get flushed */ EXIT_LOOP: - CHNLSM_InterruptDSP2(pDevContext, MBX_PM_DSPWAKEUP); - HW_MMU_TLBFlushAll(pDevContext->dwDSPMmuBase); + flush_all(pDevContext); DBG_Trace(DBG_LEVEL1, "WMD_BRD_MemUnMap vaCurr %x, pteAddrL1 %x " "pteAddrL2 %x\n", vaCurr, pteAddrL1, pteAddrL2); DBG_Trace(DBG_ENTER, "< WMD_BRD_MemUnMap status %x remBytes %x, " @@ -2055,9 +2061,7 @@ func_cont: * This is called from here instead from PteUpdate to avoid unnecessary * repetition while mapping non-contiguous physical regions of a virtual * region */ - /* Waking up DSP before calling TLB Flush */ - CHNLSM_InterruptDSP2(pDevContext, MBX_PM_DSPWAKEUP); - HW_MMU_TLBFlushAll(pDevContext->dwDSPMmuBase); + flush_all(pDevContext); DBG_Trace(DBG_LEVEL7, "< WMD_BRD_MemMap at end status %x\n", status); return status; }