From patchwork Wed Jul 31 19:28:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 2836551 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 DB324C0319 for ; Wed, 31 Jul 2013 19:28:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 021A52025A for ; Wed, 31 Jul 2013 19:28:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 44BD020292 for ; Wed, 31 Jul 2013 19:28:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752816Ab3GaT2o (ORCPT ); Wed, 31 Jul 2013 15:28:44 -0400 Received: from mail-yh0-f46.google.com ([209.85.213.46]:57790 "EHLO mail-yh0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751888Ab3GaT2n (ORCPT ); Wed, 31 Jul 2013 15:28:43 -0400 Received: by mail-yh0-f46.google.com with SMTP id i57so525642yha.33 for ; Wed, 31 Jul 2013 12:28:41 -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=njC0t2vneuit9otH+9sg+ugc4qH9qVAlSWR5FmR29CQ=; b=P63AlNe0etUsi57eHxs/5xuRlIMB46D7n+xybE3m7S8vAXvG7zL7GDRPlHZVg2FAHV PpopKIpjcozcbgpvoy3nQ5yeEcpj4spwhitpeolgdNKLZr0a5Zmxlx/Ljh8ncU+sP8SS +/Crm4AAlzMg+h3dVh7qQrHzgR7zieHsVZwNzZmcOVM15pHsMo+UzAibjiEd2kqCmfEh kcilSRwI3xa7N2WrTDe+uuWuwu1FMMw/EvwyemZ2Khvl3rt9BjeZfr8UMJzpLOKGHslp ssOfJ7kfobjldLxSuUdOWvV5TmiE4/LJsdgFr2230tm+0oHtzQTggXsUf0ryY3POYSU8 PsMg== 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=njC0t2vneuit9otH+9sg+ugc4qH9qVAlSWR5FmR29CQ=; b=TiAdmR+6DmYmwm68zERMZzTIcq2Flf7xX1MqiD4vc7duyRkoDMUgIyTBvAVIBSv2NE PYqtFOlF2IR1J/HChyjDsLOXlB8D/CWSdRvgMTqPK9BYef072FrUYc5xEk+VzDljW/qv jgAtNCtsfvPF4zy5aClc/OF2UsJxkcTh7DF3E3Ny6ql8fdy+1Y+tyRp7J7Eet+OZAgGG nkWqtLZdrqE2L3OICHKdV+OIG9KsisJoAXZTHo2E5lY/tSFdHdl6wj/ieKCi0AOh7JlW FEPk/bguu/+SfEUxk6iJxbuz5PKJ5nxyGl00BO5KomI2QXEGiDkBo+Obt8nfrxa44rNw qwSg== X-Received: by 10.236.46.4 with SMTP id q4mr33557632yhb.217.1375298920963; Wed, 31 Jul 2013 12:28:40 -0700 (PDT) Received: from localhost ([172.29.120.19]) by mx.google.com with ESMTPSA id s29sm4367281yhf.6.2013.07.31.12.28.39 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 31 Jul 2013 12:28:40 -0700 (PDT) Subject: [PATCH v2] 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: Wed, 31 Jul 2013 13:28:37 -0600 Message-ID: <20130731192837.8393.78635.stgit@bhelgaas-glaptop> User-Agent: StGit/0.16 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQnTQz83wvuBYIIl0yGIn6gCLAK5l7VYD2DX0hKTpc/nJxMUmzyemj/tSYk4kuFwEOeD7X2+3AD9ms+1Qgz9/zfmH8wn6iqW8kLnjWEe8JPhzgjvrHmqGOHutM55wYqZofgbiuhgmvTEYqlT9robLvMw3fTd8zTptVm6pn2Y814CZBigsgY8lhCaN2dfDvFRTy64e7eBcQwt7qo6LOSNu7IpjUp/Og== Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-8.3 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 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 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 5ee7a81..3cf7b86 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); @@ -137,10 +138,8 @@ acpi_status acpi_read(u64 *return_value, struct acpi_generic_address *reg) return (status); } - /* Initialize entire 64-bit return value to zero */ - - *return_value = 0; value = 0; + word = 0; /* * Two address spaces supported: Memory or IO. PCI_Config is @@ -161,32 +160,33 @@ 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))); - return (status); + return (AE_OK); } ACPI_EXPORT_SYMBOL(acpi_read)