net: ipa: fix bug in resource group limit programming
authorAlex Elder <elder@linaro.org>
Fri, 26 Mar 2021 15:11:12 +0000 (10:11 -0500)
committerDavid S. Miller <davem@davemloft.net>
Fri, 26 Mar 2021 22:02:38 +0000 (15:02 -0700)
If the number of resource groups supported by the hardware is less
than a certain number, we return early in ipa_resource_config_src()
and ipa_resource_config_dst() (to avoid programming resource limits
for non-existent groups).

Unfortunately, these checks are off by one.  Fix this problem in the
four places it occurs.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ipa/ipa_resource.c

index 2f0f2dc..edd9d1e 100644 (file)
@@ -139,14 +139,14 @@ static void ipa_resource_config_src(struct ipa *ipa,
        ylimits = group_count == 1 ? NULL : &resource->limits[1];
        ipa_resource_config_common(ipa, offset, &resource->limits[0], ylimits);
 
-       if (group_count < 2)
+       if (group_count < 3)
                return;
 
        offset = IPA_REG_SRC_RSRC_GRP_23_RSRC_TYPE_N_OFFSET(resource->type);
        ylimits = group_count == 3 ? NULL : &resource->limits[3];
        ipa_resource_config_common(ipa, offset, &resource->limits[2], ylimits);
 
-       if (group_count < 4)
+       if (group_count < 5)
                return;
 
        offset = IPA_REG_SRC_RSRC_GRP_45_RSRC_TYPE_N_OFFSET(resource->type);
@@ -165,14 +165,14 @@ static void ipa_resource_config_dst(struct ipa *ipa,
        ylimits = group_count == 1 ? NULL : &resource->limits[1];
        ipa_resource_config_common(ipa, offset, &resource->limits[0], ylimits);
 
-       if (group_count < 2)
+       if (group_count < 3)
                return;
 
        offset = IPA_REG_DST_RSRC_GRP_23_RSRC_TYPE_N_OFFSET(resource->type);
        ylimits = group_count == 3 ? NULL : &resource->limits[3];
        ipa_resource_config_common(ipa, offset, &resource->limits[2], ylimits);
 
-       if (group_count < 4)
+       if (group_count < 5)
                return;
 
        offset = IPA_REG_DST_RSRC_GRP_45_RSRC_TYPE_N_OFFSET(resource->type);