public inbox for linux-watchdog@vger.kernel.org
 help / color / mirror / Atom feed
From: Timur Tabi <timur@codeaurora.org>
To: Guenter Roeck <linux@roeck-us.net>
Cc: linux-watchdog@vger.kernel.org,
	Ashwin Chaugule <ashwin.chaugule@linaro.org>,
	Vipul Gandhi <vgandhi@codeaurora.org>, Fu Wei <fu.wei@linaro.org>,
	Al Stone <al.stone@linaro.org>, Wim Van Sebroeck <wim@iguana.be>,
	Hanjun Guo <hanjun.guo@linaro.org>,
	linaro-acpi@lists.linaro.org
Subject: Re: [PATCH] watchdog: introduce the ARM64 SBSA watchdog driver
Date: Fri, 01 May 2015 13:42:41 -0500	[thread overview]
Message-ID: <5543C921.9050800@codeaurora.org> (raw)
In-Reply-To: <20150501174953.GB7712@roeck-us.net>

On 05/01/2015 12:49 PM, Guenter Roeck wrote:

>>> That is an interesting one. Makes me wonder if you ever tried to unload
>>> this driver.
>>> Did you ?
>>
>> The driver can only be compiled in-kernel.
>>
> And that makes it valid to have both a global and a local variable named
> arm_sbsa_wdt_pdev ? Please explain the rationale.

Because the driver has to create the ACPI platform device, it needs to 
call functions that are not exported:

ERROR: "acpi_parse_entries" [drivers/watchdog/arm_sbsa_wdt.ko] undefined!
ERROR: "arch_timer_get_rate" [drivers/watchdog/arm_sbsa_wdt.ko] undefined!
ERROR: "arch_timer_read_counter" [drivers/watchdog/arm_sbsa_wdt.ko] 
undefined!

>> If the table is uninitialized, then all the values are probably zero.  I was
>> trying to come up with something.  These are the only tests I could come up
>> with I know work.
>>
> How would it be uninitialized ? A quick glance to other code seems to suggest
> that this isn't needed elsewhere. Why is it needed here ?

I don't have a good answer to that, except that when I wrote this code, 
I wanted to add some error checking for the ACPI tables, and this is 
what I came up with.

If you're telling me that the code is wrong and it will generate false 
positives, then I can fix it.  But if you're telling me that you don't 
understand why I'm doing some error checking on the ACPI tables that I'm 
parsing, well, I don't understand what could be wrong with that.

>> It's the best I could come up with.  Sure it seems weird, but it works, and
>> since it's copied from BAD_MADT_ENTRY, I figured it was acceptable.
>>
> That doesn't explain if length is supposed to be 16 or 8 bit, if the length
> is supposed to be stored as big or little endian value, and what would happen
> if it was stored as big endian value on some system and is 16 bit wide.

All lengths and endianness of the fields in the ACPI structures are 
already defined in the ACPI spec, so that stuff is fixed and already 
known.  I'm not sure what you're getting at.  I'm just doing some basic 
error checking, no different than any of the code that calls 
BAD_MADT_ENTRY does.

In fact, I suspect that the only reason that BAD_GTDT_ENTRY does not yet 
exist is because there isn't much support for ACPI timers in the kernel 
yet.

> If the length is in fact 16 bit, you could just check its value directly,
> instead of doing all the typecasting. And if it is 16 bit and has a fixed
> endianness (not host byte order), you should convert it to host byte order
> before validating it. Alternatively, something appears to be wrong with
> acpi_gtdt_header and/or with acpi_gtdt_watchdog.

I don't understand what you mean when you say something is wrong with 
acpi_gtdt_header and/or with acpi_gtdt_watchdog.  These structures look 
perfectly fine to me, and they work.  My driver successfully loads and 
parses the ACPI tables on a real ARM64 server system.

>> I think the GTDT is required.  Most likely, the kernel will fail to boot
>> long before we get to this point if the GTDT is missing or corrupt.
>
> ACPI, the center of the universe ;-). Is ACPI support on arm64 now mandatory ?
> I thought it also supports devicetree ?

Yes, ACPI for ARM64 *servers* is mandatory.  ARM64 servers are not 
supposed to use device tree.

And since this is a driver for SBSA systems (SBSA = Server Base System 
Architecture), this driver will only ever be used on an ARM64 server 
system with ACPI and no device tree at all.

> Assuming that there can be an image which boots both with ACPI and devicetree
> based configurations, I can understand that this driver would only load on ACPI
> based arm64 systems, but that doesn't mean it should dump an error message
> if the system does not use ACPI (or if its ACPI tables do not include an entry
> for the watchdog, for that matter).

I can have the driver silently exit if the GTDT table is missing. 
However, if it does exist, then all the other error messages are valid.

>> I can't use acpi_bus_register_driver() because there are no ACPI IDs to
>> probe on.  Watchdog information is stored as a subtable of the GTDT table,
>> and there's nothing in the ACPI layer that automatically creates platforms
>> from subtables.  I have to create the platform from scratch, which is why
>> the code looks so messy.
>>
> Weird. I'll really want to know from some ACPI experts if this is really
> how ACPI drivers are supposed to be instantiated. Can you give me some
> other examples where this is done ?

A lot of this code is taken from the GIC driver, which is the closest 
match.  There really isn't much similar, because there's little code 
that supports the ACPI tables as-is.  A lot of the ACPI data is in the 
form of device nodes, which are device-tree like and are probed very 
differently.

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.

  reply	other threads:[~2015-05-01 18:42 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-29 19:33 [PATCH] watchdog: introduce the ARM64 SBSA watchdog driver Timur Tabi
2015-05-01  3:30 ` Guenter Roeck
2015-05-01 16:16   ` Timur Tabi
2015-05-01 17:28     ` Timur Tabi
2015-05-01 17:32       ` Guenter Roeck
2015-05-01 17:41         ` Timur Tabi
2015-05-01 17:59           ` Guenter Roeck
2015-05-01 18:46             ` Timur Tabi
2015-05-01 17:49     ` Guenter Roeck
2015-05-01 18:42       ` Timur Tabi [this message]
2015-05-01 19:24         ` [Linaro-acpi] " Arnd Bergmann
2015-05-01 19:56           ` Timur Tabi
2015-05-01 23:31             ` Guenter Roeck
2015-05-02 13:16               ` Timur Tabi
2015-05-01 19:26         ` Guenter Roeck
2015-05-01 19:49           ` Timur Tabi
2015-05-01 19:19     ` [Linaro-acpi] " Arnd Bergmann
2015-05-01 20:15       ` Timur Tabi
2015-05-01 23:16         ` Guenter Roeck
2015-05-01 23:22           ` Timur Tabi
2015-05-01 23:33             ` Guenter Roeck
2015-05-01 13:09 ` Ashwin Chaugule
2015-05-02 13:55 ` Hanjun Guo

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=5543C921.9050800@codeaurora.org \
    --to=timur@codeaurora.org \
    --cc=al.stone@linaro.org \
    --cc=ashwin.chaugule@linaro.org \
    --cc=fu.wei@linaro.org \
    --cc=hanjun.guo@linaro.org \
    --cc=linaro-acpi@lists.linaro.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=vgandhi@codeaurora.org \
    --cc=wim@iguana.be \
    /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