From patchwork Mon May 18 12:59:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 48687 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D0E212121F for ; Mon, 18 May 2015 13:00:21 +0000 (UTC) Received: by wgtl5 with SMTP id l5sf53761665wgt.1 for ; Mon, 18 May 2015 06:00:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=9r4KEUtBMMUboZuh19H0Hbp4U6oVaZEFKwmCy32Z9B8=; b=c9eazrDzPK00HYNnM7nGvY7XKalLmnQ7Bn5mWJMmJovOdO0IvTN+Gv4HT6x1r+1lpd 3E2/Ct/BQOaKWVRxnT7LYTM8JFMXoOos04H7OohY8r/7qtGK7lsQoiKFy65O+H3sF8O8 ctjSzBxOkUPV9ucWEiBuKeJsQ9EQfO5xM24PWxPXLhRTr0lCLXxarqNLnFmjreuS9i5T jgCGO/kiRwdLJwvKUx12h1pdyv1ToVqjvIpL8DXJ9mYLmfqQZ4p5ASB/qznw92IuCfg0 wbeU6W5hV4hVcbPOsuSs8IBB9sadLy1p7b/75uKyPfR43SIK/+EHPQfrZrWzrgQxWk/5 uNpA== X-Gm-Message-State: ALoCoQlIHP1eziMksu/OUYIS6fQMgXkWpWIWAT1dpq8Ms/7gEwVP5GV3c23fGqNjJOQaNVB9mu3g X-Received: by 10.194.47.179 with SMTP id e19mr17826675wjn.4.1431954021182; Mon, 18 May 2015 06:00:21 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.225.167 with SMTP id rl7ls152965lac.74.gmail; Mon, 18 May 2015 06:00:21 -0700 (PDT) X-Received: by 10.112.17.8 with SMTP id k8mr17420933lbd.28.1431954021020; Mon, 18 May 2015 06:00:21 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id t17si2007409laz.32.2015.05.18.06.00.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 May 2015 06:00:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by laat2 with SMTP id t2so218270395laa.1 for ; Mon, 18 May 2015 06:00:20 -0700 (PDT) X-Received: by 10.152.21.136 with SMTP id v8mr9578515lae.19.1431954020924; Mon, 18 May 2015 06:00:20 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp67524lbb; Mon, 18 May 2015 06:00:19 -0700 (PDT) X-Received: by 10.70.22.131 with SMTP id d3mr43955749pdf.67.1431954015486; Mon, 18 May 2015 06:00:15 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dt10si15932790pdb.120.2015.05.18.06.00.14; Mon, 18 May 2015 06:00:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752761AbbERNAM (ORCPT + 7 others); Mon, 18 May 2015 09:00:12 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:36425 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752783AbbERNAH (ORCPT ); Mon, 18 May 2015 09:00:07 -0400 Received: by pabts4 with SMTP id ts4so151397593pab.3 for ; Mon, 18 May 2015 06:00:06 -0700 (PDT) X-Received: by 10.68.247.166 with SMTP id yf6mr43710593pbc.3.1431954006747; Mon, 18 May 2015 06:00:06 -0700 (PDT) Received: from localhost ([180.150.148.224]) by mx.google.com with ESMTPSA id q4sm10065808pdo.42.2015.05.18.06.00.05 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 18 May 2015 06:00:06 -0700 (PDT) From: Hanjun Guo To: Marc Zyngier , Jason Cooper , Will Deacon , Catalin Marinas , "Rafael J. Wysocki" Cc: Jiang Liu , Lorenzo Pieralisi , Arnd Bergmann , Tomasz Nowicki , Grant Likely , Thomas Gleixner , Olof Johansson , linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, Hanjun Guo Subject: [PATCH 06/11] ACPI / gsi: Add gsi_mutex to synchronize acpi_register_gsi()/acpi_unregister_gsi() Date: Mon, 18 May 2015 20:59:16 +0800 Message-Id: <1431953961-22706-7-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431953961-22706-1-git-send-email-hanjun.guo@linaro.org> References: <1431953961-22706-1-git-send-email-hanjun.guo@linaro.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: hanjun.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add a mutex for acpi_register_gsi()/acpi_unregister_gsi() to avoid concurrency issues. Signed-off-by: Hanjun Guo --- drivers/acpi/gsi.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/gsi.c b/drivers/acpi/gsi.c index 55b5f31..ab0dcb4 100644 --- a/drivers/acpi/gsi.c +++ b/drivers/acpi/gsi.c @@ -16,6 +16,7 @@ enum acpi_irq_model_id acpi_irq_model; /* ACPI core domian pointing to GICv2/3 core domain */ struct irq_domain *acpi_irq_domain __read_mostly; +static DEFINE_MUTEX(gsi_mutex); static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity) { @@ -73,20 +74,24 @@ int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int irq; unsigned int irq_type = acpi_gsi_get_irq_type(trigger, polarity); + mutex_lock(&gsi_mutex); irq = irq_find_mapping(acpi_irq_domain, gsi); if (irq > 0) - return irq; + goto out; irq = irq_domain_alloc_irqs(acpi_irq_domain, 1, dev_to_node(dev), &gsi); if (irq <= 0) - return -EINVAL; + goto out; /* Set irq type if specified and different than the current one */ if (irq_type != IRQ_TYPE_NONE && irq_type != irq_get_trigger_type(irq)) irq_set_irq_type(irq, irq_type); - return irq; + +out: + mutex_unlock(&gsi_mutex); + return irq > 0 ? irq : -EINVAL; } EXPORT_SYMBOL_GPL(acpi_register_gsi); @@ -96,8 +101,12 @@ EXPORT_SYMBOL_GPL(acpi_register_gsi); */ void acpi_unregister_gsi(u32 gsi) { - int irq = irq_find_mapping(acpi_irq_domain, gsi); + int irq; + + mutex_lock(&gsi_mutex); + irq = irq_find_mapping(acpi_irq_domain, gsi); irq_dispose_mapping(irq); + mutex_unlock(&gsi_mutex); } EXPORT_SYMBOL_GPL(acpi_unregister_gsi);