Received: by 10.223.185.116 with SMTP id b49csp4552706wrg; Mon, 26 Feb 2018 21:19:44 -0800 (PST) X-Google-Smtp-Source: AH8x2275Gw+m+IpOY/HFYkzudN/TUNDGxFogSORDX43rqo0aDQSqNrnB1Gocj8QjF8gjsniaiiNp X-Received: by 10.98.108.65 with SMTP id h62mr13073150pfc.32.1519708784677; Mon, 26 Feb 2018 21:19:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519708784; cv=none; d=google.com; s=arc-20160816; b=QbigFrys+NbFyggPjEQGzAIGfyvA3fNRbaKOb1zXUyZOMxZmAhvLzY3Bm46mPf5Okm XU/mW9KCSPOZeSEmBy/7ywY+N1X9XFOfCVeb11Dr49lW2W5MC0xsg3kBj9W5zACPVmuj dC+9Nh4LVjXLdODN+c6qfGpHqWJmNS43SDRDjAf111bb7KoBo74WgFImD7G1pZgWbA9G /yMxBkMvsgxGf4QnBMVxyG1eDu3udgx//UagvEpPi+frU/zZWeKOAnIFwTRjvCy4qihK tMovUgxLnHz8HmGvSHBDIjFccvHMbSKw1jACekcHyAm700lGJuIVFMPleUFWnqBUbX1m 3CAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=1++SVcz9cTo1mTnyxHvKjf2Tt48gbXRlttO6GVImAr4=; b=BBdaf+hvW/a0h6+Y1otOQuV41V4Lcg4oK+smXm+vwzzs09dXtixf8eDp4O17k037ml dg5eaFtZKrmj3x9AKU2vFhEvHtPOhCUT5m3tLvnMspT3po5nb/sUz6FeQpUvHWVSJ1Ot HOI1UxUM7eIa5qUUuytG5lTmz+Qrd7EPobnpuO+Y2QCMorRIQ+IkDixVq+z1UIW3uRkb zrv56EQ3ICbXAJtVcn5jDmuBrpr6RgZmK6vWEcdbPf/+NV4C9i7+1Z0FR2SPkaw01vyY QZVeF+70oZzq/oIeqeuHj35OdSOsACOaQ09MsDzjYrIq/wJWvGCUg/623nc60rli+pD1 TdyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=BL/0WHTK; dkim=pass header.i=@codeaurora.org header.s=default header.b=fdwUZsr/; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r19si8007792pfi.100.2018.02.26.21.19.29; Mon, 26 Feb 2018 21:19:44 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=BL/0WHTK; dkim=pass header.i=@codeaurora.org header.s=default header.b=fdwUZsr/; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751979AbeB0FQw (ORCPT + 99 others); Tue, 27 Feb 2018 00:16:52 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:36410 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751679AbeB0FQf (ORCPT ); Tue, 27 Feb 2018 00:16:35 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 2F02060115; Tue, 27 Feb 2018 05:16:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519708595; bh=w8xWyo19L5AceBiUNyeQNcszUnkb7sUS90MX0EhH4uo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=BL/0WHTK0+HftoEE98J2eRZyzRjTvtjoHagZcWmhl5/I59RguJHwLmIezO3YzcuJl AylI0DajkB0J6ldPd9EciYqYyfq1NAjbYXyjEdMiWgX470xiTE7FuFzoBqy0xvOaOG D5fSGGXcPErE1KN3BjEfXw3RBmmjveB+FVb1RumE= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 1459660115; Tue, 27 Feb 2018 05:16:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519708594; bh=w8xWyo19L5AceBiUNyeQNcszUnkb7sUS90MX0EhH4uo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fdwUZsr/Dl9rjyIrwo3+eFVcGc3k5c0Y3o+MfEnVe+JhAOliYYe0DE2uoUgVavNJn Atpsdory44z7yxQy8O02JRkc9XYrRcaUmkW9LjpV+k91tw2eYwPb9ttTeIi4L/3Psv pI+g+lYZYlC4JXwbSHr+wDJ1xdzcPT3OriEo9zPg= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 27 Feb 2018 10:46:34 +0530 From: poza@codeaurora.org To: Bjorn Helgaas Cc: 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 Subject: Re: [PATCH v11 3/7] PCI/ERR: add mutex to synchronize recovery In-Reply-To: <20180223234525.GQ14632@bhelgaas-glaptop.roam.corp.google.com> References: <1519374244-20539-1-git-send-email-poza@codeaurora.org> <1519374244-20539-4-git-send-email-poza@codeaurora.org> <20180223234525.GQ14632@bhelgaas-glaptop.roam.corp.google.com> Message-ID: <34e4c9a98a9ed3494a0295d00e181fe9@codeaurora.org> X-Sender: poza@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-02-24 05:15, Bjorn Helgaas wrote: > On Fri, Feb 23, 2018 at 01:54:00PM +0530, Oza Pawandeep wrote: >> This patch protects pci_do_recovery with mutex. > > pcie_do_recovery() > > Please explain why the mutex is necessary. What bad things happen > without the mutex? > > You named (some) of the other things "pcie"; maybe use "pcie" in the > mutex name as well so they look the same. > PCIe specification: 6.2.10 When DPC is triggered due to receipt of an uncorrectable error Message, the Requester ID from the Message is recorded in the DPC Error Source ID register and that Message is discarded and not forwarded Upstream. So, having said that, what we think is we dont need Mutex, because in DPC enabled system either AER or DPC can be triggered, not both. so right now there is no need of guarding pcie_do_recovery() with mutex. but I was in a thought that; since pcie_do_recovery is supposed to be used by error clients, from sw architecture point of view, adding mutex takes care of concurrency if it exists (in corner cases, faulty hw where both AER and DPC triggered etc..) We can choose to drop this patch, since we dont require mutex. Bjorn, please advise. >> Signed-off-by: Oza Pawandeep >> >> diff --git a/drivers/pci/pcie/pcie-err.c b/drivers/pci/pcie/pcie-err.c >> index fcd5add..f830975 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 pcie_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 pcie_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); >> } >> -- >> Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm >> Technologies, Inc., >> a Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a >> Linux Foundation Collaborative Project. >>