Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1283057 > unrolled thread

[PATCH] mmc: sdhci-acpi: set non-removable in ACPI table

Started byPhilip Elcan <pelcan@codeaurora.org>
First post2015-12-03 14:50 +0100
Last post2015-12-11 23:30 +0100
Articles 7 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mmc: sdhci-acpi: set non-removable in ACPI table Philip Elcan <pelcan@codeaurora.org> - 2015-12-03 14:50 +0100
    Re: [PATCH] mmc: sdhci-acpi: set non-removable in ACPI table Adrian Hunter <adrian.hunter@intel.com> - 2015-12-03 15:20 +0100
      Re: [PATCH] mmc: sdhci-acpi: set non-removable in ACPI table Philip Elcan <pelcan@codeaurora.org> - 2015-12-04 16:50 +0100
        Re: [PATCH] mmc: sdhci-acpi: set non-removable in ACPI table Adrian Hunter <adrian.hunter@intel.com> - 2015-12-07 09:40 +0100
          Re: [PATCH] mmc: sdhci-acpi: set non-removable in ACPI table Philip Elcan <pelcan@codeaurora.org> - 2015-12-10 22:00 +0100
            Re: [PATCH] mmc: sdhci-acpi: set non-removable in ACPI table Adrian Hunter <adrian.hunter@intel.com> - 2015-12-11 09:30 +0100
              Re: [PATCH] mmc: sdhci-acpi: set non-removable in ACPI table "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2015-12-11 23:30 +0100

#1283057 — [PATCH] mmc: sdhci-acpi: set non-removable in ACPI table

FromPhilip Elcan <pelcan@codeaurora.org>
Date2015-12-03 14:50 +0100
Subject[PATCH] mmc: sdhci-acpi: set non-removable in ACPI table
Message-ID<qBCqL-5Om-11@gated-at.bofh.it>
This allows setting an SDHC controller as non-removable
by using the _RMV method in the ACPI table. It doesn't
mark it as non-removable if GPIO card detection is
already setup.

Signed-off-by: Philip Elcan <pelcan@codeaurora.org>
---
 drivers/mmc/host/sdhci-acpi.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
index f6047fc..8c06ba6 100644
--- a/drivers/mmc/host/sdhci-acpi.c
+++ b/drivers/mmc/host/sdhci-acpi.c
@@ -288,6 +288,20 @@ static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(const char *hid,
 	return NULL;
 }
 
+static bool sdhci_acpi_is_removable(acpi_handle handle)
+{
+	acpi_status status;
+	unsigned long long removable = 1; /* default to removable */
+
+	if (acpi_has_method(handle, "_EJ0"))
+		return true;
+	status = acpi_evaluate_integer(handle, "_RMV", NULL, &removable);
+	if (ACPI_SUCCESS(status) && !removable)
+		return false;
+
+	return true;
+}
+
 static int sdhci_acpi_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -300,6 +314,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
 	const char *hid;
 	const char *uid;
 	int err;
+	bool gpio_cd = false;
 
 	if (acpi_bus_get_device(handle, &device))
 		return -ENODEV;
@@ -373,9 +388,14 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
 		if (mmc_gpiod_request_cd(host->mmc, NULL, 0, v, 0, NULL)) {
 			dev_warn(dev, "failed to setup card detect gpio\n");
 			c->use_runtime_pm = false;
+		} else {
+			gpio_cd = true;
 		}
 	}
 
+	if (!gpio_cd && !sdhci_acpi_is_removable(handle))
+		host->mmc->caps |= MMC_CAP_NONREMOVABLE;
+
 	err = sdhci_add_host(host);
 	if (err)
 		goto err_free;
-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1283068

FromAdrian Hunter <adrian.hunter@intel.com>
Date2015-12-03 15:20 +0100
Message-ID<qBCTM-6fn-1@gated-at.bofh.it>
In reply to#1283057
On 03/12/15 15:48, Philip Elcan wrote:
> This allows setting an SDHC controller as non-removable
> by using the _RMV method in the ACPI table. It doesn't

Is that _RMV on the host controller?  Shouldn't it be on the card i.e. child
device node?

> mark it as non-removable if GPIO card detection is
> already setup.
> 
> Signed-off-by: Philip Elcan <pelcan@codeaurora.org>
> ---
>  drivers/mmc/host/sdhci-acpi.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
> index f6047fc..8c06ba6 100644
> --- a/drivers/mmc/host/sdhci-acpi.c
> +++ b/drivers/mmc/host/sdhci-acpi.c
> @@ -288,6 +288,20 @@ static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(const char *hid,
>  	return NULL;
>  }
>  
> +static bool sdhci_acpi_is_removable(acpi_handle handle)
> +{
> +	acpi_status status;
> +	unsigned long long removable = 1; /* default to removable */
> +
> +	if (acpi_has_method(handle, "_EJ0"))
> +		return true;
> +	status = acpi_evaluate_integer(handle, "_RMV", NULL, &removable);
> +	if (ACPI_SUCCESS(status) && !removable)
> +		return false;
> +
> +	return true;
> +}
> +
>  static int sdhci_acpi_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
> @@ -300,6 +314,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
>  	const char *hid;
>  	const char *uid;
>  	int err;
> +	bool gpio_cd = false;
>  
>  	if (acpi_bus_get_device(handle, &device))
>  		return -ENODEV;
> @@ -373,9 +388,14 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
>  		if (mmc_gpiod_request_cd(host->mmc, NULL, 0, v, 0, NULL)) {
>  			dev_warn(dev, "failed to setup card detect gpio\n");
>  			c->use_runtime_pm = false;
> +		} else {
> +			gpio_cd = true;
>  		}
>  	}
>  
> +	if (!gpio_cd && !sdhci_acpi_is_removable(handle))
> +		host->mmc->caps |= MMC_CAP_NONREMOVABLE;
> +
>  	err = sdhci_add_host(host);
>  	if (err)
>  		goto err_free;
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1283955

FromPhilip Elcan <pelcan@codeaurora.org>
Date2015-12-04 16:50 +0100
Message-ID<qC0Mq-4A2-35@gated-at.bofh.it>
In reply to#1283068
On 12/03/2015 09:14 AM, Adrian Hunter wrote:
> On 03/12/15 15:48, Philip Elcan wrote:
>> This allows setting an SDHC controller as non-removable
>> by using the _RMV method in the ACPI table. It doesn't
> Is that _RMV on the host controller?  Shouldn't it be on the card i.e. child
> device node?

Yes, this is on the host controller. The ACPI table only describes the
host controller, not the child nodes.

>
>> mark it as non-removable if GPIO card detection is
>> already setup.
>>
>> Signed-off-by: Philip Elcan <pelcan@codeaurora.org>
>> ---
>>

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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1285083

FromAdrian Hunter <adrian.hunter@intel.com>
Date2015-12-07 09:40 +0100
Message-ID<qCZuW-24d-7@gated-at.bofh.it>
In reply to#1283955
On 04/12/15 17:40, Philip Elcan wrote:
> 
> On 12/03/2015 09:14 AM, Adrian Hunter wrote:
>> On 03/12/15 15:48, Philip Elcan wrote:
>>> This allows setting an SDHC controller as non-removable
>>> by using the _RMV method in the ACPI table. It doesn't
>> Is that _RMV on the host controller?  Shouldn't it be on the card i.e. child
>> device node?
> 
> Yes, this is on the host controller. The ACPI table only describes the
> host controller, not the child nodes.
> 

If you look at Intel devices, the _RMV is on the child e.g.

        Device (SDHA)
        {
            Name (_HID, "80860F14")  // _HID: Hardware ID
            Name (_CID, "PNP0D40")  // _CID: Compatible ID
            Name (_DDN, "Intel(R) eMMC Controller - 80860F14")  // _DDN: DOS Device Name
	    ...
            Device (EMMD)
            {
		...
                Method (_RMV, 0, NotSerialized)  // _RMV: Removal Status
                {
                    Return (Zero)
                }
            }
        }

I am not an ACPI expert but that seems like the correct place for it.

>>
>>> mark it as non-removable if GPIO card detection is
>>> already setup.
>>>
>>> Signed-off-by: Philip Elcan <pelcan@codeaurora.org>
>>> ---
>>>
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1288919

FromPhilip Elcan <pelcan@codeaurora.org>
Date2015-12-10 22:00 +0100
Message-ID<qEgtI-2KO-13@gated-at.bofh.it>
In reply to#1285083
On 12/07/2015 03:30 AM, Adrian Hunter wrote:
> On 04/12/15 17:40, Philip Elcan wrote:
>> On 12/03/2015 09:14 AM, Adrian Hunter wrote:
>>> On 03/12/15 15:48, Philip Elcan wrote:
>>>> This allows setting an SDHC controller as non-removable
>>>> by using the _RMV method in the ACPI table. It doesn't
>>> Is that _RMV on the host controller?  Shouldn't it be on the card i.e. child
>>> device node?
>> Yes, this is on the host controller. The ACPI table only describes the
>> host controller, not the child nodes.
>>
> If you look at Intel devices, the _RMV is on the child e.g.
>
>         Device (SDHA)
>         {
>             Name (_HID, "80860F14")  // _HID: Hardware ID
>             Name (_CID, "PNP0D40")  // _CID: Compatible ID
>             Name (_DDN, "Intel(R) eMMC Controller - 80860F14")  // _DDN: DOS Device Name
> 	    ...
>             Device (EMMD)
>             {
> 		...
>                 Method (_RMV, 0, NotSerialized)  // _RMV: Removal Status
>                 {
>                     Return (Zero)
>                 }
>             }
>         }
>
> I am not an ACPI expert but that seems like the correct place for it.
My understanding is that in ACPI you don't generally create child devices on buses that are discoverable.
>
>>>> mark it as non-removable if GPIO card detection is
>>>> already setup.
>>>>
>>>> Signed-off-by: Philip Elcan <pelcan@codeaurora.org>
>>>> ---
>>>>

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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1289312

FromAdrian Hunter <adrian.hunter@intel.com>
Date2015-12-11 09:30 +0100
Message-ID<qErfs-1Fq-19@gated-at.bofh.it>
In reply to#1288919
On 10/12/15 22:57, Philip Elcan wrote:
> 
> On 12/07/2015 03:30 AM, Adrian Hunter wrote:
>> On 04/12/15 17:40, Philip Elcan wrote:
>>> On 12/03/2015 09:14 AM, Adrian Hunter wrote:
>>>> On 03/12/15 15:48, Philip Elcan wrote:
>>>>> This allows setting an SDHC controller as non-removable
>>>>> by using the _RMV method in the ACPI table. It doesn't
>>>> Is that _RMV on the host controller?  Shouldn't it be on the card i.e. child
>>>> device node?
>>> Yes, this is on the host controller. The ACPI table only describes the
>>> host controller, not the child nodes.
>>>
>> If you look at Intel devices, the _RMV is on the child e.g.
>>
>>         Device (SDHA)
>>         {
>>             Name (_HID, "80860F14")  // _HID: Hardware ID
>>             Name (_CID, "PNP0D40")  // _CID: Compatible ID
>>             Name (_DDN, "Intel(R) eMMC Controller - 80860F14")  // _DDN: DOS Device Name
>> 	    ...
>>             Device (EMMD)
>>             {
>> 		...
>>                 Method (_RMV, 0, NotSerialized)  // _RMV: Removal Status
>>                 {
>>                     Return (Zero)
>>                 }
>>             }
>>         }
>>
>> I am not an ACPI expert but that seems like the correct place for it.
> My understanding is that in ACPI you don't generally create child devices on buses that are discoverable.

I've cc'ed Rafael and the linux-acpi mailing list.  Maybe someone there can
comment.

>>
>>>>> mark it as non-removable if GPIO card detection is
>>>>> already setup.
>>>>>
>>>>> Signed-off-by: Philip Elcan <pelcan@codeaurora.org>
>>>>> ---
>>>>>
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1289963

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2015-12-11 23:30 +0100
Message-ID<qEEmm-21X-21@gated-at.bofh.it>
In reply to#1289312
On Friday, December 11, 2015 10:17:18 AM Adrian Hunter wrote:
> On 10/12/15 22:57, Philip Elcan wrote:
> > 
> > On 12/07/2015 03:30 AM, Adrian Hunter wrote:
> >> On 04/12/15 17:40, Philip Elcan wrote:
> >>> On 12/03/2015 09:14 AM, Adrian Hunter wrote:
> >>>> On 03/12/15 15:48, Philip Elcan wrote:
> >>>>> This allows setting an SDHC controller as non-removable
> >>>>> by using the _RMV method in the ACPI table. It doesn't
> >>>> Is that _RMV on the host controller?  Shouldn't it be on the card i.e. child
> >>>> device node?
> >>> Yes, this is on the host controller. The ACPI table only describes the
> >>> host controller, not the child nodes.
> >>>
> >> If you look at Intel devices, the _RMV is on the child e.g.
> >>
> >>         Device (SDHA)
> >>         {
> >>             Name (_HID, "80860F14")  // _HID: Hardware ID
> >>             Name (_CID, "PNP0D40")  // _CID: Compatible ID
> >>             Name (_DDN, "Intel(R) eMMC Controller - 80860F14")  // _DDN: DOS Device Name
> >> 	    ...
> >>             Device (EMMD)
> >>             {
> >> 		...
> >>                 Method (_RMV, 0, NotSerialized)  // _RMV: Removal Status
> >>                 {
> >>                     Return (Zero)
> >>                 }
> >>             }
> >>         }
> >>
> >> I am not an ACPI expert but that seems like the correct place for it.
> > My understanding is that in ACPI you don't generally create child devices on buses that are discoverable.
> 
> I've cc'ed Rafael and the linux-acpi mailing list.  Maybe someone there can
> comment.

The context here is a bit unclear to me.

Quite frankly, I don't see now _RMV above is useful for anything.  As per the
spec, _RMV is only necessary for devices that *can* be removed from the system
and where there's no eject mechanism controlled by software.  For those
devices _RMV is intended to indicate that it is safe to remove the device
at the time _RMV is evaluated.  Devices that can never be removed don't
need _RMV at all.

Thanks,
Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web