From patchwork Wed May 31 15:48:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 13262476 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03D8BC7EE2F for ; Wed, 31 May 2023 15:49:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94AF88E000D; Wed, 31 May 2023 11:49:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FAC28E0003; Wed, 31 May 2023 11:49:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 726458E000D; Wed, 31 May 2023 11:49:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 654FE8E0003 for ; Wed, 31 May 2023 11:49:39 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 28794802C0 for ; Wed, 31 May 2023 15:49:39 +0000 (UTC) X-FDA: 80850985278.18.CEF738C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id 4FABA140019 for ; Wed, 31 May 2023 15:49:36 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf09.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685548177; a=rsa-sha256; cv=none; b=OBWStHF2Pr4z+YRI4v80iuGNHCvCmkDFY/g8wMa9q/fqq4EYqYmZT2MFUp3yyw9xX6UKhT GJNI4tD8ZsEzOS+Sz86m3RQ3YrRt+jVW9feAjQMcbWgAebhZDbNthWOimQZC71Fj8/Rr6+ 5PHkPYYT23AdDp9Aeyh5RRL2Rfj/8rQ= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf09.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685548177; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u1UyWoVJ6Ep1SVIdrbWokxdwP4Oi3eNvYJYbfxSDnZ0=; b=o4lXYBvRMbnfLbkePqPZHj0GaaXmtOZ1oghS1q1AcTSnqi9/CfUXdArvvues97fN9cuIjj BlvRUZMNXrh/yFhxtca6etjODMoE0Oe3ieTxhb4QOAxShuSIbs1Yrmi5gaeq4kPiXR/1fj CqgJKNbGuSADjD21CEuptKsd3SWZbuU= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 556EA63D5F; Wed, 31 May 2023 15:49:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC8BDC433A1; Wed, 31 May 2023 15:49:31 +0000 (UTC) From: Catalin Marinas To: Linus Torvalds , Christoph Hellwig , Robin Murphy Cc: Arnd Bergmann , Greg Kroah-Hartman , Will Deacon , Marc Zyngier , Andrew Morton , Herbert Xu , Ard Biesheuvel , Isaac Manjarres , Saravana Kannan , Alasdair Kergon , Daniel Vetter , Joerg Roedel , Mark Brown , Mike Snitzer , "Rafael J. Wysocki" , Jonathan Cameron , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Jerry Snitselaar , Logan Gunthorpe Subject: [PATCH v6 13/17] dma-mapping: Name SG DMA flag helpers consistently Date: Wed, 31 May 2023 16:48:32 +0100 Message-Id: <20230531154836.1366225-14-catalin.marinas@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230531154836.1366225-1-catalin.marinas@arm.com> References: <20230531154836.1366225-1-catalin.marinas@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 4FABA140019 X-Stat-Signature: nre4hx18xcxbezcud57nrgdg47jnm7xa X-Rspam-User: X-HE-Tag: 1685548176-55773 X-HE-Meta: U2FsdGVkX19dQIbELjEsZpBDEc9qkwiZQcCjJkBFdb+9yLfRAIQFx0tRvfs6qacuSv/w7SFbMHQSkDcbSiJ+WOs722WRvJRprK9e9AKh+Pz4XMJ4KGC/iSVk4rGaKPIuYUXdqJxYPJlUcDwwlUHbAcG2tS75bjBHQ5RdS08+7Cwoo7fQY/khoj2bgVVXnbkmH2zfpN4ydU8icdvP2M3vkk3wGGB9IFPgKU6Kvac3DjP/CNPF1FRLq+POQpMbxZZFVoVK3wcz8DhVbRnPPCmxBUjbkTEIUVMVmwmsknzlu9PetM9PHZy5j8O6PW1vWbJV2Riffy2WeJIzDIXTgLS2srOCDRXo4VW2rCRlDMx9fXbtUmtVCny7vWRzziCI3H3DH0NPZndhjy66BiNE0TehJISh0gsCQYCqiEFzuwBFVx4UP9rXxNO0EhT9APzFNYo8SpyOPHLnAHvT51cxS9gAjQ9Ld4orGZHiyhw1b9x2VujETGJ9UUaWpFhngsKrQdY6pJxL3lF46/t8obJVK/FJ0mpqx/NZOBtUd0zSzWf71QbOgKx7J1L/jcZD63btWWgiQwHs6IohC2xw1lMmKKFaueBEaS/nzHwUnYhbPak4bfVcWjREzrmlNdECyJMXH9NYAPM1dxTFJy48pDoe5lKS7brTyLmNuD23xo8mNTZ/NBRQQO+CtEWhf8jPnT3aXXCfI9ukLdLHzhkOO0lehJfVsjXlxCpjkuXtEXytvwvsiWIW4VsdrYJEIJV+2CmUabHfIJli68t82s4KvIA0xbSJJXnkNNgbXF8/J/F9vEfGJYnMO51kkifaw6HNU5ynAu+M2IIoDJfW0+OrPHE5SP+uZH50uQrV0yOcxiVs4Hu7gjKJ1UGLq2a8qTa2lLdR0OsKaHKrQDs01wavxZpVu3b2KDLmy1Ud+2cLh5Vpo+9mG2KGSNmz7XrbyDXNv97DtWWdarxHsenjGHU+W/Ci23V tOn5PwZw k28uPEx6VkfinAz8w86FbMNprKb1aorGaYwYlhpTTinVFC1PjGQF0MfyuU2d/ai+8n+6y0URXnFWZvbQbooN2mPfvqLiwjxJudQCA1C4PlbLlj5Hyf+QYSyadm7OA8ly61/eB8rKKj+ZH6jv+OEAnE0q9WHxphypftuWdjvxZArsczIZdG/h1YOhOH0gEwemR+SpcRK4qWXdh7blOu+0Bs+ydodJylcSP8L6CDPVF1XJfVwhtbw1SpTWnkJxp3NAUckIoBUD1aN+HAikUqK8NCxGZFvlUkg+2ejQ1YhrZyPYn59A9EtfYL6jO1cZB97sjsa9QXXk7N30skafPnuVFpiF9DVATQ6TH4gR1n1jOpdALMlsA3wEv7HyNUkHJ5SOgRSM/NBwulO7kpT0VvsCBsI/0pSgtK0S8ZjWNkK1xF7mno+ihPSoyCUzSpPTfPBe1fmrTM8qMyqfNvDfgzwQlROLc2vyXs4RnsUn44x5fvNQd8EWeqYfO27eVbgjDUJWGIyyTAe3YajaNJ2pIiaUw3CJgILjxIkDmag0eu5VpHCOZqs8kNj/Ckm2UiI7azkY/L42QSIQMTPD2hCmPatbcaCXvtgbUDRJFRD1D X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Robin Murphy sg_is_dma_bus_address() is inconsistent with the naming pattern of its corresponding setters and its own kerneldoc, so take the majority vote and rename it sg_dma_is_bus_address() (and fix up the missing underscores in the kerneldoc too). This gives us a nice clear pattern where SG DMA flags are SG_DMA_, and the helpers for acting on them are sg_dma__(). Signed-off-by: Robin Murphy Reviewed-by: Christoph Hellwig Reviewed-by: Jerry Snitselaar Reviewed-by: Logan Gunthorpe Link: https://lore.kernel.org/r/fa2eca2862c7ffc41b50337abffb2dfd2864d3ea.1685036694.git.robin.murphy@arm.com Signed-off-by: Catalin Marinas --- drivers/iommu/dma-iommu.c | 8 ++++---- drivers/iommu/iommu.c | 2 +- include/linux/scatterlist.h | 8 ++++---- kernel/dma/direct.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 7a9f0b0bddbd..b8bba4aa196f 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -1080,7 +1080,7 @@ static int __finalise_sg(struct device *dev, struct scatterlist *sg, int nents, sg_dma_address(s) = DMA_MAPPING_ERROR; sg_dma_len(s) = 0; - if (sg_is_dma_bus_address(s)) { + if (sg_dma_is_bus_address(s)) { if (i > 0) cur = sg_next(cur); @@ -1136,7 +1136,7 @@ static void __invalidate_sg(struct scatterlist *sg, int nents) int i; for_each_sg(sg, s, nents, i) { - if (sg_is_dma_bus_address(s)) { + if (sg_dma_is_bus_address(s)) { sg_dma_unmark_bus_address(s); } else { if (sg_dma_address(s) != DMA_MAPPING_ERROR) @@ -1329,7 +1329,7 @@ static void iommu_dma_unmap_sg(struct device *dev, struct scatterlist *sg, * just have to be determined. */ for_each_sg(sg, tmp, nents, i) { - if (sg_is_dma_bus_address(tmp)) { + if (sg_dma_is_bus_address(tmp)) { sg_dma_unmark_bus_address(tmp); continue; } @@ -1343,7 +1343,7 @@ static void iommu_dma_unmap_sg(struct device *dev, struct scatterlist *sg, nents -= i; for_each_sg(tmp, tmp, nents, i) { - if (sg_is_dma_bus_address(tmp)) { + if (sg_dma_is_bus_address(tmp)) { sg_dma_unmark_bus_address(tmp); continue; } diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index f1dcfa3f1a1b..eb620552967b 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2567,7 +2567,7 @@ ssize_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova, len = 0; } - if (sg_is_dma_bus_address(sg)) + if (sg_dma_is_bus_address(sg)) goto next; if (len) { diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 19833fd4113b..2f06178996ba 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -258,7 +258,7 @@ static inline void sg_unmark_end(struct scatterlist *sg) #define SG_DMA_BUS_ADDRESS (1 << 0) /** - * sg_dma_is_bus address - Return whether a given segment was marked + * sg_dma_is_bus_address - Return whether a given segment was marked * as a bus address * @sg: SG entry * @@ -266,13 +266,13 @@ static inline void sg_unmark_end(struct scatterlist *sg) * Returns true if sg_dma_mark_bus_address() has been called on * this segment. **/ -static inline bool sg_is_dma_bus_address(struct scatterlist *sg) +static inline bool sg_dma_is_bus_address(struct scatterlist *sg) { return sg->dma_flags & SG_DMA_BUS_ADDRESS; } /** - * sg_dma_mark_bus address - Mark the scatterlist entry as a bus address + * sg_dma_mark_bus_address - Mark the scatterlist entry as a bus address * @sg: SG entry * * Description: @@ -300,7 +300,7 @@ static inline void sg_dma_unmark_bus_address(struct scatterlist *sg) #else -static inline bool sg_is_dma_bus_address(struct scatterlist *sg) +static inline bool sg_dma_is_bus_address(struct scatterlist *sg) { return false; } diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 5595d1d5cdcc..d29cade048db 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -463,7 +463,7 @@ void dma_direct_unmap_sg(struct device *dev, struct scatterlist *sgl, int i; for_each_sg(sgl, sg, nents, i) { - if (sg_is_dma_bus_address(sg)) + if (sg_dma_is_bus_address(sg)) sg_dma_unmark_bus_address(sg); else dma_direct_unmap_page(dev, sg->dma_address,