From: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
To: Toshi Kani <toshi.kani@hp.com>
Cc: rjw@sisk.pl, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org,
vasilis.liaskovitis@profitbricks.com
Subject: Re: [PATCH v2] ACPI: Add sysfs links from memory device to memblocks
Date: Tue, 26 Feb 2013 14:37:11 +0900 [thread overview]
Message-ID: <512C4A07.40903@jp.fujitsu.com> (raw)
In-Reply-To: <1361826130-31062-1-git-send-email-toshi.kani@hp.com>
2013/02/26 6:02, Toshi Kani wrote:
> In order to eject a memory device object represented as "PNP0C80:%d"
> in sysfs, its associated memblocks (system/memory/memory%d) need to
> be off-lined. However, there is no user friendly way to correlate
> between a memory device object and its memblocks in sysfs.
>
> This patch creates sysfs links to memblocks under a memory device
> object so that a user can easily checks and manipulates its memblocks
> in sysfs.
>
> For example, when PNP0C80:05 is associated with memory8 and memory9,
> the following two links are created under PNP0C80:05. This allows
> a user to access memory8/9 directly from PNP0C80:05.
>
> # ll /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C80:05
> lrwxrwxrwx. memory8 -> ../../../system/memory/memory8
> lrwxrwxrwx. memory9 -> ../../../system/memory/memory9
>
> Signed-off-by: Toshi Kani <toshi.kani@hp.com>
> ---
I confirmed that the patch has no problem.
Feel free to add:
Tested-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Acked-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Thanks,
Yasuaki Ishimatsu
>
> This patch applies on top of the Rafael's patch below.
> https://patchwork.kernel.org/patch/2153261/
>
> v2: Added a NULL return check for find_memory_block_hinted() as
> pointed by Yasuaki Ishimatsu.
>
> ---
> drivers/acpi/acpi_memhotplug.c | 56 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 56 insertions(+)
>
> diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
> index 3b3abbc..98477a5 100644
> --- a/drivers/acpi/acpi_memhotplug.c
> +++ b/drivers/acpi/acpi_memhotplug.c
> @@ -28,6 +28,7 @@
> */
>
> #include <linux/acpi.h>
> +#include <linux/memory.h>
> #include <linux/memory_hotplug.h>
>
> #include "internal.h"
> @@ -168,6 +169,55 @@ static int acpi_memory_check_device(struct acpi_memory_device *mem_device)
> return 0;
> }
>
> +static void acpi_setup_mem_blk_links(struct acpi_memory_device *mem_device,
> + struct acpi_memory_info *info, bool add_links)
> +{
> + struct memory_block *mem_blk = NULL;
> + struct mem_section *mem_sect;
> + unsigned long start_pfn, end_pfn, pfn;
> + unsigned long section_nr;
> + int ret;
> +
> + start_pfn = PFN_DOWN(info->start_addr);
> + end_pfn = PFN_UP(info->start_addr + info->length-1);
> +
> + for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
> + section_nr = pfn_to_section_nr(pfn);
> +
> + if (!present_section_nr(section_nr))
> + continue;
> +
> + mem_sect = __nr_to_section(section_nr);
> +
> + /* skip if the same memblock */
> + if (mem_blk)
> + if ((section_nr >= mem_blk->start_section_nr) &&
> + (section_nr <= mem_blk->end_section_nr))
> + continue;
> +
> + mem_blk = find_memory_block_hinted(mem_sect, mem_blk);
> + if (!mem_blk)
> + continue;
> +
> + if (add_links) {
> + ret = sysfs_create_link_nowarn(
> + &mem_device->device->dev.kobj,
> + &mem_blk->dev.kobj,
> + kobject_name(&mem_blk->dev.kobj));
> + if (ret && ret != -EEXIST)
> + dev_err(&mem_device->device->dev,
> + "Failed to create sysfs link %s\n",
> + kobject_name(&mem_blk->dev.kobj));
> + } else {
> + sysfs_remove_link(&mem_device->device->dev.kobj,
> + kobject_name(&mem_blk->dev.kobj));
> + }
> + }
> +
> + if (mem_blk)
> + kobject_put(&mem_blk->dev.kobj);
> +}
> +
> static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
> {
> int result, num_enabled = 0;
> @@ -207,6 +257,9 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
> continue;
> }
>
> + /* Create sysfs links to its mem_blk devices */
> + acpi_setup_mem_blk_links(mem_device, info, true);
> +
> if (!result)
> info->enabled = 1;
> /*
> @@ -241,6 +294,9 @@ static int acpi_memory_remove_memory(struct acpi_memory_device *mem_device)
> /* The kernel does not use this memory block */
> continue;
>
> + /* Remove sysfs links to its mem_blk devices */
> + acpi_setup_mem_blk_links(mem_device, info, false);
> +
> if (!info->enabled)
> /*
> * The kernel uses this memory block, but it may be not
>
WARNING: multiple messages have this Message-ID (diff)
From: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
To: Toshi Kani <toshi.kani@hp.com>
Cc: <rjw@sisk.pl>, <linux-acpi@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
<vasilis.liaskovitis@profitbricks.com>
Subject: Re: [PATCH v2] ACPI: Add sysfs links from memory device to memblocks
Date: Tue, 26 Feb 2013 14:37:11 +0900 [thread overview]
Message-ID: <512C4A07.40903@jp.fujitsu.com> (raw)
In-Reply-To: <1361826130-31062-1-git-send-email-toshi.kani@hp.com>
2013/02/26 6:02, Toshi Kani wrote:
> In order to eject a memory device object represented as "PNP0C80:%d"
> in sysfs, its associated memblocks (system/memory/memory%d) need to
> be off-lined. However, there is no user friendly way to correlate
> between a memory device object and its memblocks in sysfs.
>
> This patch creates sysfs links to memblocks under a memory device
> object so that a user can easily checks and manipulates its memblocks
> in sysfs.
>
> For example, when PNP0C80:05 is associated with memory8 and memory9,
> the following two links are created under PNP0C80:05. This allows
> a user to access memory8/9 directly from PNP0C80:05.
>
> # ll /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C80:05
> lrwxrwxrwx. memory8 -> ../../../system/memory/memory8
> lrwxrwxrwx. memory9 -> ../../../system/memory/memory9
>
> Signed-off-by: Toshi Kani <toshi.kani@hp.com>
> ---
I confirmed that the patch has no problem.
Feel free to add:
Tested-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Acked-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Thanks,
Yasuaki Ishimatsu
>
> This patch applies on top of the Rafael's patch below.
> https://patchwork.kernel.org/patch/2153261/
>
> v2: Added a NULL return check for find_memory_block_hinted() as
> pointed by Yasuaki Ishimatsu.
>
> ---
> drivers/acpi/acpi_memhotplug.c | 56 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 56 insertions(+)
>
> diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
> index 3b3abbc..98477a5 100644
> --- a/drivers/acpi/acpi_memhotplug.c
> +++ b/drivers/acpi/acpi_memhotplug.c
> @@ -28,6 +28,7 @@
> */
>
> #include <linux/acpi.h>
> +#include <linux/memory.h>
> #include <linux/memory_hotplug.h>
>
> #include "internal.h"
> @@ -168,6 +169,55 @@ static int acpi_memory_check_device(struct acpi_memory_device *mem_device)
> return 0;
> }
>
> +static void acpi_setup_mem_blk_links(struct acpi_memory_device *mem_device,
> + struct acpi_memory_info *info, bool add_links)
> +{
> + struct memory_block *mem_blk = NULL;
> + struct mem_section *mem_sect;
> + unsigned long start_pfn, end_pfn, pfn;
> + unsigned long section_nr;
> + int ret;
> +
> + start_pfn = PFN_DOWN(info->start_addr);
> + end_pfn = PFN_UP(info->start_addr + info->length-1);
> +
> + for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
> + section_nr = pfn_to_section_nr(pfn);
> +
> + if (!present_section_nr(section_nr))
> + continue;
> +
> + mem_sect = __nr_to_section(section_nr);
> +
> + /* skip if the same memblock */
> + if (mem_blk)
> + if ((section_nr >= mem_blk->start_section_nr) &&
> + (section_nr <= mem_blk->end_section_nr))
> + continue;
> +
> + mem_blk = find_memory_block_hinted(mem_sect, mem_blk);
> + if (!mem_blk)
> + continue;
> +
> + if (add_links) {
> + ret = sysfs_create_link_nowarn(
> + &mem_device->device->dev.kobj,
> + &mem_blk->dev.kobj,
> + kobject_name(&mem_blk->dev.kobj));
> + if (ret && ret != -EEXIST)
> + dev_err(&mem_device->device->dev,
> + "Failed to create sysfs link %s\n",
> + kobject_name(&mem_blk->dev.kobj));
> + } else {
> + sysfs_remove_link(&mem_device->device->dev.kobj,
> + kobject_name(&mem_blk->dev.kobj));
> + }
> + }
> +
> + if (mem_blk)
> + kobject_put(&mem_blk->dev.kobj);
> +}
> +
> static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
> {
> int result, num_enabled = 0;
> @@ -207,6 +257,9 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
> continue;
> }
>
> + /* Create sysfs links to its mem_blk devices */
> + acpi_setup_mem_blk_links(mem_device, info, true);
> +
> if (!result)
> info->enabled = 1;
> /*
> @@ -241,6 +294,9 @@ static int acpi_memory_remove_memory(struct acpi_memory_device *mem_device)
> /* The kernel does not use this memory block */
> continue;
>
> + /* Remove sysfs links to its mem_blk devices */
> + acpi_setup_mem_blk_links(mem_device, info, false);
> +
> if (!info->enabled)
> /*
> * The kernel uses this memory block, but it may be not
>
next prev parent reply other threads:[~2013-02-26 5:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-25 21:02 [PATCH v2] ACPI: Add sysfs links from memory device to memblocks Toshi Kani
2013-02-26 5:37 ` Yasuaki Ishimatsu [this message]
2013-02-26 5:37 ` Yasuaki Ishimatsu
2013-02-26 17:16 ` Toshi Kani
2013-03-26 13:04 ` Rafael J. Wysocki
2013-03-26 15:42 ` Toshi Kani
2013-03-26 22:39 ` Rafael J. Wysocki
2013-03-26 22:59 ` Toshi Kani
2013-03-26 23:39 ` Rafael J. Wysocki
2013-03-27 17:13 ` Toshi Kani
2013-04-11 22:23 ` Rafael J. Wysocki
2013-04-12 18:13 ` Toshi Kani
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=512C4A07.40903@jp.fujitsu.com \
--to=isimatu.yasuaki@jp.fujitsu.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rjw@sisk.pl \
--cc=toshi.kani@hp.com \
--cc=vasilis.liaskovitis@profitbricks.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.