From patchwork Fri Jan 19 11:10:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oza Pawandeep X-Patchwork-Id: 10175053 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2429060386 for ; Fri, 19 Jan 2018 11:10:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1511B2856E for ; Fri, 19 Jan 2018 11:10:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0867828632; Fri, 19 Jan 2018 11:10:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E1D02856E for ; Fri, 19 Jan 2018 11:10:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755445AbeASLKq (ORCPT ); Fri, 19 Jan 2018 06:10:46 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:60544 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751212AbeASLK3 (ORCPT ); Fri, 19 Jan 2018 06:10:29 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 40CE760A5F; Fri, 19 Jan 2018 11:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1516360229; bh=AsvJ+SOFQRslN6hmcHEEPHLzEs1VFTOYfij4cYW9OVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L98P/CS+BCPFJVZ3Vwr7wQRiMBzEMkNuiM2fVglwGD0vfPjdwCPRKNgSfDibv2bFQ AW1A+IBk4GfqdUUtO09JNlRUkJyzoOPhbIOoqthvwZZuec+0ZFjHZCsu+CUvHmGNDP 4raSgZRR+0ceiUE96ymNXcL58KSurThPMfh35Rw4= Received: from blr-ubuntu-poza.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: poza@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id D9D8E60452; Fri, 19 Jan 2018 11:10:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1516360228; bh=AsvJ+SOFQRslN6hmcHEEPHLzEs1VFTOYfij4cYW9OVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TnKcH3q/4r8z9LW38v1Yqu+YBHrQpJxJyawAsAkDhdOzCkqu84GqSPShIG1ukpgHl P6qnCnwbpx1VU65iWGSIdUHrIz0Hcr++JscGT3P80+NwwPq8wqo01aoJpqCXwsTMZq oJLMBIu5z3W58nFeaJIEpXAFByCwKNZnnXSEf/Gg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D9D8E60452 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=poza@codeaurora.org From: Oza Pawandeep To: Bjorn Helgaas , Philippe Ombredanne , Thomas Gleixner , Greg Kroah-Hartman , Kate Stewart , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Dongdong Liu , Keith Busch , Wei Zhang , Sinan Kaya , Timur Tabi Cc: Oza Pawandeep Subject: [PATCH v6 3/7] PCI/ERR: add mutex to synchronize recovery Date: Fri, 19 Jan 2018 16:40:00 +0530 Message-Id: <1516360204-1586-4-git-send-email-poza@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1516360204-1586-1-git-send-email-poza@codeaurora.org> References: <1516360204-1586-1-git-send-email-poza@codeaurora.org> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch protects pci_do_recovery with mutex. Signed-off-by: Oza Pawandeep diff --git a/drivers/pci/pcie/pcie-err.c b/drivers/pci/pcie/pcie-err.c index a532fe0..8318c84 100644 --- a/drivers/pci/pcie/pcie-err.c +++ b/drivers/pci/pcie/pcie-err.c @@ -20,6 +20,8 @@ #include #include "portdrv.h" +static DEFINE_MUTEX(pci_err_recovery_lock); + struct aer_broadcast_data { enum pci_channel_state state; enum pci_ers_result result; @@ -283,6 +285,8 @@ void pci_do_recovery(struct pci_dev *dev, int severity) pci_ers_result_t status, result = PCI_ERS_RESULT_RECOVERED; enum pci_channel_state state; + mutex_lock(&pci_err_recovery_lock); + if (severity == AER_FATAL) state = pci_channel_io_frozen; else @@ -326,9 +330,11 @@ void pci_do_recovery(struct pci_dev *dev, int severity) report_resume); dev_info(&dev->dev, "Device recovery successful\n"); + mutex_unlock(&pci_err_recovery_lock); return; failed: /* TODO: Should kernel panic here? */ dev_info(&dev->dev, "Device recovery failed\n"); + mutex_unlock(&pci_err_recovery_lock); }