]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: airoha: Wait for NPU PPE configuration to complete in airoha_ppe_offload_setup()
authorLorenzo Bianconi <lorenzo@kernel.org>
Tue, 14 Apr 2026 14:08:52 +0000 (16:08 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 17 Apr 2026 02:02:58 +0000 (19:02 -0700)
In order to properly enable flowtable hw offloading, poll
REG_PPE_FLOW_CFG register in airoha_ppe_offload_setup routine and
wait for NPU PPE configuration triggered by ppe_init callback to complete
before running airoha_ppe_hw_init().

Fixes: 00a7678310fe3 ("net: airoha: Introduce flowtable offload support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/20260414-airoha-wait-for-npu-config-offload-setup-v2-1-5a9bf6d43aee@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/airoha/airoha_ppe.c

index 03115c1c106301d633b380cbdfc6934eb96631d6..859818676b69d288bf441216e01da102b02b4f90 100644 (file)
@@ -1356,6 +1356,29 @@ static struct airoha_npu *airoha_ppe_npu_get(struct airoha_eth *eth)
        return npu;
 }
 
+static int airoha_ppe_wait_for_npu_init(struct airoha_eth *eth)
+{
+       int err;
+       u32 val;
+
+       /* PPE_FLOW_CFG default register value is 0. Since we reset FE
+        * during the device probe we can just check the configured value
+        * is not 0 here.
+        */
+       err = read_poll_timeout(airoha_fe_rr, val, val, USEC_PER_MSEC,
+                               100 * USEC_PER_MSEC, false, eth,
+                               REG_PPE_PPE_FLOW_CFG(0));
+       if (err)
+               return err;
+
+       if (airoha_ppe_is_enabled(eth, 1))
+               err = read_poll_timeout(airoha_fe_rr, val, val, USEC_PER_MSEC,
+                                       100 * USEC_PER_MSEC, false, eth,
+                                       REG_PPE_PPE_FLOW_CFG(1));
+
+       return err;
+}
+
 static int airoha_ppe_offload_setup(struct airoha_eth *eth)
 {
        struct airoha_npu *npu = airoha_ppe_npu_get(eth);
@@ -1369,6 +1392,11 @@ static int airoha_ppe_offload_setup(struct airoha_eth *eth)
        if (err)
                goto error_npu_put;
 
+       /* Wait for NPU PPE configuration to complete */
+       err = airoha_ppe_wait_for_npu_init(eth);
+       if (err)
+               goto error_npu_put;
+
        ppe_num_stats_entries = airoha_ppe_get_total_num_stats_entries(ppe);
        if (ppe_num_stats_entries > 0) {
                err = npu->ops.ppe_init_stats(npu, ppe->foe_stats_dma,