Skip to contentSkip to conversation

mhi: Enable unique QRTR node ID support

RFC PATCH New Gokul Sriram Palanisamy 3 participants 4 messages Oct 16, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 mhi: Enable unique QRTR node ID support

On multi-mhi platforms, host WiFi driver and QMI test driver needs to differntiate between QMI packets received from multiple mhi devices.

With QCN9000 PCI cards, once SBL gets loaded, we utilize ERRDBG2 register to write a unique value per mhi device from device-tree that the device utilizes to set a unique QRTR node ID and instance ID for the QMI service. This helps QRTR stack in differenting the packets in a multi-mhi environment and can route them accordingly.

sample:

root@OpenWrt:/# qrtr-lookup
  Service Version Instance Node  Port
       69       1       40   40     2 ATH10k WLAN firmware service
       15       1        0   40     1 Test service
       69       1       39   39     2 ATH10k WLAN firmware service
       15       1        0   39     1 Test service

Here on column 4, 39 and 40 are the node IDs that is unique per mhi device.

Gokul Sriram Palanisamy (1):
bus: mhi: core: Enable unique QRTR node ID support

 .../devicetree/bindings/mhi/qcom,mhi.yaml          | 36 ++++++++++++++++++++++
 drivers/bus/mhi/core/boot.c                        | 14 +++++++++
 2 files changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mhi/qcom,mhi.yaml
Signature · 1 line
2.7.4
#1 lore raw

RFC PATCH 1/1 bus: mhi: core: Enable unique QRTR node ID support

On multi-mhi platforms, host WiFi driver and QMI test driver needs to differntiate between QMI packets received from multiple mhi devices.

With QCN9000 PCI cards, once SBL gets loaded, we utilize ERRDBG2 register to write a unique value per mhi device from device-tree that the device utilizes to set a unique QRTR node ID and instance ID for the QMI service. This helps QRTR stack in differenting the packets in a multi-mhi environment and can route them accordingly.

sample:

root@OpenWrt:/# qrtr-lookup
  Service Version Instance Node  Port
       69       1       40   40     2 ATH10k WLAN firmware service
       15       1        0   40     1 Test service
       69       1       39   39     2 ATH10k WLAN firmware service
       15       1        0   39     1 Test service

Here on column 4, 39 and 40 are the node IDs that is unique per mhi device.

---
 .../devicetree/bindings/mhi/qcom,mhi.yaml          | 36 ++++++++++++++++++++++
 drivers/bus/mhi/core/boot.c                        | 14 +++++++++
 2 files changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mhi/qcom,mhi.yaml
Documentation/devicetree/bindings/mhi/qcom,mhi.yaml new file +36 -0
new file mode 100644
index 0000000..f763e9f
@@ -0,0 +1,36 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/pci/qcom,pcie.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Qualcomm Modem Host Interface
+
+maintainers:
+  - Gokul Sriram Palanisamy <[email protected]>
+
+properties:
+  qrtr-instance-id:
+    const: 32
+
+required:
+  - reg
+  - qrtr-instance-id
+
+examples:
+  - |
+    pcie: pci@10000000 {
+        compatible = "qcom,pcie-qcs404";
+        status = "ok";
+        perst-gpio = <&tlmm 58 0x1>;
+
+        pcie0_rp: pcie0_rp {
+            reg = <0 0 0 0 0>;
+            status = "ok";
+            mhi_0: qcom,mhi@0 {
+                reg = <0 0 0 0 0 >;
+                qrtr_instance_id = <0x20>;
+            };
+        };
+    };
drivers/bus/mhi/core/boot.c +14 -0
index 0b38014..7406f28 100644
@@ -18,6 +18,9 @@
 #include <linux/wait.h>
 #include "internal.h"
 
+#define QRTR_INSTANCE_MASK	0x0000FFFF
+#define QRTR_INSTANCE_SHIFT	0
+
 /* Setup RDDM vector table for RDDM transfer and program RXVEC */
 void mhi_rddm_prepare(struct mhi_controller *mhi_cntrl,
 		      struct image_info *img_info)
@@ -445,6 +448,17 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
 		return;
 	}
 
+	if (!ret && mhi_cntrl->cntrl_dev->of_node) {
+		ret = of_property_read_u32(mhi_cntrl->cntrl_dev->of_node,
+					   "qrtr-instance-id", &instance);
+		if (!ret) {
+			instance &= QRTR_INSTANCE_MASK;
+			mhi_write_reg_field(mhi_cntrl, mhi_cntrl->bhi,
+					    BHI_ERRDBG2, QRTR_INSTANCE_MASK,
+					    QRTR_INSTANCE_SHIFT, instance);
+		}
+	}
+
 	if (mhi_cntrl->ee == MHI_EE_EDL)
 		return;
 
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH RFC] bus: mhi: core: Enable unique QRTR node ID support

Quoted 62 lines · Gokul Sriram Palanisamy

On multi-mhi platforms, host WiFi driver and QMI test driver needs to differntiate between QMI packets received from multiple mhi devices.

With QCN9000 PCI cards, once SBL gets loaded, we utilize ERRDBG2 register to write a unique value per mhi device from device-tree that the device utilizes to set a unique QRTR node ID and instance ID for the QMI service. This helps QRTR stack in differenting the packets in a multi-mhi environment and can route them accordingly.

sample:

root@OpenWrt:/# qrtr-lookup
   Service Version Instance Node  Port
        69       1       40   40     2 ATH10k WLAN firmware service
        15       1        0   40     1 Test service
        69       1       39   39     2 ATH10k WLAN firmware service
        15       1        0   39     1 Test service

Here on column 4, 39 and 40 are the node IDs that is unique per mhi device.

---
  .../devicetree/bindings/mhi/qcom,mhi.yaml          | 36 ++++++++++++++++++++++
  drivers/bus/mhi/core/boot.c                        | 14 +++++++++
  2 files changed, 50 insertions(+)

create mode 100644 Documentation/devicetree/bindings/mhi/qcom,mhi.yaml

Documentation/devicetree/bindings/mhi/qcom,mhi.yaml new file +26 -0
new file mode 100644
index 0000000..f763e9f
@@ -0,0 +1,36 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/pci/qcom,pcie.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Qualcomm Modem Host Interface
+
+maintainers:
+  - Gokul Sriram Palanisamy <[email protected]>
+
+properties:
+  qrtr-instance-id:
+    const: 32
+
+required:
+  - reg
+  - qrtr-instance-id
+
+examples:
+  - |
+    pcie: pci@10000000 {
+        compatible = "qcom,pcie-qcs404";
+        status = "ok";
+        perst-gpio = <&tlmm 58 0x1>;

Documentation/devicetree/bindings/mhi/qcom,mhi.yaml line 36

Quoted 10 lines
Documentation/devicetree/bindings/mhi/qcom,mhi.yaml new file +10 -0
+
+        pcie0_rp: pcie0_rp {
+            reg = <0 0 0 0 0>;
+            status = "ok";
+            mhi_0: qcom,mhi@0 {
+                reg = <0 0 0 0 0 >;
+                qrtr_instance_id = <0x20>;
+            };
+        };
+    };

So, its impossible for me to have multiple QCN9000 PCI devices on say an x86 host, since x86 doesn't support DT?

Also, I have to know ahead of time, when I'm writing the DT, how many of these devices I'm going to have in a system, and if I decide to add N more at a later time, I'm back at square 1?

drivers/bus/mhi/core/boot.c line 22

Quoted 10 lines
drivers/bus/mhi/core/boot.c +2 -0
index 0b38014..7406f28 100644
@@ -18,6 +18,9 @@
  #include <linux/wait.h>
  #include "internal.h"
 
+#define QRTR_INSTANCE_MASK	0x0000FFFF
+#define QRTR_INSTANCE_SHIFT	0

I fail to understand why IPC Router specific stuff is being clobbered into MHI.

Quoted 6 lines
drivers/bus/mhi/core/boot.c +1 -0
+
  /* Setup RDDM vector table for RDDM transfer and program RXVEC */
  void mhi_rddm_prepare(struct mhi_controller *mhi_cntrl,
  		      struct image_info *img_info)
@@ -445,6 +448,17 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
  		return;

drivers/bus/mhi/core/boot.c void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl) · line 458

Quoted 10 lines
drivers/bus/mhi/core/boot.c +8 -0
  	}
 
+	if (!ret && mhi_cntrl->cntrl_dev->of_node) {
+		ret = of_property_read_u32(mhi_cntrl->cntrl_dev->of_node,
+					   "qrtr-instance-id", &instance);
+		if (!ret) {
+			instance &= QRTR_INSTANCE_MASK;
+			mhi_write_reg_field(mhi_cntrl, mhi_cntrl->bhi,
+					    BHI_ERRDBG2, QRTR_INSTANCE_MASK,
+					    QRTR_INSTANCE_SHIFT, instance);

This violates the BHI spec which states that this register is read only from the host perspective. You cannot write to it.

Overall, I get why you are attempting to do this, but solution proposed in this RFC is pretty bad. I'm thinking it would be better to have the QCN9000 "generate" its node id based on the assigned PCI bus address (SBDF) The current Router maintainers should probably weigh in to ensure that won't cause conflicts in the node id space.

Signature · 3 lines
Jeffrey Hugo
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
#3 lore raw

Re: [PATCH RFC] bus: mhi: core: Enable unique QRTR node ID support

In reply to Gokul Sriram Palanisamy
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]

Hi Gokul,

[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on linus/master]
[also build test ERROR on v5.9 next-20201016]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Gokul-Sriram-Palanisamy/bus-mhi-core-Enable-unique-QRTR-node-ID-support/20201017-030555
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 9ff9b0d392ea08090cd1780fb196f36dbb586529
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/7a9b56e151211022c138dff2099281fa12103f00
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Gokul-Sriram-Palanisamy/bus-mhi-core-Enable-unique-QRTR-node-ID-support/20201017-030555 git checkout 7a9b56e151211022c138dff2099281fa12103f00
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

drivers/bus/mhi/core/boot.c: In function 'mhi_fw_load_handler':

>> drivers/bus/mhi/core/boot.c:467:9: error: implicit declaration of function 'of_property_read_u32' [-Werror=implicit-function-declaration]
     467 |   ret = of_property_read_u32(mhi_cntrl->cntrl_dev->of_node,
         |         ^~~~~~~~~~~~~~~~~~~~
   drivers/bus/mhi/core/boot.c:468:30: error: 'instance' undeclared (first use in this function)
     468 |         "qrtr-instance-id", &instance);
         |                              ^~~~~~~~

drivers/bus/mhi/core/boot.c:468:30: note: each undeclared identifier is reported only once for each function it appears in
cc1: some warnings being treated as errors

vim +/of_property_read_u32 +467 drivers/bus/mhi/core/boot.c

388
389 void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
390 {
391 const struct firmware *firmware = NULL;
392 struct image_info *image_info;
393 struct device *dev = &mhi_cntrl->mhi_dev->dev;
394 const char *fw_name;
395 void *buf;
396 dma_addr_t dma_addr;
397 size_t size;
398 int i, ret;
399
400 if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) {
401 dev_err(dev, "Device MHI is not in valid state\n");
402 return;
403 }
404
405 /* save hardware info from BHI */
406 ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_SERIALNU,
407 &mhi_cntrl->serial_number);
408 if (ret)
409 dev_err(dev, "Could not capture serial number via BHI\n");
410
411 for (i = 0; i < ARRAY_SIZE(mhi_cntrl->oem_pk_hash); i++) {
412 ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_OEMPKHASH(i),
413 &mhi_cntrl->oem_pk_hash[i]);
414 if (ret) {
415 dev_err(dev, "Could not capture OEM PK HASH via BHI\n");
416 break;
417 }
418 }
419
420 /* If device is in pass through, do reset to ready state transition */
421 if (mhi_cntrl->ee == MHI_EE_PTHRU)
422 goto fw_load_ee_pthru;
423
424 fw_name = (mhi_cntrl->ee == MHI_EE_EDL) ?
425 mhi_cntrl->edl_image : mhi_cntrl->fw_image;
426
427 if (!fw_name || (mhi_cntrl->fbc_download && (!mhi_cntrl->sbl_size ||
428 !mhi_cntrl->seg_len))) {
429 dev_err(dev,
430 "No firmware image defined or !sbl_size || !seg_len\n");
431 return;
432 }
433
434 ret = request_firmware(&firmware, fw_name, dev);
435 if (ret) {
436 dev_err(dev, "Error loading firmware: %d\n", ret);
437 return;
438 }
439
440 size = (mhi_cntrl->fbc_download) ? mhi_cntrl->sbl_size : firmware->size;
441
442 /* SBL size provided is maximum size, not necessarily the image size */
443 if (size > firmware->size)
444 size = firmware->size;
445
446 buf = mhi_alloc_coherent(mhi_cntrl, size, &dma_addr, GFP_KERNEL);
447 if (!buf) {
448 release_firmware(firmware);
449 return;
450 }
451
452 /* Download SBL image */
453 memcpy(buf, firmware->data, size);
454 ret = mhi_fw_load_sbl(mhi_cntrl, dma_addr, size);
455 mhi_free_coherent(mhi_cntrl, size, buf, dma_addr);
456
457 if (!mhi_cntrl->fbc_download || ret || mhi_cntrl->ee == MHI_EE_EDL)
458 release_firmware(firmware);
459
460 /* Error or in EDL mode, we're done */
461 if (ret) {
462 dev_err(dev, "MHI did not load SBL, ret:%d\n", ret);
463 return;
464 }
465
466 if (!ret && mhi_cntrl->cntrl_dev->of_node) {

 > 467			ret = of_property_read_u32(mhi_cntrl->cntrl_dev->of_node,

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org