From patchwork Mon Jun 30 16:51:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olav Haugan X-Patchwork-Id: 4453211 Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5C3B1BEEAA for ; Mon, 30 Jun 2014 16:52:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0761C2037E for ; Mon, 30 Jun 2014 16:52:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 927AF2034B for ; Mon, 30 Jun 2014 16:52:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754697AbaF3Qw1 (ORCPT ); Mon, 30 Jun 2014 12:52:27 -0400 Received: from smtp.codeaurora.org ([198.145.11.231]:57537 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754689AbaF3QwZ (ORCPT ); Mon, 30 Jun 2014 12:52:25 -0400 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 6325113FEB6; Mon, 30 Jun 2014 16:52:25 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 4FFCD13FEB7; Mon, 30 Jun 2014 16:52:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from ohaugan-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: ohaugan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 9A2DF13FEAC; Mon, 30 Jun 2014 16:52:24 +0000 (UTC) From: Olav Haugan To: linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org Cc: linux-arm-msm@vger.kernel.org, will.deacon@arm.com, thierry.reding@gmail.com, joro@8bytes.org, vgandhi@codeaurora.org, Olav Haugan Subject: [RFC/PATCH 7/7] iommu-api: Add domain attribute to enable coherent HTW Date: Mon, 30 Jun 2014 09:51:56 -0700 Message-Id: <1404147116-4598-8-git-send-email-ohaugan@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1404147116-4598-1-git-send-email-ohaugan@codeaurora.org> References: <1404147116-4598-1-git-send-email-ohaugan@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a new iommu domain attribute that can be used to enable cache coherent hardware table walks (HTW) by the SMMU. HTW might be supported by the SMMU HW but depending on the use case and the usage of the SMMU in the SoC it might not be always beneficial to always turn on coherent HTW for all domains/iommu's. Signed-off-by: Olav Haugan --- drivers/iommu/msm_iommu-v1.c | 16 ++++++++++++++++ include/linux/iommu.h | 1 + 2 files changed, 17 insertions(+) diff --git a/drivers/iommu/msm_iommu-v1.c b/drivers/iommu/msm_iommu-v1.c index 2c574ef..e163ffc 100644 --- a/drivers/iommu/msm_iommu-v1.c +++ b/drivers/iommu/msm_iommu-v1.c @@ -1456,8 +1456,16 @@ static int msm_domain_get_attr(struct iommu_domain *domain, enum iommu_attr attr, void *data) { s32 ret = 0; + struct msm_iommu_priv *priv = domain->priv; switch (attr) { + case DOMAIN_ATTR_COHERENT_HTW: + { + s32 *int_ptr = (s32 *) data; + + *int_ptr = priv->pt.redirect; + break; + } default: pr_err("Unsupported attribute type\n"); ret = -EINVAL; @@ -1471,8 +1479,16 @@ static int msm_domain_set_attr(struct iommu_domain *domain, enum iommu_attr attr, void *data) { s32 ret = 0; + struct msm_iommu_priv *priv = domain->priv; switch (attr) { + case DOMAIN_ATTR_COHERENT_HTW: + { + s32 *int_ptr = (s32 *) data; + + priv->pt.redirect = *int_ptr; + break; + } default: pr_err("Unsupported attribute type\n"); ret = -EINVAL; diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 63dca6d..6d9596d 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -81,6 +81,7 @@ enum iommu_attr { DOMAIN_ATTR_FSL_PAMU_STASH, DOMAIN_ATTR_FSL_PAMU_ENABLE, DOMAIN_ATTR_FSL_PAMUV1, + DOMAIN_ATTR_COHERENT_HTW, DOMAIN_ATTR_MAX, };