From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rafael J. Wysocki" Subject: Re: [PATCH V7 05/11] acpi, pci: Support IO resources when parsing PCI host bridge resources. Date: Tue, 10 May 2016 20:20:32 +0200 Message-ID: References: <1462893601-8937-1-git-send-email-tn@semihalf.com> <1462893601-8937-6-git-send-email-tn@semihalf.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: In-Reply-To: <1462893601-8937-6-git-send-email-tn@semihalf.com> Sender: linux-kernel-owner@vger.kernel.org To: Tomasz Nowicki Cc: Bjorn Helgaas , Arnd Bergmann , Will Deacon , Catalin Marinas , "Rafael J. Wysocki" , Hanjun Guo , Lorenzo Pieralisi , Sinan Kaya , jchandra@broadcom.com, robert.richter@caviumnetworks.com, mw@semihalf.com, Liviu.Dudau@arm.com, David Daney , wangyijing@huawei.com, Suravee Suthikulanit , Mark Salter , Linux PCI , "linux-arm-kernel@lists.infradead.org" , ACPI Devel Maling List , Linux Kernel Mailing List , "linaro-acpi@lists.linaro.org" , Jon Masters and List-Id: linux-acpi@vger.kernel.org On Tue, May 10, 2016 at 5:19 PM, Tomasz Nowicki wrote: > Platforms that have memory mapped IO port (such as ARM64) need special > handling for PCI I/O resources. For host bridge's resource probing case > these resources need to be fixed up with pci_register_io_range/pci_remap_iospace etc. > > The same I/O resources need to be released after hotplug > removal so that it can be re-added back by the pci_remap_iospace > function during insertion. As a consequence we unmap I/O resources > with pci_unmap_iospace when we release host bridge resources. > > Signed-off-by: Jayachandran C > Signed-off-by: Sinan Kaya > Signed-off-by: Tomasz Nowicki > --- > drivers/acpi/pci_root.c | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c > index ae3fe4e..cb3071d 100644 > --- a/drivers/acpi/pci_root.c > +++ b/drivers/acpi/pci_root.c > @@ -719,6 +719,34 @@ next: > resource_list_add_tail(entry, resources); > } > } > +static void acpi_pci_root_remap_iospace(struct resource_entry *entry) > +{ > +#ifdef PCI_IOBASE Same comment about the #ifdefs as in the other patch. > + struct resource *res = entry->res; > + resource_size_t cpu_addr = res->start; > + resource_size_t pci_addr = cpu_addr - entry->offset; > + resource_size_t length = resource_size(res); > + unsigned long port; > + > + if (pci_register_io_range(cpu_addr, length)) > + goto err; > + > + port = pci_address_to_pio(cpu_addr); > + if (port == (unsigned long)-1) > + goto err; > + > + res->start = port; > + res->end = port + length - 1; > + entry->offset = port - pci_addr; > + > + if (pci_remap_iospace(res, cpu_addr) < 0) > + goto err; An empty line here? > + pr_info("Remapped I/O %pa to %pR\n", &cpu_addr, res); > + return; > +err: > + res->flags |= IORESOURCE_DISABLED; > +#endif > +} > > int acpi_pci_probe_root_resources(struct acpi_pci_root_info *info) > { > @@ -740,6 +768,9 @@ int acpi_pci_probe_root_resources(struct acpi_pci_root_info *info) > "no IO and memory resources present in _CRS\n"); > else { > resource_list_for_each_entry_safe(entry, tmp, list) { > + if (entry->res->flags & IORESOURCE_IO) > + acpi_pci_root_remap_iospace(entry); > + > if (entry->res->flags & IORESOURCE_DISABLED) > resource_list_destroy_entry(entry); > else > @@ -811,6 +842,8 @@ static void acpi_pci_root_release_info(struct pci_host_bridge *bridge) > > resource_list_for_each_entry(entry, &bridge->windows) { > res = entry->res; > + if (res->flags & IORESOURCE_IO) > + pci_unmap_iospace(res); > if (res->parent && > (res->flags & (IORESOURCE_MEM | IORESOURCE_IO))) > release_resource(res); > -- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752155AbcEJSUg (ORCPT ); Tue, 10 May 2016 14:20:36 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36788 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751812AbcEJSUe (ORCPT ); Tue, 10 May 2016 14:20:34 -0400 MIME-Version: 1.0 In-Reply-To: <1462893601-8937-6-git-send-email-tn@semihalf.com> References: <1462893601-8937-1-git-send-email-tn@semihalf.com> <1462893601-8937-6-git-send-email-tn@semihalf.com> Date: Tue, 10 May 2016 20:20:32 +0200 X-Google-Sender-Auth: gHGaPHZRhjOybinh8qgy8UbQRP8 Message-ID: Subject: Re: [PATCH V7 05/11] acpi, pci: Support IO resources when parsing PCI host bridge resources. From: "Rafael J. Wysocki" To: Tomasz Nowicki Cc: Bjorn Helgaas , Arnd Bergmann , Will Deacon , Catalin Marinas , "Rafael J. Wysocki" , Hanjun Guo , Lorenzo Pieralisi , Sinan Kaya , jchandra@broadcom.com, robert.richter@caviumnetworks.com, mw@semihalf.com, Liviu.Dudau@arm.com, David Daney , wangyijing@huawei.com, Suravee Suthikulanit , Mark Salter , Linux PCI , "linux-arm-kernel@lists.infradead.org" , ACPI Devel Maling List , Linux Kernel Mailing List , "linaro-acpi@lists.linaro.org" , Jon Masters , andrea.gallo@linaro.org, dhdang@apm.com, jeremy.linton@arm.com, liudongdong3@huawei.com, Christopher Covington Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 10, 2016 at 5:19 PM, Tomasz Nowicki wrote: > Platforms that have memory mapped IO port (such as ARM64) need special > handling for PCI I/O resources. For host bridge's resource probing case > these resources need to be fixed up with pci_register_io_range/pci_remap_iospace etc. > > The same I/O resources need to be released after hotplug > removal so that it can be re-added back by the pci_remap_iospace > function during insertion. As a consequence we unmap I/O resources > with pci_unmap_iospace when we release host bridge resources. > > Signed-off-by: Jayachandran C > Signed-off-by: Sinan Kaya > Signed-off-by: Tomasz Nowicki > --- > drivers/acpi/pci_root.c | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c > index ae3fe4e..cb3071d 100644 > --- a/drivers/acpi/pci_root.c > +++ b/drivers/acpi/pci_root.c > @@ -719,6 +719,34 @@ next: > resource_list_add_tail(entry, resources); > } > } > +static void acpi_pci_root_remap_iospace(struct resource_entry *entry) > +{ > +#ifdef PCI_IOBASE Same comment about the #ifdefs as in the other patch. > + struct resource *res = entry->res; > + resource_size_t cpu_addr = res->start; > + resource_size_t pci_addr = cpu_addr - entry->offset; > + resource_size_t length = resource_size(res); > + unsigned long port; > + > + if (pci_register_io_range(cpu_addr, length)) > + goto err; > + > + port = pci_address_to_pio(cpu_addr); > + if (port == (unsigned long)-1) > + goto err; > + > + res->start = port; > + res->end = port + length - 1; > + entry->offset = port - pci_addr; > + > + if (pci_remap_iospace(res, cpu_addr) < 0) > + goto err; An empty line here? > + pr_info("Remapped I/O %pa to %pR\n", &cpu_addr, res); > + return; > +err: > + res->flags |= IORESOURCE_DISABLED; > +#endif > +} > > int acpi_pci_probe_root_resources(struct acpi_pci_root_info *info) > { > @@ -740,6 +768,9 @@ int acpi_pci_probe_root_resources(struct acpi_pci_root_info *info) > "no IO and memory resources present in _CRS\n"); > else { > resource_list_for_each_entry_safe(entry, tmp, list) { > + if (entry->res->flags & IORESOURCE_IO) > + acpi_pci_root_remap_iospace(entry); > + > if (entry->res->flags & IORESOURCE_DISABLED) > resource_list_destroy_entry(entry); > else > @@ -811,6 +842,8 @@ static void acpi_pci_root_release_info(struct pci_host_bridge *bridge) > > resource_list_for_each_entry(entry, &bridge->windows) { > res = entry->res; > + if (res->flags & IORESOURCE_IO) > + pci_unmap_iospace(res); > if (res->parent && > (res->flags & (IORESOURCE_MEM | IORESOURCE_IO))) > release_resource(res); > -- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Return-Path: MIME-Version: 1.0 Sender: rjwysocki@gmail.com In-Reply-To: <1462893601-8937-6-git-send-email-tn@semihalf.com> References: <1462893601-8937-1-git-send-email-tn@semihalf.com> <1462893601-8937-6-git-send-email-tn@semihalf.com> Date: Tue, 10 May 2016 20:20:32 +0200 Message-ID: Subject: Re: [PATCH V7 05/11] acpi, pci: Support IO resources when parsing PCI host bridge resources. From: "Rafael J. Wysocki" To: Tomasz Nowicki Cc: Bjorn Helgaas , Arnd Bergmann , Will Deacon , Catalin Marinas , "Rafael J. Wysocki" , Hanjun Guo , Lorenzo Pieralisi , Sinan Kaya , jchandra@broadcom.com, robert.richter@caviumnetworks.com, mw@semihalf.com, Liviu.Dudau@arm.com, David Daney , wangyijing@huawei.com, Suravee Suthikulanit , Mark Salter , Linux PCI , "linux-arm-kernel@lists.infradead.org" , ACPI Devel Maling List , Linux Kernel Mailing List , "linaro-acpi@lists.linaro.org" , Jon Masters , andrea.gallo@linaro.org, dhdang@apm.com, jeremy.linton@arm.com, liudongdong3@huawei.com, Christopher Covington Content-Type: text/plain; charset=UTF-8 List-ID: On Tue, May 10, 2016 at 5:19 PM, Tomasz Nowicki wrote: > Platforms that have memory mapped IO port (such as ARM64) need special > handling for PCI I/O resources. For host bridge's resource probing case > these resources need to be fixed up with pci_register_io_range/pci_remap_iospace etc. > > The same I/O resources need to be released after hotplug > removal so that it can be re-added back by the pci_remap_iospace > function during insertion. As a consequence we unmap I/O resources > with pci_unmap_iospace when we release host bridge resources. > > Signed-off-by: Jayachandran C > Signed-off-by: Sinan Kaya > Signed-off-by: Tomasz Nowicki > --- > drivers/acpi/pci_root.c | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c > index ae3fe4e..cb3071d 100644 > --- a/drivers/acpi/pci_root.c > +++ b/drivers/acpi/pci_root.c > @@ -719,6 +719,34 @@ next: > resource_list_add_tail(entry, resources); > } > } > +static void acpi_pci_root_remap_iospace(struct resource_entry *entry) > +{ > +#ifdef PCI_IOBASE Same comment about the #ifdefs as in the other patch. > + struct resource *res = entry->res; > + resource_size_t cpu_addr = res->start; > + resource_size_t pci_addr = cpu_addr - entry->offset; > + resource_size_t length = resource_size(res); > + unsigned long port; > + > + if (pci_register_io_range(cpu_addr, length)) > + goto err; > + > + port = pci_address_to_pio(cpu_addr); > + if (port == (unsigned long)-1) > + goto err; > + > + res->start = port; > + res->end = port + length - 1; > + entry->offset = port - pci_addr; > + > + if (pci_remap_iospace(res, cpu_addr) < 0) > + goto err; An empty line here? > + pr_info("Remapped I/O %pa to %pR\n", &cpu_addr, res); > + return; > +err: > + res->flags |= IORESOURCE_DISABLED; > +#endif > +} > > int acpi_pci_probe_root_resources(struct acpi_pci_root_info *info) > { > @@ -740,6 +768,9 @@ int acpi_pci_probe_root_resources(struct acpi_pci_root_info *info) > "no IO and memory resources present in _CRS\n"); > else { > resource_list_for_each_entry_safe(entry, tmp, list) { > + if (entry->res->flags & IORESOURCE_IO) > + acpi_pci_root_remap_iospace(entry); > + > if (entry->res->flags & IORESOURCE_DISABLED) > resource_list_destroy_entry(entry); > else > @@ -811,6 +842,8 @@ static void acpi_pci_root_release_info(struct pci_host_bridge *bridge) > > resource_list_for_each_entry(entry, &bridge->windows) { > res = entry->res; > + if (res->flags & IORESOURCE_IO) > + pci_unmap_iospace(res); > if (res->parent && > (res->flags & (IORESOURCE_MEM | IORESOURCE_IO))) > release_resource(res); > -- From mboxrd@z Thu Jan 1 00:00:00 1970 From: rafael@kernel.org (Rafael J. Wysocki) Date: Tue, 10 May 2016 20:20:32 +0200 Subject: [PATCH V7 05/11] acpi, pci: Support IO resources when parsing PCI host bridge resources. In-Reply-To: <1462893601-8937-6-git-send-email-tn@semihalf.com> References: <1462893601-8937-1-git-send-email-tn@semihalf.com> <1462893601-8937-6-git-send-email-tn@semihalf.com> Message-ID: To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Tue, May 10, 2016 at 5:19 PM, Tomasz Nowicki wrote: > Platforms that have memory mapped IO port (such as ARM64) need special > handling for PCI I/O resources. For host bridge's resource probing case > these resources need to be fixed up with pci_register_io_range/pci_remap_iospace etc. > > The same I/O resources need to be released after hotplug > removal so that it can be re-added back by the pci_remap_iospace > function during insertion. As a consequence we unmap I/O resources > with pci_unmap_iospace when we release host bridge resources. > > Signed-off-by: Jayachandran C > Signed-off-by: Sinan Kaya > Signed-off-by: Tomasz Nowicki > --- > drivers/acpi/pci_root.c | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c > index ae3fe4e..cb3071d 100644 > --- a/drivers/acpi/pci_root.c > +++ b/drivers/acpi/pci_root.c > @@ -719,6 +719,34 @@ next: > resource_list_add_tail(entry, resources); > } > } > +static void acpi_pci_root_remap_iospace(struct resource_entry *entry) > +{ > +#ifdef PCI_IOBASE Same comment about the #ifdefs as in the other patch. > + struct resource *res = entry->res; > + resource_size_t cpu_addr = res->start; > + resource_size_t pci_addr = cpu_addr - entry->offset; > + resource_size_t length = resource_size(res); > + unsigned long port; > + > + if (pci_register_io_range(cpu_addr, length)) > + goto err; > + > + port = pci_address_to_pio(cpu_addr); > + if (port == (unsigned long)-1) > + goto err; > + > + res->start = port; > + res->end = port + length - 1; > + entry->offset = port - pci_addr; > + > + if (pci_remap_iospace(res, cpu_addr) < 0) > + goto err; An empty line here? > + pr_info("Remapped I/O %pa to %pR\n", &cpu_addr, res); > + return; > +err: > + res->flags |= IORESOURCE_DISABLED; > +#endif > +} > > int acpi_pci_probe_root_resources(struct acpi_pci_root_info *info) > { > @@ -740,6 +768,9 @@ int acpi_pci_probe_root_resources(struct acpi_pci_root_info *info) > "no IO and memory resources present in _CRS\n"); > else { > resource_list_for_each_entry_safe(entry, tmp, list) { > + if (entry->res->flags & IORESOURCE_IO) > + acpi_pci_root_remap_iospace(entry); > + > if (entry->res->flags & IORESOURCE_DISABLED) > resource_list_destroy_entry(entry); > else > @@ -811,6 +842,8 @@ static void acpi_pci_root_release_info(struct pci_host_bridge *bridge) > > resource_list_for_each_entry(entry, &bridge->windows) { > res = entry->res; > + if (res->flags & IORESOURCE_IO) > + pci_unmap_iospace(res); > if (res->parent && > (res->flags & (IORESOURCE_MEM | IORESOURCE_IO))) > release_resource(res); > --