From patchwork Thu Nov 8 18:29:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasilis Liaskovitis X-Patchwork-Id: 1716861 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 5DE873FCF7 for ; Thu, 8 Nov 2012 18:30:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756618Ab2KHS3o (ORCPT ); Thu, 8 Nov 2012 13:29:44 -0500 Received: from mail-bk0-f46.google.com ([209.85.214.46]:44469 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756624Ab2KHS3n (ORCPT ); Thu, 8 Nov 2012 13:29:43 -0500 Received: by mail-bk0-f46.google.com with SMTP id jk13so1346644bkc.19 for ; Thu, 08 Nov 2012 10:29:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=UemZS5t1XvnAn8l6rL8olJnJv+urjELfRKQQ36cbXiE=; b=WJAjRpV2051woFWxA7EQQPItZL8nNHAR+bU2xAz0yJuc8i/8XfaHSncscUhBslz0YV U++bBQyPl9cEbasTqzJPIdneKz98uGrtGHv/6zDkF+uY9QD2HD38vAnIUh4GKv/IDm4x NW0YHnSgDzs0MzKkACq83TObAUL+vgFwOLboP7Gl831/CVUEZxMhjyX+Q1hduELFG9Qv pgumCS6s9ncarQkFRbyQFfB+21bmKUZm/3iL64BGXTgh9Y0jkzXPluRmAyv7h0q68scI EHOhRB8P1KrzHhQCipT1Mw8fPkMg5cfF776FkgHWbln2eqorrRyXodZqhLg/JpcgDGGM JeAQ== Received: by 10.204.130.21 with SMTP id q21mr2580010bks.5.1352399382340; Thu, 08 Nov 2012 10:29:42 -0800 (PST) Received: from dhcp-192-168-178-175.ri.profitbricks.localdomain ([62.217.45.26]) by mx.google.com with ESMTPS id z22sm17670961bkw.2.2012.11.08.10.29.40 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 08 Nov 2012 10:29:41 -0800 (PST) From: Vasilis Liaskovitis To: linux-acpi@vger.kernel.org, isimatu.yasuaki@jp.fujitsu.com Cc: rjw@sisk.pl, wency@cn.fujitsu.com, lenb@kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, Vasilis Liaskovitis Subject: [RFC PATCH 3/3] acpi_memhotplug: Add prepare_remove operation Date: Thu, 8 Nov 2012 19:29:31 +0100 Message-Id: <1352399371-8015-4-git-send-email-vasilis.liaskovitis@profitbricks.com> X-Mailer: git-send-email 1.7.9 In-Reply-To: <1352399371-8015-1-git-send-email-vasilis.liaskovitis@profitbricks.com> References: <1352399371-8015-1-git-send-email-vasilis.liaskovitis@profitbricks.com> X-Gm-Message-State: ALoCoQl3r+QpEcTw0119PmugHnGobR3exGuFAQfzF1fJQEjVttKKdEK+EUgSqn6qTuTTBBQkZ1b7 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Offlining and removal of memory is now done in the prepare_remove callback, not in the remove callback. Signed-off-by: Vasilis Liaskovitis --- drivers/acpi/acpi_memhotplug.c | 22 ++++++++++++++++++++-- 1 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index 7fcc844..9b734a5 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c @@ -54,6 +54,7 @@ MODULE_LICENSE("GPL"); static int acpi_memory_device_add(struct acpi_device *device); static int acpi_memory_device_remove(struct acpi_device *device, int type); +static int acpi_memory_device_prepare_remove(struct acpi_device *device); static const struct acpi_device_id memory_device_ids[] = { {ACPI_MEMORY_DEVICE_HID, 0}, @@ -68,6 +69,7 @@ static struct acpi_driver acpi_memory_device_driver = { .ops = { .add = acpi_memory_device_add, .remove = acpi_memory_device_remove, + .prepare_remove = acpi_memory_device_prepare_remove, }, }; @@ -499,6 +501,20 @@ static int acpi_memory_device_add(struct acpi_device *device) static int acpi_memory_device_remove(struct acpi_device *device, int type) { struct acpi_memory_device *mem_device = NULL; + + if (!device || !acpi_driver_data(device)) + return -EINVAL; + + mem_device = acpi_driver_data(device); + + kfree(mem_device); + + return 0; +} + +static int acpi_memory_device_prepare_remove(struct acpi_device *device) +{ + struct acpi_memory_device *mem_device = NULL; int result; if (!device || !acpi_driver_data(device)) @@ -506,12 +522,14 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type) mem_device = acpi_driver_data(device); + /* + * offline and remove memory only when the memory device is + * ejected. + */ result = acpi_memory_remove_memory(mem_device); if (result) return result; - kfree(mem_device); - return 0; }