[PATCH 2/2] memory: brcmstb_memc: Simplify compatible matching

Florian Fainelli posted 2 patches 6 months, 3 weeks ago
There is a newer version of this series
[PATCH 2/2] memory: brcmstb_memc: Simplify compatible matching
Posted by Florian Fainelli 6 months, 3 weeks ago
Now that a "brcm,brcmstb-memc-ddr-rev-b.2.x" fallback compatible string
has been defined, we can greatly simplify the matching within the driver
to only look for that compatible string and nothing else.

The fallback "brcm,brcmstb-memc-ddr" is also updated to assume the V21
register layout since that is the most common nowadays.

Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 drivers/memory/brcmstb_memc.c | 58 ++---------------------------------
 1 file changed, 3 insertions(+), 55 deletions(-)

diff --git a/drivers/memory/brcmstb_memc.c b/drivers/memory/brcmstb_memc.c
index c87b37e2c1f0..ec4c198ddc49 100644
--- a/drivers/memory/brcmstb_memc.c
+++ b/drivers/memory/brcmstb_memc.c
@@ -181,65 +181,13 @@ static const struct of_device_id brcmstb_memc_of_match[] = {
 		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V20]
 	},
 	{
-		.compatible = "brcm,brcmstb-memc-ddr-rev-b.2.1",
+		.compatible = "brcm,brcmstb-memc-ddr-rev-b.2.x",
 		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
 	},
-	{
-		.compatible = "brcm,brcmstb-memc-ddr-rev-b.2.2",
-		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
-	},
-	{
-		.compatible = "brcm,brcmstb-memc-ddr-rev-b.2.3",
-		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
-	},
-	{
-		.compatible = "brcm,brcmstb-memc-ddr-rev-b.2.5",
-		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
-	},
-	{
-		.compatible = "brcm,brcmstb-memc-ddr-rev-b.2.6",
-		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
-	},
-	{
-		.compatible = "brcm,brcmstb-memc-ddr-rev-b.2.7",
-		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
-	},
-	{
-		.compatible = "brcm,brcmstb-memc-ddr-rev-b.2.8",
-		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
-	},
-	{
-		.compatible = "brcm,brcmstb-memc-ddr-rev-b.3.0",
-		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
-	},
-	{
-		.compatible = "brcm,brcmstb-memc-ddr-rev-b.3.1",
-		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
-	},
-	{
-		.compatible = "brcm,brcmstb-memc-ddr-rev-c.1.0",
-		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
-	},
-	{
-		.compatible = "brcm,brcmstb-memc-ddr-rev-c.1.1",
-		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
-	},
-	{
-		.compatible = "brcm,brcmstb-memc-ddr-rev-c.1.2",
-		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
-	},
-	{
-		.compatible = "brcm,brcmstb-memc-ddr-rev-c.1.3",
-		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
-	},
-	{
-		.compatible = "brcm,brcmstb-memc-ddr-rev-c.1.4",
-		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
-	},
-	/* default to the original offset */
+	/* default to the V21 offset */
 	{
 		.compatible = "brcm,brcmstb-memc-ddr",
-		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V1X]
+		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
 	},
 	{}
 };
-- 
2.43.0
Re: [PATCH 2/2] memory: brcmstb_memc: Simplify compatible matching
Posted by Rob Herring 6 months, 1 week ago
On Fri, May 23, 2025 at 11:43:54AM -0700, Florian Fainelli wrote:
> Now that a "brcm,brcmstb-memc-ddr-rev-b.2.x" fallback compatible string
> has been defined, we can greatly simplify the matching within the driver
> to only look for that compatible string and nothing else.
> 
> The fallback "brcm,brcmstb-memc-ddr" is also updated to assume the V21
> register layout since that is the most common nowadays.
> 
> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
> ---
>  drivers/memory/brcmstb_memc.c | 58 ++---------------------------------
>  1 file changed, 3 insertions(+), 55 deletions(-)
> 
> diff --git a/drivers/memory/brcmstb_memc.c b/drivers/memory/brcmstb_memc.c
> index c87b37e2c1f0..ec4c198ddc49 100644
> --- a/drivers/memory/brcmstb_memc.c
> +++ b/drivers/memory/brcmstb_memc.c
> @@ -181,65 +181,13 @@ static const struct of_device_id brcmstb_memc_of_match[] = {
>  		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V20]
>  	},
>  	{
> -		.compatible = "brcm,brcmstb-memc-ddr-rev-b.2.1",
> +		.compatible = "brcm,brcmstb-memc-ddr-rev-b.2.x",
>  		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]

This entry is pointless because the default will get V21.

In fact, I don't think you need the new compatible string at all. It 
doesn't work to add fallbacks after the fact.

Rob
Re: [PATCH 2/2] memory: brcmstb_memc: Simplify compatible matching
Posted by Florian Fainelli 6 months, 1 week ago
On 6/5/25 11:55, Rob Herring wrote:
> On Fri, May 23, 2025 at 11:43:54AM -0700, Florian Fainelli wrote:
>> Now that a "brcm,brcmstb-memc-ddr-rev-b.2.x" fallback compatible string
>> has been defined, we can greatly simplify the matching within the driver
>> to only look for that compatible string and nothing else.
>>
>> The fallback "brcm,brcmstb-memc-ddr" is also updated to assume the V21
>> register layout since that is the most common nowadays.
>>
>> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
>> ---
>>   drivers/memory/brcmstb_memc.c | 58 ++---------------------------------
>>   1 file changed, 3 insertions(+), 55 deletions(-)
>>
>> diff --git a/drivers/memory/brcmstb_memc.c b/drivers/memory/brcmstb_memc.c
>> index c87b37e2c1f0..ec4c198ddc49 100644
>> --- a/drivers/memory/brcmstb_memc.c
>> +++ b/drivers/memory/brcmstb_memc.c
>> @@ -181,65 +181,13 @@ static const struct of_device_id brcmstb_memc_of_match[] = {
>>   		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V20]
>>   	},
>>   	{
>> -		.compatible = "brcm,brcmstb-memc-ddr-rev-b.2.1",
>> +		.compatible = "brcm,brcmstb-memc-ddr-rev-b.2.x",
>>   		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
> 
> This entry is pointless because the default will get V21.
> 
> In fact, I don't think you need the new compatible string at all. It
> doesn't work to add fallbacks after the fact.

I agree and would prefer to keep adding new compatible strings which is 
what I initially did here:

https://lore.kernel.org/all/20241217194439.929040-2-florian.fainelli@broadcom.com/

but the feedback was that this should not be done, and hence this 
attempt at defining a compatible string that would avoid needless churn.

So which way should I go now?
-- 
Florian
Re: [PATCH 2/2] memory: brcmstb_memc: Simplify compatible matching
Posted by Krzysztof Kozlowski 6 months, 1 week ago
On 05/06/2025 21:10, Florian Fainelli wrote:
> On 6/5/25 11:55, Rob Herring wrote:
>> On Fri, May 23, 2025 at 11:43:54AM -0700, Florian Fainelli wrote:
>>> Now that a "brcm,brcmstb-memc-ddr-rev-b.2.x" fallback compatible string
>>> has been defined, we can greatly simplify the matching within the driver
>>> to only look for that compatible string and nothing else.
>>>
>>> The fallback "brcm,brcmstb-memc-ddr" is also updated to assume the V21
>>> register layout since that is the most common nowadays.
>>>
>>> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
>>> ---
>>>   drivers/memory/brcmstb_memc.c | 58 ++---------------------------------
>>>   1 file changed, 3 insertions(+), 55 deletions(-)
>>>
>>> diff --git a/drivers/memory/brcmstb_memc.c b/drivers/memory/brcmstb_memc.c
>>> index c87b37e2c1f0..ec4c198ddc49 100644
>>> --- a/drivers/memory/brcmstb_memc.c
>>> +++ b/drivers/memory/brcmstb_memc.c
>>> @@ -181,65 +181,13 @@ static const struct of_device_id brcmstb_memc_of_match[] = {
>>>   		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V20]
>>>   	},
>>>   	{
>>> -		.compatible = "brcm,brcmstb-memc-ddr-rev-b.2.1",
>>> +		.compatible = "brcm,brcmstb-memc-ddr-rev-b.2.x",
>>>   		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
>>
>> This entry is pointless because the default will get V21.
>>
>> In fact, I don't think you need the new compatible string at all. It
>> doesn't work to add fallbacks after the fact.
> 
> I agree and would prefer to keep adding new compatible strings which is 

So you agree that adding such entries is pointless?

> what I initially did here:
> 
> https://lore.kernel.org/all/20241217194439.929040-2-florian.fainelli@broadcom.com/
> 
> but the feedback was that this should not be done, and hence this 
> attempt at defining a compatible string that would avoid needless churn.
> 
> So which way should I go now?

And the advice was to use v2.1 fallback, not replace v2.1 with something
else or keep adding pointless entries:
https://lore.kernel.org/all/2e33t7ft5ermsfr7c4ympxrn6l5sqdef3wml4hlbnhdupoouwj@gfjpbmowjadi/


Best regards,
Krzysztof
Re: [PATCH 2/2] memory: brcmstb_memc: Simplify compatible matching
Posted by Florian Fainelli 6 months, 1 week ago
On 6/5/25 13:30, Krzysztof Kozlowski wrote:
> On 05/06/2025 21:10, Florian Fainelli wrote:
>> On 6/5/25 11:55, Rob Herring wrote:
>>> On Fri, May 23, 2025 at 11:43:54AM -0700, Florian Fainelli wrote:
>>>> Now that a "brcm,brcmstb-memc-ddr-rev-b.2.x" fallback compatible string
>>>> has been defined, we can greatly simplify the matching within the driver
>>>> to only look for that compatible string and nothing else.
>>>>
>>>> The fallback "brcm,brcmstb-memc-ddr" is also updated to assume the V21
>>>> register layout since that is the most common nowadays.
>>>>
>>>> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
>>>> ---
>>>>    drivers/memory/brcmstb_memc.c | 58 ++---------------------------------
>>>>    1 file changed, 3 insertions(+), 55 deletions(-)
>>>>
>>>> diff --git a/drivers/memory/brcmstb_memc.c b/drivers/memory/brcmstb_memc.c
>>>> index c87b37e2c1f0..ec4c198ddc49 100644
>>>> --- a/drivers/memory/brcmstb_memc.c
>>>> +++ b/drivers/memory/brcmstb_memc.c
>>>> @@ -181,65 +181,13 @@ static const struct of_device_id brcmstb_memc_of_match[] = {
>>>>    		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V20]
>>>>    	},
>>>>    	{
>>>> -		.compatible = "brcm,brcmstb-memc-ddr-rev-b.2.1",
>>>> +		.compatible = "brcm,brcmstb-memc-ddr-rev-b.2.x",
>>>>    		.data = &brcmstb_memc_versions[BRCMSTB_MEMC_V21]
>>>
>>> This entry is pointless because the default will get V21.
>>>
>>> In fact, I don't think you need the new compatible string at all. It
>>> doesn't work to add fallbacks after the fact.
>>
>> I agree and would prefer to keep adding new compatible strings which is
> 
> So you agree that adding such entries is pointless?

I don't think it is pointless, it's overly descriptive and we don't key 
off of it for now.

> 
>> what I initially did here:
>>
>> https://lore.kernel.org/all/20241217194439.929040-2-florian.fainelli@broadcom.com/
>>
>> but the feedback was that this should not be done, and hence this
>> attempt at defining a compatible string that would avoid needless churn.
>>
>> So which way should I go now?
> 
> And the advice was to use v2.1 fallback, not replace v2.1 with something
> else or keep adding pointless entries:
> https://lore.kernel.org/all/2e33t7ft5ermsfr7c4ympxrn6l5sqdef3wml4hlbnhdupoouwj@gfjpbmowjadi/

Fair enough then, I will re-spin accordingly. Thank you both.
-- 
Florian