From patchwork Wed Mar 4 15:51:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baptiste Reynal X-Patchwork-Id: 5937431 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B4E979F380 for ; Wed, 4 Mar 2015 15:54:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DE96E2026C for ; Wed, 4 Mar 2015 15:54:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 09FDE20272 for ; Wed, 4 Mar 2015 15:54:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YTBax-0007zU-MB; Wed, 04 Mar 2015 15:52:23 +0000 Received: from mail-we0-f182.google.com ([74.125.82.182]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YTBas-0007U8-9n for linux-arm-kernel@lists.infradead.org; Wed, 04 Mar 2015 15:52:19 +0000 Received: by wesu56 with SMTP id u56so47236348wes.10 for ; Wed, 04 Mar 2015 07:51:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ckDyTFt2AXofZVwRTHD+Co4ojIS9d4IeUTc15YFPDp4=; b=CDm5eMRRiuo9UwutosEIANPFy8pfdobt1Q1WQXWyaEISNbhPe+FqTjvMbFDMBrF86w R40Jh6jXIkm3+yPxmm8bhlwtZudBD3fF6ufCcC0ZizLusKUxkyXkaCmLaDLEPFZGsPrl 1eVglQZ1o5wHvIc/BzVTP1PLQx3Q/bNFLLq4yDeCLpOup4rWQHandnHiJEE9WcD9VUXY piSdI4L6pY0rFZkcqFH92rIqQ00fyMoccRNnq9sBGxOUhn87jlxpCEN6wEuTVluKkQHA p7O9kNz6aJkugOQRFAYvDplZ4hvr6gjFBZ+3L3Mdm3wQXLXqwBr2307RGwgsphU7fcOG feAQ== X-Gm-Message-State: ALoCoQltgSmMWBzw0b8pw610UTesgbKtWuzP4TM6A29/KCkSLJVdRu0+j8lsTQlNSaZOCbf3PvZl X-Received: by 10.194.78.114 with SMTP id a18mr9771546wjx.0.1425484314189; Wed, 04 Mar 2015 07:51:54 -0800 (PST) Received: from localhost (LPuteaux-656-1-278-113.w80-15.abo.wanadoo.fr. [80.15.154.113]) by mx.google.com with ESMTPSA id h11sm25732764wic.14.2015.03.04.07.51.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Mar 2015 07:51:53 -0800 (PST) From: Baptiste Reynal To: iommu@lists.linux-foundation.org, kvmarm@lists.cs.columbia.edu, will.deacon@arm.com Subject: [PATCH v2 1/1] iommu/arm-smmu: fix ARM_SMMU_FEAT_TRANS_OPS condition Date: Wed, 4 Mar 2015 16:51:06 +0100 Message-Id: <1425484266-5449-1-git-send-email-b.reynal@virtualopensystems.com> X-Mailer: git-send-email 2.3.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150304_075218_501968_ADEB8891 X-CRM114-Status: GOOD ( 11.75 ) X-Spam-Score: -0.7 (/) Cc: Joerg Roedel , tech@virtualopensystems.com, Baptiste Reynal , open list , "moderated list:ARM SMMU DRIVER" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch is a fix to "iommu/arm-smmu: add support for iova_to_phys through ATS1PR". According to ARM documentation, translation registers are optional even in SMMUv1, so ID0_S1TS needs to be checked to verify their presence. Also, we check that the domain is a stage-1 domain. Signed-off-by: Baptiste Reynal Acked-by: Will Deacon --- v1 -> v2: Add domain stage test (Thanks to Will Deacon) --- drivers/iommu/arm-smmu.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index fc13dd5..a3adde6 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1288,10 +1288,13 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain, return 0; spin_lock_irqsave(&smmu_domain->pgtbl_lock, flags); - if (smmu_domain->smmu->features & ARM_SMMU_FEAT_TRANS_OPS) + if (smmu_domain->smmu->features & ARM_SMMU_FEAT_TRANS_OPS && + smmu_domain->stage == ARM_SMMU_DOMAIN_S1) { ret = arm_smmu_iova_to_phys_hard(domain, iova); - else + } else { ret = ops->iova_to_phys(ops, iova); + } + spin_unlock_irqrestore(&smmu_domain->pgtbl_lock, flags); return ret; @@ -1556,7 +1559,7 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu) return -ENODEV; } - if (smmu->version == 1 || (!(id & ID0_ATOSNS) && (id & ID0_S1TS))) { + if ((id & ID0_S1TS) && ((smmu->version == 1) || (id & ID0_ATOSNS))) { smmu->features |= ARM_SMMU_FEAT_TRANS_OPS; dev_notice(smmu->dev, "\taddress translation ops\n"); }