From patchwork Mon Nov 2 21:00:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 314219 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 BDA65C55179 for ; Mon, 2 Nov 2020 21:00:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7631A206E5 for ; Mon, 2 Nov 2020 21:00:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727035AbgKBVAn (ORCPT ); Mon, 2 Nov 2020 16:00:43 -0500 Received: from mga07.intel.com ([134.134.136.100]:25781 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726392AbgKBVA3 (ORCPT ); Mon, 2 Nov 2020 16:00:29 -0500 IronPort-SDR: Sdn5DtlSGsZrvAHR6NIgr0aj+KiZukDZandxJO0hW1YOLpymdI7S4V90n77FNMwt/EmIKqU5BC DEPQ5ndeY0GA== X-IronPort-AV: E=McAfee;i="6000,8403,9793"; a="233120541" X-IronPort-AV: E=Sophos;i="5.77,445,1596524400"; d="scan'208";a="233120541" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2020 13:00:28 -0800 IronPort-SDR: vS8xqHfsrKqzXlMcO8TTympxFHvz47n5wdMNdurV9Cr8dn8P4g9bc92+N2GvEBvDhD/Sjx8ZUW Ag04ouSDt+CA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,445,1596524400"; d="scan'208";a="362734814" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 02 Nov 2020 13:00:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id C537E15C; Mon, 2 Nov 2020 23:00:25 +0200 (EET) From: Andy Shevchenko To: linux-acpi@vger.kernel.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: Andy Shevchenko , "Rafael J . Wysocki" Subject: [PATCH v4 2/6] resource: Group resource_overlaps() with other inline helpers Date: Mon, 2 Nov 2020 23:00:21 +0200 Message-Id: <20201102210025.53520-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201102210025.53520-1-andriy.shevchenko@linux.intel.com> References: <20201102210025.53520-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 Reviewed-by: Rafael J. Wysocki --- 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 Mon Nov 2 21:00:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 314221 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 8435AC00A89 for ; Mon, 2 Nov 2020 21:00:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C804206E5 for ; Mon, 2 Nov 2020 21:00:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726020AbgKBVA2 (ORCPT ); Mon, 2 Nov 2020 16:00:28 -0500 Received: from mga11.intel.com ([192.55.52.93]:8786 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725833AbgKBVA2 (ORCPT ); Mon, 2 Nov 2020 16:00:28 -0500 IronPort-SDR: wsbWtstLOXIsb/9eK2/qbFyOW4dMBISPZmP1Z1wCCPLCMFWihMltnj/UcxWBlhf2uErGuC480e BjElN+l495kg== X-IronPort-AV: E=McAfee;i="6000,8403,9793"; a="165447779" X-IronPort-AV: E=Sophos;i="5.77,445,1596524400"; d="scan'208";a="165447779" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2020 13:00:28 -0800 IronPort-SDR: gQDYPevJNS+SGJ8mq5x5nTjbq+NHjMkijqCS9Bf8bisOr63vpCkwqIafRc2tulGA8LnDm9UhSw RP8CKe+y3iLg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,445,1596524400"; d="scan'208";a="528149404" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 02 Nov 2020 13:00:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id DC8691F5; Mon, 2 Nov 2020 23:00:25 +0200 (EET) From: Andy Shevchenko To: linux-acpi@vger.kernel.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: Andy Shevchenko , "Rafael J . Wysocki" Subject: [PATCH v4 4/6] resource: Introduce resource_intersection() for overlapping resources Date: Mon, 2 Nov 2020 23:00:23 +0200 Message-Id: <20201102210025.53520-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201102210025.53520-1-andriy.shevchenko@linux.intel.com> References: <20201102210025.53520-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 Reviewed-by: Rafael J. Wysocki --- 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 Mon Nov 2 21:00:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 314220 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 2BB7EC2D0A3 for ; Mon, 2 Nov 2020 21:00:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA10922226 for ; Mon, 2 Nov 2020 21:00:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726908AbgKBVAg (ORCPT ); Mon, 2 Nov 2020 16:00:36 -0500 Received: from mga11.intel.com ([192.55.52.93]:8786 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726716AbgKBVAb (ORCPT ); Mon, 2 Nov 2020 16:00:31 -0500 IronPort-SDR: +O3J0qmVF0SMSNy2fe91eTl/i22wH0M5eU/aRZbfNap+XBb3QlgNLhRC/S2cR9hopwgV/na686 xKkEg0YLHjDQ== X-IronPort-AV: E=McAfee;i="6000,8403,9793"; a="165447790" X-IronPort-AV: E=Sophos;i="5.77,445,1596524400"; d="scan'208";a="165447790" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2020 13:00:31 -0800 IronPort-SDR: Yii/02bBfKzSq3bo1yCcMeTlHF/iSIF+Gdq8xsrnGcuyjWgzNPIkSinklZpGQQz2m+MMoaDXDV wKxkctbOD3SQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,445,1596524400"; d="scan'208";a="396323989" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 02 Nov 2020 13:00:28 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id E674F357; Mon, 2 Nov 2020 23:00:25 +0200 (EET) From: Andy Shevchenko To: linux-acpi@vger.kernel.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Kuppuswamy Sathyanarayanan , Bjorn Helgaas , linux-pci@vger.kernel.org, "Rafael J . Wysocki" Subject: [PATCH v4 5/6] PCI/ACPI: Replace open coded variant of resource_union() Date: Mon, 2 Nov 2020 23:00:24 +0200 Message-Id: <20201102210025.53520-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201102210025.53520-1-andriy.shevchenko@linux.intel.com> References: <20201102210025.53520-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 Reviewed-by: Kuppuswamy Sathyanarayanan --- 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;