Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp844714pxb; Sat, 18 Sep 2021 21:10:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJsfcfb56jf8Ar48eZ0dPVEBVaBVQswS1Q17R+PVJmGiyrXTwroKJ+4tRv9vpUaSr9xFfy X-Received: by 2002:a5d:851a:: with SMTP id q26mr14040667ion.163.1632024604354; Sat, 18 Sep 2021 21:10:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632024604; cv=none; d=google.com; s=arc-20160816; b=iIfUBLXtD1gBIokDAKOp772Tx9jZqFPEwPaptpugMg81tuaz8u8/3tBYpaWfQlyZD0 Af7x9BfyvfDTRPYqtz/vMGYwizXFhB5fyQ4zzn2J1ABHUcyf5aoJKeWkqnWqSX3PxIl6 1ByaRkFjXtjfN6jfRAMsWFuq1YBWtAxeFUbd1sBFby5Mv2Wu8U3nbFcsR5D80XbTHIqC Zu4rtHs8IiAviRkdIlP6wD3nlqYIPTmAltCqsQV7I2wR8atL/iHArOjDi8eNsaJs8RrI axQKDVJnp74LPT6YhbE+EaDNo0B8fE2+uPQqW194xMGATbALMQjKIOLY+oK3ADfU+NM9 ZCew== 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; bh=apgDtxDM9wvinKBG7XKbcakIZnjFXNKUvC7+bkjLZF8=; b=k/XtA00+V+3RK0O173nFYTZk5bGSP0ucfJODoD4DI7n4XQiml+F+DB+YVAtW2r3shI kjP9CB+2qbX1aAozqbJawW+T0MvHZSZwSVGu9bg8bL3DxmLvoALxdPj/WKEa21fhkauI 4NndScZooM6yE4fIELrNZ77T7NHwRQPG5mab+0tDf45tnJKl0V7dNe/GwWzuTEU1Y+MI gNRXVyndzbVMpbW/GB2K2nrIN2Ns0iP04HZF4Ib/nmqBLPBMPJL7DsOJSXni0HalXYZ+ o0dngfBzQwIvlBERVxv0y4Z3pJabeee1wKI1rkz75QZsNK8vvWsL+8jrigvtDfAkR9NV AsbQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q7si11657786ilu.111.2021.09.18.21.09.53; Sat, 18 Sep 2021 21:10:04 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239338AbhIRNcP (ORCPT + 99 others); Sat, 18 Sep 2021 09:32:15 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:57564 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238981AbhIRNcJ (ORCPT ); Sat, 18 Sep 2021 09:32:09 -0400 Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 3.0.0) id 5c65a5afa5370310; Sat, 18 Sep 2021 15:30:44 +0200 Received: from kreacher.localnet (89-77-51-84.dynamic.chello.pl [89.77.51.84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 3847F66A51F; Sat, 18 Sep 2021 15:30:43 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI , Linux PCI , x86 Maintainers Cc: LKML , Bjorn Helgaas , Andy Shevchenko , Mika Westerberg , Len Brown Subject: [PATCH v1 1/5] PCI: PM: x86: Drop Intel MID PCI PM support Date: Sat, 18 Sep 2021 15:21:10 +0200 Message-ID: <1798761.CQOukoFCf9@kreacher> In-Reply-To: <8003272.NyiUUSuA9g@kreacher> References: <8003272.NyiUUSuA9g@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 89.77.51.84 X-CLIENT-HOSTNAME: 89-77-51-84.dynamic.chello.pl X-VADE-SPAMSTATE: spam:low X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvtddrudehkedgieefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenogfuphgrmhfkphculdeftddtmdenucfjughrpefhvffufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvjeelgffhiedukedtleekkedvudfggefhgfegjefgueekjeelvefggfdvledutdenucfkphepkeelrdejjedrhedurdekgeenucfuphgrmhfkphepkeelrdejjedrhedurdekgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeekledrjeejrdehuddrkeegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqphgtihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopeigkeeisehkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdr ohhrghdprhgtphhtthhopehhvghlghgrrghssehkvghrnhgvlhdrohhrghdprhgtphhtthhopegrnhgurhhihidrshhhvghvtghhvghnkhhosehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepmhhikhgrrdifvghsthgvrhgsvghrgheslhhinhhugidrihhnthgvlhdrtghomhdprhgtphhtthhopehlvghnrdgsrhhofihnsehinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=32 Fuz1=32 Fuz2=32 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Support for Intel MID platforms has mostly gone away with the SFI support removal in commit 4590d98f5a4f ("sfi: Remove framework for deprecated firmware"), but there are some pieces of it still in the tree. One of them is the MID PCI PM support code which gets in the way of subsequent PCI PM simplifications and trying to update it is rather pointless, so get rid of it completely along with the arch code pieces that are only used by it. Signed-off-by: Rafael J. Wysocki --- I am going to post patches removing the rest of MID support from arch/x86/ and elsewhere, but that is still quite a bit of stuff and I don't want this simple PCI PM series to depend on that work. --- arch/x86/include/asm/intel-mid.h | 3 arch/x86/platform/intel-mid/pwr.c | 150 -------------------------------------- drivers/pci/Makefile | 1 drivers/pci/pci-mid.c | 77 ------------------- 4 files changed, 231 deletions(-) Index: linux-pm/drivers/pci/Makefile =================================================================== --- linux-pm.orig/drivers/pci/Makefile +++ linux-pm/drivers/pci/Makefile @@ -22,7 +22,6 @@ obj-$(CONFIG_PCI_ATS) += ats.o obj-$(CONFIG_PCI_IOV) += iov.o obj-$(CONFIG_PCI_BRIDGE_EMUL) += pci-bridge-emul.o obj-$(CONFIG_PCI_LABEL) += pci-label.o -obj-$(CONFIG_X86_INTEL_MID) += pci-mid.o obj-$(CONFIG_PCI_SYSCALL) += syscall.o obj-$(CONFIG_PCI_STUB) += pci-stub.o obj-$(CONFIG_PCI_PF_STUB) += pci-pf-stub.o Index: linux-pm/drivers/pci/pci-mid.c =================================================================== --- linux-pm.orig/drivers/pci/pci-mid.c +++ /dev/null @@ -1,77 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Intel MID platform PM support - * - * Copyright (C) 2016, Intel Corporation - * - * Author: Andy Shevchenko - */ - -#include -#include - -#include -#include -#include - -#include "pci.h" - -static bool mid_pci_power_manageable(struct pci_dev *dev) -{ - return true; -} - -static int mid_pci_set_power_state(struct pci_dev *pdev, pci_power_t state) -{ - return intel_mid_pci_set_power_state(pdev, state); -} - -static pci_power_t mid_pci_get_power_state(struct pci_dev *pdev) -{ - return intel_mid_pci_get_power_state(pdev); -} - -static pci_power_t mid_pci_choose_state(struct pci_dev *pdev) -{ - return PCI_D3hot; -} - -static int mid_pci_wakeup(struct pci_dev *dev, bool enable) -{ - return 0; -} - -static bool mid_pci_need_resume(struct pci_dev *dev) -{ - return false; -} - -static const struct pci_platform_pm_ops mid_pci_platform_pm = { - .is_manageable = mid_pci_power_manageable, - .set_state = mid_pci_set_power_state, - .get_state = mid_pci_get_power_state, - .choose_state = mid_pci_choose_state, - .set_wakeup = mid_pci_wakeup, - .need_resume = mid_pci_need_resume, -}; - -/* - * This table should be in sync with the one in - * arch/x86/platform/intel-mid/pwr.c. - */ -static const struct x86_cpu_id lpss_cpu_ids[] = { - X86_MATCH_INTEL_FAM6_MODEL(ATOM_SALTWELL_MID, NULL), - X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT_MID, NULL), - {} -}; - -static int __init mid_pci_init(void) -{ - const struct x86_cpu_id *id; - - id = x86_match_cpu(lpss_cpu_ids); - if (id) - pci_set_platform_pm(&mid_pci_platform_pm); - return 0; -} -arch_initcall(mid_pci_init); Index: linux-pm/arch/x86/platform/intel-mid/pwr.c =================================================================== --- linux-pm.orig/arch/x86/platform/intel-mid/pwr.c +++ linux-pm/arch/x86/platform/intel-mid/pwr.c @@ -5,13 +5,6 @@ * Copyright (C) 2016, Intel Corporation * * Author: Andy Shevchenko - * - * Intel MID Power Management Unit device driver handles the South Complex PCI - * devices such as GPDMA, SPI, I2C, PWM, and so on. By default PCI core - * modifies bits in PMCSR register in the PCI configuration space. This is not - * enough on some SoCs like Intel Tangier. In such case PCI core sets a new - * power state of the device in question through a PM hook registered in struct - * pci_platform_pm_ops (see drivers/pci/pci-mid.c). */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt @@ -103,11 +96,6 @@ struct mid_pwr { static struct mid_pwr *midpwr; -static u32 mid_pwr_get_state(struct mid_pwr *pwr, int reg) -{ - return readl(pwr->regs + PM_SSS(reg)); -} - static void mid_pwr_set_state(struct mid_pwr *pwr, int reg, u32 value) { writel(value, pwr->regs + PM_SSC(reg)); @@ -150,143 +138,6 @@ static int mid_pwr_wait_for_cmd(struct m return mid_pwr_wait(pwr); } -static int __update_power_state(struct mid_pwr *pwr, int reg, int bit, int new) -{ - int curstate; - u32 power; - int ret; - - /* Check if the device is already in desired state */ - power = mid_pwr_get_state(pwr, reg); - curstate = (power >> bit) & 3; - if (curstate == new) - return 0; - - /* Update the power state */ - mid_pwr_set_state(pwr, reg, (power & ~(3 << bit)) | (new << bit)); - - /* Send command to SCU */ - ret = mid_pwr_wait_for_cmd(pwr, CMD_SET_CFG); - if (ret) - return ret; - - /* Check if the device is already in desired state */ - power = mid_pwr_get_state(pwr, reg); - curstate = (power >> bit) & 3; - if (curstate != new) - return -EAGAIN; - - return 0; -} - -static pci_power_t __find_weakest_power_state(struct mid_pwr_dev *lss, - struct pci_dev *pdev, - pci_power_t state) -{ - pci_power_t weakest = PCI_D3hot; - unsigned int j; - - /* Find device in cache or first free cell */ - for (j = 0; j < LSS_MAX_SHARED_DEVS; j++) { - if (lss[j].pdev == pdev || !lss[j].pdev) - break; - } - - /* Store the desired state in cache */ - if (j < LSS_MAX_SHARED_DEVS) { - lss[j].pdev = pdev; - lss[j].state = state; - } else { - dev_WARN(&pdev->dev, "No room for device in PWRMU LSS cache\n"); - weakest = state; - } - - /* Find the power state we may use */ - for (j = 0; j < LSS_MAX_SHARED_DEVS; j++) { - if (lss[j].state < weakest) - weakest = lss[j].state; - } - - return weakest; -} - -static int __set_power_state(struct mid_pwr *pwr, struct pci_dev *pdev, - pci_power_t state, int id, int reg, int bit) -{ - const char *name; - int ret; - - state = __find_weakest_power_state(pwr->lss[id], pdev, state); - name = pci_power_name(state); - - ret = __update_power_state(pwr, reg, bit, (__force int)state); - if (ret) { - dev_warn(&pdev->dev, "Can't set power state %s: %d\n", name, ret); - return ret; - } - - dev_vdbg(&pdev->dev, "Set power state %s\n", name); - return 0; -} - -static int mid_pwr_set_power_state(struct mid_pwr *pwr, struct pci_dev *pdev, - pci_power_t state) -{ - int id, reg, bit; - int ret; - - id = intel_mid_pwr_get_lss_id(pdev); - if (id < 0) - return id; - - reg = (id * LSS_PWS_BITS) / 32; - bit = (id * LSS_PWS_BITS) % 32; - - /* We support states between PCI_D0 and PCI_D3hot */ - if (state < PCI_D0) - state = PCI_D0; - if (state > PCI_D3hot) - state = PCI_D3hot; - - mutex_lock(&pwr->lock); - ret = __set_power_state(pwr, pdev, state, id, reg, bit); - mutex_unlock(&pwr->lock); - return ret; -} - -int intel_mid_pci_set_power_state(struct pci_dev *pdev, pci_power_t state) -{ - struct mid_pwr *pwr = midpwr; - int ret = 0; - - might_sleep(); - - if (pwr && pwr->available) - ret = mid_pwr_set_power_state(pwr, pdev, state); - dev_vdbg(&pdev->dev, "set_power_state() returns %d\n", ret); - - return 0; -} - -pci_power_t intel_mid_pci_get_power_state(struct pci_dev *pdev) -{ - struct mid_pwr *pwr = midpwr; - int id, reg, bit; - u32 power; - - if (!pwr || !pwr->available) - return PCI_UNKNOWN; - - id = intel_mid_pwr_get_lss_id(pdev); - if (id < 0) - return PCI_UNKNOWN; - - reg = (id * LSS_PWS_BITS) / 32; - bit = (id * LSS_PWS_BITS) % 32; - power = mid_pwr_get_state(pwr, reg); - return (__force pci_power_t)((power >> bit) & 3); -} - void intel_mid_pwr_power_off(void) { struct mid_pwr *pwr = midpwr; @@ -469,7 +320,6 @@ static const struct mid_pwr_device_info .set_initial_state = tng_set_initial_state, }; -/* This table should be in sync with the one in drivers/pci/pci-mid.c */ static const struct pci_device_id mid_pwr_pci_ids[] = { { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PENWELL), (kernel_ulong_t)&pnw_info }, { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_TANGIER), (kernel_ulong_t)&tng_info }, Index: linux-pm/arch/x86/include/asm/intel-mid.h =================================================================== --- linux-pm.orig/arch/x86/include/asm/intel-mid.h +++ linux-pm/arch/x86/include/asm/intel-mid.h @@ -10,9 +10,6 @@ #include extern int intel_mid_pci_init(void); -extern int intel_mid_pci_set_power_state(struct pci_dev *pdev, pci_power_t state); -extern pci_power_t intel_mid_pci_get_power_state(struct pci_dev *pdev); - extern void intel_mid_pwr_power_off(void); #define INTEL_MID_PWR_LSS_OFFSET 4