Skip to contentSkip to conversation

ti-test: Add hwspinlocktest

PATCH Superseded Judith Mendez 5 participants 8 messages Nov 1, 2024 – Nov 7, 2024

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ti-test: Add hwspinlocktest

Add hwspinlock recipe to build out of tree module hwspinlock test.

---
 .../recipes-core/packagegroups/ti-test.bb     |   1 +
 .../hwspinlocktest/files/LICENSE              |  29 ++
 .../hwspinlocktest/files/Makefile             |  19 ++
 .../files/omap_hwspinlock_test.c              | 251 ++++++++++++++++++
 .../hwspinlocktest/hwspinlocktest_0.1.bb      |  18 ++
 5 files changed, 318 insertions(+)
 create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE
 create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile
 create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c
 create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb
meta-arago-test/recipes-core/packagegroups/ti-test.bb +1 -0
index 85398eaf..98fd0f56 100644
@@ -18,6 +18,7 @@ TI_TEST_BASE = "\
     evtest \
     fio \
     git \
+    hwspinlocktest \
     hdparm \
     i2c-tools \
     iozone3 \
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +29 -0
new file mode 100644
index 00000000..f5351a25
@@ -0,0 +1,29 @@
+BSD 3-Clause License
+
+Copyright (c) 2019, Suman Anna
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile new file +19 -0
new file mode 100644
index 00000000..d8fe76dc
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+#
+# TI OMAP HwSpinlock Unit Test
+#
+
+obj-m := omap_hwspinlock_test.o
+
+SRC := $(shell pwd)
+
+all:
+	$(MAKE) -C $(KERNEL_SRC) M=$(SRC)
+
+modules_install:
+	$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
+
+clean:
+	rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
+	rm -f Module.markers Module.symvers modules.order
+	rm -rf .tmp_versions Modules.symvers
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +251 -0

251 lines not on this page · raw message

meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb new file +18 -0
new file mode 100644
index 00000000..2edd93f6
@@ -0,0 +1,18 @@
+SUMMARY = "Build hwspinlock test as an external Linux kernel module"
+DESCRIPTION = "${SUMMARY}"
+LICENSE = "GPL-2.0-only | BSD-3-Clause"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=bfa02c83df161e37647ee23a2c7eacd4"
+
+inherit module
+
+SRC_URI = "file://Makefile \
+           file://omap_hwspinlock_test.c \
+           file://LICENSE \
+          "
+
+S = "${WORKDIR}"
+
+# The inherit of module.bbclass will automatically name module packages with
+# "kernel-module-" prefix as required by the oe-core build environment.
+
+RPROVIDES:${PN} += "kernel-module-hwspinlocktest"
Signature · 1 line
2.47.0
#1 lore raw

Hi all,

Is there anything missing/pending for this patch?

~ Judith

Quoted 368 lines · Judith Mendez

Add hwspinlock recipe to build out of tree module hwspinlock test.

---
  .../recipes-core/packagegroups/ti-test.bb     |   1 +
  .../hwspinlocktest/files/LICENSE              |  29 ++
  .../hwspinlocktest/files/Makefile             |  19 ++
  .../files/omap_hwspinlock_test.c              | 251 ++++++++++++++++++
  .../hwspinlocktest/hwspinlocktest_0.1.bb      |  18 ++
  5 files changed, 318 insertions(+)

create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb

meta-arago-test/recipes-core/packagegroups/ti-test.bb +1 -0
index 85398eaf..98fd0f56 100644
@@ -18,6 +18,7 @@ TI_TEST_BASE = "\
      evtest \
      fio \
      git \
+    hwspinlocktest \
      hdparm \
      i2c-tools \
      iozone3 \
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +29 -0
new file mode 100644
index 00000000..f5351a25
@@ -0,0 +1,29 @@
+BSD 3-Clause License
+
+Copyright (c) 2019, Suman Anna
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile new file +19 -0
new file mode 100644
index 00000000..d8fe76dc
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+#
+# TI OMAP HwSpinlock Unit Test
+#
+
+obj-m := omap_hwspinlock_test.o
+
+SRC := $(shell pwd)
+
+all:
+	$(MAKE) -C $(KERNEL_SRC) M=$(SRC)
+
+modules_install:
+	$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
+
+clean:
+	rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
+	rm -f Module.markers Module.symvers modules.order
+	rm -rf .tmp_versions Modules.symvers
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +251 -0
new file mode 100644
index 00000000..b1801389
@@ -0,0 +1,251 @@
+// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+/*
+ * OMAP hardware spinlock test driver
+ *
+ * Copyright (C) 2014-2021 Texas Instruments Incorporated - https://www.ti.com
+ *	Suman Anna <[email protected]>
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/sched.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#include <linux/hwspinlock.h>
+
+/* load-time options */
+static int count = 2;
+module_param(count, int, 0444);
+
+struct hwspinlock_data {
+	const char *compatible;
+	const unsigned int max_locks;
+};
+
+static int hwspin_lock_test(struct hwspinlock *hwlock)
+{
+	int i;
+	int ret;
+
+	pr_err("\nTesting lock %d\n", hwspin_lock_get_id(hwlock));
+	for (i = 0; i < count; i++) {
+		ret = hwspin_trylock(hwlock);
+		if (ret) {
+			pr_err("%s: Initial lock failed\n", __func__);
+			return -EFAULT;
+		}
+		pr_err("trylock #1 status[%d] = %d\n", i, ret);
+
+		/* Verify lock actually works - re-acquiring it should fail */
+		ret = hwspin_trylock(hwlock);
+		pr_err("trylock #2 status[%d] = %d\n", i, ret);
+		if (!ret) {
+			/* Keep locks balanced even in failure cases */
+			hwspin_unlock(hwlock);
+			hwspin_unlock(hwlock);
+			pr_err("%s: Recursive lock succeeded unexpectedly\n",
+			       __func__);
+			return -EFAULT;
+		}
+
+		/* Verify unlock by re-acquiring the lock after releasing it */
+		hwspin_unlock(hwlock);
+		ret = hwspin_trylock(hwlock);
+		pr_err("trylock after unlock status[%d] = %d\n", i, ret);
+		if (ret) {
+			pr_err("%s: Unlock failed\n", __func__);
+			return -EINVAL;
+		}
+
+		hwspin_unlock(hwlock);
+	}
+
+	return 0;
+}
+
+static int hwspin_lock_test_all_locks(unsigned int max_locks)
+{
+	int i;
+	int ret = 0, ret1 = 0;
+	struct hwspinlock *hwlock = NULL;
+
+	pr_err("Testing %d locks\n", max_locks);
+	for (i = 0; i < max_locks; i++) {
+		hwlock = hwspin_lock_request_specific(i);
+		if (!hwlock) {
+			pr_err("request lock %d failed\n", i);
+			ret = -EIO;
+			continue;
+		}
+
+		ret1 = hwspin_lock_test(hwlock);
+		if (ret1) {
+			pr_err("hwspinlock tests failed on lock %d\n", i);
+			ret = ret1;
+			goto free_lock;
+		}
+
+free_lock:
+		ret1 = hwspin_lock_free(hwlock);
+		if (ret1) {
+			pr_err("hwspin_lock_free failed on lock %d\n", i);
+			ret = ret1;
+		}
+	}
+
+	return ret;
+}
+
+static const struct of_device_id omap_hwspinlock_test_of_match[] = {
+	{ .compatible = "ti,omap-hwspinlock-test",   },
+	{ .compatible = "ti,omap4-hwspinlock-test",  },
+	{ .compatible = "ti,omap5-hwspinlock-test",  },
+	{ .compatible = "ti,dra7-hwspinlock-test",   },
+	{ .compatible = "ti,am33xx-hwspinlock-test", },
+	{ .compatible = "ti,am43xx-hwspinlock-test", },
+	{ .compatible = "ti,am654-hwspinlock-test",  },
+	{ /* end */ },
+};
+
+static int hwspin_lock_test_all_phandle_locks(unsigned int max_locks)
+{
+	struct device_node *np = NULL;
+	struct hwspinlock *hwlock = NULL;
+	int ret = 0, ret1 = 0;
+	unsigned int i;
+	int num_locks;
+	int hwlock_id;
+
+	np = of_find_matching_node_and_match(NULL,
+					     omap_hwspinlock_test_of_match,
+					     NULL);
+	if (!np) {
+		pr_err("\nNo test node provided\n");
+		return 0;
+	}
+
+	num_locks = of_count_phandle_with_args(np, "hwlocks", "#hwlock-cells");
+	pr_err("Number of phandles = %d max_locks = %d\n",
+	       num_locks, max_locks);
+
+	for (i = 0; i < num_locks; i++) {
+		hwlock_id = of_hwspin_lock_get_id(np, i);
+		if (hwlock_id < 0) {
+			pr_err("unable to get hwlock_id : %d\n", hwlock_id);
+			ret = -EINVAL;
+			continue;
+		};
+
+		hwlock = hwspin_lock_request_specific(hwlock_id);
+		if (!hwlock) {
+			pr_err("unable to get hwlock\n");
+			ret = -EINVAL;
+			continue;
+		}
+
+		ret1 = hwspin_lock_test(hwlock);
+		if (ret1) {
+			pr_err("hwspinlock test failed on DT lock %d, ret = %d\n",
+			       hwspin_lock_get_id(hwlock), ret1);
+			ret = ret1;
+		}
+
+		ret1 = hwspin_lock_free(hwlock);
+		if (ret1) {
+			pr_err("hwspin_lock_free failed on lock %d\n",
+			       hwspin_lock_get_id(hwlock));
+			ret = ret1;
+		}
+	}
+
+	return ret;
+}
+
+static
+unsigned int omap_hwspinlock_get_locks(const struct hwspinlock_data *data)
+{
+	unsigned int locks = 0;
+
+	while (data->compatible) {
+		if (of_machine_is_compatible(data->compatible)) {
+			locks = data->max_locks;
+			break;
+		}
+		data++;
+	}
+
+	return locks;
+}
+
+static const struct of_device_id omap_hwspinlock_of_match[] = {
+	{ .compatible = "ti,omap4-hwspinlock", },
+	{ .compatible = "ti,am654-hwspinlock", },
+	{ .compatible = "ti,am64-hwspinlock",  },
+	{ /* end */ },
+};
+
+static const struct hwspinlock_data soc_data[] = {
+	{ "ti,omap4",	32, },
+	{ "ti,omap5",	32, },
+	{ "ti,dra7",	256, },
+	{ "ti,am33xx",	128, },
+	{ "ti,am43",	128, },
+	{ "ti,am654",	256, },
+	{ "ti,j721e",	256, },
+	{ "ti,j7200",	256, },
+	{ "ti,am642",	256, },
+	{ "ti,j721s2",	256, },
+	{ /* sentinel */ },
+};
+
+static int omap_hwspinlock_test_init(void)
+{
+	struct device_node *np;
+	unsigned int max_locks;
+	int ret;
+
+	pr_err("\n** HwSpinLock Unit Test Module initiated **\n");
+
+	max_locks = omap_hwspinlock_get_locks(soc_data);
+	if (!max_locks) {
+		pr_err("\nNot a compatible platform\n");
+		return -ENODEV;
+	}
+
+	np = of_find_matching_node_and_match(NULL, omap_hwspinlock_of_match,
+					     NULL);
+	if (!np || !of_device_is_available(np)) {
+		pr_err("\nNo HwSpinlock node provided/enabled\n");
+		return -ENODEV;
+	}
+
+	pr_err("\n***** Begin - Test All Locks ****\n");
+	ret = hwspin_lock_test_all_locks(max_locks);
+	if (ret)
+		pr_err("hwspin_lock_test_all_locks failed, ret = %d\n", ret);
+	pr_err("\n***** End - Test All Locks ****\n");
+
+	pr_err("\n***** Begin - Test All pHandle Locks ****\n");
+	ret = hwspin_lock_test_all_phandle_locks(max_locks);
+	if (ret)
+		pr_err("hwspin_lock_test_all_locks failed, ret = %d\n", ret);
+	pr_err("\n***** End - Test All pHandle Locks ****\n");
+
+	return 0;
+}
+
+static void omap_hwspinlock_test_exit(void)
+{
+	pr_err("\n** HwSpinLock Unit Test Module finished **\n");
+}
+
+module_init(omap_hwspinlock_test_init);
+module_exit(omap_hwspinlock_test_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("Hardware spinlock Test driver for TI SoCs");
+MODULE_AUTHOR("Suman Anna <[email protected]>");
meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb new file +18 -0
new file mode 100644
index 00000000..2edd93f6
@@ -0,0 +1,18 @@
+SUMMARY = "Build hwspinlock test as an external Linux kernel module"
+DESCRIPTION = "${SUMMARY}"
+LICENSE = "GPL-2.0-only | BSD-3-Clause"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=bfa02c83df161e37647ee23a2c7eacd4"
+
+inherit module
+
+SRC_URI = "file://Makefile \
+           file://omap_hwspinlock_test.c \
+           file://LICENSE \
+          "
+
+S = "${WORKDIR}"
+
+# The inherit of module.bbclass will automatically name module packages with
+# "kernel-module-" prefix as required by the oe-core build environment.
+
+RPROVIDES:${PN} += "kernel-module-hwspinlocktest"
#2 lore raw
In reply to Judith Mendez
Quoted 8 lines · Judith via lists.yoctoproject.org

Add hwspinlock recipe to build out of tree module hwspinlock test.

---
  .../recipes-core/packagegroups/ti-test.bb     |   1 +
  .../hwspinlocktest/files/LICENSE              |  29 ++
  .../hwspinlocktest/files/Makefile             |  19 ++
  .../files/omap_hwspinlock_test.c              | 251 ++++++++++++++++++

Why are we adding the entire source of this project into meta-arago? Is this not the upstream: https://github.com/sumananna/omap-hwspinlock-test ?

You should point to that and fetch from there like normal recipes.

Andrew

Quoted 360 lines
  .../hwspinlocktest/hwspinlocktest_0.1.bb      |  18 ++
  5 files changed, 318 insertions(+)

create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb

meta-arago-test/recipes-core/packagegroups/ti-test.bb +1 -0
index 85398eaf..98fd0f56 100644
@@ -18,6 +18,7 @@ TI_TEST_BASE = "\
      evtest \
      fio \
      git \
+    hwspinlocktest \
      hdparm \
      i2c-tools \
      iozone3 \
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +29 -0
new file mode 100644
index 00000000..f5351a25
@@ -0,0 +1,29 @@
+BSD 3-Clause License
+
+Copyright (c) 2019, Suman Anna
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile new file +19 -0
new file mode 100644
index 00000000..d8fe76dc
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+#
+# TI OMAP HwSpinlock Unit Test
+#
+
+obj-m := omap_hwspinlock_test.o
+
+SRC := $(shell pwd)
+
+all:
+	$(MAKE) -C $(KERNEL_SRC) M=$(SRC)
+
+modules_install:
+	$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
+
+clean:
+	rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
+	rm -f Module.markers Module.symvers modules.order
+	rm -rf .tmp_versions Modules.symvers
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +251 -0
new file mode 100644
index 00000000..b1801389
@@ -0,0 +1,251 @@
+// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+/*
+ * OMAP hardware spinlock test driver
+ *
+ * Copyright (C) 2014-2021 Texas Instruments Incorporated - https://www.ti.com
+ *	Suman Anna <[email protected]>
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/sched.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#include <linux/hwspinlock.h>
+
+/* load-time options */
+static int count = 2;
+module_param(count, int, 0444);
+
+struct hwspinlock_data {
+	const char *compatible;
+	const unsigned int max_locks;
+};
+
+static int hwspin_lock_test(struct hwspinlock *hwlock)
+{
+	int i;
+	int ret;
+
+	pr_err("\nTesting lock %d\n", hwspin_lock_get_id(hwlock));
+	for (i = 0; i < count; i++) {
+		ret = hwspin_trylock(hwlock);
+		if (ret) {
+			pr_err("%s: Initial lock failed\n", __func__);
+			return -EFAULT;
+		}
+		pr_err("trylock #1 status[%d] = %d\n", i, ret);
+
+		/* Verify lock actually works - re-acquiring it should fail */
+		ret = hwspin_trylock(hwlock);
+		pr_err("trylock #2 status[%d] = %d\n", i, ret);
+		if (!ret) {
+			/* Keep locks balanced even in failure cases */
+			hwspin_unlock(hwlock);
+			hwspin_unlock(hwlock);
+			pr_err("%s: Recursive lock succeeded unexpectedly\n",
+			       __func__);
+			return -EFAULT;
+		}
+
+		/* Verify unlock by re-acquiring the lock after releasing it */
+		hwspin_unlock(hwlock);
+		ret = hwspin_trylock(hwlock);
+		pr_err("trylock after unlock status[%d] = %d\n", i, ret);
+		if (ret) {
+			pr_err("%s: Unlock failed\n", __func__);
+			return -EINVAL;
+		}
+
+		hwspin_unlock(hwlock);
+	}
+
+	return 0;
+}
+
+static int hwspin_lock_test_all_locks(unsigned int max_locks)
+{
+	int i;
+	int ret = 0, ret1 = 0;
+	struct hwspinlock *hwlock = NULL;
+
+	pr_err("Testing %d locks\n", max_locks);
+	for (i = 0; i < max_locks; i++) {
+		hwlock = hwspin_lock_request_specific(i);
+		if (!hwlock) {
+			pr_err("request lock %d failed\n", i);
+			ret = -EIO;
+			continue;
+		}
+
+		ret1 = hwspin_lock_test(hwlock);
+		if (ret1) {
+			pr_err("hwspinlock tests failed on lock %d\n", i);
+			ret = ret1;
+			goto free_lock;
+		}
+
+free_lock:
+		ret1 = hwspin_lock_free(hwlock);
+		if (ret1) {
+			pr_err("hwspin_lock_free failed on lock %d\n", i);
+			ret = ret1;
+		}
+	}
+
+	return ret;
+}
+
+static const struct of_device_id omap_hwspinlock_test_of_match[] = {
+	{ .compatible = "ti,omap-hwspinlock-test",   },
+	{ .compatible = "ti,omap4-hwspinlock-test",  },
+	{ .compatible = "ti,omap5-hwspinlock-test",  },
+	{ .compatible = "ti,dra7-hwspinlock-test",   },
+	{ .compatible = "ti,am33xx-hwspinlock-test", },
+	{ .compatible = "ti,am43xx-hwspinlock-test", },
+	{ .compatible = "ti,am654-hwspinlock-test",  },
+	{ /* end */ },
+};
+
+static int hwspin_lock_test_all_phandle_locks(unsigned int max_locks)
+{
+	struct device_node *np = NULL;
+	struct hwspinlock *hwlock = NULL;
+	int ret = 0, ret1 = 0;
+	unsigned int i;
+	int num_locks;
+	int hwlock_id;
+
+	np = of_find_matching_node_and_match(NULL,
+					     omap_hwspinlock_test_of_match,
+					     NULL);
+	if (!np) {
+		pr_err("\nNo test node provided\n");
+		return 0;
+	}
+
+	num_locks = of_count_phandle_with_args(np, "hwlocks", "#hwlock-cells");
+	pr_err("Number of phandles = %d max_locks = %d\n",
+	       num_locks, max_locks);
+
+	for (i = 0; i < num_locks; i++) {
+		hwlock_id = of_hwspin_lock_get_id(np, i);
+		if (hwlock_id < 0) {
+			pr_err("unable to get hwlock_id : %d\n", hwlock_id);
+			ret = -EINVAL;
+			continue;
+		};
+
+		hwlock = hwspin_lock_request_specific(hwlock_id);
+		if (!hwlock) {
+			pr_err("unable to get hwlock\n");
+			ret = -EINVAL;
+			continue;
+		}
+
+		ret1 = hwspin_lock_test(hwlock);
+		if (ret1) {
+			pr_err("hwspinlock test failed on DT lock %d, ret = %d\n",
+			       hwspin_lock_get_id(hwlock), ret1);
+			ret = ret1;
+		}
+
+		ret1 = hwspin_lock_free(hwlock);
+		if (ret1) {
+			pr_err("hwspin_lock_free failed on lock %d\n",
+			       hwspin_lock_get_id(hwlock));
+			ret = ret1;
+		}
+	}
+
+	return ret;
+}
+
+static
+unsigned int omap_hwspinlock_get_locks(const struct hwspinlock_data *data)
+{
+	unsigned int locks = 0;
+
+	while (data->compatible) {
+		if (of_machine_is_compatible(data->compatible)) {
+			locks = data->max_locks;
+			break;
+		}
+		data++;
+	}
+
+	return locks;
+}
+
+static const struct of_device_id omap_hwspinlock_of_match[] = {
+	{ .compatible = "ti,omap4-hwspinlock", },
+	{ .compatible = "ti,am654-hwspinlock", },
+	{ .compatible = "ti,am64-hwspinlock",  },
+	{ /* end */ },
+};
+
+static const struct hwspinlock_data soc_data[] = {
+	{ "ti,omap4",	32, },
+	{ "ti,omap5",	32, },
+	{ "ti,dra7",	256, },
+	{ "ti,am33xx",	128, },
+	{ "ti,am43",	128, },
+	{ "ti,am654",	256, },
+	{ "ti,j721e",	256, },
+	{ "ti,j7200",	256, },
+	{ "ti,am642",	256, },
+	{ "ti,j721s2",	256, },
+	{ /* sentinel */ },
+};
+
+static int omap_hwspinlock_test_init(void)
+{
+	struct device_node *np;
+	unsigned int max_locks;
+	int ret;
+
+	pr_err("\n** HwSpinLock Unit Test Module initiated **\n");
+
+	max_locks = omap_hwspinlock_get_locks(soc_data);
+	if (!max_locks) {
+		pr_err("\nNot a compatible platform\n");
+		return -ENODEV;
+	}
+
+	np = of_find_matching_node_and_match(NULL, omap_hwspinlock_of_match,
+					     NULL);
+	if (!np || !of_device_is_available(np)) {
+		pr_err("\nNo HwSpinlock node provided/enabled\n");
+		return -ENODEV;
+	}
+
+	pr_err("\n***** Begin - Test All Locks ****\n");
+	ret = hwspin_lock_test_all_locks(max_locks);
+	if (ret)
+		pr_err("hwspin_lock_test_all_locks failed, ret = %d\n", ret);
+	pr_err("\n***** End - Test All Locks ****\n");
+
+	pr_err("\n***** Begin - Test All pHandle Locks ****\n");
+	ret = hwspin_lock_test_all_phandle_locks(max_locks);
+	if (ret)
+		pr_err("hwspin_lock_test_all_locks failed, ret = %d\n", ret);
+	pr_err("\n***** End - Test All pHandle Locks ****\n");
+
+	return 0;
+}
+
+static void omap_hwspinlock_test_exit(void)
+{
+	pr_err("\n** HwSpinLock Unit Test Module finished **\n");
+}
+
+module_init(omap_hwspinlock_test_init);
+module_exit(omap_hwspinlock_test_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("Hardware spinlock Test driver for TI SoCs");
+MODULE_AUTHOR("Suman Anna <[email protected]>");
meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb new file +18 -0
new file mode 100644
index 00000000..2edd93f6
@@ -0,0 +1,18 @@
+SUMMARY = "Build hwspinlock test as an external Linux kernel module"
+DESCRIPTION = "${SUMMARY}"
+LICENSE = "GPL-2.0-only | BSD-3-Clause"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=bfa02c83df161e37647ee23a2c7eacd4"
+
+inherit module
+
+SRC_URI = "file://Makefile \
+           file://omap_hwspinlock_test.c \
+           file://LICENSE \
+          "
+
+S = "${WORKDIR}"
+
+# The inherit of module.bbclass will automatically name module packages with
+# "kernel-module-" prefix as required by the oe-core build environment.
+
+RPROVIDES:${PN} += "kernel-module-hwspinlocktest"
#3 lore raw
Quoted 10 lines · Andrew Davis via lists.yoctoproject.org
Quoted 8 lines · Judith via lists.yoctoproject.org

Add hwspinlock recipe to build out of tree module hwspinlock test.

---
 .../recipes-core/packagegroups/ti-test.bb     |   1 +
 .../hwspinlocktest/files/LICENSE              |  29 ++
 .../hwspinlocktest/files/Makefile             |  19 ++
 .../files/omap_hwspinlock_test.c              | 251 ++++++++++++++++++
Quoted 4 lines

Why are we adding the entire source of this project into meta-arago? Is this not the upstream: https://github.com/sumananna/omap-hwspinlock-test ?

You should point to that and fetch from there like normal recipes.

FYI, this has been asked and answered already:
https://lists.yoctoproject.org/g/meta-arago/topic/109054399#msg15583

Quoted 360 lines
Quoted 360 lines
 .../hwspinlocktest/hwspinlocktest_0.1.bb      |  18 ++
 5 files changed, 318 insertions(+)
 create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE
 create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile
 create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c
 create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb
meta-arago-test/recipes-core/packagegroups/ti-test.bb +1 -0
index 85398eaf..98fd0f56 100644
@@ -18,6 +18,7 @@ TI_TEST_BASE = "\
     evtest \
     fio \
     git \
+    hwspinlocktest \
     hdparm \
     i2c-tools \
     iozone3 \
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +29 -0
new file mode 100644
index 00000000..f5351a25
@@ -0,0 +1,29 @@
+BSD 3-Clause License
+
+Copyright (c) 2019, Suman Anna
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile new file +19 -0
new file mode 100644
index 00000000..d8fe76dc
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+#
+# TI OMAP HwSpinlock Unit Test
+#
+
+obj-m := omap_hwspinlock_test.o
+
+SRC := $(shell pwd)
+
+all:
+	$(MAKE) -C $(KERNEL_SRC) M=$(SRC)
+
+modules_install:
+	$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
+
+clean:
+	rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
+	rm -f Module.markers Module.symvers modules.order
+	rm -rf .tmp_versions Modules.symvers
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +251 -0
new file mode 100644
index 00000000..b1801389
@@ -0,0 +1,251 @@
+// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+/*
+ * OMAP hardware spinlock test driver
+ *
+ * Copyright (C) 2014-2021 Texas Instruments Incorporated - https://www.ti.com
+ *	Suman Anna <[email protected]>
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/sched.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#include <linux/hwspinlock.h>
+
+/* load-time options */
+static int count = 2;
+module_param(count, int, 0444);
+
+struct hwspinlock_data {
+	const char *compatible;
+	const unsigned int max_locks;
+};
+
+static int hwspin_lock_test(struct hwspinlock *hwlock)
+{
+	int i;
+	int ret;
+
+	pr_err("\nTesting lock %d\n", hwspin_lock_get_id(hwlock));
+	for (i = 0; i < count; i++) {
+		ret = hwspin_trylock(hwlock);
+		if (ret) {
+			pr_err("%s: Initial lock failed\n", __func__);
+			return -EFAULT;
+		}
+		pr_err("trylock #1 status[%d] = %d\n", i, ret);
+
+		/* Verify lock actually works - re-acquiring it should fail */
+		ret = hwspin_trylock(hwlock);
+		pr_err("trylock #2 status[%d] = %d\n", i, ret);
+		if (!ret) {
+			/* Keep locks balanced even in failure cases */
+			hwspin_unlock(hwlock);
+			hwspin_unlock(hwlock);
+			pr_err("%s: Recursive lock succeeded unexpectedly\n",
+			       __func__);
+			return -EFAULT;
+		}
+
+		/* Verify unlock by re-acquiring the lock after releasing it */
+		hwspin_unlock(hwlock);
+		ret = hwspin_trylock(hwlock);
+		pr_err("trylock after unlock status[%d] = %d\n", i, ret);
+		if (ret) {
+			pr_err("%s: Unlock failed\n", __func__);
+			return -EINVAL;
+		}
+
+		hwspin_unlock(hwlock);
+	}
+
+	return 0;
+}
+
+static int hwspin_lock_test_all_locks(unsigned int max_locks)
+{
+	int i;
+	int ret = 0, ret1 = 0;
+	struct hwspinlock *hwlock = NULL;
+
+	pr_err("Testing %d locks\n", max_locks);
+	for (i = 0; i < max_locks; i++) {
+		hwlock = hwspin_lock_request_specific(i);
+		if (!hwlock) {
+			pr_err("request lock %d failed\n", i);
+			ret = -EIO;
+			continue;
+		}
+
+		ret1 = hwspin_lock_test(hwlock);
+		if (ret1) {
+			pr_err("hwspinlock tests failed on lock %d\n", i);
+			ret = ret1;
+			goto free_lock;
+		}
+
+free_lock:
+		ret1 = hwspin_lock_free(hwlock);
+		if (ret1) {
+			pr_err("hwspin_lock_free failed on lock %d\n", i);
+			ret = ret1;
+		}
+	}
+
+	return ret;
+}
+
+static const struct of_device_id omap_hwspinlock_test_of_match[] = {
+	{ .compatible = "ti,omap-hwspinlock-test",   },
+	{ .compatible = "ti,omap4-hwspinlock-test",  },
+	{ .compatible = "ti,omap5-hwspinlock-test",  },
+	{ .compatible = "ti,dra7-hwspinlock-test",   },
+	{ .compatible = "ti,am33xx-hwspinlock-test", },
+	{ .compatible = "ti,am43xx-hwspinlock-test", },
+	{ .compatible = "ti,am654-hwspinlock-test",  },
+	{ /* end */ },
+};
+
+static int hwspin_lock_test_all_phandle_locks(unsigned int max_locks)
+{
+	struct device_node *np = NULL;
+	struct hwspinlock *hwlock = NULL;
+	int ret = 0, ret1 = 0;
+	unsigned int i;
+	int num_locks;
+	int hwlock_id;
+
+	np = of_find_matching_node_and_match(NULL,
+					     omap_hwspinlock_test_of_match,
+					     NULL);
+	if (!np) {
+		pr_err("\nNo test node provided\n");
+		return 0;
+	}
+
+	num_locks = of_count_phandle_with_args(np, "hwlocks", "#hwlock-cells");
+	pr_err("Number of phandles = %d max_locks = %d\n",
+	       num_locks, max_locks);
+
+	for (i = 0; i < num_locks; i++) {
+		hwlock_id = of_hwspin_lock_get_id(np, i);
+		if (hwlock_id < 0) {
+			pr_err("unable to get hwlock_id : %d\n", hwlock_id);
+			ret = -EINVAL;
+			continue;
+		};
+
+		hwlock = hwspin_lock_request_specific(hwlock_id);
+		if (!hwlock) {
+			pr_err("unable to get hwlock\n");
+			ret = -EINVAL;
+			continue;
+		}
+
+		ret1 = hwspin_lock_test(hwlock);
+		if (ret1) {
+			pr_err("hwspinlock test failed on DT lock %d, ret = %d\n",
+			       hwspin_lock_get_id(hwlock), ret1);
+			ret = ret1;
+		}
+
+		ret1 = hwspin_lock_free(hwlock);
+		if (ret1) {
+			pr_err("hwspin_lock_free failed on lock %d\n",
+			       hwspin_lock_get_id(hwlock));
+			ret = ret1;
+		}
+	}
+
+	return ret;
+}
+
+static
+unsigned int omap_hwspinlock_get_locks(const struct hwspinlock_data *data)
+{
+	unsigned int locks = 0;
+
+	while (data->compatible) {
+		if (of_machine_is_compatible(data->compatible)) {
+			locks = data->max_locks;
+			break;
+		}
+		data++;
+	}
+
+	return locks;
+}
+
+static const struct of_device_id omap_hwspinlock_of_match[] = {
+	{ .compatible = "ti,omap4-hwspinlock", },
+	{ .compatible = "ti,am654-hwspinlock", },
+	{ .compatible = "ti,am64-hwspinlock",  },
+	{ /* end */ },
+};
+
+static const struct hwspinlock_data soc_data[] = {
+	{ "ti,omap4",	32, },
+	{ "ti,omap5",	32, },
+	{ "ti,dra7",	256, },
+	{ "ti,am33xx",	128, },
+	{ "ti,am43",	128, },
+	{ "ti,am654",	256, },
+	{ "ti,j721e",	256, },
+	{ "ti,j7200",	256, },
+	{ "ti,am642",	256, },
+	{ "ti,j721s2",	256, },
+	{ /* sentinel */ },
+};
+
+static int omap_hwspinlock_test_init(void)
+{
+	struct device_node *np;
+	unsigned int max_locks;
+	int ret;
+
+	pr_err("\n** HwSpinLock Unit Test Module initiated **\n");
+
+	max_locks = omap_hwspinlock_get_locks(soc_data);
+	if (!max_locks) {
+		pr_err("\nNot a compatible platform\n");
+		return -ENODEV;
+	}
+
+	np = of_find_matching_node_and_match(NULL, omap_hwspinlock_of_match,
+					     NULL);
+	if (!np || !of_device_is_available(np)) {
+		pr_err("\nNo HwSpinlock node provided/enabled\n");
+		return -ENODEV;
+	}
+
+	pr_err("\n***** Begin - Test All Locks ****\n");
+	ret = hwspin_lock_test_all_locks(max_locks);
+	if (ret)
+		pr_err("hwspin_lock_test_all_locks failed, ret = %d\n", ret);
+	pr_err("\n***** End - Test All Locks ****\n");
+
+	pr_err("\n***** Begin - Test All pHandle Locks ****\n");
+	ret = hwspin_lock_test_all_phandle_locks(max_locks);
+	if (ret)
+		pr_err("hwspin_lock_test_all_locks failed, ret = %d\n", ret);
+	pr_err("\n***** End - Test All pHandle Locks ****\n");
+
+	return 0;
+}
+
+static void omap_hwspinlock_test_exit(void)
+{
+	pr_err("\n** HwSpinLock Unit Test Module finished **\n");
+}
+
+module_init(omap_hwspinlock_test_init);
+module_exit(omap_hwspinlock_test_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("Hardware spinlock Test driver for TI SoCs");
+MODULE_AUTHOR("Suman Anna <[email protected]>");
meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb new file +18 -0
new file mode 100644
index 00000000..2edd93f6
@@ -0,0 +1,18 @@
+SUMMARY = "Build hwspinlock test as an external Linux kernel module"
+DESCRIPTION = "${SUMMARY}"
+LICENSE = "GPL-2.0-only | BSD-3-Clause"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=bfa02c83df161e37647ee23a2c7eacd4"
+
+inherit module
+
+SRC_URI = "file://Makefile \
+           file://omap_hwspinlock_test.c \
+           file://LICENSE \
+          "
+
+S = "${WORKDIR}"
+
+# The inherit of module.bbclass will automatically name module packages with
+# "kernel-module-" prefix as required by the oe-core build environment.
+
+RPROVIDES:${PN} += "kernel-module-hwspinlocktest"
#4 lore raw
Quoted 11 lines · Denys Dmytriyenko
Quoted 10 lines · Andrew Davis via lists.yoctoproject.org
Quoted 8 lines · Judith via lists.yoctoproject.org

Add hwspinlock recipe to build out of tree module hwspinlock test.

---
  .../recipes-core/packagegroups/ti-test.bb     |   1 +
  .../hwspinlocktest/files/LICENSE              |  29 ++
  .../hwspinlocktest/files/Makefile             |  19 ++
  .../files/omap_hwspinlock_test.c              | 251 ++++++++++++++++++
Quoted 8 lines
Quoted 4 lines

Why are we adding the entire source of this project into meta-arago? Is this not the upstream: https://github.com/sumananna/omap-hwspinlock-test ?

You should point to that and fetch from there like normal recipes.

FYI, this has been asked and answered already:
https://lists.yoctoproject.org/g/meta-arago/topic/109054399#msg15583

Ah, didn't see any hint to this not being the first version of this series..

Copying the answer here to respond inline,

Quoted 1 line

Apparently we do not want to pull from personal repos

Since when? We do that for lots of recipes.

Quoted 4 lines

there is a JIRA req to move
the repo to ti.com, but the target date is for 11.0. Since we want to add the test asap, the idea is to add to yocto and update the recipe later when the repo has been moved.

If you really want to use a ti.com based source repo, then do that first. If setting up the repo clone is not a priority, then this test can't be that important either. Do this in the right order. Copying the whole source into the layer is hacky.

Andrew

Quoted 361 lines
Quoted 361 lines
Quoted 361 lines
  .../hwspinlocktest/hwspinlocktest_0.1.bb      |  18 ++
  5 files changed, 318 insertions(+)

create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb

meta-arago-test/recipes-core/packagegroups/ti-test.bb +1 -0
index 85398eaf..98fd0f56 100644
@@ -18,6 +18,7 @@ TI_TEST_BASE = "\
      evtest \
      fio \
      git \
+    hwspinlocktest \
      hdparm \
      i2c-tools \
      iozone3 \
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +29 -0
new file mode 100644
index 00000000..f5351a25
@@ -0,0 +1,29 @@
+BSD 3-Clause License
+
+Copyright (c) 2019, Suman Anna
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile new file +19 -0
new file mode 100644
index 00000000..d8fe76dc
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+#
+# TI OMAP HwSpinlock Unit Test
+#
+
+obj-m := omap_hwspinlock_test.o
+
+SRC := $(shell pwd)
+
+all:
+	$(MAKE) -C $(KERNEL_SRC) M=$(SRC)
+
+modules_install:
+	$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
+
+clean:
+	rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
+	rm -f Module.markers Module.symvers modules.order
+	rm -rf .tmp_versions Modules.symvers
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +251 -0
new file mode 100644
index 00000000..b1801389
@@ -0,0 +1,251 @@
+// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+/*
+ * OMAP hardware spinlock test driver
+ *
+ * Copyright (C) 2014-2021 Texas Instruments Incorporated - https://www.ti.com
+ *	Suman Anna <[email protected]>
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/sched.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#include <linux/hwspinlock.h>
+
+/* load-time options */
+static int count = 2;
+module_param(count, int, 0444);
+
+struct hwspinlock_data {
+	const char *compatible;
+	const unsigned int max_locks;
+};
+
+static int hwspin_lock_test(struct hwspinlock *hwlock)
+{
+	int i;
+	int ret;
+
+	pr_err("\nTesting lock %d\n", hwspin_lock_get_id(hwlock));
+	for (i = 0; i < count; i++) {
+		ret = hwspin_trylock(hwlock);
+		if (ret) {
+			pr_err("%s: Initial lock failed\n", __func__);
+			return -EFAULT;
+		}
+		pr_err("trylock #1 status[%d] = %d\n", i, ret);
+
+		/* Verify lock actually works - re-acquiring it should fail */
+		ret = hwspin_trylock(hwlock);
+		pr_err("trylock #2 status[%d] = %d\n", i, ret);
+		if (!ret) {
+			/* Keep locks balanced even in failure cases */
+			hwspin_unlock(hwlock);
+			hwspin_unlock(hwlock);
+			pr_err("%s: Recursive lock succeeded unexpectedly\n",
+			       __func__);
+			return -EFAULT;
+		}
+
+		/* Verify unlock by re-acquiring the lock after releasing it */
+		hwspin_unlock(hwlock);
+		ret = hwspin_trylock(hwlock);
+		pr_err("trylock after unlock status[%d] = %d\n", i, ret);
+		if (ret) {
+			pr_err("%s: Unlock failed\n", __func__);
+			return -EINVAL;
+		}
+
+		hwspin_unlock(hwlock);
+	}
+
+	return 0;
+}
+
+static int hwspin_lock_test_all_locks(unsigned int max_locks)
+{
+	int i;
+	int ret = 0, ret1 = 0;
+	struct hwspinlock *hwlock = NULL;
+
+	pr_err("Testing %d locks\n", max_locks);
+	for (i = 0; i < max_locks; i++) {
+		hwlock = hwspin_lock_request_specific(i);
+		if (!hwlock) {
+			pr_err("request lock %d failed\n", i);
+			ret = -EIO;
+			continue;
+		}
+
+		ret1 = hwspin_lock_test(hwlock);
+		if (ret1) {
+			pr_err("hwspinlock tests failed on lock %d\n", i);
+			ret = ret1;
+			goto free_lock;
+		}
+
+free_lock:
+		ret1 = hwspin_lock_free(hwlock);
+		if (ret1) {
+			pr_err("hwspin_lock_free failed on lock %d\n", i);
+			ret = ret1;
+		}
+	}
+
+	return ret;
+}
+
+static const struct of_device_id omap_hwspinlock_test_of_match[] = {
+	{ .compatible = "ti,omap-hwspinlock-test",   },
+	{ .compatible = "ti,omap4-hwspinlock-test",  },
+	{ .compatible = "ti,omap5-hwspinlock-test",  },
+	{ .compatible = "ti,dra7-hwspinlock-test",   },
+	{ .compatible = "ti,am33xx-hwspinlock-test", },
+	{ .compatible = "ti,am43xx-hwspinlock-test", },
+	{ .compatible = "ti,am654-hwspinlock-test",  },
+	{ /* end */ },
+};
+
+static int hwspin_lock_test_all_phandle_locks(unsigned int max_locks)
+{
+	struct device_node *np = NULL;
+	struct hwspinlock *hwlock = NULL;
+	int ret = 0, ret1 = 0;
+	unsigned int i;
+	int num_locks;
+	int hwlock_id;
+
+	np = of_find_matching_node_and_match(NULL,
+					     omap_hwspinlock_test_of_match,
+					     NULL);
+	if (!np) {
+		pr_err("\nNo test node provided\n");
+		return 0;
+	}
+
+	num_locks = of_count_phandle_with_args(np, "hwlocks", "#hwlock-cells");
+	pr_err("Number of phandles = %d max_locks = %d\n",
+	       num_locks, max_locks);
+
+	for (i = 0; i < num_locks; i++) {
+		hwlock_id = of_hwspin_lock_get_id(np, i);
+		if (hwlock_id < 0) {
+			pr_err("unable to get hwlock_id : %d\n", hwlock_id);
+			ret = -EINVAL;
+			continue;
+		};
+
+		hwlock = hwspin_lock_request_specific(hwlock_id);
+		if (!hwlock) {
+			pr_err("unable to get hwlock\n");
+			ret = -EINVAL;
+			continue;
+		}
+
+		ret1 = hwspin_lock_test(hwlock);
+		if (ret1) {
+			pr_err("hwspinlock test failed on DT lock %d, ret = %d\n",
+			       hwspin_lock_get_id(hwlock), ret1);
+			ret = ret1;
+		}
+
+		ret1 = hwspin_lock_free(hwlock);
+		if (ret1) {
+			pr_err("hwspin_lock_free failed on lock %d\n",
+			       hwspin_lock_get_id(hwlock));
+			ret = ret1;
+		}
+	}
+
+	return ret;
+}
+
+static
+unsigned int omap_hwspinlock_get_locks(const struct hwspinlock_data *data)
+{
+	unsigned int locks = 0;
+
+	while (data->compatible) {
+		if (of_machine_is_compatible(data->compatible)) {
+			locks = data->max_locks;
+			break;
+		}
+		data++;
+	}
+
+	return locks;
+}
+
+static const struct of_device_id omap_hwspinlock_of_match[] = {
+	{ .compatible = "ti,omap4-hwspinlock", },
+	{ .compatible = "ti,am654-hwspinlock", },
+	{ .compatible = "ti,am64-hwspinlock",  },
+	{ /* end */ },
+};
+
+static const struct hwspinlock_data soc_data[] = {
+	{ "ti,omap4",	32, },
+	{ "ti,omap5",	32, },
+	{ "ti,dra7",	256, },
+	{ "ti,am33xx",	128, },
+	{ "ti,am43",	128, },
+	{ "ti,am654",	256, },
+	{ "ti,j721e",	256, },
+	{ "ti,j7200",	256, },
+	{ "ti,am642",	256, },
+	{ "ti,j721s2",	256, },
+	{ /* sentinel */ },
+};
+
+static int omap_hwspinlock_test_init(void)
+{
+	struct device_node *np;
+	unsigned int max_locks;
+	int ret;
+
+	pr_err("\n** HwSpinLock Unit Test Module initiated **\n");
+
+	max_locks = omap_hwspinlock_get_locks(soc_data);
+	if (!max_locks) {
+		pr_err("\nNot a compatible platform\n");
+		return -ENODEV;
+	}
+
+	np = of_find_matching_node_and_match(NULL, omap_hwspinlock_of_match,
+					     NULL);
+	if (!np || !of_device_is_available(np)) {
+		pr_err("\nNo HwSpinlock node provided/enabled\n");
+		return -ENODEV;
+	}
+
+	pr_err("\n***** Begin - Test All Locks ****\n");
+	ret = hwspin_lock_test_all_locks(max_locks);
+	if (ret)
+		pr_err("hwspin_lock_test_all_locks failed, ret = %d\n", ret);
+	pr_err("\n***** End - Test All Locks ****\n");
+
+	pr_err("\n***** Begin - Test All pHandle Locks ****\n");
+	ret = hwspin_lock_test_all_phandle_locks(max_locks);
+	if (ret)
+		pr_err("hwspin_lock_test_all_locks failed, ret = %d\n", ret);
+	pr_err("\n***** End - Test All pHandle Locks ****\n");
+
+	return 0;
+}
+
+static void omap_hwspinlock_test_exit(void)
+{
+	pr_err("\n** HwSpinLock Unit Test Module finished **\n");
+}
+
+module_init(omap_hwspinlock_test_init);
+module_exit(omap_hwspinlock_test_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("Hardware spinlock Test driver for TI SoCs");
+MODULE_AUTHOR("Suman Anna <[email protected]>");
meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb new file +18 -0
new file mode 100644
index 00000000..2edd93f6
@@ -0,0 +1,18 @@
+SUMMARY = "Build hwspinlock test as an external Linux kernel module"
+DESCRIPTION = "${SUMMARY}"
+LICENSE = "GPL-2.0-only | BSD-3-Clause"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=bfa02c83df161e37647ee23a2c7eacd4"
+
+inherit module
+
+SRC_URI = "file://Makefile \
+           file://omap_hwspinlock_test.c \
+           file://LICENSE \
+          "
+
+S = "${WORKDIR}"
+
+# The inherit of module.bbclass will automatically name module packages with
+# "kernel-module-" prefix as required by the oe-core build environment.
+
+RPROVIDES:${PN} += "kernel-module-hwspinlocktest"
#5 lore raw

Hi,

Quoted 25 lines · Andrew Davis via lists.yoctoproject.org

On 11/6/24 12: 51 PM, Denys Dmytriyenko wrote: > On Wed, Nov 06, 2024 at 12: 38: 22PM -0600, Andrew Davis via lists. yoctoproject. org wrote: >> On 11/1/24 5: 23 PM, Mendez, Judith via lists. yoctoproject. org wrote: >>> Add hwspinlock ZjQcmQRYFpfptBannerStart
This message was sent from outside of Texas Instruments.
Do not click links or open attachments unless you recognize the source of this email and know the content is safe.
Report Suspicious
<https://us-phishalarm-ewt.proofpoint.com/EWT/v1/G3vK!uRdgPddvNq17YMXE9plD3zTLKnyJbVe1FodO6EjXrOaXkmYyXRGdlH8ZSsFNdu-TFl7WbSmHAk_5B3rrQaunEaKBsGI$>

ZjQcmQRYFpfptBannerEnd

Quoted 16 lines · Denys Dmytriyenko
Quoted 14 lines · Andrew Davis via lists.yoctoproject.org
Quoted 8 lines · Judith via lists.yoctoproject.org

Add hwspinlock recipe to build out of tree module hwspinlock test.

---
  .../recipes-core/packagegroups/ti-test.bb     |   1 +
  .../hwspinlocktest/files/LICENSE              |  29 ++
  .../hwspinlocktest/files/Makefile             |  19 ++
  .../files/omap_hwspinlock_test.c              | 251 ++++++++++++++++++

Why are we adding the entire source of this project into meta-arago? Is this
not the upstream: https://urldefense.com/v3/__https://github.com/sumananna/omap-hwspinlock-test__;!!G3vK!WVH4EBhOyWaCKM4e8c1enaXqXi1veX83MJeCPbdmMBnPnQ9I204_9Lt67eVQDP0pvUGsDcd6IPErmS7jF38gQ3nOrODt$ ?

You should point to that and fetch from there like normal recipes.

Quoted 7 lines
Quoted 3 lines

FYI, this has been asked and answered already:
https://urldefense.com/v3/__https://lists.yoctoproject.org/g/meta-arago/topic/109054399*msg15583__;Iw!!G3vK!WVH4EBhOyWaCKM4e8c1enaXqXi1veX83MJeCPbdmMBnPnQ9I204_9Lt67eVQDP0pvUGsDcd6IPErmS7jF38gQ72NHmnf$

Ah, didn't see any hint to this not being the first version of this series..

Copying the answer here to respond inline,

Thanks for doing that. Will use this thread to respond.

Quoted 10 lines
Quoted 2 lines

Apparently we do not want to pull from personal repos

Since when? We do that for lots of recipes.

Quoted 4 lines

there is a JIRA req to move
the repo to ti.com, but the target date is for 11.0. Since we want to add the test asap, the idea is to add to yocto and update the recipe later when the repo has been moved.

Quoted 4 lines

If you really want to use a ti.com based source repo, then do that first. If setting up the repo clone is not a priority, then this test can't be that important either. Do this in the right order. Copying the whole source into the layer is hacky.

I agree to Andrew's suggestion (that's the reason I had raised the same question). Also, I don't see any harm in using personal repositories as long
as the LICENSE file seems fine.

Till ti.com movement happens, we can use the existing repository on GitHub

---
Chirag

Quoted 375 lines

Andrew

Quoted 353 lines
Quoted 353 lines
Quoted 353 lines
  .../hwspinlocktest/hwspinlocktest_0.1.bb      |  18 ++
  5 files changed, 318 insertions(+)

create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c create mode 100644 meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb

meta-arago-test/recipes-core/packagegroups/ti-test.bb +1 -0
index 85398eaf..98fd0f56 100644
@@ -18,6 +18,7 @@ TI_TEST_BASE = "\
      evtest \
      fio \
      git \
+    hwspinlocktest \
      hdparm \
      i2c-tools \
      iozone3 \
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +29 -0
new file mode 100644
index 00000000..f5351a25
@@ -0,0 +1,29 @@
+BSD 3-Clause License
+
+Copyright (c) 2019, Suman Anna
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile new file +19 -0
new file mode 100644
index 00000000..d8fe76dc
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+#
+# TI OMAP HwSpinlock Unit Test
+#
+
+obj-m := omap_hwspinlock_test.o
+
+SRC := $(shell pwd)
+
+all:
+	$(MAKE) -C $(KERNEL_SRC) M=$(SRC)
+
+modules_install:
+	$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
+
+clean:
+	rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
+	rm -f Module.markers Module.symvers modules.order
+	rm -rf .tmp_versions Modules.symvers
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +251 -0
new file mode 100644
index 00000000..b1801389
@@ -0,0 +1,251 @@
+// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+/*
+ * OMAP hardware spinlock test driver
+ *
+ * Copyright (C) 2014-2021 Texas Instruments Incorporated - https://www.ti.com
+ *	Suman Anna <[email protected]>
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/sched.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#include <linux/hwspinlock.h>
+
+/* load-time options */
+static int count = 2;
+module_param(count, int, 0444);
+
+struct hwspinlock_data {
+	const char *compatible;
+	const unsigned int max_locks;
+};
+
+static int hwspin_lock_test(struct hwspinlock *hwlock)
+{
+	int i;
+	int ret;
+
+	pr_err("\nTesting lock %d\n", hwspin_lock_get_id(hwlock));
+	for (i = 0; i < count; i++) {
+		ret = hwspin_trylock(hwlock);
+		if (ret) {
+			pr_err("%s: Initial lock failed\n", __func__);
+			return -EFAULT;
+		}
+		pr_err("trylock #1 status[%d] = %d\n", i, ret);
+
+		/* Verify lock actually works - re-acquiring it should fail */
+		ret = hwspin_trylock(hwlock);
+		pr_err("trylock #2 status[%d] = %d\n", i, ret);
+		if (!ret) {
+			/* Keep locks balanced even in failure cases */
+			hwspin_unlock(hwlock);
+			hwspin_unlock(hwlock);
+			pr_err("%s: Recursive lock succeeded unexpectedly\n",
+			       __func__);
+			return -EFAULT;
+		}
+
+		/* Verify unlock by re-acquiring the lock after releasing it */
+		hwspin_unlock(hwlock);
+		ret = hwspin_trylock(hwlock);
+		pr_err("trylock after unlock status[%d] = %d\n", i, ret);
+		if (ret) {
+			pr_err("%s: Unlock failed\n", __func__);
+			return -EINVAL;
+		}
+
+		hwspin_unlock(hwlock);
+	}
+
+	return 0;
+}
+
+static int hwspin_lock_test_all_locks(unsigned int max_locks)
+{
+	int i;
+	int ret = 0, ret1 = 0;
+	struct hwspinlock *hwlock = NULL;
+
+	pr_err("Testing %d locks\n", max_locks);
+	for (i = 0; i < max_locks; i++) {
+		hwlock = hwspin_lock_request_specific(i);
+		if (!hwlock) {
+			pr_err("request lock %d failed\n", i);
+			ret = -EIO;
+			continue;
+		}
+
+		ret1 = hwspin_lock_test(hwlock);
+		if (ret1) {
+			pr_err("hwspinlock tests failed on lock %d\n", i);
+			ret = ret1;
+			goto free_lock;
+		}
+
+free_lock:
+		ret1 = hwspin_lock_free(hwlock);
+		if (ret1) {
+			pr_err("hwspin_lock_free failed on lock %d\n", i);
+			ret = ret1;
+		}
+	}
+
+	return ret;
+}
+
+static const struct of_device_id omap_hwspinlock_test_of_match[] = {
+	{ .compatible = "ti,omap-hwspinlock-test",   },
+	{ .compatible = "ti,omap4-hwspinlock-test",  },
+	{ .compatible = "ti,omap5-hwspinlock-test",  },
+	{ .compatible = "ti,dra7-hwspinlock-test",   },
+	{ .compatible = "ti,am33xx-hwspinlock-test", },
+	{ .compatible = "ti,am43xx-hwspinlock-test", },
+	{ .compatible = "ti,am654-hwspinlock-test",  },
+	{ /* end */ },
+};
+
+static int hwspin_lock_test_all_phandle_locks(unsigned int max_locks)
+{
+	struct device_node *np = NULL;
+	struct hwspinlock *hwlock = NULL;
+	int ret = 0, ret1 = 0;
+	unsigned int i;
+	int num_locks;
+	int hwlock_id;
+
+	np = of_find_matching_node_and_match(NULL,
+					     omap_hwspinlock_test_of_match,
+					     NULL);
+	if (!np) {
+		pr_err("\nNo test node provided\n");
+		return 0;
+	}
+
+	num_locks = of_count_phandle_with_args(np, "hwlocks", "#hwlock-cells");
+	pr_err("Number of phandles = %d max_locks = %d\n",
+	       num_locks, max_locks);
+
+	for (i = 0; i < num_locks; i++) {
+		hwlock_id = of_hwspin_lock_get_id(np, i);
+		if (hwlock_id < 0) {
+			pr_err("unable to get hwlock_id : %d\n", hwlock_id);
+			ret = -EINVAL;
+			continue;
+		};
+
+		hwlock = hwspin_lock_request_specific(hwlock_id);
+		if (!hwlock) {
+			pr_err("unable to get hwlock\n");
+			ret = -EINVAL;
+			continue;
+		}
+
+		ret1 = hwspin_lock_test(hwlock);
+		if (ret1) {
+			pr_err("hwspinlock test failed on DT lock %d, ret = %d\n",
+			       hwspin_lock_get_id(hwlock), ret1);
+			ret = ret1;
+		}
+
+		ret1 = hwspin_lock_free(hwlock);
+		if (ret1) {
+			pr_err("hwspin_lock_free failed on lock %d\n",
+			       hwspin_lock_get_id(hwlock));
+			ret = ret1;
+		}
+	}
+
+	return ret;
+}
+
+static
+unsigned int omap_hwspinlock_get_locks(const struct hwspinlock_data *data)
+{
+	unsigned int locks = 0;
+
+	while (data->compatible) {
+		if (of_machine_is_compatible(data->compatible)) {
+			locks = data->max_locks;
+			break;
+		}
+		data++;
+	}
+
+	return locks;
+}
+
+static const struct of_device_id omap_hwspinlock_of_match[] = {
+	{ .compatible = "ti,omap4-hwspinlock", },
+	{ .compatible = "ti,am654-hwspinlock", },
+	{ .compatible = "ti,am64-hwspinlock",  },
+	{ /* end */ },
+};
+
+static const struct hwspinlock_data soc_data[] = {
+	{ "ti,omap4",	32, },
+	{ "ti,omap5",	32, },
+	{ "ti,dra7",	256, },
+	{ "ti,am33xx",	128, },
+	{ "ti,am43",	128, },
+	{ "ti,am654",	256, },
+	{ "ti,j721e",	256, },
+	{ "ti,j7200",	256, },
+	{ "ti,am642",	256, },
+	{ "ti,j721s2",	256, },
+	{ /* sentinel */ },
+};
+
+static int omap_hwspinlock_test_init(void)
+{
+	struct device_node *np;
+	unsigned int max_locks;
+	int ret;
+
+	pr_err("\n** HwSpinLock Unit Test Module initiated **\n");
+
+	max_locks = omap_hwspinlock_get_locks(soc_data);
+	if (!max_locks) {
+		pr_err("\nNot a compatible platform\n");
+		return -ENODEV;
+	}
+
+	np = of_find_matching_node_and_match(NULL, omap_hwspinlock_of_match,
+					     NULL);
+	if (!np || !of_device_is_available(np)) {
+		pr_err("\nNo HwSpinlock node provided/enabled\n");
+		return -ENODEV;
+	}
+
+	pr_err("\n***** Begin - Test All Locks ****\n");
+	ret = hwspin_lock_test_all_locks(max_locks);
+	if (ret)
+		pr_err("hwspin_lock_test_all_locks failed, ret = %d\n", ret);
+	pr_err("\n***** End - Test All Locks ****\n");
+
+	pr_err("\n***** Begin - Test All pHandle Locks ****\n");
+	ret = hwspin_lock_test_all_phandle_locks(max_locks);
+	if (ret)
+		pr_err("hwspin_lock_test_all_locks failed, ret = %d\n", ret);
+	pr_err("\n***** End - Test All pHandle Locks ****\n");
+
+	return 0;
+}
+
+static void omap_hwspinlock_test_exit(void)
+{
+	pr_err("\n** HwSpinLock Unit Test Module finished **\n");
+}
+
+module_init(omap_hwspinlock_test_init);
+module_exit(omap_hwspinlock_test_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("Hardware spinlock Test driver for TI SoCs");
+MODULE_AUTHOR("Suman Anna <[email protected]>");
meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb new file +10 -0
new file mode 100644
index 00000000..2edd93f6
@@ -0,0 +1,18 @@
+SUMMARY = "Build hwspinlock test as an external Linux kernel module"
+DESCRIPTION = "${SUMMARY}"
+LICENSE = "GPL-2.0-only | BSD-3-Clause"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=bfa02c83df161e37647ee23a2c7eacd4"
+
+inherit module
+
+SRC_URI = "file://Makefile \
+           file://omap_hwspinlock_test.c \
+           file://LICENSE \
Quoted 8 lines
Quoted 8 lines

meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb line 18

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb new file +8 -0
+          "
+
+S = "${WORKDIR}"
+
+# The inherit of module.bbclass will automatically name module packages with
+# "kernel-module-" prefix as required by the oe-core build environment.
+
+RPROVIDES:${PN} += "kernel-module-hwspinlocktest"

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#15598):https://urldefense.com/v3/__https://lists.yoctoproject.org/g/meta-arago/message/15598__;!!G3vK!WVH4EBhOyWaCKM4e8c1enaXqXi1veX83MJeCPbdmMBnPnQ9I204_9Lt67eVQDP0pvUGsDcd6IPErmS7jF38gQ6aPeilQ$ Mute This Topic:https://urldefense.com/v3/__https://lists.yoctoproject.org/mt/109343942/7030289__;!!G3vK!WVH4EBhOyWaCKM4e8c1enaXqXi1veX83MJeCPbdmMBnPnQ9I204_9Lt67eVQDP0pvUGsDcd6IPErmS7jF38gQwXxQfIh$ Group Owner: [email protected]

Unsubscribe:https://urldefense.com/v3/__https://lists.yoctoproject.org/g/meta-arago/unsub__;!!G3vK!WVH4EBhOyWaCKM4e8c1enaXqXi1veX83MJeCPbdmMBnPnQ9I204_9Lt67eVQDP0pvUGsDcd6IPErmS7jF38gQ-U0q6v0$  [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
#6 lore raw

Hi all,

Quoted 59 lines · Chirag Shilwant

Hi,

Quoted 26 lines · Andrew Davis via lists.yoctoproject.org

On 11/6/24 12: 51 PM, Denys Dmytriyenko wrote: > On Wed, Nov 06, 2024 at 12: 38: 22PM -0600, Andrew Davis via lists. yoctoproject. org wrote: >> On 11/1/24 5: 23 PM, Mendez, Judith via lists. yoctoproject.  org wrote: >>> Add hwspinlock ZjQcmQRYFpfptBannerStart
This message was sent from outside of Texas Instruments.
Do not click links or open attachments unless you recognize the source of this email and know the content is safe.
Report Suspicious
<https://us-phishalarm-ewt.proofpoint.com/EWT/v1/G3vK!uRdgPddvNq17YMXE9plD3zTLKnyJbVe1FodO6EjXrOaXkmYyXRGdlH8ZSsFNdu-TFl7WbSmHAk_5B3rrQaunEaKBsGI$>
ZjQcmQRYFpfptBannerEnd

Quoted 1 line · Denys Dmytriyenko

On Wed, Nov 06, 2024 at 12:38:22PM -0600, Andrew Davis via

Quoted 9 lines · lists.yoctoproject.org
Quoted 9 lines · Judith via lists.yoctoproject.org
Quoted 8 lines

Add hwspinlock recipe to build out of tree module hwspinlock test.

---
   .../recipes-core/packagegroups/ti-test.bb     |   1 + .../hwspinlocktest/files/LICENSE              |  29 ++ .../hwspinlocktest/files/Makefile             |  19 ++ .../files/omap_hwspinlock_test.c              | 251

++++++++++++++++++

Quoted 2 lines
Quoted 2 lines

Why are we adding the entire source of this project into

meta-arago? Is this

Quoted 1 line
Quoted 1 line

not the upstream:

https://urldefense.com/v3/__https://github.com/sumananna/omap-hwspinlock-test__;!!G3vK!WVH4EBhOyWaCKM4e8c1enaXqXi1veX83MJeCPbdmMBnPnQ9I204_9Lt67eVQDP0pvUGsDcd6IPErmS7jF38gQ3nOrODt$  ?

Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

You should point to that and fetch from there like normal recipes. FYI, this has been asked and answered already:

https://urldefense.com/v3/__https://lists.yoctoproject.org/g/meta-arago/topic/109054399*msg15583__;Iw!!G3vK!WVH4EBhOyWaCKM4e8c1enaXqXi1veX83MJeCPbdmMBnPnQ9I204_9Lt67eVQDP0pvUGsDcd6IPErmS7jF38gQ72NHmnf$

Quoted 1 line

Ah, didn't see any hint to this not being the first version of this series..

Copying the answer here to respond inline,

Thanks for doing that. Will use this thread to respond.

Quoted 10 lines
Quoted 2 lines

Apparently we do not want to pull from personal repos

Since when? We do that for lots of recipes.

Quoted 4 lines

there is a JIRA req to move
the repo to ti.com, but the target date is for 11.0. Since we want to add the test asap, the idea is to add to yocto and update the recipe later when the repo has been moved.

Quoted 4 lines

If you really want to use a ti.com based source repo, then do that first. If setting up the repo clone is not a priority, then this test can't be that important either. Do this in the right order. Copying the whole source into the layer is hacky.

Quoted 6 lines

I agree to Andrew's suggestion (that's the reason I had raised the same question). Also, I don't see any harm in using personal repositories as long
as the LICENSE file seems fine.

Till ti.com movement happens, we can use the existing repository on GitHub

There seems to be a misalignment on whether we should be using personal repos or not, perhaps we should pull Ryan and Praneeth to this discussion.

I will wait until everyone aligns on this and then processeed to send v2 if required.

~ Judith

Quoted 410 lines
Quoted 410 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

   .../hwspinlocktest/hwspinlocktest_0.1.bb      |  18 ++

   5 files changed, 318 insertions(+)

   create mode 100644

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE

Quoted 1 line
Quoted 1 line
Quoted 1 line

   create mode 100644

meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile

Quoted 1 line
Quoted 1 line
Quoted 1 line

   create mode 100644

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 1 line
Quoted 1 line
Quoted 1 line

   create mode 100644

meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb

Quoted 2 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +0 -0

b/meta-arago-test/recipes-core/packagegroups/ti-test.bb

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

index 85398eaf..98fd0f56 100644

meta-arago-test/recipes-core/packagegroups/ti-test.bb +0 -0
@@ -18,6 +18,7 @@ TI_TEST_BASE = "\
Quoted 8 lines
Quoted 8 lines

Review

Quoted 8 lines
meta-arago-test/recipes-core/packagegroups/ti-test.bb +1 -0
        evtest \
        fio \
        git \
+    hwspinlocktest \
        hdparm \
        i2c-tools \
        iozone3 \
(quoted diff) +0 -0

a/meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE b/meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

new file mode 100644
index 00000000..f5351a25

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +0 -0
Quoted 8 lines
Quoted 8 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 7

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +7 -0
@@ -0,0 +1,29 @@
+BSD 3-Clause License
+
+Copyright (c) 2019, Suman Anna
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following 

conditions are met:

Quoted 2 lines
Quoted 2 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 9

Quoted 2 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +2 -0
+
+1. Redistributions of source code must retain the above copyright 

notice, this

Quoted 3 lines
Quoted 3 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE

Quoted 3 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +3 -0
+   list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above 

copyright notice,

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 13

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+   this list of conditions and the following disclaimer in the 

documentation

Quoted 4 lines
Quoted 4 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE

Quoted 4 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +4 -0
+   and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its
+   contributors may be used to endorse or promote products 

derived from

Quoted 3 lines
Quoted 3 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE

Quoted 3 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +3 -0
+   this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 

CONTRIBUTORS "AS IS"

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 21

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 

TO, THE

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 22

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 

PARTICULAR PURPOSE ARE

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 23

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 

CONTRIBUTORS BE LIABLE

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 24

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 

CONSEQUENTIAL

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 25

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 

GOODS OR

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 26

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 

INTERRUPTION) HOWEVER

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 27

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 

STRICT LIABILITY,

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 28

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 

OUT OF THE USE

Quoted 2 lines
Quoted 2 lines

Review

Quoted 2 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
(quoted diff) +0 -0

a/meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile b/meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

new file mode 100644
index 00000000..d8fe76dc

meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile new file +12 -0
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+#
+# TI OMAP HwSpinlock Unit Test
+#
+
+obj-m := omap_hwspinlock_test.o
+
+SRC := $(shell pwd)
+
+all:
+    $(MAKE) -C $(KERNEL_SRC) M=$(SRC)
+
Quoted 8 lines
Quoted 8 lines

Review

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile new file +7 -0
+modules_install:
+    $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
+
+clean:
+    rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
+    rm -f Module.markers Module.symvers modules.order
+    rm -rf .tmp_versions Modules.symvers
(quoted diff) +0 -0

a/meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c b/meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

new file mode 100644
index 00000000..b1801389
--- /dev/null
+++

b/meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 6 lines
Quoted 6 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c line 5

Quoted 6 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +5 -0
@@ -0,0 +1,251 @@
+// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+/*
+ * OMAP hardware spinlock test driver
+ *
+ * Copyright (C) 2014-2021 Texas Instruments Incorporated - 

https://www.ti.com

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +30 -0
+ *    Suman Anna <[email protected]>
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/sched.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#include <linux/hwspinlock.h>
+
+/* load-time options */
+static int count = 2;
+module_param(count, int, 0444);
+
+struct hwspinlock_data {
+    const char *compatible;
+    const unsigned int max_locks;
+};
+
+static int hwspin_lock_test(struct hwspinlock *hwlock)
+{
+    int i;
+    int ret;
+
+    pr_err("\nTesting lock %d\n", hwspin_lock_get_id(hwlock));
+    for (i = 0; i < count; i++) {
Quoted 8 lines
Quoted 8 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +8 -0
+        ret = hwspin_trylock(hwlock);
+        if (ret) {
+            pr_err("%s: Initial lock failed\n", __func__);
+            return -EFAULT;
+        }
+        pr_err("trylock #1 status[%d] = %d\n", i, ret);
+
+        /* Verify lock actually works - re-acquiring it should 

fail */

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +4 -0
+        ret = hwspin_trylock(hwlock);
+        pr_err("trylock #2 status[%d] = %d\n", i, ret);
+        if (!ret) {
+            /* Keep locks balanced even in failure cases */
Quoted 8 lines
Quoted 8 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +8 -0
+            hwspin_unlock(hwlock);
+            hwspin_unlock(hwlock);
+            pr_err("%s: Recursive lock succeeded unexpectedly\n",
+                   __func__);
+            return -EFAULT;
+        }
+
+        /* Verify unlock by re-acquiring the lock after releasing 

it */

Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +51 -0
+        hwspin_unlock(hwlock);
+        ret = hwspin_trylock(hwlock);
+        pr_err("trylock after unlock status[%d] = %d\n", i, ret);
+        if (ret) {
+            pr_err("%s: Unlock failed\n", __func__);
+            return -EINVAL;
+        }
+
+        hwspin_unlock(hwlock);
+    }
+
+    return 0;
+}
+
+static int hwspin_lock_test_all_locks(unsigned int max_locks)
+{
+    int i;
+    int ret = 0, ret1 = 0;
+    struct hwspinlock *hwlock = NULL;
+
+    pr_err("Testing %d locks\n", max_locks);
+    for (i = 0; i < max_locks; i++) {
+        hwlock = hwspin_lock_request_specific(i);
+        if (!hwlock) {
+            pr_err("request lock %d failed\n", i);
+            ret = -EIO;
+            continue;
+        }
+
+        ret1 = hwspin_lock_test(hwlock);
+        if (ret1) {
+            pr_err("hwspinlock tests failed on lock %d\n", i);
+            ret = ret1;
+            goto free_lock;
+        }
+
+free_lock:
+        ret1 = hwspin_lock_free(hwlock);
+        if (ret1) {
+            pr_err("hwspin_lock_free failed on lock %d\n", i);
+            ret = ret1;
+        }
+    }
+
+    return ret;
+}
+
+static const struct of_device_id omap_hwspinlock_test_of_match[] = {
+    { .compatible = "ti,omap-hwspinlock-test",   },
+    { .compatible = "ti,omap4-hwspinlock-test",  },
+    { .compatible = "ti,omap5-hwspinlock-test",  },
Quoted 8 lines
Quoted 8 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +8 -0
+    { .compatible = "ti,dra7-hwspinlock-test",   },
+    { .compatible = "ti,am33xx-hwspinlock-test", },
+    { .compatible = "ti,am43xx-hwspinlock-test", },
+    { .compatible = "ti,am654-hwspinlock-test",  },
+    { /* end */ },
+};
+
+static int hwspin_lock_test_all_phandle_locks(unsigned int 

max_locks)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +9 -0
+{
+    struct device_node *np = NULL;
+    struct hwspinlock *hwlock = NULL;
+    int ret = 0, ret1 = 0;
+    unsigned int i;
+    int num_locks;
+    int hwlock_id;
+
+    np = of_find_matching_node_and_match(NULL,
Quoted 8 lines
Quoted 8 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +8 -0
+                         omap_hwspinlock_test_of_match,
+                         NULL);
+    if (!np) {
+        pr_err("\nNo test node provided\n");
+        return 0;
+    }
+
+    num_locks = of_count_phandle_with_args(np, "hwlocks", 

"#hwlock-cells");

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +13 -0
+    pr_err("Number of phandles = %d max_locks = %d\n",
+           num_locks, max_locks);
+
+    for (i = 0; i < num_locks; i++) {
+        hwlock_id = of_hwspin_lock_get_id(np, i);
+        if (hwlock_id < 0) {
+            pr_err("unable to get hwlock_id : %d\n", hwlock_id);
+            ret = -EINVAL;
+            continue;
+        };
+
+        hwlock = hwspin_lock_request_specific(hwlock_id);
+        if (!hwlock) {
Quoted 8 lines
Quoted 8 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +8 -0
+            pr_err("unable to get hwlock\n");
+            ret = -EINVAL;
+            continue;
+        }
+
+        ret1 = hwspin_lock_test(hwlock);
+        if (ret1) {
+            pr_err("hwspinlock test failed on DT lock %d, ret = 

%d\n",

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +9 -0
+                   hwspin_lock_get_id(hwlock), ret1);
+            ret = ret1;
+        }
+
+        ret1 = hwspin_lock_free(hwlock);
+        if (ret1) {
+            pr_err("hwspin_lock_free failed on lock %d\n",
+                   hwspin_lock_get_id(hwlock));
+            ret = ret1;
Quoted 8 lines
Quoted 8 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +8 -0
+        }
+    }
+
+    return ret;
+}
+
+static
+unsigned int omap_hwspinlock_get_locks(const struct 

hwspinlock_data *data)

Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +42 -0
+{
+    unsigned int locks = 0;
+
+    while (data->compatible) {
+        if (of_machine_is_compatible(data->compatible)) {
+            locks = data->max_locks;
+            break;
+        }
+        data++;
+    }
+
+    return locks;
+}
+
+static const struct of_device_id omap_hwspinlock_of_match[] = {
+    { .compatible = "ti,omap4-hwspinlock", },
+    { .compatible = "ti,am654-hwspinlock", },
+    { .compatible = "ti,am64-hwspinlock",  },
+    { /* end */ },
+};
+
+static const struct hwspinlock_data soc_data[] = {
+    { "ti,omap4",    32, },
+    { "ti,omap5",    32, },
+    { "ti,dra7",    256, },
+    { "ti,am33xx",    128, },
+    { "ti,am43",    128, },
+    { "ti,am654",    256, },
+    { "ti,j721e",    256, },
+    { "ti,j7200",    256, },
+    { "ti,am642",    256, },
+    { "ti,j721s2",    256, },
+    { /* sentinel */ },
+};
+
+static int omap_hwspinlock_test_init(void)
+{
+    struct device_node *np;
+    unsigned int max_locks;
+    int ret;
+
+    pr_err("\n** HwSpinLock Unit Test Module initiated **\n");
Quoted 8 lines
Quoted 8 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +8 -0
+
+    max_locks = omap_hwspinlock_get_locks(soc_data);
+    if (!max_locks) {
+        pr_err("\nNot a compatible platform\n");
+        return -ENODEV;
+    }
+
+    np = of_find_matching_node_and_match(NULL, 

omap_hwspinlock_of_match,

Quoted 10 lines
Quoted 10 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 10 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +10 -0
+                         NULL);
+    if (!np || !of_device_is_available(np)) {
+        pr_err("\nNo HwSpinlock node provided/enabled\n");
+        return -ENODEV;
+    }
+
+    pr_err("\n***** Begin - Test All Locks ****\n");
+    ret = hwspin_lock_test_all_locks(max_locks);
+    if (ret)
+        pr_err("hwspin_lock_test_all_locks failed, ret = %d\n", 

ret);

Quoted 6 lines
Quoted 6 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 6 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +6 -0
+    pr_err("\n***** End - Test All Locks ****\n");
+
+    pr_err("\n***** Begin - Test All pHandle Locks ****\n");
+    ret = hwspin_lock_test_all_phandle_locks(max_locks);
+    if (ret)
+        pr_err("hwspin_lock_test_all_locks failed, ret = %d\n", 

ret);

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +9 -0
+    pr_err("\n***** End - Test All pHandle Locks ****\n");
+
+    return 0;
+}
+
+static void omap_hwspinlock_test_exit(void)
+{
+    pr_err("\n** HwSpinLock Unit Test Module finished **\n");
+}
Quoted 8 lines
Quoted 8 lines

Review

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +7 -0
+
+module_init(omap_hwspinlock_test_init);
+module_exit(omap_hwspinlock_test_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("Hardware spinlock Test driver for TI SoCs");
+MODULE_AUTHOR("Suman Anna <[email protected]>");
(quoted diff) +0 -0

a/meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb b/meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

new file mode 100644
index 00000000..2edd93f6
--- /dev/null
+++

b/meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb

Quoted 5 lines
Quoted 5 lines

meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb line 4

Quoted 5 lines
meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb new file +4 -0
@@ -0,0 +1,18 @@
+SUMMARY = "Build hwspinlock test as an external Linux kernel module"
+DESCRIPTION = "${SUMMARY}"
+LICENSE = "GPL-2.0-only | BSD-3-Clause"
+LIC_FILES_CHKSUM = 

"file://LICENSE;md5=bfa02c83df161e37647ee23a2c7eacd4"

Quoted 11 lines
Quoted 11 lines

meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb

Quoted 11 lines
meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb new file +11 -0
+
+inherit module
+
+SRC_URI = "file://Makefile \
+           file://omap_hwspinlock_test.c \
+           file://LICENSE \
+          "
+
+S = "${WORKDIR}"
+
+# The inherit of module.bbclass will automatically name module 

packages with

Quoted 1 line
Quoted 1 line

Review line 16

Quoted 1 line
(quoted diff) +1 -0
+# "kernel-module-" prefix as required by the oe-core build 

environment.

Quoted 2 lines
Quoted 2 lines

meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb line 18

Quoted 2 lines
meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb new file +2 -0
+
+RPROVIDES:${PN} += "kernel-module-hwspinlocktest"

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#15598):https://urldefense.com/v3/__https://lists.yoctoproject.org/g/meta-arago/message/15598__;!!G3vK!WVH4EBhOyWaCKM4e8c1enaXqXi1veX83MJeCPbdmMBnPnQ9I204_9Lt67eVQDP0pvUGsDcd6IPErmS7jF38gQ6aPeilQ$ Mute This Topic:https://urldefense.com/v3/__https://lists.yoctoproject.org/mt/109343942/7030289__;!!G3vK!WVH4EBhOyWaCKM4e8c1enaXqXi1veX83MJeCPbdmMBnPnQ9I204_9Lt67eVQDP0pvUGsDcd6IPErmS7jF38gQwXxQfIh$ Group Owner: [email protected] Unsubscribe:https://urldefense.com/v3/__https://lists.yoctoproject.org/g/meta-arago/unsub__;!!G3vK!WVH4EBhOyWaCKM4e8c1enaXqXi1veX83MJeCPbdmMBnPnQ9I204_9Lt67eVQDP0pvUGsDcd6IPErmS7jF38gQ-U0q6v0$  [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#7 lore raw
Quoted 69 lines · Judith Mendez

Hi all,

Quoted 59 lines · Chirag Shilwant

Hi,

Quoted 26 lines · Andrew Davis via lists.yoctoproject.org

On 11/6/24 12: 51 PM, Denys Dmytriyenko wrote: > On Wed, Nov 06, 2024 at 12: 38: 22PM -0600, Andrew Davis via lists. yoctoproject. org wrote: >> On 11/1/24 5: 23 PM, Mendez, Judith via lists.  yoctoproject.  org wrote: >>> Add hwspinlock ZjQcmQRYFpfptBannerStart
This message was sent from outside of Texas Instruments.
Do not click links or open attachments unless you recognize the source of this email and know the content is safe.
Report Suspicious
<https://us-phishalarm-ewt.proofpoint.com/EWT/v1/G3vK!uRdgPddvNq17YMXE9plD3zTLKnyJbVe1FodO6EjXrOaXkmYyXRGdlH8ZSsFNdu-TFl7WbSmHAk_5B3rrQaunEaKBsGI$>
ZjQcmQRYFpfptBannerEnd

Quoted 1 line · Denys Dmytriyenko

On Wed, Nov 06, 2024 at 12:38:22PM -0600, Andrew Davis via

Quoted 9 lines · lists.yoctoproject.org
Quoted 9 lines · Judith via lists.yoctoproject.org
Quoted 8 lines

Add hwspinlock recipe to build out of tree module hwspinlock test.

---
   .../recipes-core/packagegroups/ti-test.bb     |   1 + .../hwspinlocktest/files/LICENSE              |  29 ++ .../hwspinlocktest/files/Makefile             |  19 ++ .../files/omap_hwspinlock_test.c              | 251

++++++++++++++++++

Quoted 2 lines
Quoted 2 lines

Why are we adding the entire source of this project into

meta-arago? Is this

Quoted 1 line
Quoted 1 line

not the upstream:

https://urldefense.com/v3/__https://github.com/sumananna/omap-hwspinlock-test__;!!G3vK!WVH4EBhOyWaCKM4e8c1enaXqXi1veX83MJeCPbdmMBnPnQ9I204_9Lt67eVQDP0pvUGsDcd6IPErmS7jF38gQ3nOrODt$  ?

Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

You should point to that and fetch from there like normal recipes. FYI, this has been asked and answered already:

https://urldefense.com/v3/__https://lists.yoctoproject.org/g/meta-arago/topic/109054399*msg15583__;Iw!!G3vK!WVH4EBhOyWaCKM4e8c1enaXqXi1veX83MJeCPbdmMBnPnQ9I204_9Lt67eVQDP0pvUGsDcd6IPErmS7jF38gQ72NHmnf$

Quoted 1 line

Ah, didn't see any hint to this not being the first version of this series..

Copying the answer here to respond inline,

Thanks for doing that. Will use this thread to respond.

Quoted 10 lines
Quoted 2 lines

Apparently we do not want to pull from personal repos

Since when? We do that for lots of recipes.

Quoted 4 lines

there is a JIRA req to move
the repo to ti.com, but the target date is for 11.0. Since we want to add the test asap, the idea is to add to yocto and update the recipe later when the repo has been moved.

Quoted 4 lines

If you really want to use a ti.com based source repo, then do that first. If setting up the repo clone is not a priority, then this test can't be that important either. Do this in the right order. Copying the whole source into the layer is hacky.

Quoted 6 lines

I agree to Andrew's suggestion (that's the reason I had raised the same question). Also, I don't see any harm in using personal repositories as long
as the LICENSE file seems fine.

Till ti.com movement happens, we can use the existing repository on GitHub

Quoted 6 lines

There seems to be a misalignment on whether we should be using personal repos or not, perhaps we should pull Ryan and Praneeth to this discussion.

I will wait until everyone aligns on this and then processeed to send v2 if required.

Is there a need to change any of the code in the test to fix issues? In other words, do we need to tweak the code at all?

If there is no need to modify the code, then I would say to move over to using the current github repo even if it is a private repo. We can always put in another patch to change the SRC_URI once we have the new git repo set up.

Even if we need to make changes, we can always carry patches in meta-arago with those changes while we are working to set up the new git repo.

I vote for a v2.

Quoted 416 lines

~ Judith

Quoted 413 lines
Quoted 413 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

   .../hwspinlocktest/hwspinlocktest_0.1.bb      |  18 ++

   5 files changed, 318 insertions(+)

   create mode 100644

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE

Quoted 1 line
Quoted 1 line
Quoted 1 line

   create mode 100644

meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile

Quoted 1 line
Quoted 1 line
Quoted 1 line

   create mode 100644

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 1 line
Quoted 1 line
Quoted 1 line

   create mode 100644

meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb

Quoted 2 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +0 -0

a/meta-arago-test/recipes-core/packagegroups/ti-test.bb b/meta-arago-test/recipes-core/packagegroups/ti-test.bb

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

index 85398eaf..98fd0f56 100644

meta-arago-test/recipes-core/packagegroups/ti-test.bb +0 -0
@@ -18,6 +18,7 @@ TI_TEST_BASE = "\
Quoted 8 lines
Quoted 8 lines

Review

Quoted 8 lines
meta-arago-test/recipes-core/packagegroups/ti-test.bb +1 -0
        evtest \
        fio \
        git \
+    hwspinlocktest \
        hdparm \
        i2c-tools \
        iozone3 \
(quoted diff) +0 -0

a/meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE b/meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

new file mode 100644
index 00000000..f5351a25

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +0 -0
Quoted 8 lines
Quoted 8 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 7

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +7 -0
@@ -0,0 +1,29 @@
+BSD 3-Clause License
+
+Copyright (c) 2019, Suman Anna
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following 

conditions are met:

Quoted 2 lines
Quoted 2 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 9

Quoted 2 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +2 -0
+
+1. Redistributions of source code must retain the above 

copyright notice, this

Quoted 3 lines
Quoted 3 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE

Quoted 3 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +3 -0
+   list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above 

copyright notice,

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 13

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+   this list of conditions and the following disclaimer in the 

documentation

Quoted 4 lines
Quoted 4 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE

Quoted 4 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +4 -0
+   and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its
+   contributors may be used to endorse or promote products 

derived from

Quoted 3 lines
Quoted 3 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE

Quoted 3 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +3 -0
+   this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 

CONTRIBUTORS "AS IS"

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 21

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 

LIMITED TO, THE

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 22

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 

PARTICULAR PURPOSE ARE

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 23

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 

CONTRIBUTORS BE LIABLE

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 24

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 

CONSEQUENTIAL

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 25

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 

SUBSTITUTE GOODS OR

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 26

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 

INTERRUPTION) HOWEVER

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 27

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 

STRICT LIABILITY,

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 28

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 

OUT OF THE USE

Quoted 1 line
Quoted 1 line

meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE line 29

Quoted 1 line
meta-arago-test/recipes-kernel/hwspinlocktest/files/LICENSE new file +1 -0
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 

DAMAGE.

Quoted 1 line
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

a/meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile b/meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

new file mode 100644
index 00000000..d8fe76dc

meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile new file +12 -0
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+#
+# TI OMAP HwSpinlock Unit Test
+#
+
+obj-m := omap_hwspinlock_test.o
+
+SRC := $(shell pwd)
+
+all:
+    $(MAKE) -C $(KERNEL_SRC) M=$(SRC)
+
Quoted 8 lines
Quoted 8 lines

Review

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/Makefile new file +7 -0
+modules_install:
+    $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
+
+clean:
+    rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
+    rm -f Module.markers Module.symvers modules.order
+    rm -rf .tmp_versions Modules.symvers
(quoted diff) +0 -0

a/meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c b/meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

new file mode 100644
index 00000000..b1801389
--- /dev/null
+++

b/meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 6 lines
Quoted 6 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c line 5

Quoted 6 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +5 -0
@@ -0,0 +1,251 @@
+// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+/*
+ * OMAP hardware spinlock test driver
+ *
+ * Copyright (C) 2014-2021 Texas Instruments Incorporated - 

https://www.ti.com

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +30 -0
+ *    Suman Anna <[email protected]>
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/sched.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#include <linux/hwspinlock.h>
+
+/* load-time options */
+static int count = 2;
+module_param(count, int, 0444);
+
+struct hwspinlock_data {
+    const char *compatible;
+    const unsigned int max_locks;
+};
+
+static int hwspin_lock_test(struct hwspinlock *hwlock)
+{
+    int i;
+    int ret;
+
+    pr_err("\nTesting lock %d\n", hwspin_lock_get_id(hwlock));
+    for (i = 0; i < count; i++) {
Quoted 8 lines
Quoted 8 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +8 -0
+        ret = hwspin_trylock(hwlock);
+        if (ret) {
+            pr_err("%s: Initial lock failed\n", __func__);
+            return -EFAULT;
+        }
+        pr_err("trylock #1 status[%d] = %d\n", i, ret);
+
+        /* Verify lock actually works - re-acquiring it should 

fail */

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +4 -0
+        ret = hwspin_trylock(hwlock);
+        pr_err("trylock #2 status[%d] = %d\n", i, ret);
+        if (!ret) {
+            /* Keep locks balanced even in failure cases */
Quoted 8 lines
Quoted 8 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +8 -0
+            hwspin_unlock(hwlock);
+            hwspin_unlock(hwlock);
+            pr_err("%s: Recursive lock succeeded unexpectedly\n",
+                   __func__);
+            return -EFAULT;
+        }
+
+        /* Verify unlock by re-acquiring the lock after 

releasing it */

Quoted 40 lines
Quoted 40 lines
Quoted 40 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +40 -0
+        hwspin_unlock(hwlock);
+        ret = hwspin_trylock(hwlock);
+        pr_err("trylock after unlock status[%d] = %d\n", i, ret);
+        if (ret) {
+            pr_err("%s: Unlock failed\n", __func__);
+            return -EINVAL;
+        }
+
+        hwspin_unlock(hwlock);
+    }
+
+    return 0;
+}
+
+static int hwspin_lock_test_all_locks(unsigned int max_locks)
+{
+    int i;
+    int ret = 0, ret1 = 0;
+    struct hwspinlock *hwlock = NULL;
+
+    pr_err("Testing %d locks\n", max_locks);
+    for (i = 0; i < max_locks; i++) {
+        hwlock = hwspin_lock_request_specific(i);
+        if (!hwlock) {
+            pr_err("request lock %d failed\n", i);
+            ret = -EIO;
+            continue;
+        }
+
+        ret1 = hwspin_lock_test(hwlock);
+        if (ret1) {
+            pr_err("hwspinlock tests failed on lock %d\n", i);
+            ret = ret1;
+            goto free_lock;
+        }
+
+free_lock:
+        ret1 = hwspin_lock_free(hwlock);
+        if (ret1) {
+            pr_err("hwspin_lock_free failed on lock %d\n", i);
Quoted 8 lines
Quoted 8 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +8 -0
+            ret = ret1;
+        }
+    }
+
+    return ret;
+}
+
+static const struct of_device_id omap_hwspinlock_test_of_match[] 

= {

Quoted 11 lines
Quoted 11 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 11 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +11 -0
+    { .compatible = "ti,omap-hwspinlock-test",   },
+    { .compatible = "ti,omap4-hwspinlock-test",  },
+    { .compatible = "ti,omap5-hwspinlock-test",  },
+    { .compatible = "ti,dra7-hwspinlock-test",   },
+    { .compatible = "ti,am33xx-hwspinlock-test", },
+    { .compatible = "ti,am43xx-hwspinlock-test", },
+    { .compatible = "ti,am654-hwspinlock-test",  },
+    { /* end */ },
+};
+
+static int hwspin_lock_test_all_phandle_locks(unsigned int 

max_locks)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +9 -0
+{
+    struct device_node *np = NULL;
+    struct hwspinlock *hwlock = NULL;
+    int ret = 0, ret1 = 0;
+    unsigned int i;
+    int num_locks;
+    int hwlock_id;
+
+    np = of_find_matching_node_and_match(NULL,
Quoted 8 lines
Quoted 8 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +8 -0
+                         omap_hwspinlock_test_of_match,
+                         NULL);
+    if (!np) {
+        pr_err("\nNo test node provided\n");
+        return 0;
+    }
+
+    num_locks = of_count_phandle_with_args(np, "hwlocks", 

"#hwlock-cells");

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +13 -0
+    pr_err("Number of phandles = %d max_locks = %d\n",
+           num_locks, max_locks);
+
+    for (i = 0; i < num_locks; i++) {
+        hwlock_id = of_hwspin_lock_get_id(np, i);
+        if (hwlock_id < 0) {
+            pr_err("unable to get hwlock_id : %d\n", hwlock_id);
+            ret = -EINVAL;
+            continue;
+        };
+
+        hwlock = hwspin_lock_request_specific(hwlock_id);
+        if (!hwlock) {
Quoted 8 lines
Quoted 8 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +8 -0
+            pr_err("unable to get hwlock\n");
+            ret = -EINVAL;
+            continue;
+        }
+
+        ret1 = hwspin_lock_test(hwlock);
+        if (ret1) {
+            pr_err("hwspinlock test failed on DT lock %d, ret = 

%d\n",

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +9 -0
+                   hwspin_lock_get_id(hwlock), ret1);
+            ret = ret1;
+        }
+
+        ret1 = hwspin_lock_free(hwlock);
+        if (ret1) {
+            pr_err("hwspin_lock_free failed on lock %d\n",
+                   hwspin_lock_get_id(hwlock));
+            ret = ret1;
Quoted 8 lines
Quoted 8 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +8 -0
+        }
+    }
+
+    return ret;
+}
+
+static
+unsigned int omap_hwspinlock_get_locks(const struct 

hwspinlock_data *data)

Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +42 -0
+{
+    unsigned int locks = 0;
+
+    while (data->compatible) {
+        if (of_machine_is_compatible(data->compatible)) {
+            locks = data->max_locks;
+            break;
+        }
+        data++;
+    }
+
+    return locks;
+}
+
+static const struct of_device_id omap_hwspinlock_of_match[] = {
+    { .compatible = "ti,omap4-hwspinlock", },
+    { .compatible = "ti,am654-hwspinlock", },
+    { .compatible = "ti,am64-hwspinlock",  },
+    { /* end */ },
+};
+
+static const struct hwspinlock_data soc_data[] = {
+    { "ti,omap4",    32, },
+    { "ti,omap5",    32, },
+    { "ti,dra7",    256, },
+    { "ti,am33xx",    128, },
+    { "ti,am43",    128, },
+    { "ti,am654",    256, },
+    { "ti,j721e",    256, },
+    { "ti,j7200",    256, },
+    { "ti,am642",    256, },
+    { "ti,j721s2",    256, },
+    { /* sentinel */ },
+};
+
+static int omap_hwspinlock_test_init(void)
+{
+    struct device_node *np;
+    unsigned int max_locks;
+    int ret;
+
+    pr_err("\n** HwSpinLock Unit Test Module initiated **\n");
Quoted 8 lines
Quoted 8 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +8 -0
+
+    max_locks = omap_hwspinlock_get_locks(soc_data);
+    if (!max_locks) {
+        pr_err("\nNot a compatible platform\n");
+        return -ENODEV;
+    }
+
+    np = of_find_matching_node_and_match(NULL, 

omap_hwspinlock_of_match,

Quoted 10 lines
Quoted 10 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 10 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +10 -0
+                         NULL);
+    if (!np || !of_device_is_available(np)) {
+        pr_err("\nNo HwSpinlock node provided/enabled\n");
+        return -ENODEV;
+    }
+
+    pr_err("\n***** Begin - Test All Locks ****\n");
+    ret = hwspin_lock_test_all_locks(max_locks);
+    if (ret)
+        pr_err("hwspin_lock_test_all_locks failed, ret = %d\n", 

ret);

Quoted 6 lines
Quoted 6 lines

meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c

Quoted 6 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +6 -0
+    pr_err("\n***** End - Test All Locks ****\n");
+
+    pr_err("\n***** Begin - Test All pHandle Locks ****\n");
+    ret = hwspin_lock_test_all_phandle_locks(max_locks);
+    if (ret)
+        pr_err("hwspin_lock_test_all_locks failed, ret = %d\n", 

ret);

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +9 -0
+    pr_err("\n***** End - Test All pHandle Locks ****\n");
+
+    return 0;
+}
+
+static void omap_hwspinlock_test_exit(void)
+{
+    pr_err("\n** HwSpinLock Unit Test Module finished **\n");
+}
Quoted 8 lines
Quoted 8 lines

Review

Quoted 8 lines
meta-arago-test/recipes-kernel/hwspinlocktest/files/omap_hwspinlock_test.c new file +7 -0
+
+module_init(omap_hwspinlock_test_init);
+module_exit(omap_hwspinlock_test_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("Hardware spinlock Test driver for TI SoCs");
+MODULE_AUTHOR("Suman Anna <[email protected]>");
(quoted diff) +0 -0

a/meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb b/meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

new file mode 100644
index 00000000..2edd93f6
--- /dev/null
+++

b/meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb

Quoted 2 lines
Quoted 2 lines

Review line 1

Quoted 2 lines
(quoted diff) +1 -0
@@ -0,0 +1,18 @@
+SUMMARY = "Build hwspinlock test as an external Linux kernel 

module"

Quoted 3 lines
Quoted 3 lines

meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb

Quoted 3 lines
meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb new file +3 -0
+DESCRIPTION = "${SUMMARY}"
+LICENSE = "GPL-2.0-only | BSD-3-Clause"
+LIC_FILES_CHKSUM = 

"file://LICENSE;md5=bfa02c83df161e37647ee23a2c7eacd4"

Quoted 11 lines
Quoted 11 lines

meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb

Quoted 11 lines
meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb new file +11 -0
+
+inherit module
+
+SRC_URI = "file://Makefile \
+           file://omap_hwspinlock_test.c \
+           file://LICENSE \
+          "
+
+S = "${WORKDIR}"
+
+# The inherit of module.bbclass will automatically name module 

packages with

Quoted 1 line
Quoted 1 line

Review line 16

Quoted 1 line
(quoted diff) +1 -0
+# "kernel-module-" prefix as required by the oe-core build 

environment.

Quoted 2 lines
Quoted 2 lines

meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb line 18

Quoted 2 lines
meta-arago-test/recipes-kernel/hwspinlocktest/hwspinlocktest_0.1.bb new file +2 -0
+
+RPROVIDES:${PN} += "kernel-module-hwspinlocktest"

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#15598):https://urldefense.com/v3/__https://lists.yoctoproject.org/g/meta-arago/message/15598__;!!G3vK!WVH4EBhOyWaCKM4e8c1enaXqXi1veX83MJeCPbdmMBnPnQ9I204_9Lt67eVQDP0pvUGsDcd6IPErmS7jF38gQ6aPeilQ$ Mute This Topic:https://urldefense.com/v3/__https://lists.yoctoproject.org/mt/109343942/7030289__;!!G3vK!WVH4EBhOyWaCKM4e8c1enaXqXi1veX83MJeCPbdmMBnPnQ9I204_9Lt67eVQDP0pvUGsDcd6IPErmS7jF38gQwXxQfIh$ Group Owner: [email protected] Unsubscribe:https://urldefense.com/v3/__https://lists.yoctoproject.org/g/meta-arago/unsub__;!!G3vK!WVH4EBhOyWaCKM4e8c1enaXqXi1veX83MJeCPbdmMBnPnQ9I204_9Lt67eVQDP0pvUGsDcd6IPErmS7jF38gQ-U0q6v0$  [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
Ryan Eatmon                [email protected]
-----------------------------------------
Texas Instruments, Inc.  -  LCPD  -  MGTS