From: Marc Zyngier <marc.zyngier@arm.com>
To: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Len Brown <lenb@kernel.org>,
"hanjun.guo@linaro.org" <hanjun.guo@linaro.org>,
Tomasz Nowicki <tn@semihalf.com>,
Thomas Gleixner <tglx@linutronix.de>,
Jason Cooper <jason@lakedaemon.net>,
Sudeep Holla <Sudeep.Holla@arm.com>,
Will Deacon <Will.Deacon@arm.com>,
Catalin Marinas <Catalin.Marinas@arm.com>,
"linaro-acpi@lists.linaro.org" <linaro-acpi@lists.linaro.org>,
"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
msalter@redhat.com
Subject: Re: [PATCH 1/5] acpi: Add basic device probing infrastructure
Date: Mon, 07 Sep 2015 18:35:52 +0100 [thread overview]
Message-ID: <55EDCAF8.6080605@arm.com> (raw)
In-Reply-To: <20150907160045.GC29293@red-moon>
On 07/09/15 17:00, Lorenzo Pieralisi wrote:
> [+M.Salter]
>
> On Fri, Sep 04, 2015 at 06:06:48PM +0100, Marc Zyngier wrote:
>> IRQ controllers and timers are the two types of device the kernel
>> requires before being able to use the device driver model.
>>
>> ACPI so far lacks a proper probing infrastructure similar to the one
>> we have with DT, where we're able to declare IRQ chips and
>> clocksources inside the driver code, and let the core code pick it up
>> and call us back on a match. This leads to all kind of really ugly
>> hacks all over the arm64 code and even in the ACPI layer.
>>
>> In order to allow some basic probing based on the ACPI tables,
>> introduce "struct acpi_probe_entry" which contains just enough
>> data and callbacks to match a table, an optional subtable, and
>> call a probe function. A driver can, at build time, register itself
>> and expect being called if the right entry exists in the ACPI
>> table.
>>
>> A acpi_probe_device_init() is provided, taking an ACPI table
>> identifier, and iterating over the registered entries.
>>
>> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
>> ---
>> drivers/acpi/scan.c | 41 ++++++++++++++++++++++++++++
>> include/asm-generic/vmlinux.lds.h | 11 ++++++++
>> include/linux/acpi.h | 56 +++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 108 insertions(+)
>>
>> diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
>> index ec25635..9e920ec 100644
>> --- a/drivers/acpi/scan.c
>> +++ b/drivers/acpi/scan.c
>> @@ -2793,3 +2793,44 @@ int __init acpi_scan_init(void)
>> mutex_unlock(&acpi_scan_lock);
>> return result;
>> }
>> +
>> +static const struct acpi_probe_entry device_acpi_probe_end
>> + __used __section(__device_acpi_probe_table_end);
>> +extern struct acpi_probe_entry __device_acpi_probe_table[];
>> +static struct acpi_probe_entry *ape;
>> +static int acpi_probe_count;
>> +static DEFINE_SPINLOCK(acpi_probe_lock);
>> +
>> +static int __init acpi_match_madt(struct acpi_subtable_header *header,
>> + const unsigned long end)
>> +{
>> + if (!ape->validate_subtbl || ape->validate_subtbl(header, ape))
>> + if (!ape->probe_subtbl(header, end))
>> + acpi_probe_count++;
>> +
>> + return 0;
>> +}
>> +
>> +int __init acpi_probe_device_table(const char *id)
>> +{
>> + int count = 0;
>> +
>> + if (acpi_disabled)
>> + return 0;
>> +
>> + spin_lock(&acpi_probe_lock);
>> + for (ape = __device_acpi_probe_table; ape->probe_table; ape++) {
>> + if (!ACPI_COMPARE_NAME(id, ape->id))
>> + continue;
>> + if (ACPI_COMPARE_NAME(ACPI_SIG_MADT, ape->id)) {
>> + acpi_probe_count = 0;
>> + acpi_table_parse_madt(ape->type, acpi_match_madt, 0);
>> + count += acpi_probe_count;
>> + } else {
>> + count = acpi_table_parse(ape->id, ape->probe_table);
>> + }
>> + }
>> + spin_unlock(&acpi_probe_lock);
>> +
>> + return count;
>> +}
>
> We should add a mechanism to prevent re-parsing the same entries
> multiple times (in case this function is called with the same
> signature multiple times). We could create a separate table of device
> entries, per-subsystem, that we want to parse (irqchip specific table,
> timers, etc.) instead of adding all the devices to the same table (ie
> linker section), you can do this already with the current patchset by
> just choosing different table names as DT does.
Yeah, my initial approach was to have multiple tables, but I ended up
deciding against it because nothing required it so far, and I wanted to
avoid the over-engineered syndrome.
Also, it could be useful to flag entries that have been successfully
probed to ensure we don't try them again. Though having separate tables
would probably greatly reduce the usefulness of this.
> We may also want to extend this set so that it can be used to parse the
> same table, same subtype multiple times at different stages in the boot
> path (but let's first see if it is a) really needed b) feasible).
>
> Basically it is to avoid parsing the MADT multiple times:
> http://lists.infradead.org/pipermail/linux-arm-kernel/2015-May/340267.html
>
> Those can be extensions to the current patchset (because basically
> they are not real issues at present), it is just a heads-up.
I'll see if I can whip that up by the end of the week - the PMU stuff is
definitely interesting.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2015-09-07 17:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-04 17:06 [PATCH 0/5] ACPI probing infrastructure Marc Zyngier
2015-09-04 17:06 ` [PATCH 1/5] acpi: Add basic device " Marc Zyngier
2015-09-07 16:00 ` Lorenzo Pieralisi
2015-09-07 17:35 ` Marc Zyngier [this message]
2015-09-07 21:29 ` Rafael J. Wysocki
2015-09-08 9:57 ` Marc Zyngier
2015-09-08 13:01 ` Hanjun Guo
2015-09-04 17:06 ` [PATCH 2/5] irqchip/acpi: Add probing infrastructure for ACPI-based irqchips Marc Zyngier
2015-09-04 17:06 ` [PATCH 3/5] irqchip/gic: Convert the GIC driver to ACPI probing Marc Zyngier
2015-09-04 17:06 ` [PATCH 4/5] clocksource/acpi: Add probing infrastructure for ACPI-based clocksources Marc Zyngier
2015-09-04 17:06 ` [PATCH 5/5] clocksource/arm_arch_timer: Convert to ACPI probing Marc Zyngier
2015-09-07 6:58 ` [PATCH 0/5] ACPI probing infrastructure Tomasz Nowicki
2015-09-08 14:38 ` Tomasz Nowicki
2015-09-07 21:26 ` Rafael J. Wysocki
2015-09-08 9:45 ` Marc Zyngier
2015-09-08 22:26 ` Rafael J. Wysocki
2015-09-08 13:19 ` Hanjun Guo
2015-09-10 9:03 ` Hanjun Guo
2015-09-11 14:06 ` Marc Zyngier
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=55EDCAF8.6080605@arm.com \
--to=marc.zyngier@arm.com \
--cc=Catalin.Marinas@arm.com \
--cc=Sudeep.Holla@arm.com \
--cc=Will.Deacon@arm.com \
--cc=hanjun.guo@linaro.org \
--cc=jason@lakedaemon.net \
--cc=lenb@kernel.org \
--cc=linaro-acpi@lists.linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=msalter@redhat.com \
--cc=rjw@rjwysocki.net \
--cc=tglx@linutronix.de \
--cc=tn@semihalf.com \
/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;
as well as URLs for NNTP newsgroup(s).