Re: [PATCH v5 08/20] iommu/mediatek: Add larb-id remapped support
On Mon, Dec 31, 2018 at 7:58 PM Yong Wu wrote: > > The larb-id may be remapped in the smi-common, this means the > larb-id reported in the mtk_iommu_isr isn't the real larb-id, > > Take mt8183 as a example: >M4U > | > - > | SMI common | > -0-7-5-6-1-2--3-4- <- Id remapped > | | | | | | | | > larb0 larb1 IPU0 IPU1 larb4 larb5 larb6 CCU > disp vdec img cam venc imgcam > As above, larb0 connects with the id 0 in smi-common. > larb1 connects with the id 7 in smi-common. > ... > If the larb-id reported in the isr is 7, actually it's larb1(vdec). > In order to output the right larb-id in the isr, we add a larb-id > remapping relationship in this patch. > > If there is no this larb-id remapping in some SoCs, use the linear > mapping array instead. > > This also is a preparing patch for mt8183. > > Signed-off-by: Yong Wu > --- > drivers/iommu/mtk_iommu.c | 4 > drivers/iommu/mtk_iommu.h | 2 ++ > 2 files changed, 6 insertions(+) > > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c > index 847082c..eca1536 100644 > --- a/drivers/iommu/mtk_iommu.c > +++ b/drivers/iommu/mtk_iommu.c > @@ -220,6 +220,8 @@ static irqreturn_t mtk_iommu_isr(int irq, void *dev_id) > fault_larb = F_MMU0_INT_ID_LARB_ID(regval); > fault_port = F_MMU0_INT_ID_PORT_ID(regval); > > + fault_larb = data->plat_data->larbid_remap[fault_larb]; > + > if (report_iommu_fault(>domain, data->dev, fault_iova, >write ? IOMMU_FAULT_WRITE : IOMMU_FAULT_READ)) > { > dev_err_ratelimited( > @@ -742,12 +744,14 @@ static int __maybe_unused mtk_iommu_resume(struct > device *dev) > .m4u_plat = M4U_MT2712, > .has_4gb_mode = true, > .has_bclk = true, > + .larbid_remap = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, > }; > > static const struct mtk_iommu_plat_data mt8173_data = { > .m4u_plat = M4U_MT8173, > .has_4gb_mode = true, > .has_bclk = true, > + .larbid_remap = {0, 1, 2, 3, 4, 5}, /* Linear mapping. */ I briefly considered bikeshedding about how to define these arrays in a way that might save memory for linear-map devices, but then decided this is fine. Reviewed-by: Evan Green ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v5 08/20] iommu/mediatek: Add larb-id remapped support
On Tue, Jan 1, 2019 at 11:58 AM Yong Wu wrote: > > The larb-id may be remapped in the smi-common, this means the > larb-id reported in the mtk_iommu_isr isn't the real larb-id, > > Take mt8183 as a example: >M4U > | > - > | SMI common | > -0-7-5-6-1-2--3-4- <- Id remapped > | | | | | | | | > larb0 larb1 IPU0 IPU1 larb4 larb5 larb6 CCU > disp vdec img cam venc imgcam > As above, larb0 connects with the id 0 in smi-common. > larb1 connects with the id 7 in smi-common. > ... > If the larb-id reported in the isr is 7, actually it's larb1(vdec). > In order to output the right larb-id in the isr, we add a larb-id > remapping relationship in this patch. > > If there is no this larb-id remapping in some SoCs, use the linear > mapping array instead. > > This also is a preparing patch for mt8183. > > Signed-off-by: Yong Wu I think it's a little cleaner this way, thanks. Reviewed-by: Nicolas Boichat > --- > drivers/iommu/mtk_iommu.c | 4 > drivers/iommu/mtk_iommu.h | 2 ++ > 2 files changed, 6 insertions(+) > > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c > index 847082c..eca1536 100644 > --- a/drivers/iommu/mtk_iommu.c > +++ b/drivers/iommu/mtk_iommu.c > @@ -220,6 +220,8 @@ static irqreturn_t mtk_iommu_isr(int irq, void *dev_id) > fault_larb = F_MMU0_INT_ID_LARB_ID(regval); > fault_port = F_MMU0_INT_ID_PORT_ID(regval); > > + fault_larb = data->plat_data->larbid_remap[fault_larb]; > + > if (report_iommu_fault(>domain, data->dev, fault_iova, >write ? IOMMU_FAULT_WRITE : IOMMU_FAULT_READ)) > { > dev_err_ratelimited( > @@ -742,12 +744,14 @@ static int __maybe_unused mtk_iommu_resume(struct > device *dev) > .m4u_plat = M4U_MT2712, > .has_4gb_mode = true, > .has_bclk = true, > + .larbid_remap = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, > }; > > static const struct mtk_iommu_plat_data mt8173_data = { > .m4u_plat = M4U_MT8173, > .has_4gb_mode = true, > .has_bclk = true, > + .larbid_remap = {0, 1, 2, 3, 4, 5}, /* Linear mapping. */ > }; > > static const struct of_device_id mtk_iommu_of_ids[] = { > diff --git a/drivers/iommu/mtk_iommu.h b/drivers/iommu/mtk_iommu.h > index b8749ac..eec19a6 100644 > --- a/drivers/iommu/mtk_iommu.h > +++ b/drivers/iommu/mtk_iommu.h > @@ -47,6 +47,8 @@ struct mtk_iommu_plat_data { > > /* HW will use the EMI clock if there isn't the "bclk". */ > boolhas_bclk; > + > + unsigned char larbid_remap[MTK_LARB_NR_MAX]; > }; > > struct mtk_iommu_domain; > -- > 1.9.1 > ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v5 08/20] iommu/mediatek: Add larb-id remapped support
The larb-id may be remapped in the smi-common, this means the larb-id reported in the mtk_iommu_isr isn't the real larb-id, Take mt8183 as a example: M4U | - | SMI common | -0-7-5-6-1-2--3-4- <- Id remapped | | | | | | | | larb0 larb1 IPU0 IPU1 larb4 larb5 larb6 CCU disp vdec img cam venc imgcam As above, larb0 connects with the id 0 in smi-common. larb1 connects with the id 7 in smi-common. ... If the larb-id reported in the isr is 7, actually it's larb1(vdec). In order to output the right larb-id in the isr, we add a larb-id remapping relationship in this patch. If there is no this larb-id remapping in some SoCs, use the linear mapping array instead. This also is a preparing patch for mt8183. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 4 drivers/iommu/mtk_iommu.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 847082c..eca1536 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -220,6 +220,8 @@ static irqreturn_t mtk_iommu_isr(int irq, void *dev_id) fault_larb = F_MMU0_INT_ID_LARB_ID(regval); fault_port = F_MMU0_INT_ID_PORT_ID(regval); + fault_larb = data->plat_data->larbid_remap[fault_larb]; + if (report_iommu_fault(>domain, data->dev, fault_iova, write ? IOMMU_FAULT_WRITE : IOMMU_FAULT_READ)) { dev_err_ratelimited( @@ -742,12 +744,14 @@ static int __maybe_unused mtk_iommu_resume(struct device *dev) .m4u_plat = M4U_MT2712, .has_4gb_mode = true, .has_bclk = true, + .larbid_remap = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, }; static const struct mtk_iommu_plat_data mt8173_data = { .m4u_plat = M4U_MT8173, .has_4gb_mode = true, .has_bclk = true, + .larbid_remap = {0, 1, 2, 3, 4, 5}, /* Linear mapping. */ }; static const struct of_device_id mtk_iommu_of_ids[] = { diff --git a/drivers/iommu/mtk_iommu.h b/drivers/iommu/mtk_iommu.h index b8749ac..eec19a6 100644 --- a/drivers/iommu/mtk_iommu.h +++ b/drivers/iommu/mtk_iommu.h @@ -47,6 +47,8 @@ struct mtk_iommu_plat_data { /* HW will use the EMI clock if there isn't the "bclk". */ boolhas_bclk; + + unsigned char larbid_remap[MTK_LARB_NR_MAX]; }; struct mtk_iommu_domain; -- 1.9.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu