From patchwork Fri Oct 30 17:25:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 314224 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53D8CC5DF9D for ; Fri, 30 Oct 2020 17:26:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E3AA422263 for ; Fri, 30 Oct 2020 17:26:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726814AbgJ3R0I (ORCPT ); Fri, 30 Oct 2020 13:26:08 -0400 Received: from mga01.intel.com ([192.55.52.88]:15562 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726674AbgJ3R0G (ORCPT ); Fri, 30 Oct 2020 13:26:06 -0400 IronPort-SDR: ZyMLDwfreBVyQ3i4xHsTGNoEt9MV9xqm7oyPN5/84MhsvRZxQSpTxT5noK8ZOMB8KiyTM5oakk MCaL1GwHF3Ow== X-IronPort-AV: E=McAfee;i="6000,8403,9790"; a="186450273" X-IronPort-AV: E=Sophos;i="5.77,434,1596524400"; d="scan'208";a="186450273" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2020 10:26:05 -0700 IronPort-SDR: ZRfz/0t7Q76nTYzAiLW9NFgM31rMLPUU0W9C5gcRjF9sezjcfEl7M3Ghu7bvhEaxNsbYjbSj2d mmD4DDNP0ZMw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,434,1596524400"; d="scan'208";a="351935840" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 30 Oct 2020 10:26:04 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 639FB3CB; Fri, 30 Oct 2020 19:26:03 +0200 (EET) From: Andy Shevchenko To: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v3 2/6] resource: Group resource_overlaps() with other inline helpers Date: Fri, 30 Oct 2020 19:25:52 +0200 Message-Id: <20201030172556.21686-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201030172556.21686-1-andriy.shevchenko@linux.intel.com> References: <20201030172556.21686-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org For better maintenance group resource_overlaps() with other inline helpers. While at it, drop extra parentheses. Signed-off-by: Andy Shevchenko --- 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, From patchwork Fri Oct 30 17:25:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 314225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB0FBC56201 for ; Fri, 30 Oct 2020 17:26:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75C4420936 for ; Fri, 30 Oct 2020 17:26:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726704AbgJ3R0I (ORCPT ); Fri, 30 Oct 2020 13:26:08 -0400 Received: from mga06.intel.com ([134.134.136.31]:57807 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726814AbgJ3R0H (ORCPT ); Fri, 30 Oct 2020 13:26:07 -0400 IronPort-SDR: ndwxYtgZMSpMB/VPiZ0p/eeYX4KBJ8xeU8Y+mOmgn0ri+b/poid6Y/+BxzglACJfGZ9U0yVsyw dk66R9qeaQFg== X-IronPort-AV: E=McAfee;i="6000,8403,9790"; a="230276204" X-IronPort-AV: E=Sophos;i="5.77,434,1596524400"; d="scan'208";a="230276204" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2020 10:26:06 -0700 IronPort-SDR: PO9Rxe2POxWF8JKjpCzkqBGqSyYOm120Fdsm5hCO3NQFMgmgFT0/wVbXmYbf87NyIlpNH6flaA JduKGRCFqlgw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,434,1596524400"; d="scan'208";a="537135871" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 30 Oct 2020 10:26:04 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 79A83567; Fri, 30 Oct 2020 19:26:03 +0200 (EET) From: Andy Shevchenko To: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org Cc: Andy Shevchenko , Mika Westerberg , Kuppuswamy Sathyanarayanan , Bjorn Helgaas , linux-pci@vger.kernel.org Subject: [PATCH v3 3/6] resource: Introduce resource_union() for overlapping resources Date: Fri, 30 Oct 2020 19:25:53 +0200 Message-Id: <20201030172556.21686-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201030172556.21686-1-andriy.shevchenko@linux.intel.com> References: <20201030172556.21686-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 Cc: Mika Westerberg Cc: Kuppuswamy Sathyanarayanan Cc: Bjorn Helgaas 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 #include +#include #include -#include /* * 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) From patchwork Fri Oct 30 17:25:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 314226 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46333C4741F for ; Fri, 30 Oct 2020 17:26:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E798C208B6 for ; Fri, 30 Oct 2020 17:26:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726758AbgJ3R0G (ORCPT ); Fri, 30 Oct 2020 13:26:06 -0400 Received: from mga17.intel.com ([192.55.52.151]:49683 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726674AbgJ3R0F (ORCPT ); Fri, 30 Oct 2020 13:26:05 -0400 IronPort-SDR: qvAS1HWVHCwe0Vi/zWMjm/0nKqBPhtniyY4QsKZr3nth5c4tkbKmO0fDaGn4PD5Mw0WCMVzb7l Zg1n2hs84Lmw== X-IronPort-AV: E=McAfee;i="6000,8403,9790"; a="148495147" X-IronPort-AV: E=Sophos;i="5.77,434,1596524400"; d="scan'208";a="148495147" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2020 10:26:05 -0700 IronPort-SDR: 2aKRZ8RWwsakl6D6tiif2Vyas9OK7CnbS1qYfuCYHDw1KVxy/6brKIsmRYaUmHMlnRbskOQY2q gtcFDyZO26EA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,434,1596524400"; d="scan'208";a="356654231" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 30 Oct 2020 10:26:04 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7F5604E1; Fri, 30 Oct 2020 19:26:03 +0200 (EET) From: Andy Shevchenko To: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v3 4/6] resource: Introduce resource_intersection() for overlapping resources Date: Fri, 30 Oct 2020 19:25:54 +0200 Message-Id: <20201030172556.21686-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201030172556.21686-1-andriy.shevchenko@linux.intel.com> References: <20201030172556.21686-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 --- 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) { From patchwork Fri Oct 30 17:25:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 314223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BDA3C61DD8 for ; Fri, 30 Oct 2020 17:26:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 22B4A221EB for ; Fri, 30 Oct 2020 17:26:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726873AbgJ3R0J (ORCPT ); Fri, 30 Oct 2020 13:26:09 -0400 Received: from mga17.intel.com ([192.55.52.151]:49683 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726829AbgJ3R0I (ORCPT ); Fri, 30 Oct 2020 13:26:08 -0400 IronPort-SDR: XQx3ZIvQeCEAf9UqSLXoAkCNERzdkjRmhtdgXuO/V3wYjON6pUxItuob7YDR6oFn16K4SOnmcA 65oZAw8aBXuQ== X-IronPort-AV: E=McAfee;i="6000,8403,9790"; a="148495157" X-IronPort-AV: E=Sophos;i="5.77,434,1596524400"; d="scan'208";a="148495157" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2020 10:26:08 -0700 IronPort-SDR: /apKCsT+9wpagEK7jwAuqEGV/TBMTTXX+fbzyMLO5PvbKvq/XujP2y12yWTIxhg3GH1VJykpU4 Z2jfmUCO383w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,434,1596524400"; d="scan'208";a="356654239" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 30 Oct 2020 10:26:06 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9092E62E; Fri, 30 Oct 2020 19:26:03 +0200 (EET) From: Andy Shevchenko To: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org Cc: Andy Shevchenko , Kuppuswamy Sathyanarayanan , Bjorn Helgaas , linux-pci@vger.kernel.org, "Rafael J . Wysocki" Subject: [PATCH v3 5/6] PCI/ACPI: Replace open coded variant of resource_union() Date: Fri, 30 Oct 2020 19:25:55 +0200 Message-Id: <20201030172556.21686-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201030172556.21686-1-andriy.shevchenko@linux.intel.com> References: <20201030172556.21686-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Since we have resource_union() helper, let's utilize it here. Signed-off-by: Andy Shevchenko Cc: Kuppuswamy Sathyanarayanan Cc: Bjorn Helgaas Cc: linux-pci@vger.kernel.org Reviewed-by: Rafael J. Wysocki --- 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;