lib: arm_ffa: Downgrade our FF-A version if lower

The SPMC returns the version it supports as the
return value of FFA_VERSION. If ours is lower than
that but valid, downgrade our ffa_version variable
instead of using the one reported by the SPMC.

Bug: None
Change-Id: Ic65bbb13b7cbadd113b9757d37b3c90ceb8e1462
diff --git a/lib/arm_ffa/arm_ffa.c b/lib/arm_ffa/arm_ffa.c
index 033d51a..dd38f84 100644
--- a/lib/arm_ffa/arm_ffa.c
+++ b/lib/arm_ffa/arm_ffa.c
@@ -1186,8 +1186,13 @@
     }
 
     ffa_version = FFA_VERSION(ver_major_ret, ver_minor_ret);
-    LTRACEF("Negotiated FF-A version %" PRIu16 ".%" PRIu16 "\n", ver_major_ret,
-            ver_minor_ret);
+    if (ffa_version > FFA_CURRENT_VERSION) {
+        /* The SPMC supports a newer version, downgrade us */
+        ffa_version = FFA_CURRENT_VERSION;
+    }
+    LTRACEF("Negotiated FF-A version %" PRIu16 ".%" PRIu16 "\n",
+            FFA_VERSION_TO_MAJOR(ffa_version),
+            FFA_VERSION_TO_MINOR(ffa_version));
 
     res = arm_ffa_call_id_get(&ffa_local_id);
     if (res != NO_ERROR) {