From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752555AbbCIMVm (ORCPT ); Mon, 9 Mar 2015 08:21:42 -0400 Received: from mailgw01.mediatek.com ([218.249.47.110]:40599 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752458AbbCIMVi (ORCPT ); Mon, 9 Mar 2015 08:21:38 -0400 X-Listener-Flag: 11101 Message-ID: <1425903386.13300.33.camel@mhfsdcap03> Subject: Re: [PATCH 2/5] iommu/mediatek: Add mt8173 IOMMU driver From: Yong Wu To: Mitchel Humpherys CC: Rob Herring , Joerg Roedel , Matthias Brugger , Mark Rutland , , , Catalin Marinas , Will Deacon , , "Tomasz Figa" , , Daniel Kurtz , Sasha Hauer , , Robin Murphy , , Lucas Stach Date: Mon, 9 Mar 2015 20:16:26 +0800 In-Reply-To: References: <1425638900-24989-1-git-send-email-yong.wu@mediatek.com> <1425638900-24989-3-git-send-email-yong.wu@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear Mitchel, Thanks very much for your review. On Fri, 2015-03-06 at 09:15 -0800, Mitchel Humpherys wrote: > On Fri, Mar 06 2015 at 02:48:17 AM, wrote: > > From: Yong Wu > > > > This patch adds support for mediatek m4u (MultiMedia Memory Management Unit). > > Currently this only supports m4u gen 2 with 2 levels of page table on mt8173. > > [...] > > > +static int mtk_iommu_invalidate_tlb(const struct mtk_iommu_info *piommu, > > + int isinvall, unsigned int iova_start, > > + unsigned int iova_end) > > +{ > > + void __iomem *m4u_base = piommu->m4u_base; > > + u32 val; > > + u64 start, end; > > + > > + start = sched_clock(); > > + > > + if (!isinvall) { > > + iova_start = round_down(iova_start, SZ_4K); > > + iova_end = round_up(iova_end, SZ_4K); > > + } > > + > > + val = F_MMU_INV_EN_L2 | F_MMU_INV_EN_L1; > > + > > + writel(val, m4u_base + REG_INVLID_SEL); > > + > > + if (isinvall) { > > + writel(F_MMU_INV_ALL, m4u_base + REG_MMU_INVLD); > > + } else { > > + writel(iova_start, m4u_base + REG_MMU_INVLD_SA); > > + writel(iova_end, m4u_base + REG_MMU_INVLD_EA); > > + writel(F_MMU_INV_RANGE, m4u_base + REG_MMU_INVLD); > > + > > + while (!readl(m4u_base + REG_MMU_CPE_DONE)) { > > + end = sched_clock(); > > + if (end - start >= 100000000ULL) { > > + dev_warn(piommu->dev, "invalid don't done\n"); > > + writel(F_MMU_INV_ALL, m4u_base + REG_MMU_INVLD); > > + } > > + }; > > Superfluous `;'. Also, maybe you should be using readl_poll_timeout? Thanks. For the "readl_poll_timeout", My base is 3.19-rc7 and robin's patch. it don't have this interface. I will try to add it in the next version. > > > + writel(0, m4u_base + REG_MMU_CPE_DONE); > > + } > > + > > + return 0; > > +} > > > > -Mitch > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yong Wu Subject: Re: [PATCH 2/5] iommu/mediatek: Add mt8173 IOMMU driver Date: Mon, 9 Mar 2015 20:16:26 +0800 Message-ID: <1425903386.13300.33.camel@mhfsdcap03> References: <1425638900-24989-1-git-send-email-yong.wu@mediatek.com> <1425638900-24989-3-git-send-email-yong.wu@mediatek.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Mitchel Humpherys Cc: Mark Rutland , devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, srv_heupstream-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org, Catalin Marinas , Will Deacon , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Tomasz Figa , iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, Rob Herring , Daniel Kurtz , Sasha Hauer , Matthias Brugger , linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, Lucas Stach List-Id: devicetree@vger.kernel.org Dear Mitchel, Thanks very much for your review. On Fri, 2015-03-06 at 09:15 -0800, Mitchel Humpherys wrote: > On Fri, Mar 06 2015 at 02:48:17 AM, wrote: > > From: Yong Wu > > > > This patch adds support for mediatek m4u (MultiMedia Memory Management Unit). > > Currently this only supports m4u gen 2 with 2 levels of page table on mt8173. > > [...] > > > +static int mtk_iommu_invalidate_tlb(const struct mtk_iommu_info *piommu, > > + int isinvall, unsigned int iova_start, > > + unsigned int iova_end) > > +{ > > + void __iomem *m4u_base = piommu->m4u_base; > > + u32 val; > > + u64 start, end; > > + > > + start = sched_clock(); > > + > > + if (!isinvall) { > > + iova_start = round_down(iova_start, SZ_4K); > > + iova_end = round_up(iova_end, SZ_4K); > > + } > > + > > + val = F_MMU_INV_EN_L2 | F_MMU_INV_EN_L1; > > + > > + writel(val, m4u_base + REG_INVLID_SEL); > > + > > + if (isinvall) { > > + writel(F_MMU_INV_ALL, m4u_base + REG_MMU_INVLD); > > + } else { > > + writel(iova_start, m4u_base + REG_MMU_INVLD_SA); > > + writel(iova_end, m4u_base + REG_MMU_INVLD_EA); > > + writel(F_MMU_INV_RANGE, m4u_base + REG_MMU_INVLD); > > + > > + while (!readl(m4u_base + REG_MMU_CPE_DONE)) { > > + end = sched_clock(); > > + if (end - start >= 100000000ULL) { > > + dev_warn(piommu->dev, "invalid don't done\n"); > > + writel(F_MMU_INV_ALL, m4u_base + REG_MMU_INVLD); > > + } > > + }; > > Superfluous `;'. Also, maybe you should be using readl_poll_timeout? Thanks. For the "readl_poll_timeout", My base is 3.19-rc7 and robin's patch. it don't have this interface. I will try to add it in the next version. > > > + writel(0, m4u_base + REG_MMU_CPE_DONE); > > + } > > + > > + return 0; > > +} > > > > -Mitch > From mboxrd@z Thu Jan 1 00:00:00 1970 From: yong.wu@mediatek.com (Yong Wu) Date: Mon, 9 Mar 2015 20:16:26 +0800 Subject: [PATCH 2/5] iommu/mediatek: Add mt8173 IOMMU driver In-Reply-To: References: <1425638900-24989-1-git-send-email-yong.wu@mediatek.com> <1425638900-24989-3-git-send-email-yong.wu@mediatek.com> Message-ID: <1425903386.13300.33.camel@mhfsdcap03> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Dear Mitchel, Thanks very much for your review. On Fri, 2015-03-06 at 09:15 -0800, Mitchel Humpherys wrote: > On Fri, Mar 06 2015 at 02:48:17 AM, wrote: > > From: Yong Wu > > > > This patch adds support for mediatek m4u (MultiMedia Memory Management Unit). > > Currently this only supports m4u gen 2 with 2 levels of page table on mt8173. > > [...] > > > +static int mtk_iommu_invalidate_tlb(const struct mtk_iommu_info *piommu, > > + int isinvall, unsigned int iova_start, > > + unsigned int iova_end) > > +{ > > + void __iomem *m4u_base = piommu->m4u_base; > > + u32 val; > > + u64 start, end; > > + > > + start = sched_clock(); > > + > > + if (!isinvall) { > > + iova_start = round_down(iova_start, SZ_4K); > > + iova_end = round_up(iova_end, SZ_4K); > > + } > > + > > + val = F_MMU_INV_EN_L2 | F_MMU_INV_EN_L1; > > + > > + writel(val, m4u_base + REG_INVLID_SEL); > > + > > + if (isinvall) { > > + writel(F_MMU_INV_ALL, m4u_base + REG_MMU_INVLD); > > + } else { > > + writel(iova_start, m4u_base + REG_MMU_INVLD_SA); > > + writel(iova_end, m4u_base + REG_MMU_INVLD_EA); > > + writel(F_MMU_INV_RANGE, m4u_base + REG_MMU_INVLD); > > + > > + while (!readl(m4u_base + REG_MMU_CPE_DONE)) { > > + end = sched_clock(); > > + if (end - start >= 100000000ULL) { > > + dev_warn(piommu->dev, "invalid don't done\n"); > > + writel(F_MMU_INV_ALL, m4u_base + REG_MMU_INVLD); > > + } > > + }; > > Superfluous `;'. Also, maybe you should be using readl_poll_timeout? Thanks. For the "readl_poll_timeout", My base is 3.19-rc7 and robin's patch. it don't have this interface. I will try to add it in the next version. > > > + writel(0, m4u_base + REG_MMU_CPE_DONE); > > + } > > + > > + return 0; > > +} > > > > -Mitch >