From patchwork Wed Jul 3 00:30:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 2814891 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B3019BF4A1 for ; Wed, 3 Jul 2013 00:30:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A70A020134 for ; Wed, 3 Jul 2013 00:30:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BEB4B20121 for ; Wed, 3 Jul 2013 00:30:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753006Ab3GCAaJ (ORCPT ); Tue, 2 Jul 2013 20:30:09 -0400 Received: from mail-ie0-f169.google.com ([209.85.223.169]:34911 "EHLO mail-ie0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752639Ab3GCAaI (ORCPT ); Tue, 2 Jul 2013 20:30:08 -0400 Received: by mail-ie0-f169.google.com with SMTP id 10so14225893ied.0 for ; Tue, 02 Jul 2013 17:30:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:user-agent:mime-version :content-type:content-transfer-encoding; bh=K4Rzlagsaf8GPURjayYyiSyqZh6zxxYefZ+cXLlplwE=; b=kOATRnTjxhV+giolvl7vmSizEVZNv7U4D9ZpCsfP3qolL+Y0PP3fy0iH6P6JFN4Zg5 APIwJPjJ2J/0Z//ZJ1oYHn0f2Y3h7SAIr8wRuD4Mxr+irf5WTYbSM5kLXqpl+W1KtlBf kM/94K7lrMNodAg33A42Dm/sVyWN0rEULGrpPtAeV6BNVDBaayZJAU+IQL0z4DiozCl8 GzALTwuRfR2H8zbMXfOXbMZO90N7yTlR6ayjOQDTbVOFnuq6YNjpng6WCGYSQ+69oLkr 1hmxgcQZ6C1rPx25oxfFG0R1KKTmd82GtKvNuC8WLNjVMKKqUJFaYtST4GsR49cKkNSV vUlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:user-agent:mime-version :content-type:content-transfer-encoding:x-gm-message-state; bh=K4Rzlagsaf8GPURjayYyiSyqZh6zxxYefZ+cXLlplwE=; b=erstpi7VSG1F31uTNDql6RjXlvMvAnLIeXk30My/AcYY9CE0zAwMzcIdnIh81anaij 4nyQEkkO1Fz5DzHVq1gKtWLcaTPH7o2bqPBn57/enJg+mRzQlZTfNsGf8YhNuJtk1vsK X3ympqE2Ms2g1yYN/A2i4QfnDTA5dSOZQZAtYQyFAtJYVXq/RHCUv0demORhefnUFI62 J3WKVFMbZODzL8spEYImADgj6aslkqe8AOwkD35Q6+S21ITWnqzTZ5sljHTEN86VtLyy LYv6do3mDoRw5TmT86JQl3uLlI1DUF5AGroCZMBanwuYW+BUCocLm52TZbYdZVKWlSj6 y8cA== X-Received: by 10.50.47.12 with SMTP id z12mr15173368igm.50.1372811407103; Tue, 02 Jul 2013 17:30:07 -0700 (PDT) Received: from localhost ([172.16.48.211]) by mx.google.com with ESMTPSA id n5sm21198375igv.5.2013.07.02.17.30.06 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 02 Jul 2013 17:30:06 -0700 (PDT) Subject: [PATCH] ACPICA: acpi_read: update return_value atomically To: Bob Moore From: Bjorn Helgaas Cc: "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Lv Zheng , Len Brown Date: Tue, 02 Jul 2013 18:30:05 -0600 Message-ID: <20130703003005.27281.39531.stgit@bhelgaas-glaptop> User-Agent: StGit/0.16 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQlpNMdA88tlZljlGWBW7aukupeQuPTH72A1eCVmrPGc2EgUle4pSnWrkChwL9ueootNdcfG/6FCjtO+ay8F8Ob0GjnCR1FxxhkxLSaqBMICa5BUb2IJiaNenl08KE5FSy9jzCEzMGvmjpg0NAUBUxcrNgChpD2PHi61WvGnBQP401dpwvdbffs9zlMi5wDlpUDLKnq0C7R5VkCbsj7udR5A2eHgHA== Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Accumulate the entire 64-bit value before updating the return_value. Previously, it was possible to update the low 32 bits, then return failure if reading the upper 32 bits failed, leaving a half-updated return_value. Signed-off-by: Bjorn Helgaas --- drivers/acpi/acpica/hwxface.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c index 04c2e16..2d64972 100644 --- a/drivers/acpi/acpica/hwxface.c +++ b/drivers/acpi/acpica/hwxface.c @@ -119,9 +119,10 @@ ACPI_EXPORT_SYMBOL(acpi_reset) ******************************************************************************/ acpi_status acpi_read(u64 *return_value, struct acpi_generic_address *reg) { - u32 value; + u32 word; u32 width; u64 address; + u64 value; acpi_status status; ACPI_FUNCTION_NAME(acpi_read); @@ -141,6 +142,7 @@ acpi_status acpi_read(u64 *return_value, struct acpi_generic_address *reg) *return_value = 0; value = 0; + word = 0; /* * Two address spaces supported: Memory or IO. PCI_Config is @@ -161,28 +163,29 @@ acpi_status acpi_read(u64 *return_value, struct acpi_generic_address *reg) } status = acpi_hw_read_port((acpi_io_address) - address, &value, width); + address, &word, width); if (ACPI_FAILURE(status)) { return (status); } - *return_value = value; + value = word; if (reg->bit_width == 64) { /* Read the top 32 bits */ status = acpi_hw_read_port((acpi_io_address) - (address + 4), &value, 32); + (address + 4), &word, 32); if (ACPI_FAILURE(status)) { return (status); } - *return_value |= ((u64)value << 32); + value |= ((u64)word << 32); } } + *return_value = value; ACPI_DEBUG_PRINT((ACPI_DB_IO, "Read: %8.8X%8.8X width %2d from %8.8X%8.8X (%s)\n", - ACPI_FORMAT_UINT64(*return_value), reg->bit_width, + ACPI_FORMAT_UINT64(value), reg->bit_width, ACPI_FORMAT_UINT64(address), acpi_ut_get_region_name(reg->space_id)));