Received: by 10.223.185.116 with SMTP id b49csp5026520wrg; Tue, 27 Feb 2018 06:43:03 -0800 (PST) X-Google-Smtp-Source: AH8x227K9518WwdQaNWjF5qqH3r/MhSWReKM/iY0obqEhTABMD0YO1fe5QVO7fmIrTXvl8t2+lqu X-Received: by 2002:a17:902:6c4c:: with SMTP id h12-v6mr14310000pln.101.1519742583723; Tue, 27 Feb 2018 06:43:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519742583; cv=none; d=google.com; s=arc-20160816; b=dxYxUSZ35zco4SXq7rfWuhqgLXwLzyBIV2cATpHLJJXkcWd2Hbw38pYFAd9TWi4yOz 69bOcd0rIzapBapnIEdArveMBDjWt1CiWtapAQ9u8KFJfZXuerj48gNlQmIZcskAWpvY 7KcZjVvLqxNWelgBvDQdyKsb5Hkv4NrmEZhjnNVXihwEzd64SmS+wWlgomXVW7EWSant gNVn+DeZP314xviLmiB9s+OMKINy0nJXqBt4Mi59fINgNXuBdMvyv69Fn1M9PryhFS50 aIu2BmSu4qTZTogPWPcwHeYV9A5ddR0ndiQ+m6lqJiVHqA9XSuAhCPFhskzv8LqeN8vb eLxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:arc-authentication-results; bh=UfBDoIJRQdKicjQbe6jVS6NgyOsgIUF2m32WI91w5BA=; b=dYtbM8LcTpTiFxitWWo+RmY7N9qEvIee4w0wiqMrNrR+AU8s2n57zaTdKHnTWtYBHq B5ezKJdycHrf75FXn7sqQFfGC8M0I7US2j/nCreZdP3p8ZqmDdmmiUWO35EejKzC6SaL YYJmkz3XGb2Q25Q3q8rMU/Y+Tao7Qs2dDuBqXWIqc4rfeggCYozvVRyP6frpQhWal5q1 d511Cfo7v/J3FqrbO0lt11t7dLtQSGv4kJ6zuowh/gNIJoXaTPdE9ou7aKQasd/IrKPQ 4z+XRujsdRFnQeLWgqqu5RP+8zYWcGESguxUVBqwb761LKK6xOb2ktmKsfQVsHpuv8Hs htIQ== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s12si7111223pgr.762.2018.02.27.06.42.48; Tue, 27 Feb 2018 06:43:03 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753579AbeB0OmB (ORCPT + 99 others); Tue, 27 Feb 2018 09:42:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:43654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753156AbeB0Ol7 (ORCPT ); Tue, 27 Feb 2018 09:41:59 -0500 Received: from localhost (50-81-63-165.client.mchsi.com [50.81.63.165]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B48422168D; Tue, 27 Feb 2018 14:41:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B48422168D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=helgaas@kernel.org Date: Tue, 27 Feb 2018 08:41:57 -0600 From: Bjorn Helgaas To: poza@codeaurora.org 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 Message-ID: <20180227144157.GA112033@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> <34e4c9a98a9ed3494a0295d00e181fe9@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <34e4c9a98a9ed3494a0295d00e181fe9@codeaurora.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 27, 2018 at 10:46:34AM +0530, poza@codeaurora.org wrote: > 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. I'm not trying to convince you that we don't need the mutex. My point is that if we *do* need it, the changelog needs to say *why* (and ideally the code will either have a comment or it will be obvious from the code why it's necessary). If we don't have a clear indication that it's required, I guess I would omit it. > > > 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. > > >