[v3,3/6] PCI: hv: Remove the useless hv_pcichild_state from struct hv_pci_dev

Message ID 20230420024037.5921-4-decui@microsoft.com
State New
Headers
Series pci-hyper: Fix race condition bugs for fast device hotplug |

Commit Message

Dexuan Cui April 20, 2023, 2:40 a.m. UTC
  The hpdev->state is never really useful. The only use in
hv_pci_eject_device() and hv_eject_device_work() is not really necessary.

Signed-off-by: Dexuan Cui <decui@microsoft.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Cc: stable@vger.kernel.org
---

v2:
  No change to the patch body.
  Added Cc:stable

v3:
  Added Michael's Reviewed-by.

 drivers/pci/controller/pci-hyperv.c | 12 ------------
 1 file changed, 12 deletions(-)
  

Comments

Lorenzo Pieralisi May 25, 2023, 8:16 a.m. UTC | #1
On Wed, Apr 19, 2023 at 07:40:34PM -0700, Dexuan Cui wrote:
> The hpdev->state is never really useful. The only use in
> hv_pci_eject_device() and hv_eject_device_work() is not really necessary.
> 
> Signed-off-by: Dexuan Cui <decui@microsoft.com>
> Reviewed-by: Michael Kelley <mikelley@microsoft.com>
> Cc: stable@vger.kernel.org
> ---
> 
> v2:
>   No change to the patch body.
>   Added Cc:stable
> 
> v3:
>   Added Michael's Reviewed-by.
> 
>  drivers/pci/controller/pci-hyperv.c | 12 ------------
>  1 file changed, 12 deletions(-)

Is this patch _required_ for subsequent fixes ? It is not a fix itself
so I am asking.

Acked-by: Lorenzo Pieralisi <lpieralisi@kernel.org>

> diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
> index 1b11cf7391933..46df6d093d683 100644
> --- a/drivers/pci/controller/pci-hyperv.c
> +++ b/drivers/pci/controller/pci-hyperv.c
> @@ -553,19 +553,10 @@ struct hv_dr_state {
>  	struct hv_pcidev_description func[];
>  };
>  
> -enum hv_pcichild_state {
> -	hv_pcichild_init = 0,
> -	hv_pcichild_requirements,
> -	hv_pcichild_resourced,
> -	hv_pcichild_ejecting,
> -	hv_pcichild_maximum
> -};
> -
>  struct hv_pci_dev {
>  	/* List protected by pci_rescan_remove_lock */
>  	struct list_head list_entry;
>  	refcount_t refs;
> -	enum hv_pcichild_state state;
>  	struct pci_slot *pci_slot;
>  	struct hv_pcidev_description desc;
>  	bool reported_missing;
> @@ -2750,8 +2741,6 @@ static void hv_eject_device_work(struct work_struct *work)
>  	hpdev = container_of(work, struct hv_pci_dev, wrk);
>  	hbus = hpdev->hbus;
>  
> -	WARN_ON(hpdev->state != hv_pcichild_ejecting);
> -
>  	/*
>  	 * Ejection can come before or after the PCI bus has been set up, so
>  	 * attempt to find it and tear down the bus state, if it exists.  This
> @@ -2808,7 +2797,6 @@ static void hv_pci_eject_device(struct hv_pci_dev *hpdev)
>  		return;
>  	}
>  
> -	hpdev->state = hv_pcichild_ejecting;
>  	get_pcichild(hpdev);
>  	INIT_WORK(&hpdev->wrk, hv_eject_device_work);
>  	queue_work(hbus->wq, &hpdev->wrk);
> -- 
> 2.25.1
>
  
Dexuan Cui June 15, 2023, 4:36 a.m. UTC | #2
> From: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Sent: Thursday, May 25, 2023 1:16 AM
> To: Dexuan Cui <decui@microsoft.com>
> 
> Is this patch _required_ for subsequent fixes ?
It's not required. IMO it's good to have this patch with patch 2 since
patch 2 also touches hv_pcichild_ejecting. I'm OK if people think
it's better to merge this patch through the "next" branch rather than
the "fixes" branch.

> It is not a fix itself so I am asking.

> Acked-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Thanks!
  

Patch

diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
index 1b11cf7391933..46df6d093d683 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -553,19 +553,10 @@  struct hv_dr_state {
 	struct hv_pcidev_description func[];
 };
 
-enum hv_pcichild_state {
-	hv_pcichild_init = 0,
-	hv_pcichild_requirements,
-	hv_pcichild_resourced,
-	hv_pcichild_ejecting,
-	hv_pcichild_maximum
-};
-
 struct hv_pci_dev {
 	/* List protected by pci_rescan_remove_lock */
 	struct list_head list_entry;
 	refcount_t refs;
-	enum hv_pcichild_state state;
 	struct pci_slot *pci_slot;
 	struct hv_pcidev_description desc;
 	bool reported_missing;
@@ -2750,8 +2741,6 @@  static void hv_eject_device_work(struct work_struct *work)
 	hpdev = container_of(work, struct hv_pci_dev, wrk);
 	hbus = hpdev->hbus;
 
-	WARN_ON(hpdev->state != hv_pcichild_ejecting);
-
 	/*
 	 * Ejection can come before or after the PCI bus has been set up, so
 	 * attempt to find it and tear down the bus state, if it exists.  This
@@ -2808,7 +2797,6 @@  static void hv_pci_eject_device(struct hv_pci_dev *hpdev)
 		return;
 	}
 
-	hpdev->state = hv_pcichild_ejecting;
 	get_pcichild(hpdev);
 	INIT_WORK(&hpdev->wrk, hv_eject_device_work);
 	queue_work(hbus->wq, &hpdev->wrk);