From: Miles Chen <miles.chen@mediatek.com>
To: Matthias Brugger <matthias.bgg@gmail.com>
Cc: devicetree@vger.kernel.org, wsd_upstream@mediatek.com,
David Hildenbrand <david@redhat.com>,
linux-kernel@vger.kernel.org, Mike Rapoport <rppt@linux.ibm.com>,
Chao Hao <chao.hao@mediatek.com>,
iommu@lists.linux-foundation.org,
Rob Herring <robh+dt@kernel.org>,
linux-mediatek@lists.infradead.org,
Yingjoe Chen <yingjoe.chen@mediatek.com>,
Christoph Hellwig <hch@lst.de>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 4/4] iommu/mediatek: check 4GB mode by reading infracfg
Date: Fri, 17 Jul 2020 16:26:31 +0800 [thread overview]
Message-ID: <1594974391.12796.25.camel@mtkswgap22> (raw)
In-Reply-To: <84333997-735c-4a91-6d47-1dcb5c4a6078@gmail.com>
On Wed, 2020-07-15 at 23:05 +0200, Matthias Brugger wrote:
>
> On 02/07/2020 11:37, Miles Chen wrote:
> > In previous disscusion [1] and [2], we found that it is risky to
> > use max_pfn or totalram_pages to tell if 4GB mode is enabled.
> >
> > Check 4GB mode by reading infracfg register, remove the usage
> > of the unexported symbol max_pfn.
> >
> > [1] https://urldefense.com/v3/__https://lkml.org/lkml/2020/6/3/733__;!!CTRNKA9wMg0ARbw!16gAfVnSY87W4t5kE4iw20QPxBgS_SHBvPKlePKU7CGIb18nUzuRUjHumcf4oYVhIQ$
> > [2] https://urldefense.com/v3/__https://lkml.org/lkml/2020/6/4/136__;!!CTRNKA9wMg0ARbw!16gAfVnSY87W4t5kE4iw20QPxBgS_SHBvPKlePKU7CGIb18nUzuRUjHumcfr4i9p5g$
> >
> > Cc: Mike Rapoport <rppt@linux.ibm.com>
> > Cc: David Hildenbrand <david@redhat.com>
> > Cc: Yong Wu <yong.wu@mediatek.com>
> > Cc: Yingjoe Chen <yingjoe.chen@mediatek.com>
> > Cc: Christoph Hellwig <hch@lst.de>
> > Signed-off-by: Miles Chen <miles.chen@mediatek.com>
> > ---
> > drivers/iommu/mtk_iommu.c | 22 ++++++++++++++++++----
> > 1 file changed, 18 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> > index 2be96f1cdbd2..09be57bd8d74 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -3,7 +3,6 @@
> > * Copyright (c) 2015-2016 MediaTek Inc.
> > * Author: Yong Wu <yong.wu@mediatek.com>
> > */
> > -#include <linux/memblock.h>
> > #include <linux/bug.h>
> > #include <linux/clk.h>
> > #include <linux/component.h>
> > @@ -15,11 +14,13 @@
> > #include <linux/iommu.h>
> > #include <linux/iopoll.h>
> > #include <linux/list.h>
> > +#include <linux/mfd/syscon.h>
> > #include <linux/of_address.h>
> > #include <linux/of_iommu.h>
> > #include <linux/of_irq.h>
> > #include <linux/of_platform.h>
> > #include <linux/platform_device.h>
> > +#include <linux/regmap.h>
> > #include <linux/slab.h>
> > #include <linux/spinlock.h>
> > #include <asm/barrier.h>
> > @@ -91,6 +92,9 @@
> > #define F_MMU_INT_ID_LARB_ID(a) (((a) >> 7) & 0x7)
> > #define F_MMU_INT_ID_PORT_ID(a) (((a) >> 2) & 0x1f)
> >
> > +#define REG_INFRA_MISC 0xf00
> > +#define F_DDR_4GB_SUPPORT_EN BIT(13)
> > +
>
> As this is used for infracfg, I think it would be good to add it to
> include/linux/soc/mediatek/infracfg.h and include that file here.
Thanks for your comment.
ok. I'll do this in next version.
>
> > #define MTK_PROTECT_PA_ALIGN 128
> >
> > /*
> > @@ -599,8 +603,10 @@ static int mtk_iommu_probe(struct platform_device *pdev)
> > struct resource *res;
> > resource_size_t ioaddr;
> > struct component_match *match = NULL;
> > + struct regmap *infracfg_regmap;
>
> Maybe call it just infracfg.
ok. I'll do this in next version.
>
> > void *protect;
> > int i, larb_nr, ret;
> > + u32 val;
> >
> > data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> > if (!data)
> > @@ -614,10 +620,18 @@ static int mtk_iommu_probe(struct platform_device *pdev)
> > return -ENOMEM;
> > data->protect_base = ALIGN(virt_to_phys(protect), MTK_PROTECT_PA_ALIGN);
> >
> > - /* Whether the current dram is over 4GB */
> > - data->enable_4GB = !!(max_pfn > (BIT_ULL(32) >> PAGE_SHIFT));
> > - if (!data->plat_data->has_4gb_mode)
> > + if (data->plat_data->has_4gb_mode) {
> > + infracfg_regmap = syscon_regmap_lookup_by_phandle(dev->of_node,
> > + "mediatek,infracfg");
> > + if (IS_ERR(infracfg_regmap))
> > + return PTR_ERR(infracfg_regmap);
>
> Do we need to error out, or could we be conservative and set endable_4GB = false?
We have to error out in this case because the 4gb_mode setting must be
consistent with the h/w setting.
>
> > + ret = regmap_read(infracfg_regmap, REG_INFRA_MISC, &val);
> > + if (ret)
> > + return ret;
> > + data->enable_4GB = !!(val & F_DDR_4GB_SUPPORT_EN);
> > + } else {
> > data->enable_4GB = false;
>
> Move that before the if() and update enable_4GB only in case of has_4gb_mode.
ok. I'll do this in next version.
Miles
>
> > + }
> >
> > res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > data->base = devm_ioremap_resource(dev, res);
> >
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
WARNING: multiple messages have this Message-ID (diff)
From: Miles Chen <miles.chen@mediatek.com>
To: Matthias Brugger <matthias.bgg@gmail.com>
Cc: devicetree@vger.kernel.org, wsd_upstream@mediatek.com,
David Hildenbrand <david@redhat.com>,
Joerg Roedel <joro@8bytes.org>,
linux-kernel@vger.kernel.org, Mike Rapoport <rppt@linux.ibm.com>,
Chao Hao <chao.hao@mediatek.com>,
iommu@lists.linux-foundation.org,
Rob Herring <robh+dt@kernel.org>,
linux-mediatek@lists.infradead.org,
Yong Wu <yong.wu@mediatek.com>,
Yingjoe Chen <yingjoe.chen@mediatek.com>,
Christoph Hellwig <hch@lst.de>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 4/4] iommu/mediatek: check 4GB mode by reading infracfg
Date: Fri, 17 Jul 2020 16:26:31 +0800 [thread overview]
Message-ID: <1594974391.12796.25.camel@mtkswgap22> (raw)
In-Reply-To: <84333997-735c-4a91-6d47-1dcb5c4a6078@gmail.com>
On Wed, 2020-07-15 at 23:05 +0200, Matthias Brugger wrote:
>
> On 02/07/2020 11:37, Miles Chen wrote:
> > In previous disscusion [1] and [2], we found that it is risky to
> > use max_pfn or totalram_pages to tell if 4GB mode is enabled.
> >
> > Check 4GB mode by reading infracfg register, remove the usage
> > of the unexported symbol max_pfn.
> >
> > [1] https://urldefense.com/v3/__https://lkml.org/lkml/2020/6/3/733__;!!CTRNKA9wMg0ARbw!16gAfVnSY87W4t5kE4iw20QPxBgS_SHBvPKlePKU7CGIb18nUzuRUjHumcf4oYVhIQ$
> > [2] https://urldefense.com/v3/__https://lkml.org/lkml/2020/6/4/136__;!!CTRNKA9wMg0ARbw!16gAfVnSY87W4t5kE4iw20QPxBgS_SHBvPKlePKU7CGIb18nUzuRUjHumcfr4i9p5g$
> >
> > Cc: Mike Rapoport <rppt@linux.ibm.com>
> > Cc: David Hildenbrand <david@redhat.com>
> > Cc: Yong Wu <yong.wu@mediatek.com>
> > Cc: Yingjoe Chen <yingjoe.chen@mediatek.com>
> > Cc: Christoph Hellwig <hch@lst.de>
> > Signed-off-by: Miles Chen <miles.chen@mediatek.com>
> > ---
> > drivers/iommu/mtk_iommu.c | 22 ++++++++++++++++++----
> > 1 file changed, 18 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> > index 2be96f1cdbd2..09be57bd8d74 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -3,7 +3,6 @@
> > * Copyright (c) 2015-2016 MediaTek Inc.
> > * Author: Yong Wu <yong.wu@mediatek.com>
> > */
> > -#include <linux/memblock.h>
> > #include <linux/bug.h>
> > #include <linux/clk.h>
> > #include <linux/component.h>
> > @@ -15,11 +14,13 @@
> > #include <linux/iommu.h>
> > #include <linux/iopoll.h>
> > #include <linux/list.h>
> > +#include <linux/mfd/syscon.h>
> > #include <linux/of_address.h>
> > #include <linux/of_iommu.h>
> > #include <linux/of_irq.h>
> > #include <linux/of_platform.h>
> > #include <linux/platform_device.h>
> > +#include <linux/regmap.h>
> > #include <linux/slab.h>
> > #include <linux/spinlock.h>
> > #include <asm/barrier.h>
> > @@ -91,6 +92,9 @@
> > #define F_MMU_INT_ID_LARB_ID(a) (((a) >> 7) & 0x7)
> > #define F_MMU_INT_ID_PORT_ID(a) (((a) >> 2) & 0x1f)
> >
> > +#define REG_INFRA_MISC 0xf00
> > +#define F_DDR_4GB_SUPPORT_EN BIT(13)
> > +
>
> As this is used for infracfg, I think it would be good to add it to
> include/linux/soc/mediatek/infracfg.h and include that file here.
Thanks for your comment.
ok. I'll do this in next version.
>
> > #define MTK_PROTECT_PA_ALIGN 128
> >
> > /*
> > @@ -599,8 +603,10 @@ static int mtk_iommu_probe(struct platform_device *pdev)
> > struct resource *res;
> > resource_size_t ioaddr;
> > struct component_match *match = NULL;
> > + struct regmap *infracfg_regmap;
>
> Maybe call it just infracfg.
ok. I'll do this in next version.
>
> > void *protect;
> > int i, larb_nr, ret;
> > + u32 val;
> >
> > data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> > if (!data)
> > @@ -614,10 +620,18 @@ static int mtk_iommu_probe(struct platform_device *pdev)
> > return -ENOMEM;
> > data->protect_base = ALIGN(virt_to_phys(protect), MTK_PROTECT_PA_ALIGN);
> >
> > - /* Whether the current dram is over 4GB */
> > - data->enable_4GB = !!(max_pfn > (BIT_ULL(32) >> PAGE_SHIFT));
> > - if (!data->plat_data->has_4gb_mode)
> > + if (data->plat_data->has_4gb_mode) {
> > + infracfg_regmap = syscon_regmap_lookup_by_phandle(dev->of_node,
> > + "mediatek,infracfg");
> > + if (IS_ERR(infracfg_regmap))
> > + return PTR_ERR(infracfg_regmap);
>
> Do we need to error out, or could we be conservative and set endable_4GB = false?
We have to error out in this case because the 4gb_mode setting must be
consistent with the h/w setting.
>
> > + ret = regmap_read(infracfg_regmap, REG_INFRA_MISC, &val);
> > + if (ret)
> > + return ret;
> > + data->enable_4GB = !!(val & F_DDR_4GB_SUPPORT_EN);
> > + } else {
> > data->enable_4GB = false;
>
> Move that before the if() and update enable_4GB only in case of has_4gb_mode.
ok. I'll do this in next version.
Miles
>
> > + }
> >
> > res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > data->base = devm_ioremap_resource(dev, res);
> >
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
WARNING: multiple messages have this Message-ID (diff)
From: Miles Chen <miles.chen@mediatek.com>
To: Matthias Brugger <matthias.bgg@gmail.com>
Cc: devicetree@vger.kernel.org, wsd_upstream@mediatek.com,
David Hildenbrand <david@redhat.com>,
Joerg Roedel <joro@8bytes.org>,
linux-kernel@vger.kernel.org, Mike Rapoport <rppt@linux.ibm.com>,
Chao Hao <chao.hao@mediatek.com>,
iommu@lists.linux-foundation.org,
Rob Herring <robh+dt@kernel.org>,
linux-mediatek@lists.infradead.org,
Yong Wu <yong.wu@mediatek.com>,
Yingjoe Chen <yingjoe.chen@mediatek.com>,
Christoph Hellwig <hch@lst.de>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 4/4] iommu/mediatek: check 4GB mode by reading infracfg
Date: Fri, 17 Jul 2020 16:26:31 +0800 [thread overview]
Message-ID: <1594974391.12796.25.camel@mtkswgap22> (raw)
In-Reply-To: <84333997-735c-4a91-6d47-1dcb5c4a6078@gmail.com>
On Wed, 2020-07-15 at 23:05 +0200, Matthias Brugger wrote:
>
> On 02/07/2020 11:37, Miles Chen wrote:
> > In previous disscusion [1] and [2], we found that it is risky to
> > use max_pfn or totalram_pages to tell if 4GB mode is enabled.
> >
> > Check 4GB mode by reading infracfg register, remove the usage
> > of the unexported symbol max_pfn.
> >
> > [1] https://urldefense.com/v3/__https://lkml.org/lkml/2020/6/3/733__;!!CTRNKA9wMg0ARbw!16gAfVnSY87W4t5kE4iw20QPxBgS_SHBvPKlePKU7CGIb18nUzuRUjHumcf4oYVhIQ$
> > [2] https://urldefense.com/v3/__https://lkml.org/lkml/2020/6/4/136__;!!CTRNKA9wMg0ARbw!16gAfVnSY87W4t5kE4iw20QPxBgS_SHBvPKlePKU7CGIb18nUzuRUjHumcfr4i9p5g$
> >
> > Cc: Mike Rapoport <rppt@linux.ibm.com>
> > Cc: David Hildenbrand <david@redhat.com>
> > Cc: Yong Wu <yong.wu@mediatek.com>
> > Cc: Yingjoe Chen <yingjoe.chen@mediatek.com>
> > Cc: Christoph Hellwig <hch@lst.de>
> > Signed-off-by: Miles Chen <miles.chen@mediatek.com>
> > ---
> > drivers/iommu/mtk_iommu.c | 22 ++++++++++++++++++----
> > 1 file changed, 18 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> > index 2be96f1cdbd2..09be57bd8d74 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -3,7 +3,6 @@
> > * Copyright (c) 2015-2016 MediaTek Inc.
> > * Author: Yong Wu <yong.wu@mediatek.com>
> > */
> > -#include <linux/memblock.h>
> > #include <linux/bug.h>
> > #include <linux/clk.h>
> > #include <linux/component.h>
> > @@ -15,11 +14,13 @@
> > #include <linux/iommu.h>
> > #include <linux/iopoll.h>
> > #include <linux/list.h>
> > +#include <linux/mfd/syscon.h>
> > #include <linux/of_address.h>
> > #include <linux/of_iommu.h>
> > #include <linux/of_irq.h>
> > #include <linux/of_platform.h>
> > #include <linux/platform_device.h>
> > +#include <linux/regmap.h>
> > #include <linux/slab.h>
> > #include <linux/spinlock.h>
> > #include <asm/barrier.h>
> > @@ -91,6 +92,9 @@
> > #define F_MMU_INT_ID_LARB_ID(a) (((a) >> 7) & 0x7)
> > #define F_MMU_INT_ID_PORT_ID(a) (((a) >> 2) & 0x1f)
> >
> > +#define REG_INFRA_MISC 0xf00
> > +#define F_DDR_4GB_SUPPORT_EN BIT(13)
> > +
>
> As this is used for infracfg, I think it would be good to add it to
> include/linux/soc/mediatek/infracfg.h and include that file here.
Thanks for your comment.
ok. I'll do this in next version.
>
> > #define MTK_PROTECT_PA_ALIGN 128
> >
> > /*
> > @@ -599,8 +603,10 @@ static int mtk_iommu_probe(struct platform_device *pdev)
> > struct resource *res;
> > resource_size_t ioaddr;
> > struct component_match *match = NULL;
> > + struct regmap *infracfg_regmap;
>
> Maybe call it just infracfg.
ok. I'll do this in next version.
>
> > void *protect;
> > int i, larb_nr, ret;
> > + u32 val;
> >
> > data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> > if (!data)
> > @@ -614,10 +620,18 @@ static int mtk_iommu_probe(struct platform_device *pdev)
> > return -ENOMEM;
> > data->protect_base = ALIGN(virt_to_phys(protect), MTK_PROTECT_PA_ALIGN);
> >
> > - /* Whether the current dram is over 4GB */
> > - data->enable_4GB = !!(max_pfn > (BIT_ULL(32) >> PAGE_SHIFT));
> > - if (!data->plat_data->has_4gb_mode)
> > + if (data->plat_data->has_4gb_mode) {
> > + infracfg_regmap = syscon_regmap_lookup_by_phandle(dev->of_node,
> > + "mediatek,infracfg");
> > + if (IS_ERR(infracfg_regmap))
> > + return PTR_ERR(infracfg_regmap);
>
> Do we need to error out, or could we be conservative and set endable_4GB = false?
We have to error out in this case because the 4gb_mode setting must be
consistent with the h/w setting.
>
> > + ret = regmap_read(infracfg_regmap, REG_INFRA_MISC, &val);
> > + if (ret)
> > + return ret;
> > + data->enable_4GB = !!(val & F_DDR_4GB_SUPPORT_EN);
> > + } else {
> > data->enable_4GB = false;
>
> Move that before the if() and update enable_4GB only in case of has_4gb_mode.
ok. I'll do this in next version.
Miles
>
> > + }
> >
> > res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > data->base = devm_ioremap_resource(dev, res);
> >
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Miles Chen <miles.chen@mediatek.com>
To: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Joerg Roedel <joro@8bytes.org>, Rob Herring <robh+dt@kernel.org>,
<iommu@lists.linux-foundation.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>, <wsd_upstream@mediatek.com>,
Yong Wu <yong.wu@mediatek.com>, Chao Hao <chao.hao@mediatek.com>,
Yingjoe Chen <yingjoe.chen@mediatek.com>,
Mike Rapoport <rppt@linux.ibm.com>,
"David Hildenbrand" <david@redhat.com>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH 4/4] iommu/mediatek: check 4GB mode by reading infracfg
Date: Fri, 17 Jul 2020 16:26:31 +0800 [thread overview]
Message-ID: <1594974391.12796.25.camel@mtkswgap22> (raw)
In-Reply-To: <84333997-735c-4a91-6d47-1dcb5c4a6078@gmail.com>
On Wed, 2020-07-15 at 23:05 +0200, Matthias Brugger wrote:
>
> On 02/07/2020 11:37, Miles Chen wrote:
> > In previous disscusion [1] and [2], we found that it is risky to
> > use max_pfn or totalram_pages to tell if 4GB mode is enabled.
> >
> > Check 4GB mode by reading infracfg register, remove the usage
> > of the unexported symbol max_pfn.
> >
> > [1] https://urldefense.com/v3/__https://lkml.org/lkml/2020/6/3/733__;!!CTRNKA9wMg0ARbw!16gAfVnSY87W4t5kE4iw20QPxBgS_SHBvPKlePKU7CGIb18nUzuRUjHumcf4oYVhIQ$
> > [2] https://urldefense.com/v3/__https://lkml.org/lkml/2020/6/4/136__;!!CTRNKA9wMg0ARbw!16gAfVnSY87W4t5kE4iw20QPxBgS_SHBvPKlePKU7CGIb18nUzuRUjHumcfr4i9p5g$
> >
> > Cc: Mike Rapoport <rppt@linux.ibm.com>
> > Cc: David Hildenbrand <david@redhat.com>
> > Cc: Yong Wu <yong.wu@mediatek.com>
> > Cc: Yingjoe Chen <yingjoe.chen@mediatek.com>
> > Cc: Christoph Hellwig <hch@lst.de>
> > Signed-off-by: Miles Chen <miles.chen@mediatek.com>
> > ---
> > drivers/iommu/mtk_iommu.c | 22 ++++++++++++++++++----
> > 1 file changed, 18 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> > index 2be96f1cdbd2..09be57bd8d74 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -3,7 +3,6 @@
> > * Copyright (c) 2015-2016 MediaTek Inc.
> > * Author: Yong Wu <yong.wu@mediatek.com>
> > */
> > -#include <linux/memblock.h>
> > #include <linux/bug.h>
> > #include <linux/clk.h>
> > #include <linux/component.h>
> > @@ -15,11 +14,13 @@
> > #include <linux/iommu.h>
> > #include <linux/iopoll.h>
> > #include <linux/list.h>
> > +#include <linux/mfd/syscon.h>
> > #include <linux/of_address.h>
> > #include <linux/of_iommu.h>
> > #include <linux/of_irq.h>
> > #include <linux/of_platform.h>
> > #include <linux/platform_device.h>
> > +#include <linux/regmap.h>
> > #include <linux/slab.h>
> > #include <linux/spinlock.h>
> > #include <asm/barrier.h>
> > @@ -91,6 +92,9 @@
> > #define F_MMU_INT_ID_LARB_ID(a) (((a) >> 7) & 0x7)
> > #define F_MMU_INT_ID_PORT_ID(a) (((a) >> 2) & 0x1f)
> >
> > +#define REG_INFRA_MISC 0xf00
> > +#define F_DDR_4GB_SUPPORT_EN BIT(13)
> > +
>
> As this is used for infracfg, I think it would be good to add it to
> include/linux/soc/mediatek/infracfg.h and include that file here.
Thanks for your comment.
ok. I'll do this in next version.
>
> > #define MTK_PROTECT_PA_ALIGN 128
> >
> > /*
> > @@ -599,8 +603,10 @@ static int mtk_iommu_probe(struct platform_device *pdev)
> > struct resource *res;
> > resource_size_t ioaddr;
> > struct component_match *match = NULL;
> > + struct regmap *infracfg_regmap;
>
> Maybe call it just infracfg.
ok. I'll do this in next version.
>
> > void *protect;
> > int i, larb_nr, ret;
> > + u32 val;
> >
> > data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> > if (!data)
> > @@ -614,10 +620,18 @@ static int mtk_iommu_probe(struct platform_device *pdev)
> > return -ENOMEM;
> > data->protect_base = ALIGN(virt_to_phys(protect), MTK_PROTECT_PA_ALIGN);
> >
> > - /* Whether the current dram is over 4GB */
> > - data->enable_4GB = !!(max_pfn > (BIT_ULL(32) >> PAGE_SHIFT));
> > - if (!data->plat_data->has_4gb_mode)
> > + if (data->plat_data->has_4gb_mode) {
> > + infracfg_regmap = syscon_regmap_lookup_by_phandle(dev->of_node,
> > + "mediatek,infracfg");
> > + if (IS_ERR(infracfg_regmap))
> > + return PTR_ERR(infracfg_regmap);
>
> Do we need to error out, or could we be conservative and set endable_4GB = false?
We have to error out in this case because the 4gb_mode setting must be
consistent with the h/w setting.
>
> > + ret = regmap_read(infracfg_regmap, REG_INFRA_MISC, &val);
> > + if (ret)
> > + return ret;
> > + data->enable_4GB = !!(val & F_DDR_4GB_SUPPORT_EN);
> > + } else {
> > data->enable_4GB = false;
>
> Move that before the if() and update enable_4GB only in case of has_4gb_mode.
ok. I'll do this in next version.
Miles
>
> > + }
> >
> > res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > data->base = devm_ioremap_resource(dev, res);
> >
next prev parent reply other threads:[~2020-07-17 8:26 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 9:37 [PATCH 1/4] dt-bindings: mediatek: add mediatek,infracfg phandle Miles Chen
2020-07-02 9:37 ` Miles Chen
2020-07-02 9:37 ` Miles Chen
2020-07-02 9:37 ` Miles Chen
2020-07-02 9:37 ` [PATCH 2/4] arm64: dts: mt2712: add mediatek,infracfg to iommu Miles Chen
2020-07-02 9:37 ` Miles Chen
2020-07-02 9:37 ` Miles Chen
2020-07-02 9:37 ` Miles Chen
2020-07-02 9:37 ` [PATCH 3/4] arm64: dts: mt8173: " Miles Chen
2020-07-02 9:37 ` Miles Chen
2020-07-02 9:37 ` Miles Chen
2020-07-02 9:37 ` Miles Chen
2020-07-02 9:37 ` [PATCH 4/4] iommu/mediatek: check 4GB mode by reading infracfg Miles Chen
2020-07-02 9:37 ` Miles Chen
2020-07-02 9:37 ` Miles Chen
2020-07-02 9:37 ` Miles Chen
2020-07-15 21:05 ` Matthias Brugger
2020-07-15 21:05 ` Matthias Brugger
2020-07-15 21:05 ` Matthias Brugger
2020-07-15 21:05 ` Matthias Brugger
2020-07-17 8:26 ` Miles Chen [this message]
2020-07-17 8:26 ` Miles Chen
2020-07-17 8:26 ` Miles Chen
2020-07-17 8:26 ` Miles Chen
2020-07-15 20:51 ` [PATCH 1/4] dt-bindings: mediatek: add mediatek,infracfg phandle Rob Herring
2020-07-15 20:51 ` Rob Herring
2020-07-15 20:51 ` Rob Herring
2020-07-15 20:51 ` Rob Herring
2020-07-17 8:18 ` Miles Chen
2020-07-17 8:18 ` Miles Chen
2020-07-17 8:18 ` Miles Chen
2020-07-17 8:18 ` Miles Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1594974391.12796.25.camel@mtkswgap22 \
--to=miles.chen@mediatek.com \
--cc=chao.hao@mediatek.com \
--cc=david@redhat.com \
--cc=devicetree@vger.kernel.org \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=robh+dt@kernel.org \
--cc=rppt@linux.ibm.com \
--cc=wsd_upstream@mediatek.com \
--cc=yingjoe.chen@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.