Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp724968pxb; Tue, 2 Feb 2021 16:47:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMHN3nW9v1l5lsDQMHy016VXA0tGjKdciyGyQv6Q+92kJbVEIJId2HLctVxpCcPfTh15mB X-Received: by 2002:a17:906:4694:: with SMTP id a20mr574889ejr.201.1612313270692; Tue, 02 Feb 2021 16:47:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612313270; cv=none; d=google.com; s=arc-20160816; b=CAMzBGZFyMX2EUOBphTAvN0OdkoznEWIdOcISLERiokkU/nubeu0THSDSyeLCInlAX HjDqhfeZ/WS+kY64mvTdv/WAacH+nKkpk3ghspvM05a5TyAeiDhZ0jPjQttZGSKeL1nD qsHEqVycVxgykIdblGfsWOiP7n41iCFatYhIh6kDe28360jOh3LoPsbpwgbruBxE0SH7 RA1KVk55rZWL0JQNfyjn7H7ayQpH0bdGCa5Tu4FpcThsuzqU0psLpZhxi8hyfpfjPSUP EJrPPzdqIFnjwlq31DpqzQBPefRpY/afd0JCcXFMHnuxovCSbrs7bRXkONldlqm+ZA5e 2Cxg== 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=Ww2C7JbZiyNcgop0c0Ow1ECMoC0M6Lp3LpH9FRu4Lbg=; b=MWx62CDdne2pocxSj5kBK3P7wxtolLH79U4LBnQ9BjVYoQzCAr1dg0VpNh16c7i5hb DIdvxLL8aP9mQ5qJdy43vmxet56pVC9GmBHn8AghOI9VSqfQbh1aA8yw5K5SHkYELSRx 1xOJPz4/g8CWMSJFG/GD+NqfVqfbSDJVrhq+cihYsEqkaMpvGlMW2zMJ9ADUdgO4pmc9 bO3IJj7A59w5agT/HbIH7PETGgTmFi29TCpMhObnb6lYf1LyCZJ6H9dJc7yymrSJ5riv yjBwiwAsFd79PYX2Mc/3E8HOQwVtcGVMf8Ky0vDwBoi6sm9ZkVSoGPAHY2BS07NCWBIY Ykuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kEuilULT; 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 i9si292899ejy.32.2021.02.02.16.47.26; Tue, 02 Feb 2021 16:47:50 -0800 (PST) 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=kEuilULT; 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 S240047AbhBBTqf (ORCPT + 99 others); Tue, 2 Feb 2021 14:46:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:43136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233258AbhBBNwz (ORCPT ); Tue, 2 Feb 2021 08:52:55 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B593164FC3; Tue, 2 Feb 2021 13:43:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273433; bh=FeM70a/e17Sj8KN3mxw/2PS3XhSK6Q0N2xDEv5k0GDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kEuilULTb0BPiWt7y2Zj34KvzAv1iJijqtDB5jhj+N1plQ/kayNzFizjD7rn2vmVG ctQuDJf0qsXYzwJIhg6o/bNgYQWtTR0oyQYkeMQwaBTqVxjdbYI7YDf6QufIvwRak1 JQp3AOJAx2TERIZZOgS85sLppt32PL0JNkT25dVI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , Luca Coelho , Kalle Valo , Sasha Levin Subject: [PATCH 5.10 104/142] iwlwifi: pcie: use jiffies for memory read spin time limit Date: Tue, 2 Feb 2021 14:37:47 +0100 Message-Id: <20210202133002.000924096@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@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: Johannes Berg [ Upstream commit 6701317476bbfb1f341aa935ddf75eb73af784f9 ] There's no reason to use ktime_get() since we don't need any better precision than jiffies, and since we no longer disable interrupts around this code (when grabbing NIC access), jiffies will work fine. Use jiffies instead of ktime_get(). This cleanup is preparation for the following patch "iwlwifi: pcie: reschedule in long-running memory reads". The code gets simpler with the weird clock use etc. removed before we add cond_resched(). Signed-off-by: Johannes Berg Signed-off-by: Luca Coelho Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/iwlwifi.20210115130253.621c948b1fad.I3ee9f4bc4e74a0c9125d42fb7c35cd80df4698a1@changeid Signed-off-by: Sasha Levin --- drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c index 2fffbbc8462fc..c7161f121c0c2 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c @@ -2161,7 +2161,7 @@ static int iwl_trans_pcie_read_mem(struct iwl_trans *trans, u32 addr, while (offs < dwords) { /* limit the time we spin here under lock to 1/2s */ - ktime_t timeout = ktime_add_us(ktime_get(), 500 * USEC_PER_MSEC); + unsigned long end = jiffies + HZ / 2; if (iwl_trans_grab_nic_access(trans, &flags)) { iwl_write32(trans, HBUS_TARG_MEM_RADDR, @@ -2172,11 +2172,7 @@ static int iwl_trans_pcie_read_mem(struct iwl_trans *trans, u32 addr, HBUS_TARG_MEM_RDAT); offs++; - /* calling ktime_get is expensive so - * do it once in 128 reads - */ - if (offs % 128 == 0 && ktime_after(ktime_get(), - timeout)) + if (time_after(jiffies, end)) break; } iwl_trans_release_nic_access(trans, &flags); -- 2.27.0