The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
Cc: Mathias Nyman <mathias.nyman@intel.com>,
	"open list:USB XHCI DRIVER" <linux-usb@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] usb: xhci-pci: Add Power handling for Card readers on Apple systems
Date: Mon, 23 Nov 2026 06:28:16 +0100	[thread overview]
Message-ID: <2026112342-engorge-polymer-0717@gregkh> (raw)
In-Reply-To: <20261123051459.9581-1-atharvatiwarilinuxdev@gmail.com>

On Mon, Nov 23, 2026 at 12:14:58AM -0500, Atharva Tiwari wrote:
> Add Power handling for Card readers on Apple systems using SPWR
> ACPI method, SPWR(1) turns on the card reader, SPWR(0) turns off
> the card reader, on newer systems SPWR just writes a variable in EC.
> On previous systems it writes to GPIO pins.
> 
> Its also used by the macOS driver with the function
> AppleUSB30XHCICardReaderPort::setDevicePower in AppleUSBXHCIPCI.kext.
> 
> (This should fix https://bugzilla.kernel.org/show_bug.cgi?id=111201
>  But thats not confirmed)
> 
> (Tested on iMac20,1)
> 
> Signed-off-by: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
> ---
> Changes in v3:
> - Added changes at correct location
> - Removed accidental usb-acpi code.
> 
> Changes in v2:
> - Fixed grammatical errors.
> - Added CONFIG_ACPI check
> - Checked for xhci_suspend success before turning off power
> 
> Link to v2:
> https://lore.kernel.org/all/20261123044412.8721-1-atharvatiwarilinuxdev@gmail.com/
> 
> Link to v1:
> https://lore.kernel.org/all/20261116231926.5891-1-atharvatiwarilinuxdev@gmail.com/
> 
>  drivers/usb/host/xhci-pci.c | 25 ++++++++++++++++++++++++-
>  drivers/usb/host/xhci.h     |  1 +
>  2 files changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
> index e278db940..31961de97 100644
> --- a/drivers/usb/host/xhci-pci.c
> +++ b/drivers/usb/host/xhci-pci.c
> @@ -15,6 +15,7 @@
>  #include <linux/reset.h>
>  #include <linux/suspend.h>
>  #include <linux/bitfield.h>
> +#include <linux/platform_data/x86/apple.h>

That feels very wrong for all non-x86 systems to be forced to include.

>  
>  #include "xhci.h"
>  #include "xhci-trace.h"
> @@ -517,6 +518,18 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
>  	if (xhci->hci_version >= 0x120)
>  		xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW;
>  
> +#ifdef CONFIG_ACPI
> +	/* On Apple Machine with Card readers, we have to use SPWR(0/1) to turn
> +	 * off/on the card reader, And on boot the card reader is off, so we turn
> +	 * it on.
> +	 */

Wrong comment style :(

And why an #ifdef in this file?

> +	if (x86_apple_machine && ACPI_HANDLE(&pdev->dev) &&

So what happens on arm64 systems with ACPI?  Riscv systems?  Does this
just break the build?

> +			acpi_has_method(ACPI_HANDLE(&pdev->dev), "SPWR")) {
> +		acpi_execute_simple_method(ACPI_HANDLE(&pdev->dev), "SPWR", 1);
> +		xhci->quirks |= XHCI_APPLE_CARD_READER_POWER;
> +	}
> +#endif /* CONFIG_ACPI */
> +
>  	if (xhci->quirks & XHCI_RESET_ON_RESUME)
>  		xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
>  				"QUIRK: Resetting on resume");
> @@ -562,10 +575,14 @@ static void xhci_find_lpm_incapable_ports(struct usb_hcd *hcd, struct usb_device
>  		}
>  	}
>  }
> -
> +static void xhci_apple_card_reader_power(struct pci_dev *pdev, u64 on)
> +{
> +	acpi_execute_simple_method(ACPI_HANDLE(&pdev->dev), "SPWR", on);
> +}

You removed the blank line?

and this still feels very platform specific, why must it be in generic
xhci code?

and what about all of the sashiko review comments that were made on
this?  Are they all wrong?

thanks,

greg k-h

  reply	other threads:[~2026-11-23  5:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  5:14 [PATCH v3] usb: xhci-pci: Add Power handling for Card readers on Apple systems Atharva Tiwari
2026-11-23  5:28 ` Greg Kroah-Hartman [this message]
2026-11-23  5:47   ` Atharva Tiwari

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=2026112342-engorge-polymer-0717@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=atharvatiwarilinuxdev@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@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