From patchwork Fri Nov 23 17:50:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasilis Liaskovitis X-Patchwork-Id: 1796641 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 7B793E00B6 for ; Fri, 23 Nov 2012 17:51:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756062Ab2KWRux (ORCPT ); Fri, 23 Nov 2012 12:50:53 -0500 Received: from mail-bk0-f46.google.com ([209.85.214.46]:64017 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755803Ab2KWRuw (ORCPT ); Fri, 23 Nov 2012 12:50:52 -0500 Received: by mail-bk0-f46.google.com with SMTP id q16so3985273bkw.19 for ; Fri, 23 Nov 2012 09:50:51 -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=jeP2mJAZaZVvBdXgA/oCCigemM0ZQqA6lafx0I+dJOg=; b=EIruU5J7ZhBgyeVB69kguT5Vl8e7ttte13wbjq7GC8EqT9ZQCl1g7XDfozJNxqAY9O 0NUJ8led//mLvhCmXfBUONqN+Q4IwhJuww6OCeA3Th5whyv4mwgeY1d5cpanPB5hWK+e 170RwSdLK3C79CXsVW4DXOLAtPlNf2Sanws7HhA4uQ61G0eedKVf676gHeMBKcokpjKh +ZqDocrAh8+uavLGVFipgPfshQBg8py0wWBV3n6ZAeTpD/JXdPxLdDWSghPCDBVYn7vd z0OfMd06lbKROe4J6RyKsactx3hnxIUrxFwbcDveN1k/9wNL6UjV+P6Z6amT5RytWeOw CyPw== Received: by 10.204.130.87 with SMTP id r23mr1435974bks.90.1353693051385; Fri, 23 Nov 2012 09:50:51 -0800 (PST) Received: from dhcp-192-168-178-175.ri.profitbricks.localdomain ([62.217.45.26]) by mx.google.com with ESMTPS id 1sm5165091bks.3.2012.11.23.09.50.49 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 23 Nov 2012 09:50:50 -0800 (PST) From: Vasilis Liaskovitis To: linux-acpi@vger.kernel.org, isimatu.yasuaki@jp.fujitsu.com, wency@cn.fujitsu.com Cc: rjw@sisk.pl, lenb@kernel.org, toshi.kani@hp.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Vasilis Liaskovitis Subject: [RFC PATCH v3 3/3] acpi_memhotplug: Allow eject to proceed on rebind scenario Date: Fri, 23 Nov 2012 18:50:37 +0100 Message-Id: <1353693037-21704-4-git-send-email-vasilis.liaskovitis@profitbricks.com> X-Mailer: git-send-email 1.7.9 In-Reply-To: <1353693037-21704-1-git-send-email-vasilis.liaskovitis@profitbricks.com> References: <1353693037-21704-1-git-send-email-vasilis.liaskovitis@profitbricks.com> X-Gm-Message-State: ALoCoQnTsTQGdHtKu9AIw4ItJPeB9XV7ifCsGFQZA+1v2x3nXOxkBG5HyJtmvezbtsUvNmVYJDAR Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Consider the following sequence of operations for a hotplugged memory device: 1. echo "PNP0C80:XX" > /sys/bus/acpi/drivers/acpi_memhotplug/unbind 2. echo "PNP0C80:XX" > /sys/bus/acpi/drivers/acpi_memhotplug/bind 3. echo 1 >/sys/bus/pci/devices/PNP0C80:XX/eject The driver is successfully re-bound to the device in step 2. However step 3 will not attempt to remove the memory. This is because the acpi_memory_info enabled bit for the newly bound driver has not been set to 1. This bit needs to be set in the case where the memory is already used by the kernel (add_memory returns -EEXIST) Setting the enabled bit in this case (in acpi_memory_enable_device) makes the driver function properly after a rebind of the driver i.e. eject operation attempts to remove memory after a successful rebind. I am not sure if this breaks some other usage of the enabled bit (see commit 65479472). When is it possible for the memory to be in use by the kernel but not managed by the acpi driver, apart from a driver unbind scenario? Perhaps the patch is not needed, depending on expected semantics of re-binding. Is the newly bound driver supposed to manage the device, if it was earlier managed by the same driver? This patch is only specific to this scenario, and can be dropped from the patch series if needed. Signed-off-by: Vasilis Liaskovitis --- drivers/acpi/acpi_memhotplug.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index d0cfbd9..0562cb4 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c @@ -271,12 +271,11 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) continue; } - if (!result) - info->enabled = 1; /* * Add num_enable even if add_memory() returns -EEXIST, so the * device is bound to this driver. */ + info->enabled = 1; num_enabled++; } if (!num_enabled) {