X86 platform drivers
 help / color / mirror / Atom feed
From: Orlando Chamberlain <orlandoch.dev@gmail.com>
To: Lukas Wunner <lukas@wunner.de>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Mark Gross <markgross@kernel.org>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, Seth Forshee <sforshee@kernel.org>,
	Aditya Garg <gargaditya08@live.com>,
	Aun-Ali Zaidi <admin@kodeit.net>,
	Kerem Karabay <kekrby@gmail.com>
Subject: Re: [PATCH v3 3/5] apple-gmux: Use GMSP acpi method for interrupt clear
Date: Mon, 20 Feb 2023 23:02:15 +1100	[thread overview]
Message-ID: <20230220230215.6e7e09cf@redecorated-mbp> (raw)
In-Reply-To: <20230219221737.GA17355@wunner.de>

On Sun, 19 Feb 2023 23:17:37 +0100
Lukas Wunner <lukas@wunner.de> wrote:

> On Sun, Feb 19, 2023 at 12:20:05AM +1100, Orlando Chamberlain wrote:
> > This is needed for interrupts to be cleared correctly on MMIO based
> > gmux's. It is untested if this helps/hinders other gmux types, so
> > currently this is only enabled for the MMIO gmux's.
> > 
> > There is also a "GMLV" acpi method, and the "GMSP" method can be
> > called with 1 as its argument, but the purposes of these aren't
> > known and they don't seem to be needed.  
> 
> GMLV and GMSP access a GPIO on the PCH which is connected to the
> GMUX_INT pin of the gmux microcontroller.  I've just verified that
> in the schematics of my MBP9,1.
> 
> GMLV reads the value of the GPIO ("level").
> GMSP likely sets the value ("set polarity").
> 
> On my MBP9,1 (indexed gmux), if the gmux controller signals an
> interrupt, the platform signals a notification:
> 
>   Scope (\_GPE)
>   {
>       Method (_L16, 0, NotSerialized)  // _Lxx: Level-Triggered GPE
>       {
>           Notify (\_SB.PCI0.LPCB.GMUX, 0x80) // Status Change
>       }
>   }
> 
> Comparing this to the MBP13,3 and MBP16,1, the GPE method
> differentiates between the OS type:  On Darwin, only a notification
> is signaled, whereas on other OSes, the GPIO's value is read and then
> inverted:
> 
>   Scope (\_GPE)
>   {
>       Method (_L15, 0, NotSerialized)  // _Lxx: Level-Triggered GPE,
> xx=0x00-0xFF {
>           If (OSDW ())
>           {
>               Notify (\_SB.PCI0.LPCB.GPUC, 0x80) // Status Change
>           }
>           ElseIf ((\_SB.GGII (0x03000015) == One))
>           {
>               \_SB.SGII (0x03000015, Zero)
>           }
>           Else
>           {
>               \_SB.SGII (0x03000015, One)
>           }
>       }
>   }
> 
> Linux masquerades as Darwin, so ends up in the notification-only
> code path.
> 
> Does macOS execute the GMSP method as well?  Have you disassembled
> the gmux driver?  All vital information that belongs in the commit
> message and/or a code comment.

I think it does, if certain based bits in "HWFeatureMask" (which shows
up in `ioreg -l`) are set, but I'm not very good at RE so I don't know
exactly how macOS uses it. The kext is AppleMuxControl2.kext.

> 
> 
> > +static int gmux_call_acpi_gmsp(struct apple_gmux_data *gmux_data,
> > int arg) +{
> > +	acpi_status status = AE_OK;
> > +	union acpi_object arg0 = { ACPI_TYPE_INTEGER };
> > +	struct acpi_object_list arg_list = { 1, &arg0 };
> > +
> > +	arg0.integer.value = arg;
> > +
> > +	status = acpi_evaluate_object(gmux_data->dhandle, "GMSP",
> > &arg_list, NULL);  
> 
> Can this be simplified by using acpi_execute_simple_method() or
> one of the other helpers provided by drivers/acpi/utils.c?
> 

Yes it can thanks!

> 
> > @@ -537,6 +561,8 @@ static void gmux_clear_interrupts(struct
> > apple_gmux_data *gmux_data) /* to clear interrupts write back
> > current status */ status = gmux_interrupt_get_status(gmux_data);
> >  	gmux_write8(gmux_data, GMUX_PORT_INTERRUPT_STATUS, status);
> > +	if (gmux_data->config->use_acpi_gmsp)
> > +		gmux_call_acpi_gmsp(gmux_data, 0);
> >  }  
> 
> I think it would be clearer to check the gmux type directly here,
> so that a casual reader understands that invoking the method is
> necessary on MMIO-accessed GMUXes, but not any of the other types.
> By contrast, with the use_acpi_gmsp one has to look up first which
> of the gmux types sets this to true.

I can do it like that next version.

> 
> What happens if GMSP is not executed?  Needs to be documented in the
> commit message and/or a code comment!
> 

It gets a flood of status=0 interrupts, I'll add that as a comment.

> Thanks,
> 
> Lukas


  reply	other threads:[~2023-02-20 12:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-18 13:20 [PATCH v3 0/5] apple-gmux: support MMIO gmux type on T2 Macs Orlando Chamberlain
2023-02-18 13:20 ` [PATCH v3 1/5] apple-gmux: use first bit to check switch state Orlando Chamberlain
2023-02-18 13:20 ` [PATCH v3 2/5] apple-gmux: refactor gmux types Orlando Chamberlain
2023-02-18 13:20 ` [PATCH v3 3/5] apple-gmux: Use GMSP acpi method for interrupt clear Orlando Chamberlain
2023-02-19 22:17   ` Lukas Wunner
2023-02-20 12:02     ` Orlando Chamberlain [this message]
2023-02-18 13:20 ` [PATCH v3 4/5] apple-gmux: support MMIO gmux on T2 Macs Orlando Chamberlain
2023-02-20  9:20   ` Lukas Wunner
2023-02-20 12:16     ` Orlando Chamberlain
2023-02-18 13:20 ` [PATCH v3 5/5] apple-gmux: add debugfs interface Orlando Chamberlain
2023-03-01 12:54 ` [PATCH v3 0/5] apple-gmux: support MMIO gmux type on T2 Macs Hans de Goede
2023-03-03  7:54   ` Orlando Chamberlain

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=20230220230215.6e7e09cf@redecorated-mbp \
    --to=orlandoch.dev@gmail.com \
    --cc=admin@kodeit.net \
    --cc=gargaditya08@live.com \
    --cc=hdegoede@redhat.com \
    --cc=kekrby@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=markgross@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=sforshee@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