ASoC: SOF: ext_manifest: parse compiler version
authorKarol Trzcinski <karolx.trzcinski@linux.intel.com>
Wed, 20 May 2020 16:59:11 +0000 (19:59 +0300)
committerMark Brown <broonie@kernel.org>
Mon, 25 May 2020 13:59:37 +0000 (14:59 +0100)
The compiler version and description can be extracted from the
extended manifest content. This information known at build time
does not need to be provided in a mailbox.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20200520165911.21696-6-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/sof/ext_manifest.h
sound/soc/sof/loader.c

index 0001fc5..04359cd 100644 (file)
@@ -59,6 +59,7 @@ struct sof_ext_man_header {
 enum sof_ext_man_elem_type {
        SOF_EXT_MAN_ELEM_FW_VERSION             = 0,
        SOF_EXT_MAN_ELEM_WINDOW                 = SOF_IPC_EXT_WINDOW,
+       SOF_EXT_MAN_ELEM_CC_VERSION             = SOF_IPC_EXT_CC_INFO,
 };
 
 /* extended manifest element header */
@@ -84,4 +85,11 @@ struct sof_ext_man_window {
        struct sof_ipc_window ipc_window;
 } __packed;
 
+/* Used C compiler description */
+struct sof_ext_man_cc_version {
+       struct sof_ext_man_elem_header hdr;
+       /* use sof_ipc struct because of code re-use */
+       struct sof_ipc_cc_version cc_version;
+} __packed;
+
 #endif /* __SOF_FIRMWARE_EXT_MANIFEST_H__ */
index 6e92a12..b94fa5f 100644 (file)
@@ -49,6 +49,14 @@ static int get_cc_info(struct snd_sof_dev *sdev,
        const struct sof_ipc_cc_version *cc =
                container_of(ext_hdr, struct sof_ipc_cc_version, ext_hdr);
 
+       if (sdev->cc_version) {
+               if (memcmp(sdev->cc_version, cc, cc->ext_hdr.hdr.size)) {
+                       dev_err(sdev->dev, "error: receive diverged cc_version descriptions");
+                       return -EINVAL;
+               }
+               return 0;
+       }
+
        dev_dbg(sdev->dev, "Firmware info: used compiler %s %d:%d:%d%s used optimization flags %s\n",
                cc->name, cc->major, cc->minor, cc->micro, cc->desc,
                cc->optim);
@@ -158,6 +166,16 @@ static int ext_man_get_windows(struct snd_sof_dev *sdev,
        return get_ext_windows(sdev, &w->ipc_window.ext_hdr);
 }
 
+static int ext_man_get_cc_info(struct snd_sof_dev *sdev,
+                              const struct sof_ext_man_elem_header *hdr)
+{
+       const struct sof_ext_man_cc_version *cc;
+
+       cc = container_of(hdr, struct sof_ext_man_cc_version, hdr);
+
+       return get_cc_info(sdev, &cc->cc_version.ext_hdr);
+}
+
 static ssize_t snd_sof_ext_man_size(const struct firmware *fw)
 {
        const struct sof_ext_man_header *head;
@@ -234,6 +252,9 @@ static int snd_sof_fw_ext_man_parse(struct snd_sof_dev *sdev,
                case SOF_EXT_MAN_ELEM_WINDOW:
                        ret = ext_man_get_windows(sdev, elem_hdr);
                        break;
+               case SOF_EXT_MAN_ELEM_CC_VERSION:
+                       ret = ext_man_get_cc_info(sdev, elem_hdr);
+                       break;
                default:
                        dev_warn(sdev->dev, "warning: unknown sof_ext_man header type %d size 0x%X\n",
                                 elem_hdr->type, elem_hdr->size);