Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp506996ybe; Mon, 2 Sep 2019 05:13:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5fPIxIf2ggnYu0MIPfLN9v1chGnCdZQCm5TDZNqx7u/AwiypVOUncgQcV1iYjle5lyUsP X-Received: by 2002:a17:90a:9a1:: with SMTP id 30mr7474347pjo.71.1567426428845; Mon, 02 Sep 2019 05:13:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567426428; cv=none; d=google.com; s=arc-20160816; b=e36ThE/uVnlUS0PAjiRdm+cCNEaTCLPGuqk9GDel/ogMLWXbHVqf3FK3kwWD31H0Vl JZX9M8YGzfFpJftSjqIPdziaRJ+ZQJmaGNxNBdz7pxAxyG35rqEmijbcGFPZkX2Ln5c2 PEULySZ1kIPxJHjSfDE6Ugb/KWJTY40XukxmG2hkmtBbcUSNPJnwD//oOzZW8DWLJqWd VDQLjNmwRoIRIGtywklJh8TYY9/bmPEwCd78ICi5Cne6WfJBLnOgHoIcW/PdPVJ51O82 x+di2nk7lethsmvlYZA7fpWPDyzEe1AYRD/ArIL/cEFnbSgNxGnv/TEe38CMKuqV7qGc /QGQ== 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; bh=ZYkJ4KlTdXmZ83Ek2AJixe9iNVK7Vyp38R8BpeEYEKQ=; b=xNLKaocd72P3ymwnrUDGAwPyHrsD82sCPa+8tvmstozQVdpYf4guj8zngbYM1Tq3ab e3E6lxiIV3TNjwj10R9RUXZVye0VGKSpWmW830RqhwXiTgITZJ65MyEP8OjIVrVOJNxK UpMUmqud/c5BKgY/YI+N0DCREXs+hrY2hac5CMRvTcsjI4Qqitsc3jhRsVkkr6qDoRej eIQs+UAzVGilszC1pShcZufRkJq0zMMoi7Wkx2hFS3JY0WROGMo9iihx64T1hvWYGG43 2cB4WCnz5/wAmuseFGfuS8SUJSFDZG1TzZtlDLU2YxkGG3RntZv/fbwOkdnxGL4HaqrA uMVg== 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 j16si8446680pgj.349.2019.09.02.05.13.24; Mon, 02 Sep 2019 05:13:48 -0700 (PDT) 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 S1731076AbfIBKGS (ORCPT + 99 others); Mon, 2 Sep 2019 06:06:18 -0400 Received: from foss.arm.com ([217.140.110.172]:51404 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729854AbfIBKGP (ORCPT ); Mon, 2 Sep 2019 06:06:15 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2569328; Mon, 2 Sep 2019 03:06:15 -0700 (PDT) Received: from e121166-lin.cambridge.arm.com (unknown [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3C8E73F246; Mon, 2 Sep 2019 03:06:14 -0700 (PDT) Date: Mon, 2 Sep 2019 11:06:11 +0100 From: Lorenzo Pieralisi To: Remi Pommarel , Thomas Petazzoni Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] PCI: aardvark: Don't rely on jiffies while holding spinlock Message-ID: <20190902100611.GB14841@e121166-lin.cambridge.arm.com> References: <20190901142303.27815-1-repk@triplefau.lt> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190901142303.27815-1-repk@triplefau.lt> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 01, 2019 at 04:23:03PM +0200, Remi Pommarel wrote: > advk_pcie_wait_pio() can be called while holding a spinlock (from > pci_bus_read_config_dword()), then depends on jiffies in order to > timeout while polling on PIO state registers. In the case the PIO > transaction failed, the timeout will never happen and will also cause > the cpu to stall. > > This decrements a variable and wait instead of using jiffies. > > Signed-off-by: Remi Pommarel > --- > drivers/pci/controller/pci-aardvark.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) Thomas, I would like to merge this patch and a couple of others from Remi, may I ask you please to review them ? https://patchwork.ozlabs.org/user/todo/linux-pci/?series=&submitter=67495&state=&q=&archive= Thanks, Lorenzo > diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c > index fc0fe4d4de49..1fa6d04ad7aa 100644 > --- a/drivers/pci/controller/pci-aardvark.c > +++ b/drivers/pci/controller/pci-aardvark.c > @@ -175,7 +175,8 @@ > (PCIE_CONF_BUS(bus) | PCIE_CONF_DEV(PCI_SLOT(devfn)) | \ > PCIE_CONF_FUNC(PCI_FUNC(devfn)) | PCIE_CONF_REG(where)) > > -#define PIO_TIMEOUT_MS 1 > +#define PIO_RETRY_CNT 10 > +#define PIO_RETRY_DELAY 100 /* 100 us*/ > > #define LINK_WAIT_MAX_RETRIES 10 > #define LINK_WAIT_USLEEP_MIN 90000 > @@ -383,17 +384,16 @@ static void advk_pcie_check_pio_status(struct advk_pcie *pcie) > static int advk_pcie_wait_pio(struct advk_pcie *pcie) > { > struct device *dev = &pcie->pdev->dev; > - unsigned long timeout; > + size_t i; > > - timeout = jiffies + msecs_to_jiffies(PIO_TIMEOUT_MS); > - > - while (time_before(jiffies, timeout)) { > + for (i = 0; i < PIO_RETRY_CNT; ++i) { > u32 start, isr; > > start = advk_readl(pcie, PIO_START); > isr = advk_readl(pcie, PIO_ISR); > if (!start && isr) > return 0; > + udelay(PIO_RETRY_DELAY); > } > > dev_err(dev, "config read/write timed out\n"); > -- > 2.20.1 >