Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp589523ioo; Thu, 26 May 2022 10:02:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmIPSMKEEDzZ8ukFT8dQh2O7N7MR2vZvUGAZccN1FMdHrEtDQeyOuLKFenPVC9b/dny76V X-Received: by 2002:a17:90b:224a:b0:1e0:f91:3a3f with SMTP id hk10-20020a17090b224a00b001e00f913a3fmr3623543pjb.62.1653584551147; Thu, 26 May 2022 10:02:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653584551; cv=none; d=google.com; s=arc-20160816; b=BrxpFwFhxWVfQSpACgxANJTX6NCD8ibGseJ0fztSdXndR9kRZ4TboaY5fwqAEq1uYD /QC7+zq1RurK0nG88tennNIGleN0LOVJtwFURRdFHjfdtVRgy/TLwFQ+KbdSWNZpzTTF e5UKrYWFQZ8rxElrwb3qVNyjmgJriR7q8pUL49kmw16dMmXaMncM+y1bIKkcyVxok8Ci mquiyanzjZDV/8BQkNANmf636mJ4YGV+Nx6QAzHysAhwLqraZxs1SwdPXaCATxunaLB3 FKvRMK3vPPGkDv1PcZoCu9QNYyYLn0I9MpiVnb2JhiF504UqTRp9f5azxlVLYDWJrGpG Oc6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=UZ882IS4eo0+B+RV4XWnuXlTak5rkXXZnOU7d0kPoSQ=; b=VyRknXHLKX0UwDK4hTn+3Zi/FxDTQIKBkg66CWqbjSJ2BCfTj/Dznee3tFlt/Z3els pMvOEIgJNHXuSE/+uwAKRd+TR4z6AHnQ7c8mLha5gohm/AitiCdysnfV10twgFxvAur9 nOVRt9hzymQ1unXPXCk11jl78intprByCeyYPqLit906c7QSE6EgV/1H+BNZjungnfHI 4tkMBgJEdSFMwKWvGuODMC1NvjxPX6+R8PPIOHc/BiQO3/zLiTf0dq1HhDrwce+bQmRM 7o78EK6PbDHREhYbU4o9Y5yWsO+sqE2FImvzb8DmgSHbXbfZ4FMkPPbKtZgu5HYgZHLW 7SIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RL+NcvCP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i20-20020a631314000000b003820d821f00si3038165pgl.473.2022.05.26.10.01.52; Thu, 26 May 2022 10:02:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RL+NcvCP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343705AbiEZQy3 (ORCPT + 99 others); Thu, 26 May 2022 12:54:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238069AbiEZQy2 (ORCPT ); Thu, 26 May 2022 12:54:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0026DFC5; Thu, 26 May 2022 09:54:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 675EFB82176; Thu, 26 May 2022 16:54:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5603C385A9; Thu, 26 May 2022 16:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653584065; bh=3G1ExpudxEkUKLGdVnrmwJ/uiFkyw5RF02cjHtBsAW8=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=RL+NcvCPbWw9Ew0REV/3asS3GSQ91R0RFFIQDTW2/7YiDe7+ndSzzBvAQHsLBzTqH 8oxv6oGTahVLDIg1gRGspWvSqpyexhEaK0st9HYBNV0Ly52hayPOv4n097H61Jdm45 w6h6eWXkj6doRHPeNw/Ytirs3yK+1eSfJxt86uL7YBU8qq6fNIKCuLFgbWcQdKqH1N HR6vs2B+3KmlHGg+SlKFhafJEXh9XzVrdzrfaUitrnHZy9C17S+4IpBQ0504Vwlr7f Gz4MOWPJeylHPSbWa7NOvQEN7BZMi+2cKYYP9u67Z8w22ClK4L/8Fo/cFk7A847mBx Q+/W8cOsirSww== Date: Thu, 26 May 2022 11:54:22 -0500 From: Bjorn Helgaas To: "Rafael J. Wysocki" Cc: Linux PCI , LKML , Linux PM , Mika Westerberg , Nathan Chancellor , Anders Roxell Subject: Re: [PATCH v1 06/11] PCI/PM: Write 0 to PMCSR in pci_power_up() in all cases Message-ID: <20220526165422.GA338382@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5748066.MhkbZ0Pkbq@kreacher> X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 05, 2022 at 08:10:43PM +0200, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Make pci_power_up() write 0 to the device's PCI_PM_CTRL register in > order to put it into D0 regardless of the power state returned by > the previous read from that register which should not matter. > > Signed-off-by: Rafael J. Wysocki > --- > drivers/pci/pci.c | 11 +++-------- > 1 file changed, 3 insertions(+), 8 deletions(-) > > Index: linux-pm/drivers/pci/pci.c > =================================================================== > --- linux-pm.orig/drivers/pci/pci.c > +++ linux-pm/drivers/pci/pci.c > @@ -1230,15 +1230,10 @@ int pci_power_up(struct pci_dev *dev) > } > > /* > - * If we're (effectively) in D3, force entire word to 0. This doesn't > - * affect PME_Status, disables PME_En, and sets PowerState to 0. > + * Force the entire word to 0. This doesn't affect PME_Status, disables > + * PME_En, and sets PowerState to 0. > */ > - if (state == PCI_D3hot) > - pmcsr = 0; > - else > - pmcsr &= ~PCI_PM_CTRL_STATE_MASK; > - > - pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr); > + pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, 0); Can you reassure me why this is safe and useful? This is a 16-bit write that includes (PCIe r6.0, sec 7.5.2.2): 0x0003 PowerState RW 0x0004 RsvdP 0x0008 No_Soft_Reset RO 0x00f0 RsvdP 0x0100 PME_En RW/RWS 0x1e00 Data_Select RW, VF ROZ 0x6000 Data_Scale RO, VF ROZ 0x8000 PME_Status RW1CS We intend to set PowerState to 0 (D0), apparently intend to clear PME_En, and PME_Status is "write 1 to clear" to writing 0 does nothing, so those look OK. But the RsvdP fields are reserved for future RW bits and should be preserved, and it looks like clearing Data_Select could potentially break the Data Register power consumption reporting (which I don't think we support today). It seems like maybe we should do this instead: pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr & ~PCI_PM_CTRL_STATE_MASK) to just unconditionally clear PowerState?