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]
Date:	Fri, 11 Jul 2014 18:12:40 +0530
From:	Varka Bhadram <varkabhadram@...il.com>
To:	Ethan Zhao <ethan.zhao@...cle.com>, bhelgaas@...gle.com,
	konrad.wilk@...cle.com, boris.ostrovsky@...cle.com,
	david.vrabel@...rix.com, gleb@...nel.org, pbonzini@...hat.com,
	jeffrey.t.kirsher@...el.com, jesse.brandeburg@...el.com,
	bruce.w.allan@...el.com, carolyn.wyborny@...el.com,
	donald.c.skidmore@...el.com, gregory.v.rose@...el.com,
	alexander.h.duyck@...el.com, john.ronciak@...el.com,
	mitch.a.williams@...el.com, alex.williamson@...hat.com
CC:	linux-pci@...r.kernel.org, kvm@...r.kernel.org,
	linux.nics@...el.com, e1000-devel@...ts.sourceforge.net,
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
	ethan.kernel@...il.com, vaughan.cao@...cle.com
Subject: Re: [PATCH 2/2 V3] PCI: implement VFs assignment reference counter

On 07/11/2014 06:00 PM, Ethan Zhao wrote:
> Current implementation of helper function pci_vfs_assigned() is a
> little complex, to get sum of VFs that assigned to VM, access low
> level configuration space register and then loop in traversing
> device tree.

(...)

> @@ -650,6 +630,11 @@ EXPORT_SYMBOL_GPL(pci_vfs_assigned);
>   void pci_iov_assign_device(struct pci_dev *pdev)
>   {
>   	pdev->dev_flags |= PCI_DEV_FLAGS_ASSIGNED;
> +	if (pdev->is_virtfn && !pdev->is_physfn)
> +		if (pdev->physfn)
> +			if (pdev->physfn->sriov)

Why don't we make last two 'if' conditions into single 'if'

if (pdev->physfn && pdev->physfn->sriov)

> +				atomic_inc(&pdev->physfn->sriov->
> +					VFs_assigned_cnt);
>   }
>   EXPORT_SYMBOL_GPL(pci_iov_assign_device);
>   
> @@ -660,6 +645,11 @@ EXPORT_SYMBOL_GPL(pci_iov_assign_device);
>   void pci_iov_deassign_device(struct pci_dev *pdev)
>   {
>   	pdev->dev_flags &= ~PCI_DEV_FLAGS_ASSIGNED;
> +	if (pdev->is_virtfn && !pdev->is_physfn)
> +		if (pdev->physfn)
> +			if (pdev->physfn->sriov)

same...

> +				atomic_dec(&pdev->physfn->sriov->
> +					VFs_assigned_cnt);
>   }
>   EXPORT_SYMBOL_GPL(pci_iov_deassign_device);
>   
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 6bd0822..d17bda2 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -235,6 +235,7 @@ struct pci_sriov {
>   	u32 pgsz;		/* page size for BAR alignment */
>   	u8 link;		/* Function Dependency Link */
>   	u16 driver_max_VFs;	/* max num VFs driver supports */
> +	atomic_t VFs_assigned_cnt; /* counter of VFs assigned to VM */
>   	struct pci_dev *dev;	/* lowest numbered PF */
>   	struct pci_dev *self;	/* this PF */
>   	struct mutex lock;	/* lock for VF bus */

-- 
Regards,
Varka Bhadram.

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ