Re: [PATCH 6/6] staging: fsl-mc: Changed version matching rules for MC object drivers

2015-04-08 Thread Alexander Graf

On 03/27/2015 10:01 PM, J. German Rivera wrote:

Before this change, we were requiring a complete version match (major and
minor version numbers) between MC objects and corresponding drivers, to
allow MC objects to be bound to their drivers. We realized that a mismatch
in minor version numbers should be tolerated, as long as the major version
numbers match. This allows the driver to decide what to do in the minor
version mismatch case. For example, a driver may decide to run with
downgraded functionality if the MC firmware object has older minor version
number than the driver. Also, a driver with older minor version than the
MC firmware object may decide to run even though it cannot use newer
functionality of the MC object.

As part of this change, the dpmng Flib version was also updated
to match the latest MC firmware version.

Signed-off-by: J. German Rivera 


I think this is a step into the right direction, but you really don't 
want to match only when the minor equals. Usually you'd like something like


  if (cur_minor > max_minor) {
dev_warn("Unknown version %d.%d of fsl-mc detected. Please update 
your kernel if you encounter problems.")

  }

but always assume that cur_minor < max_minor works. In cases where the 
protocol did change between minors, add code to support the older minors 
as well.



Alex

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 6/6] staging: fsl-mc: Changed version matching rules for MC object drivers

2015-04-08 Thread Alexander Graf

On 03/27/2015 10:01 PM, J. German Rivera wrote:

Before this change, we were requiring a complete version match (major and
minor version numbers) between MC objects and corresponding drivers, to
allow MC objects to be bound to their drivers. We realized that a mismatch
in minor version numbers should be tolerated, as long as the major version
numbers match. This allows the driver to decide what to do in the minor
version mismatch case. For example, a driver may decide to run with
downgraded functionality if the MC firmware object has older minor version
number than the driver. Also, a driver with older minor version than the
MC firmware object may decide to run even though it cannot use newer
functionality of the MC object.

As part of this change, the dpmng Flib version was also updated
to match the latest MC firmware version.

Signed-off-by: J. German Rivera german.riv...@freescale.com


I think this is a step into the right direction, but you really don't 
want to match only when the minor equals. Usually you'd like something like


  if (cur_minor  max_minor) {
dev_warn(Unknown version %d.%d of fsl-mc detected. Please update 
your kernel if you encounter problems.)

  }

but always assume that cur_minor  max_minor works. In cases where the 
protocol did change between minors, add code to support the older minors 
as well.



Alex

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] staging: fsl-mc: Changed version matching rules for MC object drivers

2015-03-27 Thread J. German Rivera
Before this change, we were requiring a complete version match (major and
minor version numbers) between MC objects and corresponding drivers, to
allow MC objects to be bound to their drivers. We realized that a mismatch
in minor version numbers should be tolerated, as long as the major version
numbers match. This allows the driver to decide what to do in the minor
version mismatch case. For example, a driver may decide to run with
downgraded functionality if the MC firmware object has older minor version
number than the driver. Also, a driver with older minor version than the
MC firmware object may decide to run even though it cannot use newer
functionality of the MC object.

As part of this change, the dpmng Flib version was also updated
to match the latest MC firmware version.

Signed-off-by: J. German Rivera 
---
 drivers/staging/fsl-mc/bus/mc-bus.c| 29 +
 drivers/staging/fsl-mc/include/dpmng.h |  2 +-
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index b347db9..23512d0 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -36,6 +36,8 @@ static int fsl_mc_bus_match(struct device *dev, struct 
device_driver *drv)
struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(drv);
bool found = false;
+   bool major_version_mismatch = false;
+   bool minor_version_mismatch = false;
 
if (WARN_ON(!fsl_mc_bus_type.dev_root))
goto out;
@@ -57,14 +59,33 @@ static int fsl_mc_bus_match(struct device *dev, struct 
device_driver *drv)
 */
for (id = mc_drv->match_id_table; id->vendor != 0x0; id++) {
if (id->vendor == mc_dev->obj_desc.vendor &&
-   strcmp(id->obj_type, mc_dev->obj_desc.type) == 0 &&
-   id->ver_major == mc_dev->obj_desc.ver_major &&
-   id->ver_minor == mc_dev->obj_desc.ver_minor) {
-   found = true;
+   strcmp(id->obj_type, mc_dev->obj_desc.type) == 0) {
+   if (id->ver_major == mc_dev->obj_desc.ver_major) {
+   found = true;
+   if (id->ver_minor != mc_dev->obj_desc.ver_minor)
+   minor_version_mismatch = true;
+   } else {
+   major_version_mismatch = true;
+   }
+
break;
}
}
 
+   if (major_version_mismatch) {
+   dev_warn(dev,
+"Major version mismatch: driver version %u.%u, MC 
object version %u.%u\n",
+id->ver_major, id->ver_minor,
+mc_dev->obj_desc.ver_major,
+mc_dev->obj_desc.ver_minor);
+   } else if (minor_version_mismatch) {
+   dev_warn(dev,
+"Minor version mismatch: driver version %u.%u, MC 
object version %u.%u\n",
+id->ver_major, id->ver_minor,
+mc_dev->obj_desc.ver_major,
+mc_dev->obj_desc.ver_minor);
+   }
+
 out:
dev_dbg(dev, "%smatched\n", found ? "" : "not ");
return found;
diff --git a/drivers/staging/fsl-mc/include/dpmng.h 
b/drivers/staging/fsl-mc/include/dpmng.h
index 0fc0a57..1b052b8 100644
--- a/drivers/staging/fsl-mc/include/dpmng.h
+++ b/drivers/staging/fsl-mc/include/dpmng.h
@@ -41,7 +41,7 @@ struct fsl_mc_io;
 /**
  * Management Complex firmware version information
  */
-#define MC_VER_MAJOR 5
+#define MC_VER_MAJOR 6
 #define MC_VER_MINOR 0
 
 /**
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] staging: fsl-mc: Changed version matching rules for MC object drivers

2015-03-27 Thread J. German Rivera
Before this change, we were requiring a complete version match (major and
minor version numbers) between MC objects and corresponding drivers, to
allow MC objects to be bound to their drivers. We realized that a mismatch
in minor version numbers should be tolerated, as long as the major version
numbers match. This allows the driver to decide what to do in the minor
version mismatch case. For example, a driver may decide to run with
downgraded functionality if the MC firmware object has older minor version
number than the driver. Also, a driver with older minor version than the
MC firmware object may decide to run even though it cannot use newer
functionality of the MC object.

As part of this change, the dpmng Flib version was also updated
to match the latest MC firmware version.

Signed-off-by: J. German Rivera german.riv...@freescale.com
---
 drivers/staging/fsl-mc/bus/mc-bus.c| 29 +
 drivers/staging/fsl-mc/include/dpmng.h |  2 +-
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index b347db9..23512d0 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -36,6 +36,8 @@ static int fsl_mc_bus_match(struct device *dev, struct 
device_driver *drv)
struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(drv);
bool found = false;
+   bool major_version_mismatch = false;
+   bool minor_version_mismatch = false;
 
if (WARN_ON(!fsl_mc_bus_type.dev_root))
goto out;
@@ -57,14 +59,33 @@ static int fsl_mc_bus_match(struct device *dev, struct 
device_driver *drv)
 */
for (id = mc_drv-match_id_table; id-vendor != 0x0; id++) {
if (id-vendor == mc_dev-obj_desc.vendor 
-   strcmp(id-obj_type, mc_dev-obj_desc.type) == 0 
-   id-ver_major == mc_dev-obj_desc.ver_major 
-   id-ver_minor == mc_dev-obj_desc.ver_minor) {
-   found = true;
+   strcmp(id-obj_type, mc_dev-obj_desc.type) == 0) {
+   if (id-ver_major == mc_dev-obj_desc.ver_major) {
+   found = true;
+   if (id-ver_minor != mc_dev-obj_desc.ver_minor)
+   minor_version_mismatch = true;
+   } else {
+   major_version_mismatch = true;
+   }
+
break;
}
}
 
+   if (major_version_mismatch) {
+   dev_warn(dev,
+Major version mismatch: driver version %u.%u, MC 
object version %u.%u\n,
+id-ver_major, id-ver_minor,
+mc_dev-obj_desc.ver_major,
+mc_dev-obj_desc.ver_minor);
+   } else if (minor_version_mismatch) {
+   dev_warn(dev,
+Minor version mismatch: driver version %u.%u, MC 
object version %u.%u\n,
+id-ver_major, id-ver_minor,
+mc_dev-obj_desc.ver_major,
+mc_dev-obj_desc.ver_minor);
+   }
+
 out:
dev_dbg(dev, %smatched\n, found ?  : not );
return found;
diff --git a/drivers/staging/fsl-mc/include/dpmng.h 
b/drivers/staging/fsl-mc/include/dpmng.h
index 0fc0a57..1b052b8 100644
--- a/drivers/staging/fsl-mc/include/dpmng.h
+++ b/drivers/staging/fsl-mc/include/dpmng.h
@@ -41,7 +41,7 @@ struct fsl_mc_io;
 /**
  * Management Complex firmware version information
  */
-#define MC_VER_MAJOR 5
+#define MC_VER_MAJOR 6
 #define MC_VER_MINOR 0
 
 /**
-- 
2.3.3

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/