public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Orlando Chamberlain <orlandoch.dev@gmail.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: platform-driver-x86@vger.kernel.org,
	amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	alsa-devel@alsa-project.org,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Pan, Xinhui" <Xinhui.Pan@amd.com>,
	"David Airlie" <airlied@gmail.com>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Mark Gross" <markgross@kernel.org>,
	"Jaroslav Kysela" <perex@perex.cz>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Hawking Zhang" <Hawking.Zhang@amd.com>,
	"Lijo Lazar" <lijo.lazar@amd.com>,
	"YiPeng Chai" <YiPeng.Chai@amd.com>,
	"Somalapuram Amaranath" <Amaranath.Somalapuram@amd.com>,
	"Mario Limonciello" <mario.limonciello@amd.com>,
	"Bokun Zhang" <Bokun.Zhang@amd.com>,
	"Jack Xiao" <Jack.Xiao@amd.com>,
	"Kai Vehmanen" <kai.vehmanen@linux.intel.com>,
	"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
	"Rander Wang" <rander.wang@intel.com>,
	"Ranjani Sridharan" <ranjani.sridharan@linux.intel.com>,
	"Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>,
	"Yong Zhi" <yong.zhi@intel.com>, "Evan Quan" <evan.quan@amd.com>,
	"Kerem Karabay" <kekrby@gmail.com>,
	"Aditya Garg" <gargaditya08@live.com>,
	"Aun-Ali Zaidi" <admin@kodeit.net>
Subject: Re: [RFC PATCH 2/9] apple-gmux: consolidate version reading
Date: Sat, 11 Feb 2023 10:36:57 +1100	[thread overview]
Message-ID: <20230211103657.53108b64@redecorated-mbp> (raw)
In-Reply-To: <f4992ffa-68db-7f8c-b92d-a0e1348a7839@redhat.com>

On Fri, 10 Feb 2023 20:41:19 +0100
Hans de Goede <hdegoede@redhat.com> wrote:

> Hi,
> 
> On 2/10/23 05:48, Orlando Chamberlain wrote:
> > Read gmux version in one go as 32 bits on both indexed and classic
> > gmux's.
> > 
> > Classic gmux's used to read the version as
> > 
> > major = inb(base + 0x4);
> > minor = inb(base + 0x5);
> > release = inb(base + 0x6);
> > 
> > but this can instead be done the same way as indexed gmux's with
> > gmux_read32(), so the same version reading code is used for classic
> > and indexed gmux's (as well as mmio gmux's that will be added to
> > this driver).
> > 
> > Signed-off-by: Orlando Chamberlain <orlandoch.dev@gmail.com>
> > ---
> >  drivers/platform/x86/apple-gmux.c | 14 ++++++--------
> >  include/linux/apple-gmux.h        |  6 +-----
> >  2 files changed, 7 insertions(+), 13 deletions(-)
> > 
> > diff --git a/drivers/platform/x86/apple-gmux.c
> > b/drivers/platform/x86/apple-gmux.c index
> > e8cb084cb81f..67628104f31a 100644 ---
> > a/drivers/platform/x86/apple-gmux.c +++
> > b/drivers/platform/x86/apple-gmux.c @@ -580,15 +580,13 @@ static
> > int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
> > if (indexed) { mutex_init(&gmux_data->index_lock);
> >  		gmux_data->indexed = true;
> > -		version = gmux_read32(gmux_data,
> > GMUX_PORT_VERSION_MAJOR);
> > -		ver_major = (version >> 24) & 0xff;
> > -		ver_minor = (version >> 16) & 0xff;
> > -		ver_release = (version >> 8) & 0xff;
> > -	} else {
> > -		ver_major = gmux_read8(gmux_data,
> > GMUX_PORT_VERSION_MAJOR);
> > -		ver_minor = gmux_read8(gmux_data,
> > GMUX_PORT_VERSION_MINOR);
> > -		ver_release = gmux_read8(gmux_data,
> > GMUX_PORT_VERSION_RELEASE); }
> > +
> > +	version = gmux_read32(gmux_data, GMUX_PORT_VERSION_MAJOR);
> > +	ver_major = (version >> 24) & 0xff;
> > +	ver_minor = (version >> 16) & 0xff;
> > +	ver_release = (version >> 8) & 0xff;
> > +
> >  	pr_info("Found gmux version %d.%d.%d [%s]\n", ver_major,
> > ver_minor, ver_release, (gmux_data->indexed ? "indexed" :
> > "classic")); 
> 
> The problem with this is that there is nothing (no known register)
> at address base + 7 and now you are reading from address base + 7
> here where before the code was not, we have no idea how the hw
> will respond to this.  This should be pretty innocent but still ...

That makes sense, hopefully someone will be able to test it.

> 
> > diff --git a/include/linux/apple-gmux.h b/include/linux/apple-gmux.h
> > index 1f68b49bcd68..eb2caee04abd 100644
> > --- a/include/linux/apple-gmux.h
> > +++ b/include/linux/apple-gmux.h
> > @@ -67,7 +67,6 @@ static inline bool apple_gmux_is_indexed(unsigned
> > long iostart) */
> >  static inline bool apple_gmux_detect(struct pnp_dev *pnp_dev, bool
> > *indexed_ret) {
> > -	u8 ver_major, ver_minor, ver_release;
> >  	struct device *dev = NULL;
> >  	struct acpi_device *adev;
> >  	struct resource *res;
> > @@ -95,10 +94,7 @@ static inline bool apple_gmux_detect(struct
> > pnp_dev *pnp_dev, bool *indexed_ret)
> >  	 * Invalid version information may indicate either that
> > the gmux
> >  	 * device isn't present or that it's a new one that uses
> > indexed io. */
> > -	ver_major = inb(res->start + GMUX_PORT_VERSION_MAJOR);
> > -	ver_minor = inb(res->start + GMUX_PORT_VERSION_MINOR);
> > -	ver_release = inb(res->start + GMUX_PORT_VERSION_RELEASE);
> > -	if (ver_major == 0xff && ver_minor == 0xff && ver_release
> > == 0xff) {
> > +	if (!(~inl(res->start + GMUX_PORT_VERSION_MAJOR))) {  
> 
> Assuming we can get this tested well enough that I'm ok with the
> change in general please write this as:
> 
> 	if (inl(res->start + GMUX_PORT_VERSION_MAJOR) == 0xffffffff) {
> 
> Which I believe is what you are trying to achieve here ?

Yes that is a neater way of doing what I was trying to do, I'll use
that in v2.

> 
> Regards,
> 
> Hans
> 
> 
> 
> >  		indexed = apple_gmux_is_indexed(res->start);
> >  		if (!indexed)
> >  			goto out;  
> 


  reply	other threads:[~2023-02-10 23:37 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-10  4:48 [RFC PATCH 0/9] apple-gmux: support MMIO gmux type on T2 Macs Orlando Chamberlain
2023-02-10  4:48 ` [RFC PATCH 1/9] apple-gmux: use cpu_to_be32 instead of manual reorder Orlando Chamberlain
2023-02-10 19:09   ` Hans de Goede
2023-02-10 19:19     ` Hans de Goede
2023-02-10 23:30       ` Orlando Chamberlain
2023-02-11 11:27         ` Hans de Goede
2023-02-10 19:33     ` Hans de Goede
2023-02-10 22:52       ` David Laight
2023-02-10  4:48 ` [RFC PATCH 2/9] apple-gmux: consolidate version reading Orlando Chamberlain
2023-02-10 19:41   ` Hans de Goede
2023-02-10 23:36     ` Orlando Chamberlain [this message]
2023-02-10  4:48 ` [RFC PATCH 3/9] apple-gmux: use first bit to check switch state Orlando Chamberlain
2023-02-10  4:48 ` [RFC PATCH 4/9] apple-gmux: refactor gmux types Orlando Chamberlain
2023-02-10  4:48 ` [RFC PATCH 5/9] apple-gmux: Use GMSP acpi method for interrupt clear Orlando Chamberlain
2023-02-10 19:43   ` Hans de Goede
2023-02-10 23:40     ` Orlando Chamberlain
2023-02-10  4:48 ` [RFC PATCH 6/9] apple-gmux: support MMIO gmux on T2 Macs Orlando Chamberlain
2023-02-10  4:48 ` [RFC PATCH 7/9] apple-gmux: add sysfs interface Orlando Chamberlain
2023-02-10 20:15   ` Hans de Goede
2023-02-10 20:23     ` Hans de Goede
2023-02-10 23:44       ` Orlando Chamberlain
2023-02-10  4:48 ` [RFC PATCH 8/9] hda/hdmi: Register with vga_switcheroo on Dual GPU Macbooks Orlando Chamberlain
2023-02-10  4:48 ` [RFC PATCH 9/9] drm/amdgpu: register a vga_switcheroo client for all GPUs that are not thunderbolt attached Orlando Chamberlain
2023-02-10 15:53   ` Alex Deucher
2023-02-10 16:07     ` Hans de Goede
2023-02-10 16:37       ` Alex Deucher
2023-02-10 23:54         ` Orlando Chamberlain
2023-02-10 16:30 ` [RFC PATCH 0/9] apple-gmux: support MMIO gmux type on T2 Macs Alex Deucher

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=20230211103657.53108b64@redecorated-mbp \
    --to=orlandoch.dev@gmail.com \
    --cc=Amaranath.Somalapuram@amd.com \
    --cc=Bokun.Zhang@amd.com \
    --cc=Hawking.Zhang@amd.com \
    --cc=Jack.Xiao@amd.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=YiPeng.Chai@amd.com \
    --cc=admin@kodeit.net \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=evan.quan@amd.com \
    --cc=gargaditya08@live.com \
    --cc=hdegoede@redhat.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=kekrby@gmail.com \
    --cc=lijo.lazar@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=markgross@kernel.org \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rander.wang@intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=tiwai@suse.com \
    --cc=yong.zhi@intel.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