From patchwork Mon Aug 17 16:36:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 251750 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.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 C5B94C433DF for ; Mon, 17 Aug 2020 17:34:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A10702063A for ; Mon, 17 Aug 2020 17:34:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730936AbgHQReY (ORCPT ); Mon, 17 Aug 2020 13:34:24 -0400 Received: from mga06.intel.com ([134.134.136.31]:23627 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388854AbgHQQhR (ORCPT ); Mon, 17 Aug 2020 12:37:17 -0400 IronPort-SDR: q+rzcPlq90Auq/aRPLAqlDPeH5GJT3VVQz+mWjVNSDqeJKKzsh40NnKWiSgkCOSaD7WCgZTn4L Kl0jiT2yyU3Q== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="216269420" X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="216269420" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 09:36:50 -0700 IronPort-SDR: 6VDQ7tEzI4M1L/xzj1ckwh8odXomutyoBpGCJ9nkA6cYDqM3x0JDySAeufqtdAIucOWs7C+VAH M8OATdHytvbQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="296541466" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 17 Aug 2020 09:36:48 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id D68BA250; Mon, 17 Aug 2020 19:36:47 +0300 (EEST) 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 v2 4/8] resource: Introduce resource_union() for overlapping resources Date: Mon, 17 Aug 2020 19:36:43 +0300 Message-Id: <20200817163647.48982-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817163647.48982-1-andriy.shevchenko@linux.intel.com> References: <20200817163647.48982-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org 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 --- v2: reused min/max (Rafael) 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 50fed618d3fb..a7d50b9a3406 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.. @@ -232,6 +233,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 Mon Aug 17 16:36:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 251751 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.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 09112C433E3 for ; Mon, 17 Aug 2020 16:38:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E78462065C for ; Mon, 17 Aug 2020 16:38:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388847AbgHQQiD (ORCPT ); Mon, 17 Aug 2020 12:38:03 -0400 Received: from mga11.intel.com ([192.55.52.93]:33118 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731212AbgHQQhP (ORCPT ); Mon, 17 Aug 2020 12:37:15 -0400 IronPort-SDR: 4rqTdCYmMbAFQM9nC3KDgm6wQoHu5HiIhZfakyPPvfsgrtotPBgg0U7RVrTDUT4ZlFmsLlg8h1 gFcZXlqrVrVA== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="152384833" X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="152384833" 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; 17 Aug 2020 09:36:52 -0700 IronPort-SDR: 6B84GQZZDmQsQbfxOHVj8n4Yz9idpXy12F6Hy7YJvRdrQFvDlowwYcuIhI8weEl6kZY1ZL9rBf iGUpFh8h/qSA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="497066758" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 17 Aug 2020 09:36:48 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id DC1291C5; Mon, 17 Aug 2020 19:36:47 +0300 (EEST) From: Andy Shevchenko To: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v2 5/8] resource: Introduce resource_intersection() for overlapping resources Date: Mon, 17 Aug 2020 19:36:44 +0300 Message-Id: <20200817163647.48982-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817163647.48982-1-andriy.shevchenko@linux.intel.com> References: <20200817163647.48982-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org 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 --- v2: reused min/max (Rafael) include/linux/ioport.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index a7d50b9a3406..b4c3ca229f66 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -233,6 +233,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 Aug 17 16:36:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 251752 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.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 CA80CC433E4 for ; Mon, 17 Aug 2020 16:37:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B17B320657 for ; Mon, 17 Aug 2020 16:37:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731299AbgHQQhp (ORCPT ); Mon, 17 Aug 2020 12:37:45 -0400 Received: from mga01.intel.com ([192.55.52.88]:2967 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388847AbgHQQhK (ORCPT ); Mon, 17 Aug 2020 12:37:10 -0400 IronPort-SDR: 6OlzOGFZnoAUst3CeAnpwVOal1v5Lqhsf+q/TQ0iKMHg97eoZ7xZ0GcVkqioozHxUjzl9+mwEh FJgnWuu4XZFQ== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="172799206" X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="172799206" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 09:36:52 -0700 IronPort-SDR: ZSfQMmvkQMPsAOf5N3iev+gZGj4o7naOZRjW5QWMEF/1YIpOTmbdx1LIXiID4b7t3Gw4D1eCyt UrO7yJiY7V4g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="334125505" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 17 Aug 2020 09:36:50 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 01131456; Mon, 17 Aug 2020 19:36:47 +0300 (EEST) 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 Subject: [PATCH v2 7/8] PCI/ACPI: Fix description of @handle for acpi_is_root_bridge() Date: Mon, 17 Aug 2020 19:36:46 +0300 Message-Id: <20200817163647.48982-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817163647.48982-1-andriy.shevchenko@linux.intel.com> References: <20200817163647.48982-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Fix description of handle parameter in documentation of acpi_is_root_bridge(). Otherwise we get the following warning: CHECK drivers/acpi/pci_root.c drivers/acpi/pci_root.c:71: warning: Function parameter or member 'handle' not described in 'acpi_is_root_bridge' Signed-off-by: Andy Shevchenko Cc: Kuppuswamy Sathyanarayanan Cc: Bjorn Helgaas Cc: linux-pci@vger.kernel.org --- v2: left in the series, but maintainers still may apply it separately drivers/acpi/pci_root.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 2a6a741896de..f723679954d7 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -62,7 +62,7 @@ static DEFINE_MUTEX(osc_lock); /** * acpi_is_root_bridge - determine whether an ACPI CA node is a PCI root bridge - * @handle - the ACPI CA node in question. + * @handle: the ACPI CA node in question. * * Note: we could make this API take a struct acpi_device * instead, but * for now, it's more convenient to operate on an acpi_handle.