linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/7] resource: introduce union(), intersection() API
@ 2020-11-03 20:45 Andy Shevchenko
  2020-11-03 20:45 ` [PATCH v6 1/7] resource: Simplify region_intersects() by reducing conditionals Andy Shevchenko
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Andy Shevchenko @ 2020-11-03 20:45 UTC (permalink / raw)
  To: linux-acpi, Greg Kroah-Hartman, linux-kernel
  Cc: Andy Shevchenko, Kuppuswamy Sathyanarayanan, Bjorn Helgaas, linux-pci

Some users may want to use resource library to manage their own resources,
besides existing users that open code union() and intersection()
implementations.

Provide a generic API for wider use.

Changelog v6:
- added missed tags

Changelog v5:
- added test cases (Greg)

Changelog v4:
- added Rb tag (Rafael)
- Cc'ed to LKML and Greg (Rafael)

Changelog v3:
- rebased on top of v5.10-rc1
- dropped upstreamed dependencies
- added Rb tag to the last patch (Mika)

Cc: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org

Andy Shevchenko (7):
  resource: Simplify region_intersects() by reducing conditionals
  resource: Group resource_overlaps() with other inline helpers
  resource: Introduce resource_union() for overlapping resources
  resource: Introduce resource_intersection() for overlapping resources
  resource: Add test cases for new resource API
  PCI/ACPI: Replace open coded variant of resource_union()
  ACPI: watchdog: Replace open coded variant of resource_union()

 drivers/acpi/acpi_watchdog.c |   6 +-
 drivers/acpi/pci_root.c      |   4 +-
 include/linux/ioport.h       |  34 ++++++--
 kernel/Makefile              |   1 +
 kernel/resource.c            |  10 +--
 kernel/resource_kunit.c      | 150 +++++++++++++++++++++++++++++++++++
 lib/Kconfig.debug            |  11 +++
 7 files changed, 196 insertions(+), 20 deletions(-)
 create mode 100644 kernel/resource_kunit.c

-- 
2.28.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v6 1/7] resource: Simplify region_intersects() by reducing conditionals
  2020-11-03 20:45 [PATCH v6 0/7] resource: introduce union(), intersection() API Andy Shevchenko
@ 2020-11-03 20:45 ` Andy Shevchenko
  2020-11-03 20:45 ` [PATCH v6 2/7] resource: Group resource_overlaps() with other inline helpers Andy Shevchenko
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2020-11-03 20:45 UTC (permalink / raw)
  To: linux-acpi, Greg Kroah-Hartman, linux-kernel
  Cc: Andy Shevchenko, Hanjun Guo, Rafael J . Wysocki

Now we have for 'other' and 'type' variables

other	type	return
  0	  0	REGION_DISJOINT
  0	  x	REGION_INTERSECTS
  x	  0	REGION_DISJOINT
  x	  x	REGION_MIXED

Obviously it's easier to check 'type' for 0 first instead of
currently checked 'other'.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
Tested-by: Hanjun Guo <guohanjun@huawei.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 kernel/resource.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/resource.c b/kernel/resource.c
index 3ae2f56cc79d..82df80417489 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -557,13 +557,13 @@ int region_intersects(resource_size_t start, size_t size, unsigned long flags,
 	}
 	read_unlock(&resource_lock);
 
-	if (other == 0)
-		return type ? REGION_INTERSECTS : REGION_DISJOINT;
+	if (type == 0)
+		return REGION_DISJOINT;
 
-	if (type)
-		return REGION_MIXED;
+	if (other == 0)
+		return REGION_INTERSECTS;
 
-	return REGION_DISJOINT;
+	return REGION_MIXED;
 }
 EXPORT_SYMBOL_GPL(region_intersects);
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v6 2/7] resource: Group resource_overlaps() with other inline helpers
  2020-11-03 20:45 [PATCH v6 0/7] resource: introduce union(), intersection() API Andy Shevchenko
  2020-11-03 20:45 ` [PATCH v6 1/7] resource: Simplify region_intersects() by reducing conditionals Andy Shevchenko
@ 2020-11-03 20:45 ` Andy Shevchenko
  2020-11-03 20:45 ` [PATCH v6 3/7] resource: Introduce resource_union() for overlapping resources Andy Shevchenko
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2020-11-03 20:45 UTC (permalink / raw)
  To: linux-acpi, Greg Kroah-Hartman, linux-kernel
  Cc: Andy Shevchenko, Hanjun Guo, Rafael J . Wysocki

For better maintenance group resource_overlaps() with other inline helpers.
While at it, drop extra parentheses.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
Tested-by: Hanjun Guo <guohanjun@huawei.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 include/linux/ioport.h | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 5135d4b86cd6..df4581107536 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -229,6 +229,11 @@ static inline bool resource_contains(struct resource *r1, struct resource *r2)
 	return r1->start <= r2->start && r1->end >= r2->end;
 }
 
+/* True if any part of r1 overlaps r2 */
+static inline bool resource_overlaps(struct resource *r1, struct resource *r2)
+{
+       return r1->start <= r2->end && r1->end >= r2->start;
+}
 
 /* Convenience shorthand with allocation */
 #define request_region(start,n,name)		__request_region(&ioport_resource, (start), (n), (name), 0)
@@ -296,12 +301,6 @@ extern int
 walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, u64 end,
 		    void *arg, int (*func)(struct resource *, void *));
 
-/* True if any part of r1 overlaps r2 */
-static inline bool resource_overlaps(struct resource *r1, struct resource *r2)
-{
-       return (r1->start <= r2->end && r1->end >= r2->start);
-}
-
 struct resource *devm_request_free_mem_region(struct device *dev,
 		struct resource *base, unsigned long size);
 struct resource *request_free_mem_region(struct resource *base,
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v6 3/7] resource: Introduce resource_union() for overlapping resources
  2020-11-03 20:45 [PATCH v6 0/7] resource: introduce union(), intersection() API Andy Shevchenko
  2020-11-03 20:45 ` [PATCH v6 1/7] resource: Simplify region_intersects() by reducing conditionals Andy Shevchenko
  2020-11-03 20:45 ` [PATCH v6 2/7] resource: Group resource_overlaps() with other inline helpers Andy Shevchenko
@ 2020-11-03 20:45 ` Andy Shevchenko
  2020-11-03 20:45 ` [PATCH v6 4/7] resource: Introduce resource_intersection() " Andy Shevchenko
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2020-11-03 20:45 UTC (permalink / raw)
  To: linux-acpi, Greg Kroah-Hartman, linux-kernel
  Cc: Andy Shevchenko, Hanjun Guo, Rafael J . Wysocki, Mika Westerberg,
	Kuppuswamy Sathyanarayanan, Bjorn Helgaas, linux-pci

Some already present users may utilize resource_union() helper.
Provide it for them and for wider use in the future.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
Tested-by: Hanjun Guo <guohanjun@huawei.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org
---
 include/linux/ioport.h | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index df4581107536..40320eb5bc0e 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -10,9 +10,10 @@
 #define _LINUX_IOPORT_H
 
 #ifndef __ASSEMBLY__
+#include <linux/bits.h>
 #include <linux/compiler.h>
+#include <linux/minmax.h>
 #include <linux/types.h>
-#include <linux/bits.h>
 /*
  * Resources are tree-like, allowing
  * nesting etc..
@@ -235,6 +236,16 @@ static inline bool resource_overlaps(struct resource *r1, struct resource *r2)
        return r1->start <= r2->end && r1->end >= r2->start;
 }
 
+static inline bool
+resource_union(struct resource *r1, struct resource *r2, struct resource *r)
+{
+	if (!resource_overlaps(r1, r2))
+		return false;
+	r->start = min(r1->start, r2->start);
+	r->end = max(r1->end, r2->end);
+	return true;
+}
+
 /* Convenience shorthand with allocation */
 #define request_region(start,n,name)		__request_region(&ioport_resource, (start), (n), (name), 0)
 #define request_muxed_region(start,n,name)	__request_region(&ioport_resource, (start), (n), (name), IORESOURCE_MUXED)
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v6 4/7] resource: Introduce resource_intersection() for overlapping resources
  2020-11-03 20:45 [PATCH v6 0/7] resource: introduce union(), intersection() API Andy Shevchenko
                   ` (2 preceding siblings ...)
  2020-11-03 20:45 ` [PATCH v6 3/7] resource: Introduce resource_union() for overlapping resources Andy Shevchenko
@ 2020-11-03 20:45 ` Andy Shevchenko
  2020-11-03 20:45 ` [PATCH v6 5/7] resource: Add test cases for new resource API Andy Shevchenko
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2020-11-03 20:45 UTC (permalink / raw)
  To: linux-acpi, Greg Kroah-Hartman, linux-kernel
  Cc: Andy Shevchenko, Hanjun Guo, Rafael J . Wysocki

There will be at least one user that can utilize new helper.
Provide the helper for future user and for wider use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 include/linux/ioport.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 40320eb5bc0e..ece1a8db309c 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -236,6 +236,16 @@ static inline bool resource_overlaps(struct resource *r1, struct resource *r2)
        return r1->start <= r2->end && r1->end >= r2->start;
 }
 
+static inline bool
+resource_intersection(struct resource *r1, struct resource *r2, struct resource *r)
+{
+	if (!resource_overlaps(r1, r2))
+		return false;
+	r->start = max(r1->start, r2->start);
+	r->end = min(r1->end, r2->end);
+	return true;
+}
+
 static inline bool
 resource_union(struct resource *r1, struct resource *r2, struct resource *r)
 {
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v6 5/7] resource: Add test cases for new resource API
  2020-11-03 20:45 [PATCH v6 0/7] resource: introduce union(), intersection() API Andy Shevchenko
                   ` (3 preceding siblings ...)
  2020-11-03 20:45 ` [PATCH v6 4/7] resource: Introduce resource_intersection() " Andy Shevchenko
@ 2020-11-03 20:45 ` Andy Shevchenko
  2020-11-03 20:45 ` [PATCH v6 6/7] PCI/ACPI: Replace open coded variant of resource_union() Andy Shevchenko
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2020-11-03 20:45 UTC (permalink / raw)
  To: linux-acpi, Greg Kroah-Hartman, linux-kernel; +Cc: Andy Shevchenko

Add test cases for newly added resource APIs.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 kernel/Makefile         |   1 +
 kernel/resource_kunit.c | 150 ++++++++++++++++++++++++++++++++++++++++
 lib/Kconfig.debug       |  11 +++
 3 files changed, 162 insertions(+)
 create mode 100644 kernel/resource_kunit.c

diff --git a/kernel/Makefile b/kernel/Makefile
index af601b9bda0e..aac15aeb9d69 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -123,6 +123,7 @@ obj-$(CONFIG_HAS_IOMEM) += iomem.o
 obj-$(CONFIG_RSEQ) += rseq.o
 obj-$(CONFIG_WATCH_QUEUE) += watch_queue.o
 
+obj-$(CONFIG_RESOURCE_KUNIT_TEST) += resource_kunit.o
 obj-$(CONFIG_SYSCTL_KUNIT_TEST) += sysctl-test.o
 
 CFLAGS_stackleak.o += $(DISABLE_STACKLEAK_PLUGIN)
diff --git a/kernel/resource_kunit.c b/kernel/resource_kunit.c
new file mode 100644
index 000000000000..9fdbca8426f1
--- /dev/null
+++ b/kernel/resource_kunit.c
@@ -0,0 +1,150 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test cases for API provided by resource.c and ioport.h
+ */
+
+#include <kunit/test.h>
+#include <linux/ioport.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+
+#define R0_START	0x0000
+#define R0_END		0xffff
+#define R1_START	0x1234
+#define R1_END		0x2345
+#define R2_START	0x4567
+#define R2_END		0x5678
+#define R3_START	0x6789
+#define R3_END		0x789a
+#define R4_START	0x2000
+#define R4_END		0x7000
+
+static struct resource r0 = { .start = R0_START, .end = R0_END };
+static struct resource r1 = { .start = R1_START, .end = R1_END };
+static struct resource r2 = { .start = R2_START, .end = R2_END };
+static struct resource r3 = { .start = R3_START, .end = R3_END };
+static struct resource r4 = { .start = R4_START, .end = R4_END };
+
+struct result {
+	struct resource *r1;
+	struct resource *r2;
+	struct resource r;
+	bool ret;
+};
+
+static struct result results_for_union[] = {
+	{
+		.r1 = &r1, .r2 = &r0, .r.start = R0_START, .r.end = R0_END, .ret = true,
+	}, {
+		.r1 = &r2, .r2 = &r0, .r.start = R0_START, .r.end = R0_END, .ret = true,
+	}, {
+		.r1 = &r3, .r2 = &r0, .r.start = R0_START, .r.end = R0_END, .ret = true,
+	}, {
+		.r1 = &r4, .r2 = &r0, .r.start = R0_START, .r.end = R0_END, .ret = true,
+	}, {
+		.r1 = &r2, .r2 = &r1, .ret = false,
+	}, {
+		.r1 = &r3, .r2 = &r1, .ret = false,
+	}, {
+		.r1 = &r4, .r2 = &r1, .r.start = R1_START, .r.end = R4_END, .ret = true,
+	}, {
+		.r1 = &r2, .r2 = &r3, .ret = false,
+	}, {
+		.r1 = &r2, .r2 = &r4, .r.start = R4_START, .r.end = R4_END, .ret = true,
+	}, {
+		.r1 = &r3, .r2 = &r4, .r.start = R4_START, .r.end = R3_END, .ret = true,
+	},
+};
+
+static struct result results_for_intersection[] = {
+	{
+		.r1 = &r1, .r2 = &r0, .r.start = R1_START, .r.end = R1_END, .ret = true,
+	}, {
+		.r1 = &r2, .r2 = &r0, .r.start = R2_START, .r.end = R2_END, .ret = true,
+	}, {
+		.r1 = &r3, .r2 = &r0, .r.start = R3_START, .r.end = R3_END, .ret = true,
+	}, {
+		.r1 = &r4, .r2 = &r0, .r.start = R4_START, .r.end = R4_END, .ret = true,
+	}, {
+		.r1 = &r2, .r2 = &r1, .ret = false,
+	}, {
+		.r1 = &r3, .r2 = &r1, .ret = false,
+	}, {
+		.r1 = &r4, .r2 = &r1, .r.start = R4_START, .r.end = R1_END, .ret = true,
+	}, {
+		.r1 = &r2, .r2 = &r3, .ret = false,
+	}, {
+		.r1 = &r2, .r2 = &r4, .r.start = R2_START, .r.end = R2_END, .ret = true,
+	}, {
+		.r1 = &r3, .r2 = &r4, .r.start = R3_START, .r.end = R4_END, .ret = true,
+	},
+};
+
+static void resource_do_test(struct kunit *test, bool ret, struct resource *r,
+			     bool exp_ret, struct resource *exp_r,
+			     struct resource *r1, struct resource *r2)
+{
+	KUNIT_EXPECT_EQ_MSG(test, ret, exp_ret, "Resources %pR %pR", r1, r2);
+	KUNIT_EXPECT_EQ_MSG(test, r->start, exp_r->start, "Start elements are not equal");
+	KUNIT_EXPECT_EQ_MSG(test, r->end, exp_r->end, "End elements are not equal");
+}
+
+static void resource_do_union_test(struct kunit *test, struct result *r)
+{
+	struct resource result;
+	bool ret;
+
+	memset(&result, 0, sizeof(result));
+	ret = resource_union(r->r1, r->r2, &result);
+	resource_do_test(test, ret, &result, r->ret, &r->r, r->r1, r->r2);
+
+	memset(&result, 0, sizeof(result));
+	ret = resource_union(r->r2, r->r1, &result);
+	resource_do_test(test, ret, &result, r->ret, &r->r, r->r2, r->r1);
+}
+
+static void resource_test_union(struct kunit *test)
+{
+	struct result *r = results_for_union;
+	unsigned int i = 0;
+
+	do {
+		resource_do_union_test(test, &r[i]);
+	} while (++i < ARRAY_SIZE(results_for_union));
+}
+
+static void resource_do_intersection_test(struct kunit *test, struct result *r)
+{
+	struct resource result;
+	bool ret;
+
+	memset(&result, 0, sizeof(result));
+	ret = resource_intersection(r->r1, r->r2, &result);
+	resource_do_test(test, ret, &result, r->ret, &r->r, r->r1, r->r2);
+
+	memset(&result, 0, sizeof(result));
+	ret = resource_intersection(r->r2, r->r1, &result);
+	resource_do_test(test, ret, &result, r->ret, &r->r, r->r2, r->r1);
+}
+
+static void resource_test_intersection(struct kunit *test)
+{
+	struct result *r = results_for_intersection;
+	unsigned int i = 0;
+
+	do {
+		resource_do_intersection_test(test, &r[i]);
+	} while (++i < ARRAY_SIZE(results_for_intersection));
+}
+
+static struct kunit_case resource_test_cases[] = {
+	KUNIT_CASE(resource_test_union),
+	KUNIT_CASE(resource_test_intersection),
+	{}
+};
+
+static struct kunit_suite resource_test_suite = {
+	.name = "resource",
+	.test_cases = resource_test_cases,
+};
+kunit_test_suite(resource_test_suite);
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 8596989423bf..663e7238a56e 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -2232,6 +2232,17 @@ config BITFIELD_KUNIT
 
 	  If unsure, say N.
 
+config RESOURCE_KUNIT_TEST
+	tristate "KUnit test for resource API"
+	depends on KUNIT
+	help
+	  This builds the resource API unit test.
+	  Tests the logic of API provided by resource.c and ioport.h.
+	  For more information on KUnit and unit tests in general please refer
+	  to the KUnit documentation in Documentation/dev-tools/kunit/.
+
+	  If unsure, say N.
+
 config SYSCTL_KUNIT_TEST
 	tristate "KUnit test for sysctl" if !KUNIT_ALL_TESTS
 	depends on KUNIT
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v6 6/7] PCI/ACPI: Replace open coded variant of resource_union()
  2020-11-03 20:45 [PATCH v6 0/7] resource: introduce union(), intersection() API Andy Shevchenko
                   ` (4 preceding siblings ...)
  2020-11-03 20:45 ` [PATCH v6 5/7] resource: Add test cases for new resource API Andy Shevchenko
@ 2020-11-03 20:45 ` Andy Shevchenko
  2020-11-03 20:45 ` [PATCH v6 7/7] ACPI: watchdog: " Andy Shevchenko
  2020-11-16 16:51 ` [PATCH v6 0/7] resource: introduce union(), intersection() API Andy Shevchenko
  7 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2020-11-03 20:45 UTC (permalink / raw)
  To: linux-acpi, Greg Kroah-Hartman, linux-kernel
  Cc: Andy Shevchenko, Kuppuswamy Sathyanarayanan, Hanjun Guo,
	Bjorn Helgaas, linux-pci, Rafael J . Wysocki

Since we have resource_union() helper, let's utilize it here.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
Tested-by: Hanjun Guo <guohanjun@huawei.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/pci_root.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index c12b5fb3e8fb..0bf072cef6cf 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -722,9 +722,7 @@ static void acpi_pci_root_validate_resources(struct device *dev,
 			 * our resources no longer match the ACPI _CRS, but
 			 * the kernel resource tree doesn't allow overlaps.
 			 */
-			if (resource_overlaps(res1, res2)) {
-				res2->start = min(res1->start, res2->start);
-				res2->end = max(res1->end, res2->end);
+			if (resource_union(res1, res2, res2)) {
 				dev_info(dev, "host bridge window expanded to %pR; %pR ignored\n",
 					 res2, res1);
 				free = true;
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v6 7/7] ACPI: watchdog: Replace open coded variant of resource_union()
  2020-11-03 20:45 [PATCH v6 0/7] resource: introduce union(), intersection() API Andy Shevchenko
                   ` (5 preceding siblings ...)
  2020-11-03 20:45 ` [PATCH v6 6/7] PCI/ACPI: Replace open coded variant of resource_union() Andy Shevchenko
@ 2020-11-03 20:45 ` Andy Shevchenko
  2020-11-16 16:51 ` [PATCH v6 0/7] resource: introduce union(), intersection() API Andy Shevchenko
  7 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2020-11-03 20:45 UTC (permalink / raw)
  To: linux-acpi, Greg Kroah-Hartman, linux-kernel
  Cc: Andy Shevchenko, Hanjun Guo, Mika Westerberg, Rafael J . Wysocki

Since we have resource_union() helper, let's utilize it here.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
Tested-by: Hanjun Guo <guohanjun@huawei.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/acpi_watchdog.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/acpi/acpi_watchdog.c b/drivers/acpi/acpi_watchdog.c
index 5c1e9ea43123..ca28183f4d13 100644
--- a/drivers/acpi/acpi_watchdog.c
+++ b/drivers/acpi/acpi_watchdog.c
@@ -151,11 +151,7 @@ void __init acpi_watchdog_init(void)
 		found = false;
 		resource_list_for_each_entry(rentry, &resource_list) {
 			if (rentry->res->flags == res.flags &&
-			    resource_overlaps(rentry->res, &res)) {
-				if (res.start < rentry->res->start)
-					rentry->res->start = res.start;
-				if (res.end > rentry->res->end)
-					rentry->res->end = res.end;
+			    resource_union(rentry->res, &res, rentry->res)) {
 				found = true;
 				break;
 			}
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 0/7] resource: introduce union(), intersection() API
  2020-11-03 20:45 [PATCH v6 0/7] resource: introduce union(), intersection() API Andy Shevchenko
                   ` (6 preceding siblings ...)
  2020-11-03 20:45 ` [PATCH v6 7/7] ACPI: watchdog: " Andy Shevchenko
@ 2020-11-16 16:51 ` Andy Shevchenko
  2020-11-16 16:59   ` Rafael J. Wysocki
  7 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2020-11-16 16:51 UTC (permalink / raw)
  To: linux-acpi, Greg Kroah-Hartman, linux-kernel
  Cc: Kuppuswamy Sathyanarayanan, Bjorn Helgaas, linux-pci

On Tue, Nov 03, 2020 at 10:45:03PM +0200, Andy Shevchenko wrote:
> Some users may want to use resource library to manage their own resources,
> besides existing users that open code union() and intersection()
> implementations.
> 
> Provide a generic API for wider use.

Greg, Rafael, if there is no further comments, can it be applied?

> Changelog v6:
> - added missed tags
> 
> Changelog v5:
> - added test cases (Greg)
> 
> Changelog v4:
> - added Rb tag (Rafael)
> - Cc'ed to LKML and Greg (Rafael)
> 
> Changelog v3:
> - rebased on top of v5.10-rc1
> - dropped upstreamed dependencies
> - added Rb tag to the last patch (Mika)

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 0/7] resource: introduce union(), intersection() API
  2020-11-16 16:51 ` [PATCH v6 0/7] resource: introduce union(), intersection() API Andy Shevchenko
@ 2020-11-16 16:59   ` Rafael J. Wysocki
  2020-11-17 17:08     ` Rafael J. Wysocki
  0 siblings, 1 reply; 11+ messages in thread
From: Rafael J. Wysocki @ 2020-11-16 16:59 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: ACPI Devel Maling List, Greg Kroah-Hartman,
	Linux Kernel Mailing List, Kuppuswamy Sathyanarayanan,
	Bjorn Helgaas, Linux PCI

On Mon, Nov 16, 2020 at 5:51 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Tue, Nov 03, 2020 at 10:45:03PM +0200, Andy Shevchenko wrote:
> > Some users may want to use resource library to manage their own resources,
> > besides existing users that open code union() and intersection()
> > implementations.
> >
> > Provide a generic API for wider use.
>
> Greg, Rafael, if there is no further comments, can it be applied?

I don't have any. so I can take this series if there are no concerns from Greg.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 0/7] resource: introduce union(), intersection() API
  2020-11-16 16:59   ` Rafael J. Wysocki
@ 2020-11-17 17:08     ` Rafael J. Wysocki
  0 siblings, 0 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2020-11-17 17:08 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Andy Shevchenko, ACPI Devel Maling List, Greg Kroah-Hartman,
	Linux Kernel Mailing List, Kuppuswamy Sathyanarayanan,
	Bjorn Helgaas, Linux PCI

On Mon, Nov 16, 2020 at 5:59 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> On Mon, Nov 16, 2020 at 5:51 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > On Tue, Nov 03, 2020 at 10:45:03PM +0200, Andy Shevchenko wrote:
> > > Some users may want to use resource library to manage their own resources,
> > > besides existing users that open code union() and intersection()
> > > implementations.
> > >
> > > Provide a generic API for wider use.
> >
> > Greg, Rafael, if there is no further comments, can it be applied?
>
> I don't have any. so I can take this series if there are no concerns from Greg.

No concerns mentioned, so applied as 5.11 material, thanks!

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-11-17 17:08 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-03 20:45 [PATCH v6 0/7] resource: introduce union(), intersection() API Andy Shevchenko
2020-11-03 20:45 ` [PATCH v6 1/7] resource: Simplify region_intersects() by reducing conditionals Andy Shevchenko
2020-11-03 20:45 ` [PATCH v6 2/7] resource: Group resource_overlaps() with other inline helpers Andy Shevchenko
2020-11-03 20:45 ` [PATCH v6 3/7] resource: Introduce resource_union() for overlapping resources Andy Shevchenko
2020-11-03 20:45 ` [PATCH v6 4/7] resource: Introduce resource_intersection() " Andy Shevchenko
2020-11-03 20:45 ` [PATCH v6 5/7] resource: Add test cases for new resource API Andy Shevchenko
2020-11-03 20:45 ` [PATCH v6 6/7] PCI/ACPI: Replace open coded variant of resource_union() Andy Shevchenko
2020-11-03 20:45 ` [PATCH v6 7/7] ACPI: watchdog: " Andy Shevchenko
2020-11-16 16:51 ` [PATCH v6 0/7] resource: introduce union(), intersection() API Andy Shevchenko
2020-11-16 16:59   ` Rafael J. Wysocki
2020-11-17 17:08     ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).