lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <efbe80b8-8da1-ec0c-f6c1-c5495dea1649@linux.intel.com>
Date:   Thu, 8 Sep 2022 13:15:12 -0700
From:   Sathyanarayanan Kuppuswamy 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>
To:     Bjorn Helgaas <helgaas@...nel.org>,
        Kai-Heng Feng <kai.heng.feng@...onical.com>,
        Rajvi Jingar <rajvi.jingar@...ux.intel.com>,
        "Rafael J . Wysocki" <rafael@...nel.org>
Cc:     Koba Ko <koba.ko@...onical.com>,
        Mika Westerberg <mika.westerberg@...ux.intel.com>,
        "David E . Box" <david.e.box@...ux.intel.com>,
        linux-pci@...r.kernel.org, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org, Bjorn Helgaas <bhelgaas@...gle.com>
Subject: Re: [PATCH v3 09/10] PCI/PTM: Reorder functions in logical order



On 9/6/22 3:23 PM, Bjorn Helgaas wrote:
> From: Bjorn Helgaas <bhelgaas@...gle.com>
> 
> pci_enable_ptm() and pci_disable_ptm() were separated.
> pci_save_ptm_state() and pci_restore_ptm_state() dangled at the top.  Move
> them to logical places.
> 

Maybe add "No functional changes"? It will give clear meaning.

> Signed-off-by: Bjorn Helgaas <bhelgaas@...gle.com>
> ---
>  drivers/pci/pcie/ptm.c | 108 ++++++++++++++++++++---------------------
>  1 file changed, 54 insertions(+), 54 deletions(-)
> 
> diff --git a/drivers/pci/pcie/ptm.c b/drivers/pci/pcie/ptm.c
> index d65f5af9700d..6c09e00a7b51 100644
> --- a/drivers/pci/pcie/ptm.c
> +++ b/drivers/pci/pcie/ptm.c
> @@ -9,60 +9,6 @@
>  #include <linux/pci.h>
>  #include "../pci.h"
>  
> -static void __pci_disable_ptm(struct pci_dev *dev)
> -{
> -	int ptm = dev->ptm_cap;
> -	u16 ctrl;
> -
> -	if (!ptm)
> -		return;
> -
> -	pci_read_config_word(dev, ptm + PCI_PTM_CTRL, &ctrl);
> -	ctrl &= ~PCI_PTM_CTRL_ENABLE;
> -	pci_write_config_word(dev, ptm + PCI_PTM_CTRL, ctrl);
> -}
> -
> -void pci_disable_ptm(struct pci_dev *dev)
> -{
> -	__pci_disable_ptm(dev);
> -	dev->ptm_enabled = 0;
> -}
> -EXPORT_SYMBOL(pci_disable_ptm);
> -
> -void pci_save_ptm_state(struct pci_dev *dev)
> -{
> -	int ptm = dev->ptm_cap;
> -	struct pci_cap_saved_state *save_state;
> -	u16 *cap;
> -
> -	if (!ptm)
> -		return;
> -
> -	save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_PTM);
> -	if (!save_state)
> -		return;
> -
> -	cap = (u16 *)&save_state->cap.data[0];
> -	pci_read_config_word(dev, ptm + PCI_PTM_CTRL, cap);
> -}
> -
> -void pci_restore_ptm_state(struct pci_dev *dev)
> -{
> -	int ptm = dev->ptm_cap;
> -	struct pci_cap_saved_state *save_state;
> -	u16 *cap;
> -
> -	if (!ptm)
> -		return;
> -
> -	save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_PTM);
> -	if (!save_state)
> -		return;
> -
> -	cap = (u16 *)&save_state->cap.data[0];
> -	pci_write_config_word(dev, ptm + PCI_PTM_CTRL, *cap);
> -}
> -
>  /*
>   * If the next upstream device supports PTM, return it; otherwise return
>   * NULL.  PTM Messages are local, so both link partners must support it.
> @@ -132,6 +78,40 @@ void pci_ptm_init(struct pci_dev *dev)
>  		pci_enable_ptm(dev, NULL);
>  }
>  
> +void pci_save_ptm_state(struct pci_dev *dev)
> +{
> +	int ptm = dev->ptm_cap;
> +	struct pci_cap_saved_state *save_state;
> +	u16 *cap;
> +
> +	if (!ptm)
> +		return;
> +
> +	save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_PTM);
> +	if (!save_state)
> +		return;
> +
> +	cap = (u16 *)&save_state->cap.data[0];
> +	pci_read_config_word(dev, ptm + PCI_PTM_CTRL, cap);
> +}
> +
> +void pci_restore_ptm_state(struct pci_dev *dev)
> +{
> +	int ptm = dev->ptm_cap;
> +	struct pci_cap_saved_state *save_state;
> +	u16 *cap;
> +
> +	if (!ptm)
> +		return;
> +
> +	save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_PTM);
> +	if (!save_state)
> +		return;
> +
> +	cap = (u16 *)&save_state->cap.data[0];
> +	pci_write_config_word(dev, ptm + PCI_PTM_CTRL, *cap);
> +}
> +
>  static int __pci_enable_ptm(struct pci_dev *dev)
>  {
>  	int ptm = dev->ptm_cap;
> @@ -193,6 +173,26 @@ int pci_enable_ptm(struct pci_dev *dev, u8 *granularity)
>  }
>  EXPORT_SYMBOL(pci_enable_ptm);
>  
> +static void __pci_disable_ptm(struct pci_dev *dev)
> +{
> +	int ptm = dev->ptm_cap;
> +	u16 ctrl;
> +
> +	if (!ptm)
> +		return;
> +
> +	pci_read_config_word(dev, ptm + PCI_PTM_CTRL, &ctrl);
> +	ctrl &= ~PCI_PTM_CTRL_ENABLE;
> +	pci_write_config_word(dev, ptm + PCI_PTM_CTRL, ctrl);
> +}
> +
> +void pci_disable_ptm(struct pci_dev *dev)
> +{
> +	__pci_disable_ptm(dev);
> +	dev->ptm_enabled = 0;
> +}
> +EXPORT_SYMBOL(pci_disable_ptm);
> +
>  /*
>   * Disable PTM, but leave dev->ptm_enabled so we silently re-enable it on
>   * resume.

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ