From patchwork Tue Apr 25 09:57:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 9697815 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 54F376020A for ; Tue, 25 Apr 2017 09:58:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 435E5283F2 for ; Tue, 25 Apr 2017 09:58:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 367EC285E2; Tue, 25 Apr 2017 09:58:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C16EF283F2 for ; Tue, 25 Apr 2017 09:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=JxPVwaOHCrY7I21nTUq7Ve/UGg6283QLgNRaEX7U9vM=; b=GCY z5+ZY3PW/KMiTsSfSyvMqHcYbjXtXkTq4cF4Tr+1pWXz0+dajvmyiBWUVt4JUwU95xqntCxUwzSOj 9Tuid9BTuGhIAjDG9akxm+d/XoJjQZ4dHeRUxy44r/acjrlpwliCCkKAHE43fRj9eM5aE0KWYT6D+ zhEAvLGVIydpl/8PpIwdUsi4YeQwovZJrnMcjD29oQ+y9RY5+lsIQjYU9uYIrVqULUWq3yfnylVNJ B4WbGlQCmzIKEHX+LIdL69/+BDxNlYWrgjOLb86e+m78GSL8l28AIvpFVJV/XA+tcIyfXDyHe67vv NLc+2JynQLCbAXtM6STt5V6oV7rxzdA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d2xEw-0002Hn-5j; Tue, 25 Apr 2017 09:58:34 +0000 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2xEt-0002Fs-2V for linux-arm-kernel@lists.infradead.org; Tue, 25 Apr 2017 09:58:32 +0000 Received: by mail-pf0-x242.google.com with SMTP id a188so9182018pfa.2 for ; Tue, 25 Apr 2017 02:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=4Jh6B5/xQU/fqHYNRdWPV81o2fV3w6FjTGWZOpMhT8U=; b=Vos5Wf7BZUohg7/3dGV6sWwcfSFH6gjcrKkLyKKfDysg/TcjBdbWyLYvWFcZcHh+S2 xGe+9ucmADX4GKzjUC8SaqV7lfRmqaCPhSxb2qUKsZKKJfry31+r2hyKWDtGIUCU+FhO qYynz8lumU+iSRTuKLv/WSqdPuGUoL+ccNnNdkgrjH2QecoFtChBouPp32Va6gQKRjU5 DSn6Rp0ddK/w625fybsiFGrg3d+PJyGFT0MMbbC9yxe1I+3SSP6e7jD1Mi4hWQXIpKIt nhoNtBhanW25HR5Be6HEFefnB3s9YHkbmxlmxE/mQDmk3W0LM1NUOBFPCsReHnjTNrIA KugA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=4Jh6B5/xQU/fqHYNRdWPV81o2fV3w6FjTGWZOpMhT8U=; b=smWW0QZ7UZQZxOQCEXjIj6O8PUYkoeb21mFdVC3GPIyY+FhFeRs2YOIgedGKaaQ3be mB45/IkKrBhn2e7YP84WD1NThwzHUBWrO5XzUzjvQNg9Gz21WE1amFs0n52H6dM9A6KQ oovwA6OvBytfWjU0p+OVC75TcxYUXYgjaLrGExsw7BiVpk/GiSP6spivNXDOG26/ckyU kzZFj+pfOFTAhARD2DczeAN9SMTiaxSwOfdo1MQs03NMC1pY7WrMX/kujhik14vxdw/Q y8TpofjHNbcDxm/JET0h6eW9Dm54eWyCzvCJxREwmsWPqfZIP6SdcRrb2suisFf23cxT DHFA== X-Gm-Message-State: AN3rC/48aF99a/BoZ1MVhP+B1sJ1xSW4MLkzB3O0h4F78ZorztfFfP1r OePjRhbP2Ulp6Q== X-Received: by 10.98.14.28 with SMTP id w28mr29056077pfi.59.1493114289022; Tue, 25 Apr 2017 02:58:09 -0700 (PDT) Received: from machine421.in.caveonetworks.com ([14.140.2.178]) by smtp.googlemail.com with ESMTPSA id 17sm27352738pgg.48.2017.04.25.02.58.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Apr 2017 02:58:07 -0700 (PDT) From: sunil.kovvuri@gmail.com To: will.deacon@arm.com, iommu@lists.linux-foundation.org Subject: [PATCH v2] iommu/arm-smmu: Return IOVA in iova_to_phys when SMMU is bypassed Date: Tue, 25 Apr 2017 15:27:52 +0530 Message-Id: <1493114272-30093-1-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170425_025831_165685_D6F36C31 X-CRM114-Status: GOOD ( 10.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.richter@cavium.com, Sunil Goutham , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sunil Goutham For software initiated address translation, when domain type is IOMMU_DOMAIN_IDENTITY i.e SMMU is bypassed, mimic HW behavior i.e return the same IOVA as translated address. This patch is an extension to Will Deacon's patchset "Implement SMMU passthrough using the default domain". Signed-off-by: Sunil Goutham Acked-by: Will Deacon --- V2 - As per Will's suggestion applied fix to SMMUv3 driver as well. drivers/iommu/arm-smmu-v3.c | 3 +++ drivers/iommu/arm-smmu.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 05b4592..d412bdd 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -1714,6 +1714,9 @@ arm_smmu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova) struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); struct io_pgtable_ops *ops = smmu_domain->pgtbl_ops; + if (domain->type == IOMMU_DOMAIN_IDENTITY) + return iova; + if (!ops) return 0; diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index bfab4f7..81088cd 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1459,6 +1459,9 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain, struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops; + if (domain->type == IOMMU_DOMAIN_IDENTITY) + return iova; + if (!ops) return 0;