Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3921216pxj; Mon, 21 Jun 2021 09:24:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZNJ4zJSUAyl9CU4h1eMaQA4WZzACZAFIrXyY9YUe3e5TrPcYIhHwFcKhbTAcMXSW5M+m9 X-Received: by 2002:a17:907:9801:: with SMTP id ji1mr26154084ejc.523.1624292684264; Mon, 21 Jun 2021 09:24:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624292684; cv=none; d=google.com; s=arc-20160816; b=tt4pknYrB+IqOXJBbvaggTs8DzbE4Prd6iQ1hdd7TzdUfFo7te8sZNay+w0BrwXLeq mnBPQHjDdZaJ+6cRlfXPFBWZ5lH+NbzBNBjKJOWoVLlDPf7BoDZ89r7yicUIwFTvhOVo nvYdpc/qtpAmCoPJeNaVHaef3xDOruZSwDJR3rUygVl+wjq6AewaeTgwTYub7hUoZJNG IShczs1MoqzCiOyAoH7I7x1XJ+nZlUkU+C2CLMCN/aCy/mRB+UTE2VD2GcQ5/VQ4yEl/ bfe6FLhpo/QdEABkP0AFIohhtDb/YFvi9H6/xrdaXX8jeS+W9lnVZfTCTsWsYLDLfurY cdbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=u2oyHxVcuffJSWQWo7N3zkvlotHj3tec9Ur9OA1Nvuw=; b=ZjXdm38ugKvA+meleKwxfjqwyRFSwBs0Rpt9MD0TO2Ry7wUQcPxkiNLea7ec//NNhB TVcKJYnrFAwNNipG949gUoI3w/TeB/jxZDKerswprUuU+9rb4CYjQDbR52H2MJWpnDt/ PYce1hNFeTFAu18NDGC9XFDNSQ7e+yWYiijrCh7R/dAoI7r4AcRcPVmwgZm82Gwru6et vVb0ienoPVTA6kBhMZOVycmzNEq8IYad6ii/n6LFRkZz2o4zTAnjUP1z06F5mrONmttx 4PTZEXDe0y04UhujZeQYussS/o+hyASBxmXYcAUc6SBmBQhNEUmeXqKnEYAtdjIJ3puZ lizg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ddydscsv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j10si11003742ejd.87.2021.06.21.09.24.22; Mon, 21 Jun 2021 09:24:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ddydscsv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231288AbhFUQWo (ORCPT + 99 others); Mon, 21 Jun 2021 12:22:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:42656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231755AbhFUQVa (ORCPT ); Mon, 21 Jun 2021 12:21:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0A1C5611BD; Mon, 21 Jun 2021 16:19:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292355; bh=JQkpRwZFiWxFst1GdK2RLm3NhPUDc4ke4Y00MEoBsQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ddydscsvqCmh/c+EEQUgH1TJe6wHe2bnaZhO4tCZfXDkj5TU4Q7giRfMk1LFehP1e 1nFK6YVSLj1ClhbCH0Fpcn1Fj1pqTjR1DQNcJ/Eye3jKpyWVZR6x+4iY02bWhmZ0nM IPIIXpOU0ygZI/MXbOnFcJvlTJnw3u90PT8nQ6io= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Remi Pommarel , Lorenzo Pieralisi , Andrew Murray , Thomas Petazzoni Subject: [PATCH 5.4 60/90] PCI: aardvark: Dont rely on jiffies while holding spinlock Date: Mon, 21 Jun 2021 18:15:35 +0200 Message-Id: <20210621154906.191785136@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154904.159672728@linuxfoundation.org> References: <20210621154904.159672728@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Remi Pommarel commit 7fbcb5da811be7d47468417c7795405058abb3da upstream. 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 Signed-off-by: Lorenzo Pieralisi Reviewed-by: Andrew Murray Acked-by: Thomas Petazzoni Signed-off-by: Greg Kroah-Hartman --- drivers/pci/controller/pci-aardvark.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- 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 500 +#define PIO_RETRY_DELAY 2 /* 2 us*/ #define LINK_WAIT_MAX_RETRIES 10 #define LINK_WAIT_USLEEP_MIN 90000 @@ -392,17 +393,16 @@ static void advk_pcie_check_pio_status(s static int advk_pcie_wait_pio(struct advk_pcie *pcie) { struct device *dev = &pcie->pdev->dev; - unsigned long timeout; + int 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");