Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4558247pxb; Sat, 6 Nov 2021 16:52:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAStClmAhhsKk2mPBOgEu8Mxi+03aQgoxfyVqqHrJHgeX/eCJ7fnrz5DivzCkwZT8ozzKg X-Received: by 2002:a05:6602:2e86:: with SMTP id m6mr958638iow.55.1636242736424; Sat, 06 Nov 2021 16:52:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636242736; cv=none; d=google.com; s=arc-20160816; b=onwieY7p48GdtiKoVpc1Qinkj62BGt8vVKOT3U7sM1Jp/FP5KkA8VxkiFtJAdTvlKO 81vXGaZuWSMzNTlXDx9KBkVWx1Bx/cDfeqEA1EKAiOt3nwUFAfKe1bXme6kFXabzwBxQ i/rq79p6GiEqn8KjyJNXii4xI0/OuFcBlNHpF2v2m9OW4n5yUpvx8sqf06ffhXReq3+l BBy+QPet6OgLGzZ6TDAFuw89IHOyzD+7oQlIU7y95EgpXIttsB5635MJxyMkGXNWj0fL 6swYgEhvf8A1Qyz4BcHJfvRhl8taJW0EJKwELSoanHWt/i+Egupn90QJZe2o9S1A1nFC lXtg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6exyrB9eI4Ukr7viowD1F2sVcUX7M9z1Yw2CZoS4oow=; b=cpskz2zvDWNgM8fGcFRQOa6FwgW5P5krcQibNU8EJdhVMyRQwoeZJ9pwfXhUhUHHJW QbO3MsMbghNOTp1+UVLW7XHWJDdRhmt0TKiZuIP+q6sEmGU1/nej5IEBOtpo4AuXxq3N YxBzbp4rkT4ihf4u+V8MkzPhFuQ7faVYMoepzScuPWZ5mvKpPKkqQZW6p/Fg1mXr02yX nwvd3KP6PB+DtLz7+8Kjbna70wgQ9fEjTYOdeo2cdbBhyZvepIdwj4cmoLQGJuRIkIQY axb8xsIAo7Ts2Rrv1EKOK/SUTGF3vY5QFQ5oJfcTmDMypXQGENpb1Z40/eA3GMtN38B4 Co/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BCWceeMy; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w13si21618758ilu.83.2021.11.06.16.51.37; Sat, 06 Nov 2021 16:52:16 -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=@gmail.com header.s=20210112 header.b=BCWceeMy; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234747AbhKFR4C (ORCPT + 99 others); Sat, 6 Nov 2021 13:56:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234716AbhKFRz6 (ORCPT ); Sat, 6 Nov 2021 13:55:58 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C11A8C061714; Sat, 6 Nov 2021 10:53:16 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id f8so44912128edy.4; Sat, 06 Nov 2021 10:53:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6exyrB9eI4Ukr7viowD1F2sVcUX7M9z1Yw2CZoS4oow=; b=BCWceeMyYA42nBlr9VPVnXxupqwV8ppJ5aEzz8Cv+ZMwvP6tXIYJgRB/rdOuLRe8Jw trQyZaqKXwS1oyYZ2dWJqVzOMzX5tUslCQHZqbWW/WRMhGO3BnL4MKgBROgmG4Vv6yUL nM4lO3+vAiyTgQRabf+25BVyjDVQk4ez0o1w0mXrdIrl+EbeIiHhb6V9azvun+oHzfhE 1VlO48RVsBrk+Tr9o2Tzm6tS+FtcussABU27ThrOl9tLP6obnPPdopFPP3ZNpMaIOaVK AhrzFJB2c7mJofbFg1d67Lp/aX3DAhE5A8pcx8SwO9psB+bersFMCt5RUFh+WAShmvbw LjWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6exyrB9eI4Ukr7viowD1F2sVcUX7M9z1Yw2CZoS4oow=; b=fm7LbXAHDVU4CUzQmpdBa3MpQZVde0g2ceAxfXtrtmsmkmio/78YBz2IQfxZW8TSeV fRxFztC7eob70Y6zgFDvqKRBKFI/bxT9lZ1ieYlJd7qRz0NFsiqYqEGNfbBp+C2WpB6B w5n39mhxN0Q2GMsuggMpQyiiQGA37/H9IbNmJ3/tUVhSPowyp+bAocDW9XLr+6USaEiH V4ymXgLGKxv02dOdzEo6j6CCVJ5qRi3vX9i2uGIiMG7a+zf8Q17xukQ5nGY3DP1+t6dH pgiQ+J70RpqgRLPgbFfHQx64KARCKhkURXX65r+SKuCP47nsiMpeWXq/+OSi+b9FhZCr 8KcA== X-Gm-Message-State: AOAM5310vSdRmIWyVJCHhZ+9QtaJ9BS19icH21DrtH7ljKYt4zuJaZuH mnzHlMiqHLk7YV6g5n+wIgU= X-Received: by 2002:a17:907:86a6:: with SMTP id qa38mr7286788ejc.286.1636221195202; Sat, 06 Nov 2021 10:53:15 -0700 (PDT) Received: from localhost.localdomain ([2a02:ab88:109:9f0:f6a6:7fbe:807a:e1cc]) by smtp.googlemail.com with ESMTPSA id g10sm6364857edr.56.2021.11.06.10.53.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Nov 2021 10:53:14 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org Cc: "Saheed O. Bolarinwa" , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v4 3/4] PCI/ASPM: Remove struct pcie_link_state.acceptable Date: Sat, 6 Nov 2021 18:53:04 +0100 Message-Id: <20211106175305.25565-4-refactormyself@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211106175305.25565-1-refactormyself@gmail.com> References: <20211106175305.25565-1-refactormyself@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The acceptable latencies for each device on the bus are calculated within pcie_aspm_cap_init() and cached in struct pcie_link_state.acceptable. They are only used within pcie_aspm_check_latency() to validate actual latencies. Thus, it is possible to avoid caching these values. - remove `acceptable` from struct pcie_link_state - calculate the acceptable latency for individual device directly - remove the calculations done within pcie_aspm_cap_init() Signed-off-by: Saheed O. Bolarinwa --- drivers/pci/pcie/aspm.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 9e74df7b9dc0..6afbb86d07b8 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -65,12 +65,6 @@ struct pcie_link_state { u32 clkpm_enabled:1; /* Current Clock PM state */ u32 clkpm_default:1; /* Default Clock PM state by BIOS */ u32 clkpm_disable:1; /* Clock PM disabled */ - - /* - * Endpoint acceptable latencies. A pcie downstream port only - * has one slot under it, so at most there are 8 functions. - */ - struct aspm_latency acceptable[8]; }; static int aspm_disabled, aspm_force; @@ -389,7 +383,7 @@ static void encode_l12_threshold(u32 threshold_us, u32 *scale, u32 *value) static void pcie_aspm_check_latency(struct pci_dev *endpoint) { - u32 latency, lnkcap_up, lnkcap_dw, l1_switch_latency = 0; + u32 reg32, latency, encoding, lnkcap_up, lnkcap_dw, l1_switch_latency = 0; struct aspm_latency latency_up, latency_dw; struct aspm_latency *acceptable; struct pcie_link_state *link; @@ -400,7 +394,13 @@ static void pcie_aspm_check_latency(struct pci_dev *endpoint) return; link = endpoint->bus->self->link_state; - acceptable = &link->acceptable[PCI_FUNC(endpoint->devfn)]; + pcie_capability_read_dword(endpoint, PCI_EXP_DEVCAP, ®32); + /* Calculate endpoint L0s acceptable latency */ + encoding = (reg32 & PCI_EXP_DEVCAP_L0S) >> 6; + acceptable->l0s = calc_l0s_acceptable(encoding); + /* Calculate endpoint L1 acceptable latency */ + encoding = (reg32 & PCI_EXP_DEVCAP_L1) >> 9; + acceptable->l1 = calc_l1_acceptable(encoding); while (link) { /* Read direction exit latencies */ @@ -663,22 +663,11 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) /* Get and check endpoint acceptable latencies */ list_for_each_entry(child, &linkbus->devices, bus_list) { - u32 reg32, encoding; - struct aspm_latency *acceptable = - &link->acceptable[PCI_FUNC(child->devfn)]; if (pci_pcie_type(child) != PCI_EXP_TYPE_ENDPOINT && pci_pcie_type(child) != PCI_EXP_TYPE_LEG_END) continue; - pcie_capability_read_dword(child, PCI_EXP_DEVCAP, ®32); - /* Calculate endpoint L0s acceptable latency */ - encoding = (reg32 & PCI_EXP_DEVCAP_L0S) >> 6; - acceptable->l0s = calc_l0s_acceptable(encoding); - /* Calculate endpoint L1 acceptable latency */ - encoding = (reg32 & PCI_EXP_DEVCAP_L1) >> 9; - acceptable->l1 = calc_l1_acceptable(encoding); - pcie_aspm_check_latency(child); } } -- 2.20.1