Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3862128pxj; Tue, 15 Jun 2021 10:12:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqEY0M92y0Aykdmv4ZNfDUbGM+bVNYvlkDuIcryhut7Y3n4fh7tlSrO6zbSJQTo1qfKU2S X-Received: by 2002:a05:6402:b11:: with SMTP id bm17mr603559edb.109.1623777124072; Tue, 15 Jun 2021 10:12:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623777124; cv=none; d=google.com; s=arc-20160816; b=swrPwxPum7aD3VVkylcWQIb0jV5vU4Ph4JKLr3P+q5nVkCYckHA2ZHXiBUw5TkUVNS MaSbt1V5R8zZ+YMmi+/cklnTqonzlLj2PI/DsoSQ0pPhXyCx2+c/3YMFktpour8AqhEU jysheeiie3Vag+QIbe7saC6vg5fnVCMf3EDuzh5Ks7tiEWP1LjF6Z1npZadkydDMd8CY YQ6r+YBE+1hgI8RC9/HYXM2V+dWjXMO/fmjuktynbRzDHdq86zIv8fX0tNPm5gAeXXNA xAmD8FZnCeKkBMj3rV5o1HRScWWnE9Auo9Eo91bR5YE9xoXs/sK54YXcKhWOpjABeuzn 3UtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=jGubLOSzoJiTaWv5d1Vo6sEFRGY+lWnolL9je9La0nk=; b=mXUSfpxqOvpDFB/QcSFyCmFMfoIONLH/0IyM/X6St+6JxLAkqEt9R+KYXuSzYAM1se P7rX5fp1LkhV9aR+v7ZcMW66bHY2amnsOwGBbvTSDoMKOkY0HbIdaHaZ5HXTnQ+YjTAE IcIinuvdhC+7Q5FZ11IGo/SWuj0JNyI1ifyS0QJA0ommF/RyyiS7QeokqTl4mBBDGz7N fDJEhROysmmL/GLynCtnXCwqjIhbYT/GRnfzPpx5M6jM8A/qjUs864Nctn2aWkwVLEJ5 F2AIyh93eVP/K2+wzTUIkKqjVMfI8PVN5yBXpcnSheITkjz4yC5KVTAYv8sWac+BKBPp zicA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@quicinc.com header.s=qcdkim header.b=wEDGfR00; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id se21si17893272ejb.114.2021.06.15.10.11.39; Tue, 15 Jun 2021 10:12:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@quicinc.com header.s=qcdkim header.b=wEDGfR00; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231493AbhFORLd (ORCPT + 99 others); Tue, 15 Jun 2021 13:11:33 -0400 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:34931 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231243AbhFORK6 (ORCPT ); Tue, 15 Jun 2021 13:10:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1623776934; x=1655312934; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=rwL0tPjHeJsi9VvRsGNXckNgcDwBnKl7/N+tguBCVBM=; b=wEDGfR001+rybPuJEvwYF2UEkLQxmmq9cJfZX9LoJbz2b5CyeLkWIEXr JmjtwIOP5tSl7tgfK2k/CTgPpRBlno1eN3p8A+ntrQt/7SzRsNS3X4Ebs TvmBM1WsS0zjqs6KbBejmiX49+G1CRqcJwvcyVREI65u7XgNlRvweM/62 s=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-02.qualcomm.com with ESMTP; 15 Jun 2021 10:08:54 -0700 X-QCInternal: smtphost Received: from nasanexm03e.na.qualcomm.com ([10.85.0.48]) by ironmsg03-sd.qualcomm.com with ESMTP/TLS/AES256-SHA; 15 Jun 2021 10:08:54 -0700 Received: from th-lint-040.qualcomm.com (10.80.80.8) by nasanexm03e.na.qualcomm.com (10.85.0.48) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 15 Jun 2021 10:08:53 -0700 From: Georgi Djakov To: , CC: , , , , , , , Subject: [PATCH v6 13/15] iommu/io-pgtable-arm-v7s: Implement arm_v7s_map_pages() Date: Tue, 15 Jun 2021 10:08:31 -0700 Message-ID: <1623776913-390160-14-git-send-email-quic_c_gdjako@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1623776913-390160-1-git-send-email-quic_c_gdjako@quicinc.com> References: <1623776913-390160-1-git-send-email-quic_c_gdjako@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanexm03e.na.qualcomm.com (10.85.0.48) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Isaac J. Manjarres" Implement the map_pages() callback for the ARM v7s io-pgtable format. Signed-off-by: Isaac J. Manjarres Signed-off-by: Georgi Djakov --- drivers/iommu/io-pgtable-arm-v7s.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c index 1af060686985..5db90d7ce2ec 100644 --- a/drivers/iommu/io-pgtable-arm-v7s.c +++ b/drivers/iommu/io-pgtable-arm-v7s.c @@ -519,11 +519,12 @@ static int __arm_v7s_map(struct arm_v7s_io_pgtable *data, unsigned long iova, return __arm_v7s_map(data, iova, paddr, size, prot, lvl + 1, cptep, gfp); } -static int arm_v7s_map(struct io_pgtable_ops *ops, unsigned long iova, - phys_addr_t paddr, size_t size, int prot, gfp_t gfp) +static int arm_v7s_map_pages(struct io_pgtable_ops *ops, unsigned long iova, + phys_addr_t paddr, size_t pgsize, size_t pgcount, + int prot, gfp_t gfp, size_t *mapped) { struct arm_v7s_io_pgtable *data = io_pgtable_ops_to_data(ops); - int ret; + int ret = -EINVAL; if (WARN_ON(iova >= (1ULL << data->iop.cfg.ias) || paddr >= (1ULL << data->iop.cfg.oas))) @@ -533,7 +534,17 @@ static int arm_v7s_map(struct io_pgtable_ops *ops, unsigned long iova, if (!(prot & (IOMMU_READ | IOMMU_WRITE))) return 0; - ret = __arm_v7s_map(data, iova, paddr, size, prot, 1, data->pgd, gfp); + while (pgcount--) { + ret = __arm_v7s_map(data, iova, paddr, pgsize, prot, 1, data->pgd, + gfp); + if (ret) + break; + + iova += pgsize; + paddr += pgsize; + if (mapped) + *mapped += pgsize; + } /* * Synchronise all PTE updates for the new mapping before there's * a chance for anything to kick off a table walk for the new iova. @@ -543,6 +554,12 @@ static int arm_v7s_map(struct io_pgtable_ops *ops, unsigned long iova, return ret; } +static int arm_v7s_map(struct io_pgtable_ops *ops, unsigned long iova, + phys_addr_t paddr, size_t size, int prot, gfp_t gfp) +{ + return arm_v7s_map_pages(ops, iova, paddr, size, 1, prot, gfp, NULL); +} + static void arm_v7s_free_pgtable(struct io_pgtable *iop) { struct arm_v7s_io_pgtable *data = io_pgtable_to_data(iop); @@ -797,6 +814,7 @@ static struct io_pgtable *arm_v7s_alloc_pgtable(struct io_pgtable_cfg *cfg, data->iop.ops = (struct io_pgtable_ops) { .map = arm_v7s_map, + .map_pages = arm_v7s_map_pages, .unmap = arm_v7s_unmap, .unmap_pages = arm_v7s_unmap_pages, .iova_to_phys = arm_v7s_iova_to_phys,