RE: [PATCH v6 1/4] acpi: arm64: add iort support for PMCG
> -Original Message- > From: Lorenzo Pieralisi [mailto:lorenzo.pieral...@arm.com] > Sent: 15 February 2019 11:40 > To: Shameerali Kolothum Thodi > Cc: robin.mur...@arm.com; andrew.mur...@arm.com; > jean-philippe.bruc...@arm.com; will.dea...@arm.com; > mark.rutl...@arm.com; Guohanjun (Hanjun Guo) ; > John Garry ; pa...@codeaurora.org; > vkil...@codeaurora.org; rruig...@codeaurora.org; linux-a...@vger.kernel.org; > linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Linuxarm > ; neil.m.lee...@gmail.com > Subject: Re: [PATCH v6 1/4] acpi: arm64: add iort support for PMCG > [...] > > +/* > > + * PMCG model identifiers for use in smmu pmu driver. Please note > > + * that, this is not part of the IORT specification. > > And it is a Linux internal tag that has nothing to do with HW, it is just > fabricated > for matching a driver, I would like to have this clarified in the comment > please. > > I would have avoided adding another hook to differentiate platform data but > given that it is self-contained in IORT code that should be fine for the sake > of > making progress: > > Acked-by: Lorenzo Pieralisi Thanks. I will wait for review of main driver patches and then will sent out a revised one incorporating your comments on this. Thanks, Shameer > > + */ > > +#define IORT_SMMU_V3_PMCG_GENERIC0x /* Generic > SMMUv3 PMCG */ > > + > > int iort_register_domain_token(int trans_id, phys_addr_t base, > >struct fwnode_handle *fw_node); void > > iort_deregister_domain_token(int trans_id); > > -- > > 2.7.4 > > > >
Re: [PATCH v6 1/4] acpi: arm64: add iort support for PMCG
On Mon, Feb 04, 2019 at 12:13:21PM +, Shameer Kolothum wrote: > From: Neil Leeder > > Add support for the SMMU Performance Monitor Counter Group > information from ACPI. This is in preparation for its use > in the SMMUv3 PMU driver. Also, in case I do not get a chance to update it, please run: git log --oneline --no-merges drivers/acpi/arm64/iort.c You would notice incosistency in the $SUBJECT, fix it please. Thanks, Lorenzo > Signed-off-by: Neil Leeder > Signed-off-by: Hanjun Guo > Signed-off-by: Shameer Kolothum > Reviewed-by: Robin Murphy > --- > drivers/acpi/arm64/iort.c | 117 > -- > include/linux/acpi_iort.h | 6 +++ > 2 files changed, 99 insertions(+), 24 deletions(-) > > diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c > index e48894e..e2c9b26 100644 > --- a/drivers/acpi/arm64/iort.c > +++ b/drivers/acpi/arm64/iort.c > @@ -356,7 +356,8 @@ static struct acpi_iort_node *iort_node_get_id(struct > acpi_iort_node *node, > if (map->flags & ACPI_IORT_ID_SINGLE_MAPPING) { > if (node->type == ACPI_IORT_NODE_NAMED_COMPONENT || > node->type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX || > - node->type == ACPI_IORT_NODE_SMMU_V3) { > + node->type == ACPI_IORT_NODE_SMMU_V3 || > + node->type == ACPI_IORT_NODE_PMCG) { > *id_out = map->output_base; > return parent; > } > @@ -394,6 +395,8 @@ static int iort_get_id_mapping_index(struct > acpi_iort_node *node) > } > > return smmu->id_mapping_index; > + case ACPI_IORT_NODE_PMCG: > + return 0; > default: > return -EINVAL; > } > @@ -1218,14 +1221,23 @@ static void __init arm_smmu_v3_init_resources(struct > resource *res, > } > } > > -static bool __init arm_smmu_v3_is_coherent(struct acpi_iort_node *node) > +static void __init arm_smmu_v3_dma_configure(struct device *dev, > + struct acpi_iort_node *node) > { > struct acpi_iort_smmu_v3 *smmu; > + enum dev_dma_attr attr; > > /* Retrieve SMMUv3 specific data */ > smmu = (struct acpi_iort_smmu_v3 *)node->node_data; > > - return smmu->flags & ACPI_IORT_SMMU_V3_COHACC_OVERRIDE; > + attr = (smmu->flags & ACPI_IORT_SMMU_V3_COHACC_OVERRIDE) ? > + DEV_DMA_COHERENT : DEV_DMA_NON_COHERENT; > + > + /* We expect the dma masks to be equivalent for all SMMUv3 set-ups */ > + dev->dma_mask = >coherent_dma_mask; > + > + /* Configure DMA for the page table walker */ > + acpi_dma_configure(dev, attr); > } > > #if defined(CONFIG_ACPI_NUMA) > @@ -1301,30 +1313,82 @@ static void __init arm_smmu_init_resources(struct > resource *res, > } > } > > -static bool __init arm_smmu_is_coherent(struct acpi_iort_node *node) > +static void __init arm_smmu_dma_configure(struct device *dev, > + struct acpi_iort_node *node) > { > struct acpi_iort_smmu *smmu; > + enum dev_dma_attr attr; > > /* Retrieve SMMU specific data */ > smmu = (struct acpi_iort_smmu *)node->node_data; > > - return smmu->flags & ACPI_IORT_SMMU_COHERENT_WALK; > + attr = (smmu->flags & ACPI_IORT_SMMU_COHERENT_WALK) ? > + DEV_DMA_COHERENT : DEV_DMA_NON_COHERENT; > + > + /* We expect the dma masks to be equivalent for SMMU set-ups */ > + dev->dma_mask = >coherent_dma_mask; > + > + /* Configure DMA for the page table walker */ > + acpi_dma_configure(dev, attr); > +} > + > +static int __init arm_smmu_v3_pmcg_count_resources(struct acpi_iort_node > *node) > +{ > + struct acpi_iort_pmcg *pmcg; > + > + /* Retrieve PMCG specific data */ > + pmcg = (struct acpi_iort_pmcg *)node->node_data; > + > + /* > + * There are always 2 memory resources. > + * If the overflow_gsiv is present then add that for a total of 3. > + */ > + return pmcg->overflow_gsiv ? 3 : 2; > +} > + > +static void __init arm_smmu_v3_pmcg_init_resources(struct resource *res, > +struct acpi_iort_node *node) > +{ > + struct acpi_iort_pmcg *pmcg; > + > + /* Retrieve PMCG specific data */ > + pmcg = (struct acpi_iort_pmcg *)node->node_data; > + > + res[0].start = pmcg->page0_base_address; > + res[0].end = pmcg->page0_base_address + SZ_4K - 1; > + res[0].flags = IORESOURCE_MEM; > + res[1].start = pmcg->page1_base_address; > + res[1].end = pmcg->page1_base_address + SZ_4K - 1; > + res[1].flags = IORESOURCE_MEM; > + > + if (pmcg->overflow_gsiv) > + acpi_iort_register_irq(pmcg->overflow_gsiv, "overflow", > +ACPI_EDGE_SENSITIVE, [2]); > +} > + > +static int __init arm_smmu_v3_pmcg_add_platdata(struct platform_device *pdev) > +{ > + u32 model =
Re: [PATCH v6 1/4] acpi: arm64: add iort support for PMCG
On Mon, Feb 04, 2019 at 12:13:21PM +, Shameer Kolothum wrote: > From: Neil Leeder > > Add support for the SMMU Performance Monitor Counter Group > information from ACPI. This is in preparation for its use > in the SMMUv3 PMU driver. > > Signed-off-by: Neil Leeder > Signed-off-by: Hanjun Guo > Signed-off-by: Shameer Kolothum > Reviewed-by: Robin Murphy > --- > drivers/acpi/arm64/iort.c | 117 > -- > include/linux/acpi_iort.h | 6 +++ > 2 files changed, 99 insertions(+), 24 deletions(-) > > diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c > index e48894e..e2c9b26 100644 > --- a/drivers/acpi/arm64/iort.c > +++ b/drivers/acpi/arm64/iort.c > @@ -356,7 +356,8 @@ static struct acpi_iort_node *iort_node_get_id(struct > acpi_iort_node *node, > if (map->flags & ACPI_IORT_ID_SINGLE_MAPPING) { > if (node->type == ACPI_IORT_NODE_NAMED_COMPONENT || > node->type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX || > - node->type == ACPI_IORT_NODE_SMMU_V3) { > + node->type == ACPI_IORT_NODE_SMMU_V3 || > + node->type == ACPI_IORT_NODE_PMCG) { > *id_out = map->output_base; > return parent; > } > @@ -394,6 +395,8 @@ static int iort_get_id_mapping_index(struct > acpi_iort_node *node) > } > > return smmu->id_mapping_index; > + case ACPI_IORT_NODE_PMCG: > + return 0; > default: > return -EINVAL; > } > @@ -1218,14 +1221,23 @@ static void __init arm_smmu_v3_init_resources(struct > resource *res, > } > } > > -static bool __init arm_smmu_v3_is_coherent(struct acpi_iort_node *node) > +static void __init arm_smmu_v3_dma_configure(struct device *dev, > + struct acpi_iort_node *node) > { > struct acpi_iort_smmu_v3 *smmu; > + enum dev_dma_attr attr; > > /* Retrieve SMMUv3 specific data */ > smmu = (struct acpi_iort_smmu_v3 *)node->node_data; > > - return smmu->flags & ACPI_IORT_SMMU_V3_COHACC_OVERRIDE; > + attr = (smmu->flags & ACPI_IORT_SMMU_V3_COHACC_OVERRIDE) ? > + DEV_DMA_COHERENT : DEV_DMA_NON_COHERENT; > + > + /* We expect the dma masks to be equivalent for all SMMUv3 set-ups */ > + dev->dma_mask = >coherent_dma_mask; > + > + /* Configure DMA for the page table walker */ > + acpi_dma_configure(dev, attr); > } > > #if defined(CONFIG_ACPI_NUMA) > @@ -1301,30 +1313,82 @@ static void __init arm_smmu_init_resources(struct > resource *res, > } > } > > -static bool __init arm_smmu_is_coherent(struct acpi_iort_node *node) > +static void __init arm_smmu_dma_configure(struct device *dev, > + struct acpi_iort_node *node) > { > struct acpi_iort_smmu *smmu; > + enum dev_dma_attr attr; > > /* Retrieve SMMU specific data */ > smmu = (struct acpi_iort_smmu *)node->node_data; > > - return smmu->flags & ACPI_IORT_SMMU_COHERENT_WALK; > + attr = (smmu->flags & ACPI_IORT_SMMU_COHERENT_WALK) ? > + DEV_DMA_COHERENT : DEV_DMA_NON_COHERENT; > + > + /* We expect the dma masks to be equivalent for SMMU set-ups */ > + dev->dma_mask = >coherent_dma_mask; > + > + /* Configure DMA for the page table walker */ > + acpi_dma_configure(dev, attr); > +} > + > +static int __init arm_smmu_v3_pmcg_count_resources(struct acpi_iort_node > *node) > +{ > + struct acpi_iort_pmcg *pmcg; > + > + /* Retrieve PMCG specific data */ > + pmcg = (struct acpi_iort_pmcg *)node->node_data; > + > + /* > + * There are always 2 memory resources. > + * If the overflow_gsiv is present then add that for a total of 3. > + */ > + return pmcg->overflow_gsiv ? 3 : 2; > +} > + > +static void __init arm_smmu_v3_pmcg_init_resources(struct resource *res, > +struct acpi_iort_node *node) > +{ > + struct acpi_iort_pmcg *pmcg; > + > + /* Retrieve PMCG specific data */ > + pmcg = (struct acpi_iort_pmcg *)node->node_data; > + > + res[0].start = pmcg->page0_base_address; > + res[0].end = pmcg->page0_base_address + SZ_4K - 1; > + res[0].flags = IORESOURCE_MEM; > + res[1].start = pmcg->page1_base_address; > + res[1].end = pmcg->page1_base_address + SZ_4K - 1; > + res[1].flags = IORESOURCE_MEM; > + > + if (pmcg->overflow_gsiv) > + acpi_iort_register_irq(pmcg->overflow_gsiv, "overflow", > +ACPI_EDGE_SENSITIVE, [2]); > +} > + > +static int __init arm_smmu_v3_pmcg_add_platdata(struct platform_device *pdev) > +{ > + u32 model = IORT_SMMU_V3_PMCG_GENERIC; > + > + return platform_device_add_data(pdev, , sizeof(model)); > } > > struct iort_dev_config { > const char *name; > int (*dev_init)(struct
[PATCH v6 1/4] acpi: arm64: add iort support for PMCG
From: Neil Leeder Add support for the SMMU Performance Monitor Counter Group information from ACPI. This is in preparation for its use in the SMMUv3 PMU driver. Signed-off-by: Neil Leeder Signed-off-by: Hanjun Guo Signed-off-by: Shameer Kolothum Reviewed-by: Robin Murphy --- drivers/acpi/arm64/iort.c | 117 -- include/linux/acpi_iort.h | 6 +++ 2 files changed, 99 insertions(+), 24 deletions(-) diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index e48894e..e2c9b26 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -356,7 +356,8 @@ static struct acpi_iort_node *iort_node_get_id(struct acpi_iort_node *node, if (map->flags & ACPI_IORT_ID_SINGLE_MAPPING) { if (node->type == ACPI_IORT_NODE_NAMED_COMPONENT || node->type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX || - node->type == ACPI_IORT_NODE_SMMU_V3) { + node->type == ACPI_IORT_NODE_SMMU_V3 || + node->type == ACPI_IORT_NODE_PMCG) { *id_out = map->output_base; return parent; } @@ -394,6 +395,8 @@ static int iort_get_id_mapping_index(struct acpi_iort_node *node) } return smmu->id_mapping_index; + case ACPI_IORT_NODE_PMCG: + return 0; default: return -EINVAL; } @@ -1218,14 +1221,23 @@ static void __init arm_smmu_v3_init_resources(struct resource *res, } } -static bool __init arm_smmu_v3_is_coherent(struct acpi_iort_node *node) +static void __init arm_smmu_v3_dma_configure(struct device *dev, +struct acpi_iort_node *node) { struct acpi_iort_smmu_v3 *smmu; + enum dev_dma_attr attr; /* Retrieve SMMUv3 specific data */ smmu = (struct acpi_iort_smmu_v3 *)node->node_data; - return smmu->flags & ACPI_IORT_SMMU_V3_COHACC_OVERRIDE; + attr = (smmu->flags & ACPI_IORT_SMMU_V3_COHACC_OVERRIDE) ? + DEV_DMA_COHERENT : DEV_DMA_NON_COHERENT; + + /* We expect the dma masks to be equivalent for all SMMUv3 set-ups */ + dev->dma_mask = >coherent_dma_mask; + + /* Configure DMA for the page table walker */ + acpi_dma_configure(dev, attr); } #if defined(CONFIG_ACPI_NUMA) @@ -1301,30 +1313,82 @@ static void __init arm_smmu_init_resources(struct resource *res, } } -static bool __init arm_smmu_is_coherent(struct acpi_iort_node *node) +static void __init arm_smmu_dma_configure(struct device *dev, + struct acpi_iort_node *node) { struct acpi_iort_smmu *smmu; + enum dev_dma_attr attr; /* Retrieve SMMU specific data */ smmu = (struct acpi_iort_smmu *)node->node_data; - return smmu->flags & ACPI_IORT_SMMU_COHERENT_WALK; + attr = (smmu->flags & ACPI_IORT_SMMU_COHERENT_WALK) ? + DEV_DMA_COHERENT : DEV_DMA_NON_COHERENT; + + /* We expect the dma masks to be equivalent for SMMU set-ups */ + dev->dma_mask = >coherent_dma_mask; + + /* Configure DMA for the page table walker */ + acpi_dma_configure(dev, attr); +} + +static int __init arm_smmu_v3_pmcg_count_resources(struct acpi_iort_node *node) +{ + struct acpi_iort_pmcg *pmcg; + + /* Retrieve PMCG specific data */ + pmcg = (struct acpi_iort_pmcg *)node->node_data; + + /* +* There are always 2 memory resources. +* If the overflow_gsiv is present then add that for a total of 3. +*/ + return pmcg->overflow_gsiv ? 3 : 2; +} + +static void __init arm_smmu_v3_pmcg_init_resources(struct resource *res, + struct acpi_iort_node *node) +{ + struct acpi_iort_pmcg *pmcg; + + /* Retrieve PMCG specific data */ + pmcg = (struct acpi_iort_pmcg *)node->node_data; + + res[0].start = pmcg->page0_base_address; + res[0].end = pmcg->page0_base_address + SZ_4K - 1; + res[0].flags = IORESOURCE_MEM; + res[1].start = pmcg->page1_base_address; + res[1].end = pmcg->page1_base_address + SZ_4K - 1; + res[1].flags = IORESOURCE_MEM; + + if (pmcg->overflow_gsiv) + acpi_iort_register_irq(pmcg->overflow_gsiv, "overflow", + ACPI_EDGE_SENSITIVE, [2]); +} + +static int __init arm_smmu_v3_pmcg_add_platdata(struct platform_device *pdev) +{ + u32 model = IORT_SMMU_V3_PMCG_GENERIC; + + return platform_device_add_data(pdev, , sizeof(model)); } struct iort_dev_config { const char *name; int (*dev_init)(struct acpi_iort_node *node); - bool (*dev_is_coherent)(struct acpi_iort_node *node); + void (*dev_dma_configure)(struct device *dev, + struct acpi_iort_node *node); int