Skip to content

Commit c24449b

Browse files
committed
Merge tag 'hyperv-fixes-signed-20220215' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux
Pull hyperv fixes from Wei Liu: - Rework use of DMA_BIT_MASK in vmbus to work around a clang bug (Michael Kelley) - Fix NUMA topology (Long Li) - Fix a memory leak in vmbus (Miaoqian Lin) - One minor clean-up patch (Cai Huoqing) * tag 'hyperv-fixes-signed-20220215' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux: Drivers: hv: utils: Make use of the helper macro LIST_HEAD() Drivers: hv: vmbus: Rework use of DMA_BIT_MASK(64) Drivers: hv: vmbus: Fix memory leak in vmbus_add_channel_kobj PCI: hv: Fix NUMA node assignment when kernel boots with custom NUMA topology
2 parents d567f5d + ffc58bc commit c24449b

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

drivers/hv/hv_utils_transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "hv_utils_transport.h"
1414

1515
static DEFINE_SPINLOCK(hvt_list_lock);
16-
static struct list_head hvt_list = LIST_HEAD_INIT(hvt_list);
16+
static LIST_HEAD(hvt_list);
1717

1818
static void hvt_reset(struct hvutil_transport *hvt)
1919
{

drivers/hv/vmbus_drv.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,8 +2028,10 @@ int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel)
20282028
kobj->kset = dev->channels_kset;
20292029
ret = kobject_init_and_add(kobj, &vmbus_chan_ktype, NULL,
20302030
"%u", relid);
2031-
if (ret)
2031+
if (ret) {
2032+
kobject_put(kobj);
20322033
return ret;
2034+
}
20332035

20342036
ret = sysfs_create_group(kobj, &vmbus_chan_group);
20352037

@@ -2038,6 +2040,7 @@ int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel)
20382040
* The calling functions' error handling paths will cleanup the
20392041
* empty channel directory.
20402042
*/
2043+
kobject_put(kobj);
20412044
dev_err(device, "Unable to set up channel sysfs files\n");
20422045
return ret;
20432046
}
@@ -2079,7 +2082,6 @@ struct hv_device *vmbus_device_create(const guid_t *type,
20792082
return child_device_obj;
20802083
}
20812084

2082-
static u64 vmbus_dma_mask = DMA_BIT_MASK(64);
20832085
/*
20842086
* vmbus_device_register - Register the child device
20852087
*/
@@ -2120,8 +2122,9 @@ int vmbus_device_register(struct hv_device *child_device_obj)
21202122
}
21212123
hv_debug_add_dev_dir(child_device_obj);
21222124

2123-
child_device_obj->device.dma_mask = &vmbus_dma_mask;
21242125
child_device_obj->device.dma_parms = &child_device_obj->dma_parms;
2126+
child_device_obj->device.dma_mask = &child_device_obj->dma_mask;
2127+
dma_set_mask(&child_device_obj->device, DMA_BIT_MASK(64));
21252128
return 0;
21262129

21272130
err_kset_unregister:

drivers/pci/controller/pci-hyperv.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,8 +2155,17 @@ static void hv_pci_assign_numa_node(struct hv_pcibus_device *hbus)
21552155
if (!hv_dev)
21562156
continue;
21572157

2158-
if (hv_dev->desc.flags & HV_PCI_DEVICE_FLAG_NUMA_AFFINITY)
2159-
set_dev_node(&dev->dev, hv_dev->desc.virtual_numa_node);
2158+
if (hv_dev->desc.flags & HV_PCI_DEVICE_FLAG_NUMA_AFFINITY &&
2159+
hv_dev->desc.virtual_numa_node < num_possible_nodes())
2160+
/*
2161+
* The kernel may boot with some NUMA nodes offline
2162+
* (e.g. in a KDUMP kernel) or with NUMA disabled via
2163+
* "numa=off". In those cases, adjust the host provided
2164+
* NUMA node to a valid NUMA node used by the kernel.
2165+
*/
2166+
set_dev_node(&dev->dev,
2167+
numa_map_to_online_node(
2168+
hv_dev->desc.virtual_numa_node));
21602169

21612170
put_pcichild(hv_dev);
21622171
}

include/linux/hyperv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,7 @@ struct hv_device {
12621262
struct vmbus_channel *channel;
12631263
struct kset *channels_kset;
12641264
struct device_dma_parameters dma_parms;
1265+
u64 dma_mask;
12651266

12661267
/* place holder to keep track of the dir for hv device in debugfs */
12671268
struct dentry *debug_dir;

0 commit comments

Comments
 (0)