Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp743238pxb; Fri, 8 Jan 2021 17:52:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxgISldioOzqXHVt7kd9sJD9RMjSWzX1t/lf73yDrj6l9ZdamWnHBBy4yuefCMX4RsCrQgr X-Received: by 2002:aa7:da8f:: with SMTP id q15mr6989887eds.239.1610157176440; Fri, 08 Jan 2021 17:52:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610157176; cv=none; d=google.com; s=arc-20160816; b=ubNkYbybllzuW9M80fl7gd41irJewW5M2SB1+9+r282Hk2tBl79klAGMpD7me2bw+/ a4ZgC4HKMUTOqVcw414nRK9GRJQnVIAxeG7C61qsG+mbyAaNmPp/BXUBP5AKuag88x7q fDQIyOpst/uRz2adjTvNrqK4piRs/vVcoqAwzqrV+tvFLYzbgsTrYcQruTIkh/HS9FDV /keeMZzlLDuOWmbJoknImAzy+0AYiNEZNzlDSisahomYiznEc25pkjZYjOPAt/ukSqam V7jJLFY4wJLVqN8reHXzGk8BRuri7KHHXSAAqJs4/mOSEVMKKnocGUkztzUGDDOEhK2z SMrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dmarc-filter:sender:dkim-signature; bh=4VlYJjycp9thhHjeXNULwYOSsBipk6tgLXy1jq906Q8=; b=MwOFTnn19Saj7eO9nFW2CwiSx59qju1p8sTJ+7shwAOmQhKmli5u66CruOB+ouU3+Q dTJI93hSbOvhcSywEjqS61fR/eOOQHHZEsbDPA4StFS72OdrUWWzeG5A+FWPNoGyxsVO th9VpdUJv5wi6tQuzJsuAYZfkB8db1c0Eo5HBofoQMtVu+Ugh9HLurQelC8GHBMIq+pz y9snRLAk4tmvEllhXDzCzWr7YlfyohNilnirPn1uV1fEf5P5hD9Nzn2gdCa0EfXK8yhX dBJOE1eB6zVTpBjozSJ6GbRSrSjSHmBY1MJj3237JqPKUmJXr30PWuhUzQRakoUIM/+/ OUiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=UDghxFsB; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ck15si4169682edb.37.2021.01.08.17.52.33; Fri, 08 Jan 2021 17:52:56 -0800 (PST) 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=pass header.i=@mg.codeaurora.org header.s=smtp header.b=UDghxFsB; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726576AbhAIBvd (ORCPT + 99 others); Fri, 8 Jan 2021 20:51:33 -0500 Received: from m43-15.mailgun.net ([69.72.43.15]:10336 "EHLO m43-15.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725817AbhAIBvc (ORCPT ); Fri, 8 Jan 2021 20:51:32 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1610157071; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=4VlYJjycp9thhHjeXNULwYOSsBipk6tgLXy1jq906Q8=; b=UDghxFsB9EFiPCty4FzAewC3eqg2UewJuODl2Ah8X4KnMhd/7EfOjOP0i7XB/5JyBMj0dm5g f355ddSJtxWqqJpv6mau1MUQTj6vD+l/7yQGNFwVEytCqfXkVIMKO78J+5wLg5aOYwY6uJgT HlJ+lJVRjaM/zz+DgFhq4SGnr7I= X-Mailgun-Sending-Ip: 69.72.43.15 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n09.prod.us-east-1.postgun.com with SMTP id 5ff90bf58fb3cda82f7d6b6f (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sat, 09 Jan 2021 01:50:45 GMT Sender: isaacm=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 2476AC433CA; Sat, 9 Jan 2021 01:50:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL autolearn=no autolearn_force=no version=3.4.0 Received: from isaacm-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: isaacm) by smtp.codeaurora.org (Postfix) with ESMTPSA id 32180C433C6; Sat, 9 Jan 2021 01:50:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 32180C433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=isaacm@codeaurora.org From: "Isaac J. Manjarres" To: will@kernel.org, robin.murphy@arm.com, joro@8bytes.org Cc: "Isaac J. Manjarres" , pdaly@codeaurora.org, pratikp@codeaurora.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] iommu/io-pgtable: Introduce map_sg() as a page table op Date: Fri, 8 Jan 2021 17:50:27 -0800 Message-Id: <1610157031-26301-2-git-send-email-isaacm@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1610157031-26301-1-git-send-email-isaacm@codeaurora.org> References: <1610157031-26301-1-git-send-email-isaacm@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While mapping a scatter-gather list, iommu_map_sg() calls into the IOMMU driver through an indirect call, which can call into the io-pgtable code through another indirect call. This sequence of going through the IOMMU core code, the IOMMU driver, and finally the io-pgtable code, occurs for every element in the scatter-gather list, in the worse case, which is not optimal. Introduce a map_sg callback in the io-pgtable ops so that IOMMU drivers can invoke it with the complete scatter-gather list, so that it can be processed within the io-pgtable code entirely, reducing the number of indirect calls, and boosting overall iommu_map_sg() performance. Signed-off-by: Isaac J. Manjarres --- include/linux/io-pgtable.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/io-pgtable.h b/include/linux/io-pgtable.h index ea727eb..6d0e731 100644 --- a/include/linux/io-pgtable.h +++ b/include/linux/io-pgtable.h @@ -147,6 +147,9 @@ struct io_pgtable_cfg { * struct io_pgtable_ops - Page table manipulation API for IOMMU drivers. * * @map: Map a physically contiguous memory region. + * @map_sg: Map a scatter-gather list of physically contiguous memory + * chunks. The mapped pointer argument is used to store how + * many bytes are mapped. * @unmap: Unmap a physically contiguous memory region. * @iova_to_phys: Translate iova to physical address. * @@ -156,6 +159,9 @@ struct io_pgtable_cfg { struct io_pgtable_ops { int (*map)(struct io_pgtable_ops *ops, unsigned long iova, phys_addr_t paddr, size_t size, int prot, gfp_t gfp); + int (*map_sg)(struct io_pgtable_ops *ops, unsigned long iova, + struct scatterlist *sg, unsigned int nents, int prot, + gfp_t gfp, size_t *mapped); size_t (*unmap)(struct io_pgtable_ops *ops, unsigned long iova, size_t size, struct iommu_iotlb_gather *gather); phys_addr_t (*iova_to_phys)(struct io_pgtable_ops *ops, -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project