From: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: mst@redhat.com, qemu-devel@nongnu.org, tangchen@cn.fujitsu.com,
izumi.taku@jp.fujitsu.com, guz.fnst@cn.fujitsu.com,
pbonzini@redhat.com
Subject: Re: [Qemu-devel] [RESEND PATCH v4 6/6] acpi: Add hardware implementation for memory hot unplug
Date: Tue, 24 Mar 2015 17:38:53 +0800 [thread overview]
Message-ID: <551130AD.1060408@cn.fujitsu.com> (raw)
In-Reply-To: <20150316155933.1186d483@nial.brq.redhat.com>
On 03/16/2015 10:59 PM, Igor Mammedov wrote:
> On Mon, 16 Mar 2015 16:58:18 +0800
> Zhu Guihua <zhugh.fnst@cn.fujitsu.com> wrote:
>
>> This patch adds a new bit to memory hotplug IO port indicating that
> actually bit was added in 2/6 where is_removing had been added.
>
>> EJ0 has been evaluated by guest OS. And call pc-dimm unplug cb to do
>> the real removal.
>>
>> Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
>> ---
>> docs/specs/acpi_mem_hotplug.txt | 11 +++++++++--
>> hw/acpi/memory_hotplug.c | 21 +++++++++++++++++++--
>> hw/core/qdev.c | 2 +-
>> hw/i386/acpi-build.c | 9 +++++++++
>> hw/i386/acpi-dsdt-mem-hotplug.dsl | 10 ++++++++++
>> include/hw/acpi/pc-hotplug.h | 2 ++
>> include/hw/qdev-core.h | 1 +
>> trace-events | 1 +
>> 8 files changed, 52 insertions(+), 5 deletions(-)
>>
>> diff --git a/docs/specs/acpi_mem_hotplug.txt b/docs/specs/acpi_mem_hotplug.txt
>> index 1290994..85cd4b8 100644
>> --- a/docs/specs/acpi_mem_hotplug.txt
>> +++ b/docs/specs/acpi_mem_hotplug.txt
>> @@ -19,7 +19,9 @@ Memory hot-plug interface (IO port 0xa00-0xa17, 1-4 byte access):
>> 1: Device insert event, used to distinguish device for which
>> no device check event to OSPM was issued.
>> It's valid only when bit 1 is set.
>> - 2-7: reserved and should be ignored by OSPM
>> + 2: Device remove event, used to distinguish device for which
>> + no device check event to OSPM was issued.
>> + 3-7: reserved and should be ignored by OSPM
>> [0x15-0x17] reserved
>>
>> write access:
>> @@ -35,7 +37,12 @@ Memory hot-plug interface (IO port 0xa00-0xa17, 1-4 byte access):
>> 1: if set to 1 clears device insert event, set by OSPM
>> after it has emitted device check event for the
>> selected memory device
>> - 2-7: reserved, OSPM must clear them before writing to register
>> + 2: if set to 1 clears device remove event, set by OSPM
>> + after it has emitted device check event for the
>> + selected memory device. if guest fails to eject device, it
>> + should send OST event about it and forget about device
>> + removal.
>> + 3-7: reserved, OSPM must clear them before writing to register
>>
>> Selecting memory device slot beyond present range has no effect on platform:
>> - write accesses to memory hot-plug registers not documented above are
>> diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
>> index 687b2f1..d6b8c89 100644
>> --- a/hw/acpi/memory_hotplug.c
>> +++ b/hw/acpi/memory_hotplug.c
>> @@ -2,6 +2,7 @@
>> #include "hw/acpi/pc-hotplug.h"
>> #include "hw/mem/pc-dimm.h"
>> #include "hw/boards.h"
>> +#include "hw/qdev-core.h"
>> #include "trace.h"
>> #include "qapi-event.h"
>>
>> @@ -91,6 +92,8 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data,
>> MemHotplugState *mem_st = opaque;
>> MemStatus *mdev;
>> ACPIOSTInfo *info;
>> + DeviceState *dev = NULL;
>> + HotplugHandler *hotplug_ctrl = NULL;
>>
>> if (!mem_st->dev_count) {
>> return;
>> @@ -122,19 +125,33 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data,
>> mdev = &mem_st->devs[mem_st->selector];
>> mdev->ost_status = data;
>> trace_mhp_acpi_write_ost_status(mem_st->selector, mdev->ost_status);
>> - /* TODO: implement memory removal on guest signal */
>>
>> info = acpi_memory_device_status(mem_st->selector, mdev);
>> qapi_event_send_acpi_device_ost(info, &error_abort);
>> qapi_free_ACPIOSTInfo(info);
>> break;
>> - case 0x14:
>> + case 0x14: /* set is_* fields */
>> mdev = &mem_st->devs[mem_st->selector];
>> if (data & 2) { /* clear insert event */
>> mdev->is_inserting = false;
>> trace_mhp_acpi_clear_insert_evt(mem_st->selector);
>> + } else if (data & 4) { /* request removal of device */
> fix comment to match docs above.
>
>> + mdev->is_removing = false;
>> + trace_mhp_acpi_clear_remove_evt(mem_st->selector);
> just clear event here and don't do removal part as it doesn't match
> documentation you've written above regarding this field.
>
> It would be better to move is_removing handling from here to 2/6
> + related ASL code from DSDT which should clear it after sending device check.
>
>> + /*
>> + * QEMU memory hot unplug is an asynchronous procedure. QEMU first
>> + * calls pc-dimm unplug request cb to send a SCI to guest. When the
>> + * guest OS finished handling the SCI, it evaluates ACPI EJ0, and
>> + * QEMU calls pc-dimm unplug cb to remove memory device.
>> + */
> something like this comment, should be in acpi_mem_hotplug.txt not here.
>
>
> There is 'is_enabled' field, which is 1 if device is present, we can use it
> for triggering actual ejecting in QEMU from EJ0(), something like:
>
> } else if (data & 1) { /* eject device */
I think this is not correct. When you clear insert event, the
'is_enabled' filed was also 1.
And when we hot remove memory, the addr 0x14 will be written only once.
Thanks,
Zhu
>> + dev = DEVICE(mdev->dimm);
> potential NULL dereference, dimm could be NULL if guest does eject twice
> or does eject of empty slot.
> Perhaps add check before accessing dimm.
>
> if(!mdev->is_enabled) {
> trace_..._ejecting_invalid_slot(...)
> break;
> }
>
>> + hotplug_ctrl = qdev_get_hotplug_handler(dev);
>> + /* Call pc-dimm unplug cb. */
>> + hotplug_handler_unplug(hotplug_ctrl, dev, NULL);
> It's not that we can do anything about error at this point
> but instead of forgetting it silently at least log error in trace,
> the best would be in addition to that send QMP event to notify mgmt
> about it. (sending QMP event could be a separate patch)
>
>
>> }
>> break;
>> + default:
>> + break;
>> }
>>
>> }
>>
[...]
next prev parent reply other threads:[~2015-03-24 9:40 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-16 8:58 [Qemu-devel] [RESEND PATCH v4 0/6] QEMU memory hot unplug support Zhu Guihua
2015-03-16 8:58 ` [Qemu-devel] [RESEND PATCH v4 1/6] acpi, mem-hotplug: Add acpi_memory_slot_status() to get MemStatus Zhu Guihua
2015-03-16 13:58 ` Michael S. Tsirkin
2015-03-19 1:52 ` Zhu Guihua
2015-03-19 5:59 ` Michael S. Tsirkin
2015-03-16 8:58 ` [Qemu-devel] [RESEND PATCH v4 2/6] acpi, mem-hotplug: Add unplug request cb for memory device Zhu Guihua
2015-03-16 13:53 ` Igor Mammedov
2015-03-16 8:58 ` [Qemu-devel] [RESEND PATCH v4 3/6] pc-dimm: Add memory hot unplug request support for pc-dimm Zhu Guihua
2015-03-16 13:56 ` Igor Mammedov
2015-03-16 8:58 ` [Qemu-devel] [RESEND PATCH v4 4/6] acpi, mem-hotplug: Add unplug cb for memory device Zhu Guihua
2015-03-16 14:10 ` Igor Mammedov
2015-03-16 8:58 ` [Qemu-devel] [RESEND PATCH v4 5/6] pc-dimm: Add memory hot unplug support for pc-dimm Zhu Guihua
2015-03-16 14:20 ` Igor Mammedov
2015-03-16 8:58 ` [Qemu-devel] [RESEND PATCH v4 6/6] acpi: Add hardware implementation for memory hot unplug Zhu Guihua
2015-03-16 14:59 ` Igor Mammedov
2015-03-23 10:59 ` Zhu Guihua
2015-03-23 12:47 ` Igor Mammedov
2015-03-24 9:34 ` Zhu Guihua
2015-03-24 10:26 ` Igor Mammedov
2015-03-25 6:13 ` Zhu Guihua
2015-03-25 10:40 ` Igor Mammedov
2015-03-24 9:38 ` Zhu Guihua [this message]
2015-03-24 10:31 ` Igor Mammedov
2015-03-24 10:48 ` Zhu Guihua
2015-03-25 10:35 ` Igor Mammedov
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=551130AD.1060408@cn.fujitsu.com \
--to=zhugh.fnst@cn.fujitsu.com \
--cc=guz.fnst@cn.fujitsu.com \
--cc=imammedo@redhat.com \
--cc=izumi.taku@jp.fujitsu.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=tangchen@cn.fujitsu.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.