iommu/arm-smmu: Allow client devices to select direct mapping
Subsystems (2)
cover iommu/arm-smmu: Allow client devices to select direct mapping
This series allows drm devices to set a default identity mapping using iommu_request_dm_for_dev(). First patch is a cleanup to support other SoCs to call into QCOM specific implementation and preparation for second patch. Second patch sets the default identity domain for drm devices.
Jordan Crouse (1):
iommu/arm-smmu: Allow client devices to select direct mapping
Sai Prakash Ranjan (1):
iommu: arm-smmu-impl: Convert to a generic reset implementation
drivers/iommu/arm-smmu-impl.c | 8 +++-- drivers/iommu/arm-smmu-qcom.c | 55 +++++++++++++++++++++++++++++++++-- drivers/iommu/arm-smmu.c | 3 ++ drivers/iommu/arm-smmu.h | 5 ++++ 4 files changed, 65 insertions(+), 6 deletions(-)
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH 1/2 iommu: arm-smmu-impl: Convert to a generic reset implementation
Currently the QCOM specific smmu reset implementation is very specific to SDM845 SoC and has a wait-for-safe logic which may not be required for other SoCs. So move the SDM845 specific logic to its specific reset function. Also add SC7180 SMMU compatible for calling into QCOM specific implementation.
--- drivers/iommu/arm-smmu-impl.c | 8 +++++--- drivers/iommu/arm-smmu-qcom.c | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-)
drivers/iommu/arm-smmu-impl.c +5 -3
@@ -150,6 +150,8 @@ static const struct arm_smmu_impl arm_mmu500_impl = {struct arm_smmu_device *arm_smmu_impl_init (struct arm_smmu_device *smmu) { +const struct device_node *np = smmu->dev->of_node; +/* * We will inevitably have to combine model-specific implementation * quirks with platform-specific integration quirks, but everything
@@ -166,11 +168,11 @@ struct arm_smmu_device *arm_smmu_impl_init(struct arm_smmu_device *smmu)break ; } -if (of_property_read_bool (smmu->dev->of_node, -"calxeda,smmu-secure-config-access" )) +if (of_property_read_bool (np,"calxeda,smmu-secure-config-access" )) smmu->impl = &calxeda_impl; -if (of_device_is_compatible (smmu->dev->of_node,"qcom,sdm845-smmu-500" )) +if (of_device_is_compatible (np,"qcom,sdm845-smmu-500" ) || +of_device_is_compatible (np,"qcom,sc7180-smmu-500" ))return qcom_smmu_impl_init (smmu);return smmu;
drivers/iommu/arm-smmu-qcom.c +13 -3
@@ -15,8 +15,6 @@ static int qcom_sdm845_smmu500_reset(struct arm_smmu_device *smmu) {int ret; -arm_mmu500_reset (smmu); -/* * To address performance degradation in non-real time clients, * such as USB and UFS, turn off wait-for-safe on sdm845 based boards,
@@ -30,8 +28,20 @@ static int qcom_sdm845_smmu500_reset(struct arm_smmu_device *smmu)return ret; } +static int qcom_smmu500_reset (struct arm_smmu_device *smmu) +{ +const struct device_node *np = smmu->dev->of_node; + +arm_mmu500_reset (smmu); + +if (of_device_is_compatible (np,"qcom,sdm845-smmu-500" )) +return qcom_sdm845_smmu500_reset (smmu); + +return 0 ; +} +static const struct arm_smmu_impl qcom_smmu_impl = { - .reset = qcom_sdm845_smmu500_reset, + .reset = qcom_smmu500_reset, };struct arm_smmu_device *qcom_smmu_impl_init (struct arm_smmu_device *smmu)
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCH 1/2] iommu: arm-smmu-impl: Convert to a generic reset implementation
Quoted 7 lines · Sai Prakash Ranjan
Currently the QCOM specific smmu reset implementation is very specific to SDM845 SoC and has a wait-for-safe logic which may not be required for other SoCs. So move the SDM845 specific logic to its specific reset function. Also add SC7180 SMMU compatible for calling into QCOM specific implementation.
Signed-off-by Sai Prakash Ranjan <[email protected]>
Regards,
Bjorn
Quoted 71 lines
--- drivers/iommu/arm-smmu-impl.c | 8 +++++--- drivers/iommu/arm-smmu-qcom.c | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-)drivers/iommu/arm-smmu-impl.c +5
-3@@ -150,6 +150,8 @@ static const struct arm_smmu_impl arm_mmu500_impl = {struct arm_smmu_device *arm_smmu_impl_init (struct arm_smmu_device *smmu) { +const struct device_node *np = smmu->dev->of_node; +/* * We will inevitably have to combine model-specific implementation * quirks with platform-specific integration quirks, but everything @@ -166,11 +168,11 @@ struct arm_smmu_device *arm_smmu_impl_init(struct arm_smmu_device *smmu)break ; } -if (of_property_read_bool (smmu->dev->of_node, -"calxeda,smmu-secure-config-access" )) +if (of_property_read_bool (np,"calxeda,smmu-secure-config-access" )) smmu->impl = &calxeda_impl; -if (of_device_is_compatible (smmu->dev->of_node,"qcom,sdm845-smmu-500" )) +if (of_device_is_compatible (np,"qcom,sdm845-smmu-500" ) || +of_device_is_compatible (np,"qcom,sc7180-smmu-500" ))return qcom_smmu_impl_init (smmu);return smmu;drivers/iommu/arm-smmu-qcom.c +13
-3@@ -15,8 +15,6 @@ static int qcom_sdm845_smmu500_reset(struct arm_smmu_device *smmu) {int ret; -arm_mmu500_reset (smmu); -/* * To address performance degradation in non-real time clients, * such as USB and UFS, turn off wait-for-safe on sdm845 based boards, @@ -30,8 +28,20 @@ static int qcom_sdm845_smmu500_reset(struct arm_smmu_device *smmu)return ret; } +static int qcom_smmu500_reset (struct arm_smmu_device *smmu) +{ +const struct device_node *np = smmu->dev->of_node; + +arm_mmu500_reset (smmu); + +if (of_device_is_compatible (np,"qcom,sdm845-smmu-500" )) +return qcom_sdm845_smmu500_reset (smmu); + +return 0 ; +} +static const struct arm_smmu_impl qcom_smmu_impl = { - .reset = qcom_sdm845_smmu500_reset, + .reset = qcom_smmu500_reset, };struct arm_smmu_device *qcom_smmu_impl_init (struct arm_smmu_device *smmu)Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCH 1/2] iommu: arm-smmu-impl: Convert to a generic reset implementation
In reply to Sai Prakash RanjanQuoting Sai Prakash Ranjan (2020-01-22 03:48:01)
Quoted 8 lines
Currently the QCOM specific smmu reset implementation is very specific to SDM845 SoC and has a wait-for-safe logic which may not be required for other SoCs. So move the SDM845 specific logic to its specific reset function. Also add SC7180 SMMU compatible for calling into QCOM specific implementation.
Signed-off-by Sai Prakash Ranjan <[email protected]>---
Re: [PATCH 1/2] iommu: arm-smmu-impl: Convert to a generic reset implementation
In reply to Sai Prakash RanjanQuoted 63 lines · Sai Prakash Ranjan
Currently the QCOM specific smmu reset implementation is very specific to SDM845 SoC and has a wait-for-safe logic which may not be required for other SoCs. So move the SDM845 specific logic to its specific reset function. Also add SC7180 SMMU compatible for calling into QCOM specific implementation.
Signed-off-by Sai Prakash Ranjan <[email protected]>--- drivers/iommu/arm-smmu-impl.c | 8 +++++--- drivers/iommu/arm-smmu-qcom.c | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-)drivers/iommu/arm-smmu-impl.c +5
-3@@ -150,6 +150,8 @@ static const struct arm_smmu_impl arm_mmu500_impl = {struct arm_smmu_device *arm_smmu_impl_init (struct arm_smmu_device *smmu) { +const struct device_node *np = smmu->dev->of_node; +/* * We will inevitably have to combine model-specific implementation * quirks with platform-specific integration quirks, but everything @@ -166,11 +168,11 @@ struct arm_smmu_device *arm_smmu_impl_init(struct arm_smmu_device *smmu)break ; } -if (of_property_read_bool (smmu->dev->of_node, -"calxeda,smmu-secure-config-access" )) +if (of_property_read_bool (np,"calxeda,smmu-secure-config-access" )) smmu->impl = &calxeda_impl; -if (of_device_is_compatible (smmu->dev->of_node,"qcom,sdm845-smmu-500" )) +if (of_device_is_compatible (np,"qcom,sdm845-smmu-500" ) || +of_device_is_compatible (np,"qcom,sc7180-smmu-500" ))return qcom_smmu_impl_init (smmu);return smmu;drivers/iommu/arm-smmu-qcom.c +6
-2@@ -15,8 +15,6 @@ static int qcom_sdm845_smmu500_reset(struct arm_smmu_device *smmu) {int ret; -arm_mmu500_reset (smmu); -/* * To address performance degradation in non-real time clients, * such as USB and UFS, turn off wait-for-safe on sdm845 based boards, @@ -30,8 +28,20 @@ static int qcom_sdm845_smmu500_reset(struct arm_smmu_device *smmu)return ret; } +static int qcom_smmu500_reset (struct arm_smmu_device *smmu) +{ +const struct device_node *np = smmu->dev->of_node; + +arm_mmu500_reset (smmu); +
drivers/iommu/arm-smmu-qcom.c static int qcom_sdm845_smmu500_reset(struct arm_smmu_device *smmu) · line 45
Quoted 10 lines
drivers/iommu/arm-smmu-qcom.c +7
-1+if (of_device_is_compatible (np,"qcom,sdm845-smmu-500" )) +return qcom_sdm845_smmu500_reset (smmu); + +return 0 ; +} +static const struct arm_smmu_impl qcom_smmu_impl = { - .reset = qcom_sdm845_smmu500_reset, + .reset = qcom_smmu500_reset, };
It might be logical to have a separate SDM845 impl rather than indirecting within the callback itself, but I'm not too concerned either way. For the arm-smmu-impl.c changes,
Thanks,
Robin.
drivers/iommu/arm-smmu-qcom.c static int qcom_sdm845_smmu500_reset(struct arm_smmu_device *smmu) · line 47
Quoted 3 lines
drivers/iommu/arm-smmu-qcom.c +0
-0struct arm_smmu_device *qcom_smmu_impl_init (struct arm_smmu_device *smmu)
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 2/2 iommu/arm-smmu: Allow client devices to select direct mapping
In reply to Sai Prakash RanjanFrom: Jordan Crouse <[email protected]>
Some client devices want to directly map the IOMMU themselves instead of using the DMA domain. Allow those devices to opt in to direct mapping by way of a list of compatible strings.
--- drivers/iommu/arm-smmu-qcom.c | 39 +++++++++++++++++++++++++++++++++++ drivers/iommu/arm-smmu.c | 3 +++ drivers/iommu/arm-smmu.h | 5 +++++ 3 files changed, 47 insertions(+)
drivers/iommu/arm-smmu-qcom.c +39 -0
@@ -3,6 +3,7 @@* Copyright (c) 2019, The Linux Foundation. All rights reserved. */ +#include <linux/of_device.h> #include <linux/qcom_scm.h> #include "arm-smmu.h"
@@ -11,6 +12,43 @@ struct qcom_smmu {struct arm_smmu_device smmu; }; +static const struct arm_smmu_client_match_data qcom_adreno = { + .direct_mapping = true, +}; + +static const struct arm_smmu_client_match_data qcom_mdss = { + .direct_mapping = true, +}; + +static const struct of_device_id qcom_smmu_client_of_match[] = { + { .compatible ="qcom,adreno" , .data = &qcom_adreno }, + { .compatible ="qcom,mdp4" , .data = &qcom_mdss }, + { .compatible ="qcom,mdss" , .data = &qcom_mdss }, + { .compatible ="qcom,sc7180-mdss" , .data = &qcom_mdss }, + { .compatible ="qcom,sdm845-mdss" , .data = &qcom_mdss }, + {}, +}; + +static const struct arm_smmu_client_match_data * +qcom_smmu_client_data (struct device *dev) +{ +const struct of_device_id *match = +of_match_device (qcom_smmu_client_of_match, dev); + +return match ? match->data :NULL ; +} + +static int qcom_smmu_request_domain (struct device *dev) +{ +const struct arm_smmu_client_match_data *client; + + client =qcom_smmu_client_data (dev); +if (client) +iommu_request_dm_for_dev (dev); + +return 0 ; +} +static int qcom_sdm845_smmu500_reset (struct arm_smmu_device *smmu) {int ret;
@@ -41,6 +79,7 @@ static int qcom_smmu500_reset(struct arm_smmu_device *smmu) }static const struct arm_smmu_impl qcom_smmu_impl = { + .req_domain = qcom_smmu_request_domain, .reset = qcom_smmu500_reset, };
drivers/iommu/arm-smmu.c +3 -0
@@ -1448,6 +1448,9 @@ static int arm_smmu_add_device(struct device *dev)device_link_add (dev, smmu->dev,DL_FLAG_PM_RUNTIME |DL_FLAG_AUTOREMOVE_SUPPLIER ); +if (smmu->impl && smmu->impl->req_domain) +return smmu->impl->req_domain (dev); +return 0 ; out_cfg_free:
drivers/iommu/arm-smmu.h +5 -0
@@ -244,6 +244,10 @@ enum arm_smmu_arch_version { ARM_SMMU_V2, }; +struct arm_smmu_client_match_data { +bool direct_mapping; +}; +enum arm_smmu_implementation {GENERIC_SMMU ,ARM_MMU500 ,
@@ -386,6 +390,7 @@ struct arm_smmu_impl {int (*init_context)(struct arm_smmu_domain *smmu_domain);void (*tlb_sync)(struct arm_smmu_device *smmu,int page,int sync,int status); +int (*req_domain)(struct device *dev); };static inline void __iomem *arm_smmu_page (struct arm_smmu_device *smmu,int n)
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Quoted 29 lines · Sai Prakash Ranjan
From: Jordan Crouse <[email protected]>
Some client devices want to directly map the IOMMU themselves instead of using the DMA domain. Allow those devices to opt in to direct mapping by way of a list of compatible strings.
Signed-off-by Jordan Crouse <[email protected]>Co-developed-by Sai Prakash Ranjan <[email protected]>Signed-off-by Sai Prakash Ranjan <[email protected]>--- drivers/iommu/arm-smmu-qcom.c | 39 +++++++++++++++++++++++++++++++++++ drivers/iommu/arm-smmu.c | 3 +++ drivers/iommu/arm-smmu.h | 5 +++++ 3 files changed, 47 insertions(+)drivers/iommu/arm-smmu-qcom.c +1
-0@@ -3,6 +3,7 @@* Copyright (c) 2019, The Linux Foundation. All rights reserved. */ +#include <linux/of_device.h> #include <linux/qcom_scm.h> #include "arm-smmu.h"
drivers/iommu/arm-smmu-qcom.c struct qcom_smmu { · line 20
Quoted 9 lines
drivers/iommu/arm-smmu-qcom.c +6
-0@@ -11,6 +12,43 @@ struct qcom_smmu {struct arm_smmu_device smmu; }; +static const struct arm_smmu_client_match_data qcom_adreno = { + .direct_mapping = true, +}; + +static const struct arm_smmu_client_match_data qcom_mdss = { + .direct_mapping = true,
I don't actually see direct_mapping being used. Shouldn't this member be checked somewhere?
-Evan
Hi Evan,
Quoted 35 lines · Evan Green
Quoted 33 lines · Sai Prakash Ranjan
From: Jordan Crouse <[email protected]>
Some client devices want to directly map the IOMMU themselves instead of using the DMA domain. Allow those devices to opt in to direct mapping by way of a list of compatible strings.
Signed-off-by Jordan Crouse <[email protected]>Co-developed-by Sai Prakash Ranjan <[email protected]>Signed-off-by Sai Prakash Ranjan <[email protected]>--- drivers/iommu/arm-smmu-qcom.c | 39 +++++++++++++++++++++++++++++++++++ drivers/iommu/arm-smmu.c | 3 +++ drivers/iommu/arm-smmu.h | 5 +++++ 3 files changed, 47 insertions(+)drivers/iommu/arm-smmu-qcom.c +1
-0@@ -3,6 +3,7 @@* Copyright (c) 2019, The Linux Foundation. All rights reserved. */ +#include <linux/of_device.h> #include <linux/qcom_scm.h> #include "arm-smmu.h" @@ -11,6 +12,43 @@ struct qcom_smmu {struct arm_smmu_device smmu; };
Quoted 10 lines
drivers/iommu/arm-smmu-qcom.c struct qcom_smmu { · line 20
Quoted 6 lines
drivers/iommu/arm-smmu-qcom.c +6
-0+static const struct arm_smmu_client_match_data qcom_adreno = { + .direct_mapping = true, +}; + +static const struct arm_smmu_client_match_data qcom_mdss = { + .direct_mapping = true,I don't actually see
direct_mappingbeing used. Shouldn't this member be checked somewhere?
Thanks for spotting this, my bad. It should be checked in qcom_smmu_request_domain().
drivers/iommu/arm-smmu-qcom.c +1 -1
@@ -43,7 +43,7 @@ static int qcom_smmu_request_domain(struct device *dev)const struct arm_smmu_client_match_data *client; client =qcom_smmu_client_data (dev); -if (client) +if (client && client->direct_mapping)iommu_request_dm_for_dev (dev);return 0 ;
-Sai
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Robin Murphy
reviewerQuoted 28 lines · Sai Prakash Ranjan
From: Jordan Crouse <[email protected]>
Some client devices want to directly map the IOMMU themselves instead of using the DMA domain. Allow those devices to opt in to direct mapping by way of a list of compatible strings.
Signed-off-by Jordan Crouse <[email protected]>Co-developed-by Sai Prakash Ranjan <[email protected]>Signed-off-by Sai Prakash Ranjan <[email protected]>--- drivers/iommu/arm-smmu-qcom.c | 39 +++++++++++++++++++++++++++++++++++ drivers/iommu/arm-smmu.c | 3 +++ drivers/iommu/arm-smmu.h | 5 +++++ 3 files changed, 47 insertions(+)drivers/iommu/arm-smmu-qcom.c +1
-0@@ -3,6 +3,7 @@* Copyright (c) 2019, The Linux Foundation. All rights reserved. */ +#include <linux/of_device.h> #include <linux/qcom_scm.h> #include "arm-smmu.h"
drivers/iommu/arm-smmu-qcom.c struct qcom_smmu { · line 21
Quoted 10 lines
drivers/iommu/arm-smmu-qcom.c +7
-0@@ -11,6 +12,43 @@ struct qcom_smmu {struct arm_smmu_device smmu; }; +static const struct arm_smmu_client_match_data qcom_adreno = { + .direct_mapping = true, +}; + +static const struct arm_smmu_client_match_data qcom_mdss = { + .direct_mapping = true, +};
Might it make sense to group these by the desired SMMU behaviour rather than (apparently) what kind of device the client happens to be, which seems like a completely arbitrary distinction from the SMMU driver's PoV?
Quoted 7 lines
drivers/iommu/arm-smmu-qcom.c +7
-0+ +static const struct of_device_id qcom_smmu_client_of_match[] = { + { .compatible ="qcom,adreno" , .data = &qcom_adreno }, + { .compatible ="qcom,mdp4" , .data = &qcom_mdss }, + { .compatible ="qcom,mdss" , .data = &qcom_mdss }, + { .compatible ="qcom,sc7180-mdss" , .data = &qcom_mdss }, + { .compatible ="qcom,sdm845-mdss" , .data = &qcom_mdss },
drivers/iommu/arm-smmu-qcom.c struct qcom_smmu { · line 38
Quoted 10 lines
drivers/iommu/arm-smmu-qcom.c +10
-0+ {}, +}; + +static const struct arm_smmu_client_match_data * +qcom_smmu_client_data (struct device *dev) +{ +const struct of_device_id *match = +of_match_device (qcom_smmu_client_of_match, dev); + +return match ? match->data :NULL ;
of_device_get_match_data() is your friend.
Quoted 29 lines
drivers/iommu/arm-smmu-qcom.c +14
-0+} + +static int qcom_smmu_request_domain (struct device *dev) +{ +const struct arm_smmu_client_match_data *client; + + client =qcom_smmu_client_data (dev); +if (client) +iommu_request_dm_for_dev (dev); + +return 0 ; +} +static int qcom_sdm845_smmu500_reset (struct arm_smmu_device *smmu) {int ret;@@ -41,6 +79,7 @@ static int qcom_smmu500_reset(struct arm_smmu_device *smmu) }static const struct arm_smmu_impl qcom_smmu_impl = { + .req_domain = qcom_smmu_request_domain, .reset = qcom_smmu500_reset, };drivers/iommu/arm-smmu.c +0
-0
drivers/iommu/arm-smmu.c static int arm_smmu_add_device(struct device *dev) · line 1453
Quoted 6 lines
drivers/iommu/arm-smmu.c +3
-0@@ -1448,6 +1448,9 @@ static int arm_smmu_add_device(struct device *dev)device_link_add (dev, smmu->dev,DL_FLAG_PM_RUNTIME |DL_FLAG_AUTOREMOVE_SUPPLIER ); +if (smmu->impl && smmu->impl->req_domain) +return smmu->impl->req_domain (dev); +
There are about 5 different patchsets flying around at the moment that all touch default domain allocation, so this is a fast-moving target, but I think where the dust should settle is with arm_smmu_ops forwarding .def_domain_type (or whatever it ends up as) calls to arm_smmu_impl as appropriate.
Quoted 8 lines
drivers/iommu/arm-smmu.c +0
-0return 0 ; out_cfg_free:drivers/iommu/arm-smmu.h +0
-0
drivers/iommu/arm-smmu.h enum arm_smmu_arch_version { · line 249
Quoted 6 lines
drivers/iommu/arm-smmu.h +3
-0@@ -244,6 +244,10 @@ enum arm_smmu_arch_version { ARM_SMMU_V2, }; +struct arm_smmu_client_match_data { +bool direct_mapping; +};
Does this need to be public? I don't see the other users...
Robin.
drivers/iommu/arm-smmu.h struct arm_smmu_impl { · line 396
Quoted 13 lines
drivers/iommu/arm-smmu.h +2
-0+enum arm_smmu_implementation {GENERIC_SMMU ,ARM_MMU500 ,@@ -386,6 +390,7 @@ struct arm_smmu_impl {int (*init_context)(struct arm_smmu_domain *smmu_domain);void (*tlb_sync)(struct arm_smmu_device *smmu,int page,int sync,int status); +int (*req_domain)(struct device *dev); };static inline void __iomem *arm_smmu_page (struct arm_smmu_device *smmu,int n)
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Robin,
Quoted 34 lines · Robin Murphy
Quoted 33 lines · Sai Prakash Ranjan
From: Jordan Crouse <[email protected]>
Some client devices want to directly map the IOMMU themselves instead of using the DMA domain. Allow those devices to opt in to direct mapping by way of a list of compatible strings.
Signed-off-by Jordan Crouse <[email protected]>Co-developed-by Sai Prakash Ranjan <[email protected]>Signed-off-by Sai Prakash Ranjan <[email protected]>--- drivers/iommu/arm-smmu-qcom.c | 39 +++++++++++++++++++++++++++++++++++ drivers/iommu/arm-smmu.c | 3 +++ drivers/iommu/arm-smmu.h | 5 +++++ 3 files changed, 47 insertions(+)drivers/iommu/arm-smmu-qcom.c +3
-0@@ -3,6 +3,7 @@* Copyright (c) 2019, The Linux Foundation. All rights reserved. */ +#include <linux/of_device.h>#include <linux/qcom_scm.h> #include "arm-smmu.h" @@ -11,6 +12,43 @@ struct qcom_smmu {struct arm_smmu_device smmu; }; +static const struct arm_smmu_client_match_data qcom_adreno = { + .direct_mapping = true, +}; +
Quoted 9 lines
drivers/iommu/arm-smmu-qcom.c struct qcom_smmu { · line 21
Quoted 3 lines
drivers/iommu/arm-smmu-qcom.c +3
-0+static const struct arm_smmu_client_match_data qcom_mdss = { + .direct_mapping = true, +};Might it make sense to group these by the desired SMMU behaviour rather than (apparently) what kind of device the client happens to be, which seems like a completely arbitrary distinction from the SMMU driver's PoV?
Sorry, I did not get the "grouping by the desired SMMU behaviour" thing. Could you please give some more details?
Quoted 11 lines
Quoted 11 lines
drivers/iommu/arm-smmu-qcom.c +11
-0+ +static const struct of_device_id qcom_smmu_client_of_match[] = { + { .compatible ="qcom,adreno" , .data = &qcom_adreno }, + { .compatible ="qcom,mdp4" , .data = &qcom_mdss }, + { .compatible ="qcom,mdss" , .data = &qcom_mdss }, + { .compatible ="qcom,sc7180-mdss" , .data = &qcom_mdss }, + { .compatible ="qcom,sdm845-mdss" , .data = &qcom_mdss }, + {}, +}; + +static const struct arm_smmu_client_match_data *
Quoted 9 lines
drivers/iommu/arm-smmu-qcom.c struct qcom_smmu { · line 38
Quoted 6 lines
drivers/iommu/arm-smmu-qcom.c +6
-0+qcom_smmu_client_data(struct device *dev) +{ +const struct of_device_id *match = +of_match_device (qcom_smmu_client_of_match, dev); + +return match ? match->data :NULL ;
of_device_get_match_data()is your friend.
Ok will use it.
Quoted 32 lines
Quoted 32 lines
drivers/iommu/arm-smmu-qcom.c +14
-0+} + +static int qcom_smmu_request_domain (struct device *dev) +{ +const struct arm_smmu_client_match_data *client; + + client =qcom_smmu_client_data (dev); +if (client) +iommu_request_dm_for_dev (dev); + +return 0 ; +} +static int qcom_sdm845_smmu500_reset (struct arm_smmu_device *smmu) {int ret;@@ -41,6 +79,7 @@ static int qcom_smmu500_reset(struct arm_smmu_device *smmu) }static const struct arm_smmu_impl qcom_smmu_impl = { + .req_domain = qcom_smmu_request_domain, .reset = qcom_smmu500_reset, }; diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.cindex
16c4b87af42b..67dd9326247a100644drivers/iommu/arm-smmu.c +0
-0@@ -1448,6 +1448,9 @@ static int arm_smmu_add_device(struct device *dev)device_link_add (dev, smmu->dev,DL_FLAG_PM_RUNTIME |DL_FLAG_AUTOREMOVE_SUPPLIER ); + if (smmu->impl && smmu->impl->req_domain)
Quoted 9 lines
drivers/iommu/arm-smmu.c static int arm_smmu_add_device(struct device *dev) · line 1453
Quoted 2 lines
drivers/iommu/arm-smmu.c +2
-0+return smmu->impl->req_domain (dev); +There are about 5 different patchsets flying around at the moment that all touch default domain allocation, so this is a fast-moving target, but I think where the dust should settle is with
arm_smmu_opsforwarding .def_domain_type (or whatever it ends up as) calls toarm_smmu_implas appropriate.
I'll wait till the dust settles down and then post the next version.
Quoted 6 lines
Quoted 6 lines
drivers/iommu/arm-smmu.c +0
-0return 0 ; out_cfg_free:drivers/iommu/arm-smmu.h +0
-0
Quoted 9 lines
drivers/iommu/arm-smmu.h enum arm_smmu_arch_version { · line 248
Quoted 6 lines
drivers/iommu/arm-smmu.h +2
-0@@ -244,6 +244,10 @@ enum arm_smmu_arch_version { ARM_SMMU_V2, }; +struct arm_smmu_client_match_data { +bool direct_mapping; +};Does this need to be public? I don't see the other users...
Will move this out.
Thanks,
Sai
Signature · 7 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Robin Murphy
reviewerQuoted 46 lines · Sai Prakash Ranjan
Hi Robin,
Quoted 33 lines · Robin Murphy
Quoted 32 lines · Sai Prakash Ranjan
From: Jordan Crouse <[email protected]>
Some client devices want to directly map the IOMMU themselves instead of using the DMA domain. Allow those devices to opt in to direct mapping by way of a list of compatible strings.
Signed-off-by Jordan Crouse <[email protected]>Co-developed-by Sai Prakash Ranjan <[email protected]>Signed-off-by Sai Prakash Ranjan <[email protected]>---
drivers/iommu/arm-smmu-qcom.c| 39 +++++++++++++++++++++++++++++++++++ drivers/iommu/arm-smmu.c | 3 +++ drivers/iommu/arm-smmu.h | 5 +++++3 files changed, 47 insertions(+)drivers/iommu/arm-smmu-qcom.c +0
-0@@ -3,6 +3,7 @@* Copyright (c) 2019, The Linux Foundation. All rights reserved. */ +#include <
linux/of_device.h>
#include <linux/qcom_scm.h>
#include "arm-smmu.h"drivers/iommu/arm-smmu-qcom.c +3
-0@@ -11,6 +12,43 @@ struct qcom_smmu { struct arm_smmu_device smmu; }; +static const struct arm_smmu_client_match_data qcom_adreno = { + .direct_mapping = true, +}; +Quoted 9 lines
drivers/iommu/arm-smmu-qcom.c struct qcom_smmu { · line 21
Quoted 3 lines
drivers/iommu/arm-smmu-qcom.c +3
-0+static const struct arm_smmu_client_match_data qcom_mdss = { + .direct_mapping = true, +};Might it make sense to group these by the desired SMMU behaviour rather than (apparently) what kind of device the client happens to be, which seems like a completely arbitrary distinction from the SMMU driver's PoV?
Quoted 2 lines
Sorry, I did not get the "grouping by the desired SMMU behaviour" thing. Could you please give some more details?
I mean this pattern:
device_a_data {
.thing = this;
}device_b_data {
.thing = this;
}device_c_data {
.thing = that;
}match[] = {
{ .compatible = "A", .data = &device_a_data },
{ .compatible = "B", .data = &device_b_data },
{ .compatible = "C", .data = &device_c_data },
};...vs. this pattern:
do_this {
.thing = this;
}do_that {
.thing = that;
}match[] = {
{ .compatible = "A", .data = &do_this },
{ .compatible = "B", .data = &do_this },
{ .compatible = "C", .data = &do_that },
};From the perspective of the thing doing the thing, grouping the data by device is meaningless if all that matters is whether to do this or that. The second pattern expresses that more naturally.
Of course if every device turns out to need a unique combination of several behaviours, then there ends up being no practical difference except that it's probably easier to come up with nice names under the first pattern. I guess it's up to how you see this developing in future; whether you're likely to need fine-grained per-device control, or don't expect it to go much beyond domain type.
Robin.
Hi Robin,
Quoted 91 lines · Robin Murphy
Quoted 47 lines · Sai Prakash Ranjan
Hi Robin,
Quoted 34 lines · Robin Murphy
Quoted 33 lines · Sai Prakash Ranjan
From: Jordan Crouse <[email protected]>
Some client devices want to directly map the IOMMU themselves instead of using the DMA domain. Allow those devices to opt in to direct mapping by way of a list of compatible strings.
Signed-off-by Jordan Crouse <[email protected]>Co-developed-by Sai Prakash Ranjan <[email protected]>Signed-off-by Sai Prakash Ranjan <[email protected]>---
drivers/iommu/arm-smmu-qcom.c| 39
+++++++++++++++++++++++++++++++++++
drivers/iommu/arm-smmu.c | 3 +++
drivers/iommu/arm-smmu.h | 5 +++++3 files changed, 47 insertions(+)drivers/iommu/arm-smmu-qcom.c +0
-0@@ -3,6 +3,7 @@* Copyright (c) 2019, The Linux Foundation. All rights reserved. */ +#include <
linux/of_device.h>
#include <linux/qcom_scm.h>
#include "arm-smmu.h"drivers/iommu/arm-smmu-qcom.c +3
-0@@ -11,6 +12,43 @@ struct qcom_smmu { struct arm_smmu_device smmu; }; +static const struct arm_smmu_client_match_data qcom_adreno = { + .direct_mapping = true, +}; +Quoted 9 lines
drivers/iommu/arm-smmu-qcom.c struct qcom_smmu { · line 21
Quoted 3 lines
drivers/iommu/arm-smmu-qcom.c +3
-0+static const struct arm_smmu_client_match_data qcom_mdss = { + .direct_mapping = true, +};Might it make sense to group these by the desired SMMU behaviour rather than (apparently) what kind of device the client happens to be, which seems like a completely arbitrary distinction from the SMMU driver's PoV?
Quoted 2 lines
Sorry, I did not get the "grouping by the desired SMMU behaviour" thing. Could you please give some more details?
I mean this pattern:
device_a_data { .thing = this; }device_b_data { .thing = this; }device_c_data { .thing = that; }match[] = { { .compatible = "A", .data = &device_a_data }, { .compatible = "B", .data = &device_b_data }, { .compatible = "C", .data = &device_c_data }, };...vs. this pattern:
do_this { .thing = this; }do_that { .thing = that; }match[] = { { .compatible = "A", .data = &do_this }, { .compatible = "B", .data = &do_this }, { .compatible = "C", .data = &do_that }, };From the perspective of the thing doing the thing, grouping the data by device is meaningless if all that matters is whether to do this or that. The second pattern expresses that more naturally.
Quoted 7 lines
Of course if every device turns out to need a unique combination of several behaviours, then there ends up being no practical difference except that it's probably easier to come up with nice names under the first pattern. I guess it's up to how you see this developing in future; whether you're likely to need fine-grained per-device control, or don't expect it to go much beyond domain type.
Thanks for explaining *this thing* :)
I will update the patch to follow the 2nd pattern as it makes more sense to do_this or do_that directly. I'm not expecting anything other than domain type atleast for now but hey we can always add the functionality if the need arises.
Thanks,
Sai
Signature · 7 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hello Robin, Will
Quoted 9 lines · Sai Prakash Ranjan
This series allows drm devices to set a default identity mapping using
iommu_request_dm_for_dev(). First patch is a cleanup to support other SoCs to call into QCOM specific implementation and preparation for second patch. Second patch sets the default identity domain for drm devices.Jordan Crouse (1):
iommu/arm-smmu: Allow client devices to select direct mapping
Quoted 8 lines
Sai Prakash Ranjan (1):
iommu: arm-smmu-impl: Convert to a generic reset implementationdrivers/iommu/arm-smmu-impl.c | 8 +++-- drivers/iommu/arm-smmu-qcom.c | 55 +++++++++++++++++++++++++++++++++-- drivers/iommu/arm-smmu.c | 3 ++ drivers/iommu/arm-smmu.h | 5 ++++ 4 files changed, 65 insertions(+), 6 deletions(-)
Any review comments?
Thanks,
Sai
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Quoted 15 lines · Sai Prakash Ranjan
Hello Robin, Will
Quoted 12 lines · Sai Prakash Ranjan
This series allows drm devices to set a default identity mapping using
iommu_request_dm_for_dev(). First patch is a cleanup to support other SoCs to call into QCOM specific implementation and preparation for second patch. Second patch sets the default identity domain for drm devices.Jordan Crouse (1):
iommu/arm-smmu: Allow client devices to select direct mappingSai Prakash Ranjan (1):
iommu: arm-smmu-impl: Convert to a generic reset implementation
Quoted 7 lines
Quoted 5 lines
drivers/iommu/arm-smmu-impl.c | 8 +++-- drivers/iommu/arm-smmu-qcom.c | 55 +++++++++++++++++++++++++++++++++-- drivers/iommu/arm-smmu.c | 3 ++ drivers/iommu/arm-smmu.h | 5 ++++ 4 files changed, 65 insertions(+), 6 deletions(-)Any review comments?
Ping
What is the status of this series, is it ready to land or are any changes needed?
Thanks
Matthias
Hi Matthias,
Quoted 22 lines · Matthias Kaehlcke
Quoted 21 lines · Sai Prakash Ranjan
Hello Robin, Will
Quoted 17 lines · Sai Prakash Ranjan
This series allows drm devices to set a default identity mapping using
iommu_request_dm_for_dev(). First patch is a cleanup to support other SoCs to call into QCOM specific implementation and preparation for second patch. Second patch sets the default identity domain for drm devices.Jordan Crouse (1):
iommu/arm-smmu: Allow client devices to select direct mappingSai Prakash Ranjan (1):
iommu: arm-smmu-impl: Convert to a generic reset implementationdrivers/iommu/arm-smmu-impl.c | 8 +++-- drivers/iommu/arm-smmu-qcom.c | 55 +++++++++++++++++++++++++++++++++-- drivers/iommu/arm-smmu.c | 3 ++ drivers/iommu/arm-smmu.h | 5 ++++ 4 files changed, 65 insertions(+), 6 deletions(-)
Quoted 7 lines
Quoted 1 line
Any review comments?
Ping
What is the status of this series, is it ready to land or are any changes needed?
I am wondering the same :)
Thanks,
Sai
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Quoted 24 lines · Matthias Kaehlcke
Quoted 15 lines · Sai Prakash Ranjan
Hello Robin, Will
Quoted 12 lines · Sai Prakash Ranjan
This series allows drm devices to set a default identity mapping using
iommu_request_dm_for_dev(). First patch is a cleanup to support other SoCs to call into QCOM specific implementation and preparation for second patch. Second patch sets the default identity domain for drm devices.Jordan Crouse (1):
iommu/arm-smmu: Allow client devices to select direct mappingSai Prakash Ranjan (1):
iommu: arm-smmu-impl: Convert to a generic reset implementationQuoted 7 lines
Quoted 5 lines
drivers/iommu/arm-smmu-impl.c | 8 +++-- drivers/iommu/arm-smmu-qcom.c | 55 +++++++++++++++++++++++++++++++++-- drivers/iommu/arm-smmu.c | 3 ++ drivers/iommu/arm-smmu.h | 5 ++++ 4 files changed, 65 insertions(+), 6 deletions(-)Any review comments?
Quoted 8 lines
Ping
What is the status of this series, is it ready to land or are any changes needed?
Thanks
Matthias
I think this is up in the air following the changes that Joerg suggested:
https://lists.linuxfoundation.org/pipermail/iommu/2020-April/043017.html
Jordan
Signature · 6 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu