Skip to content

Commit 326dc2e

Browse files
longlimsftLorenzo Pieralisi
authored andcommitted
PCI: hv: Remove bus device removal unused refcount/functions
With the new method of flushing/stopping the workqueue before doing bus removal, the old mechanism of using refcount and wait for completion is no longer needed. Remove those dead code. Link: https://lore.kernel.org/r/1620806809-31055-1-git-send-email-longli@linuxonhyperv.com Signed-off-by: Long Li <longli@microsoft.com> [lorenzo.pieralisi@arm.com: Reworded subject] Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Reviewed-by: Michael Kelley <mikelley@microsoft.com>
1 parent 94d2276 commit 326dc2e

1 file changed

Lines changed: 3 additions & 31 deletions

File tree

drivers/pci/controller/pci-hyperv.c

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -452,15 +452,13 @@ struct hv_pcibus_device {
452452
/* Protocol version negotiated with the host */
453453
enum pci_protocol_version_t protocol_version;
454454
enum hv_pcibus_state state;
455-
refcount_t remove_lock;
456455
struct hv_device *hdev;
457456
resource_size_t low_mmio_space;
458457
resource_size_t high_mmio_space;
459458
struct resource *mem_config;
460459
struct resource *low_mmio_res;
461460
struct resource *high_mmio_res;
462461
struct completion *survey_event;
463-
struct completion remove_event;
464462
struct pci_bus *pci_bus;
465463
spinlock_t config_lock; /* Avoid two threads writing index page */
466464
spinlock_t device_list_lock; /* Protect lists below */
@@ -592,9 +590,6 @@ static void put_pcichild(struct hv_pci_dev *hpdev)
592590
kfree(hpdev);
593591
}
594592

595-
static void get_hvpcibus(struct hv_pcibus_device *hv_pcibus);
596-
static void put_hvpcibus(struct hv_pcibus_device *hv_pcibus);
597-
598593
/*
599594
* There is no good way to get notified from vmbus_onoffer_rescind(),
600595
* so let's use polling here, since this is not a hot path.
@@ -2063,10 +2058,8 @@ static void pci_devices_present_work(struct work_struct *work)
20632058
}
20642059
spin_unlock_irqrestore(&hbus->device_list_lock, flags);
20652060

2066-
if (!dr) {
2067-
put_hvpcibus(hbus);
2061+
if (!dr)
20682062
return;
2069-
}
20702063

20712064
/* First, mark all existing children as reported missing. */
20722065
spin_lock_irqsave(&hbus->device_list_lock, flags);
@@ -2149,7 +2142,6 @@ static void pci_devices_present_work(struct work_struct *work)
21492142
break;
21502143
}
21512144

2152-
put_hvpcibus(hbus);
21532145
kfree(dr);
21542146
}
21552147

@@ -2190,12 +2182,10 @@ static int hv_pci_start_relations_work(struct hv_pcibus_device *hbus,
21902182
list_add_tail(&dr->list_entry, &hbus->dr_list);
21912183
spin_unlock_irqrestore(&hbus->device_list_lock, flags);
21922184

2193-
if (pending_dr) {
2185+
if (pending_dr)
21942186
kfree(dr_wrk);
2195-
} else {
2196-
get_hvpcibus(hbus);
2187+
else
21972188
queue_work(hbus->wq, &dr_wrk->wrk);
2198-
}
21992189

22002190
return 0;
22012191
}
@@ -2338,8 +2328,6 @@ static void hv_eject_device_work(struct work_struct *work)
23382328
put_pcichild(hpdev);
23392329
put_pcichild(hpdev);
23402330
/* hpdev has been freed. Do not use it any more. */
2341-
2342-
put_hvpcibus(hbus);
23432331
}
23442332

23452333
/**
@@ -2363,7 +2351,6 @@ static void hv_pci_eject_device(struct hv_pci_dev *hpdev)
23632351
hpdev->state = hv_pcichild_ejecting;
23642352
get_pcichild(hpdev);
23652353
INIT_WORK(&hpdev->wrk, hv_eject_device_work);
2366-
get_hvpcibus(hbus);
23672354
queue_work(hbus->wq, &hpdev->wrk);
23682355
}
23692356

@@ -2963,17 +2950,6 @@ static int hv_send_resources_released(struct hv_device *hdev)
29632950
return 0;
29642951
}
29652952

2966-
static void get_hvpcibus(struct hv_pcibus_device *hbus)
2967-
{
2968-
refcount_inc(&hbus->remove_lock);
2969-
}
2970-
2971-
static void put_hvpcibus(struct hv_pcibus_device *hbus)
2972-
{
2973-
if (refcount_dec_and_test(&hbus->remove_lock))
2974-
complete(&hbus->remove_event);
2975-
}
2976-
29772953
#define HVPCI_DOM_MAP_SIZE (64 * 1024)
29782954
static DECLARE_BITMAP(hvpci_dom_map, HVPCI_DOM_MAP_SIZE);
29792955

@@ -3093,14 +3069,12 @@ static int hv_pci_probe(struct hv_device *hdev,
30933069
hbus->sysdata.domain = dom;
30943070

30953071
hbus->hdev = hdev;
3096-
refcount_set(&hbus->remove_lock, 1);
30973072
INIT_LIST_HEAD(&hbus->children);
30983073
INIT_LIST_HEAD(&hbus->dr_list);
30993074
INIT_LIST_HEAD(&hbus->resources_for_children);
31003075
spin_lock_init(&hbus->config_lock);
31013076
spin_lock_init(&hbus->device_list_lock);
31023077
spin_lock_init(&hbus->retarget_msi_interrupt_lock);
3103-
init_completion(&hbus->remove_event);
31043078
hbus->wq = alloc_ordered_workqueue("hv_pci_%x", 0,
31053079
hbus->sysdata.domain);
31063080
if (!hbus->wq) {
@@ -3337,8 +3311,6 @@ static int hv_pci_remove(struct hv_device *hdev)
33373311
hv_pci_free_bridge_windows(hbus);
33383312
irq_domain_remove(hbus->irq_domain);
33393313
irq_domain_free_fwnode(hbus->sysdata.fwnode);
3340-
put_hvpcibus(hbus);
3341-
wait_for_completion(&hbus->remove_event);
33423314

33433315
hv_put_dom_num(hbus->sysdata.domain);
33443316

0 commit comments

Comments
 (0)