* [PATCH] iommu: Use str_enable_disable-like helpers
@ 2025-01-14 19:26 Krzysztof Kozlowski
2025-01-14 19:53 ` Heiko Stübner
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-14 19:26 UTC (permalink / raw)
To: Will Deacon, Robin Murphy, Joerg Roedel, Yong Wu,
Matthias Brugger, AngeloGioacchino Del Regno, Heiko Stuebner,
linux-arm-kernel, iommu, linux-kernel, linux-mediatek,
linux-rockchip
Cc: Krzysztof Kozlowski
Replace ternary (condition ? "enable" : "disable") syntax with helpers
from string_choices.h because:
1. Simple function call with one argument is easier to read. Ternary
operator has three arguments and with wrapping might lead to quite
long code.
2. Is slightly shorter thus also easier to read.
3. It brings uniformity in the text - same string.
4. Allows deduping by the linker, which results in a smaller binary
file.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 3 ++-
drivers/iommu/arm/arm-smmu/arm-smmu.c | 3 ++-
drivers/iommu/mtk_iommu.c | 9 +++++----
drivers/iommu/mtk_iommu_v1.c | 3 ++-
drivers/iommu/rockchip-iommu.c | 3 ++-
5 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index 0e4cbb2c64d7..358072b4e293 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -26,6 +26,7 @@
#include <linux/pci.h>
#include <linux/pci-ats.h>
#include <linux/platform_device.h>
+#include <linux/string_choices.h>
#include <kunit/visibility.h>
#include <uapi/linux/iommufd.h>
@@ -4321,7 +4322,7 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu)
*/
if (!!(reg & IDR0_COHACC) != coherent)
dev_warn(smmu->dev, "IDR0.COHACC overridden by FW configuration (%s)\n",
- coherent ? "true" : "false");
+ str_true_false(coherent));
switch (FIELD_GET(IDR0_STALL_MODEL, reg)) {
case IDR0_STALL_MODEL_FORCE:
diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
index 79afc92e1d8b..de205a34ffc6 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
@@ -34,6 +34,7 @@
#include <linux/pm_runtime.h>
#include <linux/ratelimit.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include <linux/fsl/mc.h>
@@ -2106,7 +2107,7 @@ static void arm_smmu_rmr_install_bypass_smr(struct arm_smmu_device *smmu)
}
dev_notice(smmu->dev, "\tpreserved %d boot mapping%s\n", cnt,
- cnt == 1 ? "" : "s");
+ str_plural(cnt));
iort_put_rmr_sids(dev_fwnode(smmu->dev), &rmr_list);
}
diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index ab60901f8f92..034b0e670384 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -29,6 +29,7 @@
#include <linux/spinlock.h>
#include <linux/soc/mediatek/infracfg.h>
#include <linux/soc/mediatek/mtk_sip_svc.h>
+#include <linux/string_choices.h>
#include <asm/barrier.h>
#include <soc/mediatek/smi.h>
@@ -510,7 +511,7 @@ static irqreturn_t mtk_iommu_isr(int irq, void *dev_id)
bank->parent_dev,
"fault type=0x%x iova=0x%llx pa=0x%llx master=0x%x(larb=%d port=%d) layer=%d %s\n",
int_state, fault_iova, fault_pa, regval, fault_larb, fault_port,
- layer, write ? "write" : "read");
+ layer, str_write_read(write));
}
/* Interrupt clear */
@@ -602,7 +603,7 @@ static int mtk_iommu_config(struct mtk_iommu_data *data, struct device *dev,
larb_mmu->bank[portid] = upper_32_bits(region->iova_base);
dev_dbg(dev, "%s iommu for larb(%s) port 0x%lx region %d rgn-bank %d.\n",
- enable ? "enable" : "disable", dev_name(larb_mmu->dev),
+ str_enable_disable(enable), dev_name(larb_mmu->dev),
portid_msk, regionid, upper_32_bits(region->iova_base));
if (enable)
@@ -630,8 +631,8 @@ static int mtk_iommu_config(struct mtk_iommu_data *data, struct device *dev,
}
if (ret)
dev_err(dev, "%s iommu(%s) inframaster 0x%lx fail(%d).\n",
- enable ? "enable" : "disable",
- dev_name(data->dev), portid_msk, ret);
+ str_enable_disable(enable), dev_name(data->dev),
+ portid_msk, ret);
}
return ret;
}
diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c
index b6de1ca00cef..a565b9e40f4a 100644
--- a/drivers/iommu/mtk_iommu_v1.c
+++ b/drivers/iommu/mtk_iommu_v1.c
@@ -25,6 +25,7 @@
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
+#include <linux/string_choices.h>
#include <asm/barrier.h>
#include <asm/dma-iommu.h>
#include <dt-bindings/memory/mtk-memory-port.h>
@@ -243,7 +244,7 @@ static void mtk_iommu_v1_config(struct mtk_iommu_v1_data *data,
larb_mmu = &data->larb_imu[larbid];
dev_dbg(dev, "%s iommu port: %d\n",
- enable ? "enable" : "disable", portid);
+ str_enable_disable(enable), portid);
if (enable)
larb_mmu->mmu |= MTK_SMI_MMU_EN(portid);
diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
index 4b369419b32c..323cc665c357 100644
--- a/drivers/iommu/rockchip-iommu.c
+++ b/drivers/iommu/rockchip-iommu.c
@@ -25,6 +25,7 @@
#include <linux/pm_runtime.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
+#include <linux/string_choices.h>
#include "iommu-pages.h"
@@ -611,7 +612,7 @@ static irqreturn_t rk_iommu_irq(int irq, void *dev_id)
dev_err(iommu->dev, "Page fault at %pad of type %s\n",
&iova,
- (flags == IOMMU_FAULT_WRITE) ? "write" : "read");
+ str_write_read(flags == IOMMU_FAULT_WRITE));
log_iova(iommu, i, iova);
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] iommu: Use str_enable_disable-like helpers
2025-01-14 19:26 [PATCH] iommu: Use str_enable_disable-like helpers Krzysztof Kozlowski
@ 2025-01-14 19:53 ` Heiko Stübner
2025-01-15 19:12 ` Jason Gunthorpe
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Heiko Stübner @ 2025-01-14 19:53 UTC (permalink / raw)
To: Will Deacon, Robin Murphy, Joerg Roedel, Yong Wu,
Matthias Brugger, AngeloGioacchino Del Regno, linux-arm-kernel,
iommu, linux-kernel, linux-mediatek, linux-rockchip,
Krzysztof Kozlowski
Cc: Krzysztof Kozlowski
Am Dienstag, 14. Januar 2025, 20:26:42 CET schrieb Krzysztof Kozlowski:
> Replace ternary (condition ? "enable" : "disable") syntax with helpers
> from string_choices.h because:
> 1. Simple function call with one argument is easier to read. Ternary
> operator has three arguments and with wrapping might lead to quite
> long code.
> 2. Is slightly shorter thus also easier to read.
> 3. It brings uniformity in the text - same string.
> 4. Allows deduping by the linker, which results in a smaller binary
> file.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
> drivers/iommu/rockchip-iommu.c | 3 ++-
For the Rockchip part
Acked-by: Heiko Stuebner <heiko@sntech.de>
> diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
> index 4b369419b32c..323cc665c357 100644
> --- a/drivers/iommu/rockchip-iommu.c
> +++ b/drivers/iommu/rockchip-iommu.c
> @@ -25,6 +25,7 @@
> #include <linux/pm_runtime.h>
> #include <linux/slab.h>
> #include <linux/spinlock.h>
> +#include <linux/string_choices.h>
>
> #include "iommu-pages.h"
>
> @@ -611,7 +612,7 @@ static irqreturn_t rk_iommu_irq(int irq, void *dev_id)
>
> dev_err(iommu->dev, "Page fault at %pad of type %s\n",
> &iova,
> - (flags == IOMMU_FAULT_WRITE) ? "write" : "read");
> + str_write_read(flags == IOMMU_FAULT_WRITE));
>
> log_iova(iommu, i, iova);
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iommu: Use str_enable_disable-like helpers
2025-01-14 19:26 [PATCH] iommu: Use str_enable_disable-like helpers Krzysztof Kozlowski
2025-01-14 19:53 ` Heiko Stübner
@ 2025-01-15 19:12 ` Jason Gunthorpe
2025-01-16 3:05 ` Pranjal Shrivastava
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jason Gunthorpe @ 2025-01-15 19:12 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Will Deacon, Robin Murphy, Joerg Roedel, Yong Wu,
Matthias Brugger, AngeloGioacchino Del Regno, Heiko Stuebner,
linux-arm-kernel, iommu, linux-kernel, linux-mediatek,
linux-rockchip
On Tue, Jan 14, 2025 at 08:26:42PM +0100, Krzysztof Kozlowski wrote:
> Replace ternary (condition ? "enable" : "disable") syntax with helpers
> from string_choices.h because:
> 1. Simple function call with one argument is easier to read. Ternary
> operator has three arguments and with wrapping might lead to quite
> long code.
> 2. Is slightly shorter thus also easier to read.
> 3. It brings uniformity in the text - same string.
> 4. Allows deduping by the linker, which results in a smaller binary
> file.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 3 ++-
> drivers/iommu/arm/arm-smmu/arm-smmu.c | 3 ++-
> drivers/iommu/mtk_iommu.c | 9 +++++----
> drivers/iommu/mtk_iommu_v1.c | 3 ++-
> drivers/iommu/rockchip-iommu.c | 3 ++-
> 5 files changed, 13 insertions(+), 8 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iommu: Use str_enable_disable-like helpers
2025-01-14 19:26 [PATCH] iommu: Use str_enable_disable-like helpers Krzysztof Kozlowski
2025-01-14 19:53 ` Heiko Stübner
2025-01-15 19:12 ` Jason Gunthorpe
@ 2025-01-16 3:05 ` Pranjal Shrivastava
2025-01-17 8:01 ` Joerg Roedel
2025-01-20 12:53 ` AngeloGioacchino Del Regno
4 siblings, 0 replies; 6+ messages in thread
From: Pranjal Shrivastava @ 2025-01-16 3:05 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Will Deacon, Robin Murphy, Joerg Roedel, Yong Wu,
Matthias Brugger, AngeloGioacchino Del Regno, Heiko Stuebner,
linux-arm-kernel, iommu, linux-kernel, linux-mediatek,
linux-rockchip
On Tue, Jan 14, 2025 at 08:26:42PM +0100, Krzysztof Kozlowski wrote:
> Replace ternary (condition ? "enable" : "disable") syntax with helpers
> from string_choices.h because:
> 1. Simple function call with one argument is easier to read. Ternary
> operator has three arguments and with wrapping might lead to quite
> long code.
> 2. Is slightly shorter thus also easier to read.
> 3. It brings uniformity in the text - same string.
> 4. Allows deduping by the linker, which results in a smaller binary
> file.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 3 ++-
> drivers/iommu/arm/arm-smmu/arm-smmu.c | 3 ++-
> drivers/iommu/mtk_iommu.c | 9 +++++----
> drivers/iommu/mtk_iommu_v1.c | 3 ++-
> drivers/iommu/rockchip-iommu.c | 3 ++-
> 5 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> index 0e4cbb2c64d7..358072b4e293 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -26,6 +26,7 @@
> #include <linux/pci.h>
> #include <linux/pci-ats.h>
> #include <linux/platform_device.h>
> +#include <linux/string_choices.h>
JFYI, this include was merged in the arm/smmu/updates branch recently,
hence it shouldn't cause any trouble while merging.
> #include <kunit/visibility.h>
> #include <uapi/linux/iommufd.h>
>
> @@ -4321,7 +4322,7 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu)
> */
> if (!!(reg & IDR0_COHACC) != coherent)
> dev_warn(smmu->dev, "IDR0.COHACC overridden by FW configuration (%s)\n",
> - coherent ? "true" : "false");
> + str_true_false(coherent));
>
> switch (FIELD_GET(IDR0_STALL_MODEL, reg)) {
> case IDR0_STALL_MODEL_FORCE:
> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> index 79afc92e1d8b..de205a34ffc6 100644
> --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> @@ -34,6 +34,7 @@
> #include <linux/pm_runtime.h>
> #include <linux/ratelimit.h>
> #include <linux/slab.h>
> +#include <linux/string_choices.h>
>
> #include <linux/fsl/mc.h>
>
> @@ -2106,7 +2107,7 @@ static void arm_smmu_rmr_install_bypass_smr(struct arm_smmu_device *smmu)
> }
>
> dev_notice(smmu->dev, "\tpreserved %d boot mapping%s\n", cnt,
> - cnt == 1 ? "" : "s");
> + str_plural(cnt));
> iort_put_rmr_sids(dev_fwnode(smmu->dev), &rmr_list);
> }
>
For the arm-smmu part.
Acked-by: Pranjal Shrivastava <praan@google.com>
Thanks,
Praan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iommu: Use str_enable_disable-like helpers
2025-01-14 19:26 [PATCH] iommu: Use str_enable_disable-like helpers Krzysztof Kozlowski
` (2 preceding siblings ...)
2025-01-16 3:05 ` Pranjal Shrivastava
@ 2025-01-17 8:01 ` Joerg Roedel
2025-01-20 12:53 ` AngeloGioacchino Del Regno
4 siblings, 0 replies; 6+ messages in thread
From: Joerg Roedel @ 2025-01-17 8:01 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Will Deacon, Robin Murphy, Yong Wu, Matthias Brugger,
AngeloGioacchino Del Regno, Heiko Stuebner, linux-arm-kernel,
iommu, linux-kernel, linux-mediatek, linux-rockchip
On Tue, Jan 14, 2025 at 08:26:42PM +0100, Krzysztof Kozlowski wrote:
> Replace ternary (condition ? "enable" : "disable") syntax with helpers
> from string_choices.h because:
> 1. Simple function call with one argument is easier to read. Ternary
> operator has three arguments and with wrapping might lead to quite
> long code.
> 2. Is slightly shorter thus also easier to read.
> 3. It brings uniformity in the text - same string.
> 4. Allows deduping by the linker, which results in a smaller binary
> file.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 3 ++-
> drivers/iommu/arm/arm-smmu/arm-smmu.c | 3 ++-
> drivers/iommu/mtk_iommu.c | 9 +++++----
> drivers/iommu/mtk_iommu_v1.c | 3 ++-
> drivers/iommu/rockchip-iommu.c | 3 ++-
> 5 files changed, 13 insertions(+), 8 deletions(-)
Applied, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iommu: Use str_enable_disable-like helpers
2025-01-14 19:26 [PATCH] iommu: Use str_enable_disable-like helpers Krzysztof Kozlowski
` (3 preceding siblings ...)
2025-01-17 8:01 ` Joerg Roedel
@ 2025-01-20 12:53 ` AngeloGioacchino Del Regno
4 siblings, 0 replies; 6+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-01-20 12:53 UTC (permalink / raw)
To: Krzysztof Kozlowski, Will Deacon, Robin Murphy, Joerg Roedel,
Yong Wu, Matthias Brugger, Heiko Stuebner, linux-arm-kernel,
iommu, linux-kernel, linux-mediatek, linux-rockchip
Il 14/01/25 20:26, Krzysztof Kozlowski ha scritto:
> Replace ternary (condition ? "enable" : "disable") syntax with helpers
> from string_choices.h because:
> 1. Simple function call with one argument is easier to read. Ternary
> operator has three arguments and with wrapping might lead to quite
> long code.
> 2. Is slightly shorter thus also easier to read.
> 3. It brings uniformity in the text - same string.
> 4. Allows deduping by the linker, which results in a smaller binary
> file.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
MediaTek IOMMU/IOMMUv1
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-01-20 12:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-14 19:26 [PATCH] iommu: Use str_enable_disable-like helpers Krzysztof Kozlowski
2025-01-14 19:53 ` Heiko Stübner
2025-01-15 19:12 ` Jason Gunthorpe
2025-01-16 3:05 ` Pranjal Shrivastava
2025-01-17 8:01 ` Joerg Roedel
2025-01-20 12:53 ` AngeloGioacchino Del Regno
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).