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  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]
Date:	Mon, 11 Aug 2014 14:33:25 +0000
From:	"Bharat.Bhushan@...escale.com" <Bharat.Bhushan@...escale.com>
To:	Alexander Gordeev <agordeev@...hat.com>,
	Bjorn Helgaas <bhelgaas@...gle.com>
CC:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>,
	"linux-pci@...r.kernel.org" <linux-pci@...r.kernel.org>
Subject: RE: [PATCH v2 2/2] PCI/MSI: Remove arch_msi_check_device()



> -----Original Message-----
> From: linux-pci-owner@...r.kernel.org [mailto:linux-pci-owner@...r.kernel.org]
> On Behalf Of Alexander Gordeev
> Sent: Monday, August 11, 2014 5:16 PM
> To: Bjorn Helgaas
> Cc: linux-kernel@...r.kernel.org; linuxppc-dev@...ts.ozlabs.org; linux-
> pci@...r.kernel.org
> Subject: [PATCH v2 2/2] PCI/MSI: Remove arch_msi_check_device()
> 
> There are no archs that override arch_msi_check_device() hook. Remove it as it
> is completely redundant.

Is not we are still overriding this in powerpc (not sure I missed some patch , if so please point to that).

$ grep -r  arch_msi_check_device arch/powerpc/
Binary file arch/powerpc/kernel/msi.o matches
arch/powerpc/kernel/msi.c:int arch_msi_check_device(struct pci_dev* dev, int nvec, int type)
Binary file arch/powerpc/kernel/built-in.o matches

Thanks
-Bharat

> 
> If an arch would need to check MSI/MSI-X possibility for a device it should make
> it within arch_setup_msi_irqs() hook.
> 
> Cc: linuxppc-dev@...ts.ozlabs.org
> Cc: linux-pci@...r.kernel.org
> Signed-off-by: Alexander Gordeev <agordeev@...hat.com>
> ---
>  drivers/pci/msi.c   | 49 +++++++++++++------------------------------------
>  include/linux/msi.h |  3 ---
>  2 files changed, 13 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 5a40516..6c2cc41 100644
> --- a/drivers/pci/msi.c
> +++ b/drivers/pci/msi.c
> @@ -56,16 +56,6 @@ void __weak arch_teardown_msi_irq(unsigned int irq)
>  	chip->teardown_irq(chip, irq);
>  }
> 
> -int __weak arch_msi_check_device(struct pci_dev *dev, int nvec, int type) -{
> -	struct msi_chip *chip = dev->bus->msi;
> -
> -	if (!chip || !chip->check_device)
> -		return 0;
> -
> -	return chip->check_device(chip, dev, nvec, type);
> -}
> -
>  int __weak arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)  {
>  	struct msi_desc *entry;
> @@ -806,22 +796,23 @@ out_free:
>  }
> 
>  /**
> - * pci_msi_check_device - check whether MSI may be enabled on a device
> + * pci_msi_supported - check whether MSI may be enabled on a device
>   * @dev: pointer to the pci_dev data structure of MSI device function
>   * @nvec: how many MSIs have been requested ?
> - * @type: are we checking for MSI or MSI-X ?
>   *
>   * Look at global flags, the device itself, and its parent buses
>   * to determine if MSI/-X are supported for the device. If MSI/-X is
>   * supported return 0, else return an error code.
>   **/
> -static int pci_msi_check_device(struct pci_dev *dev, int nvec, int type)
> +static int pci_msi_supported(struct pci_dev *dev, int nvec)
>  {
>  	struct pci_bus *bus;
> -	int ret;
> 
>  	/* MSI must be globally enabled and supported by the device */
> -	if (!pci_msi_enable || !dev || dev->no_msi)
> +	if (!pci_msi_enable)
> +		return -EINVAL;
> +
> +	if (!dev || dev->no_msi || dev->current_state != PCI_D0)
>  		return -EINVAL;
> 
>  	/*
> @@ -843,10 +834,6 @@ static int pci_msi_check_device(struct pci_dev *dev, int
> nvec, int type)
>  		if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI)
>  			return -EINVAL;
> 
> -	ret = arch_msi_check_device(dev, nvec, type);
> -	if (ret)
> -		return ret;
> -
>  	return 0;
>  }
> 
> @@ -949,13 +936,13 @@ int pci_enable_msix(struct pci_dev *dev, struct msix_entry
> *entries, int nvec)
>  	int status, nr_entries;
>  	int i, j;
> 
> -	if (!entries || !dev->msix_cap || dev->current_state != PCI_D0)
> -		return -EINVAL;
> -
> -	status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSIX);
> +	status = pci_msi_supported(dev, nvec);
>  	if (status)
>  		return status;
> 
> +	if (!entries)
> +		return -EINVAL;
> +
>  	nr_entries = pci_msix_vec_count(dev);
>  	if (nr_entries < 0)
>  		return nr_entries;
> @@ -1062,8 +1049,9 @@ int pci_enable_msi_range(struct pci_dev *dev, int minvec,
> int maxvec)
>  	int nvec;
>  	int rc;
> 
> -	if (dev->current_state != PCI_D0)
> -		return -EINVAL;
> +	rc = pci_msi_supported(dev, minvec);
> +	if (rc)
> +		return rc;
> 
>  	WARN_ON(!!dev->msi_enabled);
> 
> @@ -1086,17 +1074,6 @@ int pci_enable_msi_range(struct pci_dev *dev, int minvec,
> int maxvec)
>  		nvec = maxvec;
> 
>  	do {
> -		rc = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSI);
> -		if (rc < 0) {
> -			return rc;
> -		} else if (rc > 0) {
> -			if (rc < minvec)
> -				return -ENOSPC;
> -			nvec = rc;
> -		}
> -	} while (rc);
> -
> -	do {
>  		rc = msi_capability_init(dev, nvec);
>  		if (rc < 0) {
>  			return rc;
> diff --git a/include/linux/msi.h b/include/linux/msi.h index 8103f32..dbf7cc9
> 100644
> --- a/include/linux/msi.h
> +++ b/include/linux/msi.h
> @@ -60,7 +60,6 @@ int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc
> *desc);  void arch_teardown_msi_irq(unsigned int irq);  int
> arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);  void
> arch_teardown_msi_irqs(struct pci_dev *dev); -int arch_msi_check_device(struct
> pci_dev* dev, int nvec, int type);  void arch_restore_msi_irqs(struct pci_dev
> *dev);
> 
>  void default_teardown_msi_irqs(struct pci_dev *dev); @@ -77,8 +76,6 @@ struct
> msi_chip {
>  	int (*setup_irq)(struct msi_chip *chip, struct pci_dev *dev,
>  			 struct msi_desc *desc);
>  	void (*teardown_irq)(struct msi_chip *chip, unsigned int irq);
> -	int (*check_device)(struct msi_chip *chip, struct pci_dev *dev,
> -			    int nvec, int type);
>  };
> 
>  #endif /* LINUX_MSI_H */
> --
> 1.9.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body
> of a message to majordomo@...r.kernel.org More majordomo info at
> http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists