From: Miao Wang <shankerwangmiao@gmail.com>
To: "Bjorn Helgaas" <helgaas@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Len Brown" <lenb@kernel.org>
Cc: linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH v3] ACPI: PCI: check if the root io space is page aligned
Date: Thu, 21 Nov 2024 23:01:00 +0800 [thread overview]
Message-ID: <C557A80A-0242-4D80-AE68-B21BCDB824AE@gmail.com> (raw)
In-Reply-To: <9CBE412E-25B3-4C36-80F6-5EA9248B9085@gmail.com>
> It seems that there is no reply from linux-mm about this. I believe even if
> there might be a better place for the mm subsystem to check the alignment,
> it is still necessary to do the check here, because details about which ACPI
> entry is causing the problem is only available here. If in the future, we would
> developed another better place to do the alignment check, we may refactor the
> code here.
Hi, all
Ping on this patch.
>
>>>>
>>>>> Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
>>>>> ---
>>>>> Changes in v3:
>>>>> - Adjust code formatting.
>>>>> - Reword the commit message for further description of the possible reason
>>>>> leading to misaligned IO resource addresses.
>>>>> - Link to v2: https://lore.kernel.org/r/20240814-check_pci_probe_res-v2-1-a03c8c9b498b@gmail.com
>>>>>
>>>>> Changes in v2:
>>>>> - Sorry for posting out the draft version in V1, fixed a silly compiling issue.
>>>>> - Link to v1: https://lore.kernel.org/r/20240814-check_pci_probe_res-v1-1-122ee07821ab@gmail.com
>>>>> ---
>>>>> drivers/acpi/pci_root.c | 14 +++++++++++---
>>>>> 1 file changed, 11 insertions(+), 3 deletions(-)
>>>>>
>>>>> diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
>>>>> index d0bfb3706801..a425e93024f2 100644
>>>>> --- a/drivers/acpi/pci_root.c
>>>>> +++ b/drivers/acpi/pci_root.c
>>>>> @@ -858,7 +858,7 @@ static void acpi_pci_root_validate_resources(struct device *dev,
>>>>> }
>>>>> }
>>>>>
>>>>> -static void acpi_pci_root_remap_iospace(struct fwnode_handle *fwnode,
>>>>> +static void acpi_pci_root_remap_iospace(struct acpi_device *device,
>>>>> struct resource_entry *entry)
>>>>> {
>>>>> #ifdef PCI_IOBASE
>>>>> @@ -868,7 +868,15 @@ static void acpi_pci_root_remap_iospace(struct fwnode_handle *fwnode,
>>>>> resource_size_t length = resource_size(res);
>>>>> unsigned long port;
>>>>>
>>>>> - if (pci_register_io_range(fwnode, cpu_addr, length))
>>>>> + if (!PAGE_ALIGNED(cpu_addr) || !PAGE_ALIGNED(length) ||
>>>>> + !PAGE_ALIGNED(pci_addr)) {
>>>>> + dev_err(&device->dev,
>>>>> + FW_BUG "I/O resource %pR or its offset %pa is not page aligned\n",
>>>>> + res, &entry->offset);
>>>>> + goto err;
>>>>> + }
>>>>> +
>>>>> + if (pci_register_io_range(&device->fwnode, cpu_addr, length))
>>>>> goto err;
>>>>
>>>> This change verifies alignment for the ACPI case that leads to the
>>>> pci_remap_iospace() -> vmap_page_range() -> vmap_pte_range() path, but
>>>> there are others even in drivers/pci/, e.g., pci_remap_iospace() is
>>>> also used in the DT path, where I suppose a defective DT could cause a
>>>> similar issue.
>>>>
>>>>> port = pci_address_to_pio(cpu_addr);
>>>>> @@ -910,7 +918,7 @@ int acpi_pci_probe_root_resources(struct acpi_pci_root_info *info)
>>>>> else {
>>>>> resource_list_for_each_entry_safe(entry, tmp, list) {
>>>>> if (entry->res->flags & IORESOURCE_IO)
>>>>> - acpi_pci_root_remap_iospace(&device->fwnode,
>>>>> + acpi_pci_root_remap_iospace(device,
>>>>> entry);
>>>>>
>>>>> if (entry->res->flags & IORESOURCE_DISABLED)
>>>>>
>>>>> ---
>>>>> base-commit: 7c626ce4bae1ac14f60076d00eafe71af30450ba
>>>>> change-id: 20240813-check_pci_probe_res-27e3e6df72b2
>>>>>
>>>>> Best regards,
>>>>> --
>>>>> Miao Wang <shankerwangmiao@gmail.com>
prev parent reply other threads:[~2024-11-21 15:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240814-check_pci_probe_res-v3-1-b6eaa6f99032@gmail.com>
2024-08-14 16:37 ` Bjorn Helgaas
2024-08-15 4:28 ` Miao Wang
2024-08-21 4:43 ` Miao Wang
2024-09-18 17:14 ` Miao Wang
2024-11-21 15:01 ` Miao Wang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=C557A80A-0242-4D80-AE68-B21BCDB824AE@gmail.com \
--to=shankerwangmiao@gmail.com \
--cc=bhelgaas@google.com \
--cc=helgaas@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-pci@vger.kernel.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox