From: Hans de Goede <hdegoede@redhat.com>
To: Lukas Wunner <lukas@wunner.de>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
Len Brown <lenb@kernel.org>, Aditya Garg <gargaditya08@live.com>,
Mark Gross <mgross@linux.intel.com>,
linux-acpi@vger.kernel.org, Andy Shevchenko <andy@infradead.org>,
platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH 2/3] platform/x86: apple-gmux: Add apple_gmux_detect() helper
Date: Mon, 23 Jan 2023 16:10:23 +0100 [thread overview]
Message-ID: <1db86ea3-a658-fe4f-53ae-cc16e5fa125c@redhat.com> (raw)
In-Reply-To: <a02857d6-83c1-07f7-ebf0-f0b15b190f60@redhat.com>
Hi,
On 1/23/23 16:05, Hans de Goede wrote:
> Hi,
>
> On 1/23/23 15:23, Lukas Wunner wrote:
>> On Mon, Jan 23, 2023 at 03:13:28PM +0100, Hans de Goede wrote:
>>> On 1/23/23 14:49, Lukas Wunner wrote:
>>>> On Mon, Jan 23, 2023 at 12:37:49PM +0100, Hans de Goede wrote:
>>>>> --- a/include/linux/apple-gmux.h
>>>>> +++ b/include/linux/apple-gmux.h
>>>> [...]
>>>>> +static inline bool apple_gmux_is_indexed(unsigned long iostart)
>>>>> +{
>>>>> + u16 val;
>>>>> +
>>>>> + outb(0xaa, iostart + 0xcc);
>>>>> + outb(0x55, iostart + 0xcd);
>>>>> + outb(0x00, iostart + 0xce);
>>>>> +
>>>>> + val = inb(iostart + 0xcc) | (inb(iostart + 0xcd) << 8);
>>>>> + if (val == 0x55aa)
>>>>> + return true;
>>>>> +
>>>>> + return false;
>>>>> +}
>>>>
>>>> Something like this, and especially the large apple_gmux_detect() below,
>>>> should not live in a header file.
>>>
>>> I understand where you are coming from, but these functions really
>>> are not that large.
>>>
>>>> Why can't apple_gmux.ko just export a detection function which is used
>>>> both internally and as a helper by the backlight detection?
>>>
>>> Both the acpi-video code and the apple-gmux code can be built as
>>> modules. So this will break if the acpi-video code get builtin
>>> and the apple-gmux code does not.
>>>
>>> This can be worked around in Kconfig by adding something like:
>>>
>>> depends on APPLE_GMUX || APPLE_GMUX=n
>>>
>>> to the ACPI_VIDEO Kconfig bits and then cross our fingers
>>> we don't get some Kconfig circular dep thing causing things
>>> to error out.
>>
>> Can we force APPLE_GMUX to be built-in if ACPI_VIDEO is?
>>
>> Would making APPLE_GMUX depend on ACPI_VIDEO (instead of
>> "ACPI_VIDEO=n || ACPI_VIDEO") achieve that? I believe
>> APPLE_GMUX would then inherit the setting of ACPI_VIDEO?
>
> I'm afraid that won't work, make it depend on ACPI_VIDEO would not
> make it inherit ACPI_VIDEO's setting instead it would be limited
> to ACPI_VIDEO's setting.
>
> So if we make APPLE_GMUX "depends on ACPI_VIDEO" and ACPI_VIDEO=y
> then APPLE_GMUX can be both Y or M, where as if ACPI_VIDEO=m
> then APPLE_GMUX can only be m.
>
> Note that the APPLE_GMUX Kconfig "ACPI_VIDEO=n || ACPI_VIDEO"
> bit is obsolete and should be dropped (I have already prepared
> a patch for this), the apple_gmux code no longer depends on any
> of the ACPI_VIDEO symbols. Which does make it possible to
> add a dependency the other way.
>
> I just tried the following:
>
> --- a/drivers/acpi/Kconfig
> +++ b/drivers/acpi/Kconfig
> @@ -210,6 +210,8 @@ config ACPI_VIDEO
> depends on BACKLIGHT_CLASS_DEVICE
> depends on INPUT
> depends on ACPI_WMI || !X86
> + # ACPI_VIDEO uses symbols from APPLE_GMUX if that is enabled
> + depends on APPLE_GMUX || APPLE_GMUX=n
> select THERMAL
> help
> This driver implements the ACPI Extensions For Display Adapters
>
> And that does not cause any circular dep issues it seems
And 10 seconds after hitting send I realized that things are not this simple,
because a bunch of other Kconfig bits do "select ACPI_VIDEO" and Kconfig
bits doing "select FOO" much make sure all the dependencies of FOO are met
and we have just added a new dependency...
So all those other places then would need something similar. Kconfig is
great, but with intra dependencies it really can get quite hairy.
So IMHO the (really not that big) static inline detect function really
is the best solution here.
Regards,
Hans
next prev parent reply other threads:[~2023-01-23 15:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-23 11:37 [PATCH 0/3] ACPI: video/apple-gmux: Improve apple-gmux backlight detection Hans de Goede
2023-01-23 11:37 ` [PATCH 1/3] platform/x86: apple-gmux: Move port defines to apple-gmux.h Hans de Goede
2023-01-23 11:37 ` [PATCH 2/3] platform/x86: apple-gmux: Add apple_gmux_detect() helper Hans de Goede
2023-01-23 13:49 ` Lukas Wunner
2023-01-23 14:13 ` Hans de Goede
2023-01-23 14:23 ` Lukas Wunner
2023-01-23 15:05 ` Hans de Goede
2023-01-23 15:10 ` Hans de Goede [this message]
2023-01-23 16:35 ` Andy Shevchenko
2023-01-23 11:37 ` [PATCH 3/3] ACPI: video: Fix apple gmux detection Hans de Goede
2023-01-23 16:37 ` Andy Shevchenko
2023-01-23 17:25 ` Hans de Goede
2023-01-23 19:20 ` Rafael J. Wysocki
2023-01-23 12:09 ` [PATCH 0/3] ACPI: video/apple-gmux: Improve apple-gmux backlight detection Lukas Wunner
2023-01-23 12:38 ` Hans de Goede
2023-01-23 13:58 ` Lukas Wunner
2023-01-23 15:05 ` Hans de Goede
2023-01-23 14:53 ` Aditya Garg
2023-01-24 8:21 ` Orlando Chamberlain
2023-01-24 10:26 ` Aditya Garg
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=1db86ea3-a658-fe4f-53ae-cc16e5fa125c@redhat.com \
--to=hdegoede@redhat.com \
--cc=andy@infradead.org \
--cc=gargaditya08@live.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=mgross@linux.intel.com \
--cc=platform-driver-x86@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