From patchwork Tue Feb 5 16:37:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 157482 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5375943jaa; Tue, 5 Feb 2019 08:37:36 -0800 (PST) X-Google-Smtp-Source: AHgI3IajRm3h+sr5dkMEKnLKPu9oM8XgmQ6jjb5YgjmdOPNXl0BLm3b4hf4UlszzPyNnE0o/vW3r X-Received: by 2002:a65:5c02:: with SMTP id u2mr5280822pgr.13.1549384656310; Tue, 05 Feb 2019 08:37:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549384656; cv=none; d=google.com; s=arc-20160816; b=TAoBtx0JW4CiVoWD/RADI7sJ/saeruDKYQNAkzS3Glrh3HCJW7njRP+/9HeaPLI4g7 ZAgR5h1lrm9DDUbirxnYpiREOS3vQKW89sFcQ415zcP3aW6UdCQwrwBot5Sy55Yjet9u bP16GYjIFEtp4AjhXMhu30GrH0QEQVPxL2FjWEYm6dCKBL09RhEi7vTXzsxZlxpJLiZk r37gsl6LIbsI6hHTSb/g5AU72D11AXpgkiyf9/XC+jz9dsP3dQEyGMhZzI59WCWp9ujK KFufjbDVgQxaT4HbLgbPQV4PRFORrRR0AU5h88EZbKEFD4IYAUf1bmpq8MdpYMC8/g9J X3AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=HBle8rJYyyt01ATizJJrNAmYdunnvDGlqA15wX+Mvo0=; b=IKm6WTeXSxdrwvOI9jT43nbmjFfGvQGrzlBgJCzZLkRj/X/Ppe4KTNUZv5AR0lLsRe TQUPSPWsYEZmpfjA/YiQJ7JThXVPRLkd3olsSaglWiNUi59On0rKLGEEkA7eo+zhlGlA BSsC/btrO0m/bq1u3pwjVWUe9W/+Fn5DxqpDDXlLb8fliK4PbQn5cBXhpYl50PaW/6Ba ELkghU4IX6JX4i85DJuoNrPZvC5o1u79AE2o/XlqHEEno/EIMNkvz0RPT8Pyndafabyy FxcmfNbBgLBg7vQcZo90E/HvnTNPK6xbXwd7zlHMIgRUiWqwWO63Qy9pXEK1m1XAtZRu 3UKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i189si609125pfg.265.2019.02.05.08.37.35; Tue, 05 Feb 2019 08:37:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727441AbfBEQhe (ORCPT + 15 others); Tue, 5 Feb 2019 11:37:34 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:39304 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726742AbfBEQhe (ORCPT ); Tue, 5 Feb 2019 11:37:34 -0500 Received: by mail-ot1-f65.google.com with SMTP id n8so6734202otl.6 for ; Tue, 05 Feb 2019 08:37:33 -0800 (PST) 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:mime-version :content-transfer-encoding; bh=HBle8rJYyyt01ATizJJrNAmYdunnvDGlqA15wX+Mvo0=; b=YrcnnRaUNSLQDiCQz8jyVo7QYwKlwRQzAPHaoNTKY8aChWfrflnnbdDGBQsP8vaETZ tnllRrH+vbh8P/2YCsr8VGKM5PQxfIryTRt10BIeCh7OG0WjaWjG7cBYCC4ncRfWR1Nq jSbtH6hrZ5os7hWclbjaarOdmwM+Xo24A73pNH1z4OAjZMkHoMEPY7A244VmEBTaIyNi yossW2W807aRFY05dleYoP0jmn3tKxbLQ/OaNzOaUHaCKHZSGZnMFlY+VSRT7LAQPocM 049WpIcYw/jHGdUbZHllXv+RZV4rbzxvjJAAH8ziRfwMhBZh4gVtyuqYjcxpiBbCoD1K A1bw== X-Gm-Message-State: AHQUAuZAyL3JFdEvwq5aTzPJ1v8ncNDkvLkS4gVyOirbgUmagXf1vLA6 G2aRCSTXsgmyzOMnEgAqvg== X-Received: by 2002:aca:5053:: with SMTP id e80mr160510oib.334.1549384653183; Tue, 05 Feb 2019 08:37:33 -0800 (PST) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id r9sm9312678otq.81.2019.02.05.08.37.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Feb 2019 08:37:32 -0800 (PST) From: Rob Herring To: Will Deacon , Robin Murphy , Joerg Roedel Cc: Matthias Brugger , Rob Clark , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH] iommu: Allow io-pgtable to be used outside of drivers/iommu/ Date: Tue, 5 Feb 2019 10:37:31 -0600 Message-Id: <20190205163731.17864-1-robh@kernel.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Move io-pgtable.h to include/linux/ and export alloc_io_pgtable_ops and free_io_pgtable_ops. This enables drivers outside drivers/iommu/ to use the ARM page table library. Specifically, some ARM Mali GPUs use the ARM page table formats. Cc: Will Deacon Cc: Robin Murphy Cc: Joerg Roedel Cc: Matthias Brugger Cc: Rob Clark Cc: linux-arm-kernel@lists.infradead.org Cc: iommu@lists.linux-foundation.org Cc: linux-mediatek@lists.infradead.org Cc: linux-arm-msm@vger.kernel.org Signed-off-by: Rob Herring --- This will be needed for an in-progress Mali GPU DRM driver. It's using the page table lib, but is not a full IOMMU driver. It's going to be a few cycles I'd guess before the DRM driver is anywhere close to merging. So I can carry this if preferred, but release early, release often. Rob drivers/iommu/arm-smmu-v3.c | 3 +-- drivers/iommu/arm-smmu.c | 2 +- drivers/iommu/io-pgtable-arm-v7s.c | 3 +-- drivers/iommu/io-pgtable-arm.c | 3 +-- drivers/iommu/io-pgtable.c | 5 +++-- drivers/iommu/ipmmu-vmsa.c | 3 +-- drivers/iommu/msm_iommu.c | 2 +- drivers/iommu/mtk_iommu.h | 3 +-- drivers/iommu/qcom_iommu.c | 2 +- {drivers/iommu => include/linux}/io-pgtable.h | 0 10 files changed, 11 insertions(+), 15 deletions(-) rename {drivers/iommu => include/linux}/io-pgtable.h (100%) -- 2.19.1 diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 0d284029dc73..d3880010c6cf 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -32,8 +33,6 @@ #include -#include "io-pgtable.h" - /* MMIO registers */ #define ARM_SMMU_IDR0 0x0 #define IDR0_ST_LVL GENMASK(28, 27) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index af18a7e7f917..045d93884164 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -56,7 +57,6 @@ #include #include -#include "io-pgtable.h" #include "arm-smmu-regs.h" #define ARM_MMU500_ACTLR_CPRE (1 << 1) diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c index cec29bf45c9b..75a8273d1ae9 100644 --- a/drivers/iommu/io-pgtable-arm-v7s.c +++ b/drivers/iommu/io-pgtable-arm-v7s.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -45,8 +46,6 @@ #include -#include "io-pgtable.h" - /* Struct accessors */ #define io_pgtable_to_data(x) \ container_of((x), struct arm_v7s_io_pgtable, iop) diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index 237cacd4a62b..d3700ec15cbd 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -31,8 +32,6 @@ #include -#include "io-pgtable.h" - #define ARM_LPAE_MAX_ADDR_BITS 52 #define ARM_LPAE_S2_MAX_CONCAT_PAGES 16 #define ARM_LPAE_MAX_LEVELS 4 diff --git a/drivers/iommu/io-pgtable.c b/drivers/iommu/io-pgtable.c index 127558d83667..93f2880be6c6 100644 --- a/drivers/iommu/io-pgtable.c +++ b/drivers/iommu/io-pgtable.c @@ -19,11 +19,10 @@ */ #include +#include #include #include -#include "io-pgtable.h" - static const struct io_pgtable_init_fns * io_pgtable_init_table[IO_PGTABLE_NUM_FMTS] = { #ifdef CONFIG_IOMMU_IO_PGTABLE_LPAE @@ -61,6 +60,7 @@ struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt, return &iop->ops; } +EXPORT_SYMBOL_GPL(alloc_io_pgtable_ops); /* * It is the IOMMU driver's responsibility to ensure that the page table @@ -77,3 +77,4 @@ void free_io_pgtable_ops(struct io_pgtable_ops *ops) io_pgtable_tlb_flush_all(iop); io_pgtable_init_table[iop->fmt]->free(iop); } +EXPORT_SYMBOL_GPL(free_io_pgtable_ops); diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index 7a4529c61c19..9a380c10655e 100644 --- a/drivers/iommu/ipmmu-vmsa.c +++ b/drivers/iommu/ipmmu-vmsa.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -35,8 +36,6 @@ #define arm_iommu_detach_device(...) do {} while (0) #endif -#include "io-pgtable.h" - #define IPMMU_CTX_MAX 8 struct ipmmu_features { diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c index fc4270733f11..ef7d1f995d6b 100644 --- a/drivers/iommu/msm_iommu.c +++ b/drivers/iommu/msm_iommu.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -37,7 +38,6 @@ #include "msm_iommu_hw-8xxx.h" #include "msm_iommu.h" -#include "io-pgtable.h" #define MRC(reg, processor, op1, crn, crm, op2) \ __asm__ __volatile__ ( \ diff --git a/drivers/iommu/mtk_iommu.h b/drivers/iommu/mtk_iommu.h index 778498b8633f..62c2c3e8c5df 100644 --- a/drivers/iommu/mtk_iommu.h +++ b/drivers/iommu/mtk_iommu.h @@ -19,13 +19,12 @@ #include #include #include +#include #include #include #include #include -#include "io-pgtable.h" - struct mtk_iommu_suspend_reg { u32 standard_axi_mode; u32 dcm_dis; diff --git a/drivers/iommu/qcom_iommu.c b/drivers/iommu/qcom_iommu.c index d8595f0a987d..8cdd3f059513 100644 --- a/drivers/iommu/qcom_iommu.c +++ b/drivers/iommu/qcom_iommu.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -42,7 +43,6 @@ #include #include -#include "io-pgtable.h" #include "arm-smmu-regs.h" #define SMMU_INTR_SEL_NS 0x2000 diff --git a/drivers/iommu/io-pgtable.h b/include/linux/io-pgtable.h similarity index 100% rename from drivers/iommu/io-pgtable.h rename to include/linux/io-pgtable.h