From patchwork Mon Feb 1 22:06:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Fleming X-Patchwork-Id: 60971 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp350029lbb; Mon, 1 Feb 2016 14:07:29 -0800 (PST) X-Received: by 10.98.12.29 with SMTP id u29mr41264772pfi.116.1454364449804; Mon, 01 Feb 2016 14:07:29 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v13si26626706pas.108.2016.02.01.14.07.29; Mon, 01 Feb 2016 14:07:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@codeblueprint-co-uk.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932699AbcBAWHW (ORCPT + 30 others); Mon, 1 Feb 2016 17:07:22 -0500 Received: from mail-wm0-f46.google.com ([74.125.82.46]:34779 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932612AbcBAWHS (ORCPT ); Mon, 1 Feb 2016 17:07:18 -0500 Received: by mail-wm0-f46.google.com with SMTP id 128so91899816wmz.1 for ; Mon, 01 Feb 2016 14:07:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeblueprint-co-uk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RxvQdc9uz8/19KNtdnqcbqIuMH0Lvpm64S2wa3z/Rs4=; b=TCHkVc+EpcKQsk9y28I1KFKdN/UQF9aPFM4JckiCC3XjrX0DUNKoKOoaC3sDY+C27o 1ZCOTPd00E3UAj/yjVmEkjuTxCFgDVoSrSC2SUq6buZ8h6qfwfXvyTmegR6N08+KULQ1 VVezA6uPmIcu7cFrc0gDMi9r+vNVhIVcKxzxjYVIXhhx3lyvXrTEqsYkXctHsobEFmyj OHB6ILR+oCUExXcEAwqRrfhaGPI4fc7yO6avL45Va5v38v38XIogsDSwUclj9/z8Zkpd WsLDrVpXUIg/JtvsYCi3m6RuW0G9aQIPVSEk7LNzXlr4oe7dYkEOv2NdGmVitWiGhyix FU9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RxvQdc9uz8/19KNtdnqcbqIuMH0Lvpm64S2wa3z/Rs4=; b=LH6vVmE4wEnkf5cYgBWZ3NQ9rMKCGHRGrQ9fR+u0NAvtEP0VMbczTxFpG7ovx50g57 dCrDRtg+PWG7XEhcOMAem6mRotx7RqXzR3xmFmzB+wyWwvU49Q18zxa2AZWGIlFVCcdU Xpy0CJtraD0oXcPxr6hAzOgdARUt1/rbVnahrnt6zdq4gTiHLrobaMZj7DT4jIWXt+ZY nEzckYai6JWC7M3ofWd7SXwQI85RVbSXDh6AUo4DuE54Howvm/1B7XYj5aK64mo4jsd9 Ut1CZfapqIexS5nFKrN8fvmuq8TXLaUG2oqSA6v8HnMq5nnqFHDq+/eBeJlf5qEKntEI iEzQ== X-Gm-Message-State: AG10YOQvcK6/xMcw1UnHiP4IfSdYNOYbf4b4dpXcMPB8U8MIb/uOxcQakqPxdUMDmyZ+5Q== X-Received: by 10.194.176.170 with SMTP id cj10mr25138919wjc.165.1454364437463; Mon, 01 Feb 2016 14:07:17 -0800 (PST) Received: from localhost (5ec16434.skybroadband.com. [94.193.100.52]) by smtp.gmail.com with ESMTPSA id r10sm31069218wjz.24.2016.02.01.14.07.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Feb 2016 14:07:16 -0800 (PST) From: Matt Fleming To: Ingo Molnar , "H . Peter Anvin" , Thomas Gleixner Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Ard Biesheuvel , Matt Fleming Subject: [PATCH 03/14] efi: runtime-wrappers: Add a nonblocking version of QueryVariableInfo Date: Mon, 1 Feb 2016 22:06:57 +0000 Message-Id: <1454364428-494-4-git-send-email-matt@codeblueprint.co.uk> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1454364428-494-1-git-send-email-matt@codeblueprint.co.uk> References: <1454364428-494-1-git-send-email-matt@codeblueprint.co.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ard Biesheuvel This introduces a new runtime wrapper for the QueryVariableInfo() UEFI Runtime Service, which gives up immediately rather than spins on failure to grab the efi_runtime spinlock. This is required in the non-blocking path of the efi-pstore code. Signed-off-by: Ard Biesheuvel Signed-off-by: Matt Fleming --- drivers/firmware/efi/runtime-wrappers.c | 22 ++++++++++++++++++++++ include/linux/efi.h | 1 + 2 files changed, 23 insertions(+) -- 2.6.2 diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c index 228bbf910461..e9f2867f0d91 100644 --- a/drivers/firmware/efi/runtime-wrappers.c +++ b/drivers/firmware/efi/runtime-wrappers.c @@ -230,6 +230,27 @@ static efi_status_t virt_efi_query_variable_info(u32 attr, return status; } +static efi_status_t +virt_efi_query_variable_info_nonblocking(u32 attr, + u64 *storage_space, + u64 *remaining_space, + u64 *max_variable_size) +{ + unsigned long flags; + efi_status_t status; + + if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) + return EFI_UNSUPPORTED; + + if (!spin_trylock_irqsave(&efi_runtime_lock, flags)) + return EFI_NOT_READY; + + status = efi_call_virt(query_variable_info, attr, storage_space, + remaining_space, max_variable_size); + spin_unlock_irqrestore(&efi_runtime_lock, flags); + return status; +} + static efi_status_t virt_efi_get_next_high_mono_count(u32 *count) { unsigned long flags; @@ -300,6 +321,7 @@ void efi_native_runtime_setup(void) efi.get_next_high_mono_count = virt_efi_get_next_high_mono_count; efi.reset_system = virt_efi_reset_system; efi.query_variable_info = virt_efi_query_variable_info; + efi.query_variable_info_nonblocking = virt_efi_query_variable_info_nonblocking; efi.update_capsule = virt_efi_update_capsule; efi.query_capsule_caps = virt_efi_query_capsule_caps; } diff --git a/include/linux/efi.h b/include/linux/efi.h index 8706e0aabedc..ad1e177ba48e 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -849,6 +849,7 @@ extern struct efi { efi_set_variable_t *set_variable; efi_set_variable_t *set_variable_nonblocking; efi_query_variable_info_t *query_variable_info; + efi_query_variable_info_t *query_variable_info_nonblocking; efi_update_capsule_t *update_capsule; efi_query_capsule_caps_t *query_capsule_caps; efi_get_next_high_mono_count_t *get_next_high_mono_count;