Skip to content

Commit e839a75

Browse files
committed
Merge tag 'hyperv-fixes-signed-20220912' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux
Pull hyperv fixes from Wei Liu: - Fix an error handling issue in DRM driver (Christophe JAILLET) - Fix some issues in framebuffer driver (Vitaly Kuznetsov) - Two typo fixes (Jason Wang, Shaomin Deng) - Drop unnecessary casting in kvp tool (Zhou Jie) * tag 'hyperv-fixes-signed-20220912' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux: Drivers: hv: Never allocate anything besides framebuffer from framebuffer memory region Drivers: hv: Always reserve framebuffer region for Gen1 VMs PCI: Move PCI_VENDOR_ID_MICROSOFT/PCI_DEVICE_ID_HYPERV_VIDEO definitions to pci_ids.h tools: hv: kvp: remove unnecessary (void*) conversions Drivers: hv: remove duplicate word in a comment tools: hv: Remove an extraneous "the" drm/hyperv: Fix an error handling path in hyperv_vmbus_probe()
2 parents 6504d82 + f0880e2 commit e839a75

File tree

7 files changed

+52
-33
lines changed

7 files changed

+52
-33
lines changed

drivers/gpu/drm/hyperv/hyperv_drm_drv.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
#define DRIVER_MAJOR 1
2424
#define DRIVER_MINOR 0
2525

26-
#define PCI_VENDOR_ID_MICROSOFT 0x1414
27-
#define PCI_DEVICE_ID_HYPERV_VIDEO 0x5353
28-
2926
DEFINE_DRM_GEM_FOPS(hv_fops);
3027

3128
static struct drm_driver hyperv_driver = {
@@ -133,7 +130,6 @@ static int hyperv_vmbus_probe(struct hv_device *hdev,
133130
}
134131

135132
ret = hyperv_setup_vram(hv, hdev);
136-
137133
if (ret)
138134
goto err_vmbus_close;
139135

@@ -150,18 +146,20 @@ static int hyperv_vmbus_probe(struct hv_device *hdev,
150146

151147
ret = hyperv_mode_config_init(hv);
152148
if (ret)
153-
goto err_vmbus_close;
149+
goto err_free_mmio;
154150

155151
ret = drm_dev_register(dev, 0);
156152
if (ret) {
157153
drm_err(dev, "Failed to register drm driver.\n");
158-
goto err_vmbus_close;
154+
goto err_free_mmio;
159155
}
160156

161157
drm_fbdev_generic_setup(dev, 0);
162158

163159
return 0;
164160

161+
err_free_mmio:
162+
vmbus_free_mmio(hv->mem->start, hv->fb_size);
165163
err_vmbus_close:
166164
vmbus_close(hdev->channel);
167165
err_hv_set_drv_data:

drivers/hv/hv_fcopy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static void fcopy_send_data(struct work_struct *dummy)
129129

130130
/*
131131
* The strings sent from the host are encoded in
132-
* in utf16; convert it to utf8 strings.
132+
* utf16; convert it to utf8 strings.
133133
* The host assures us that the utf16 strings will not exceed
134134
* the max lengths specified. We will however, reserve room
135135
* for the string terminating character - in the utf16s_utf8s()

drivers/hv/vmbus_drv.c

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <linux/kernel.h>
3636
#include <linux/syscore_ops.h>
3737
#include <linux/dma-map-ops.h>
38+
#include <linux/pci.h>
3839
#include <clocksource/hyperv_timer.h>
3940
#include "hyperv_vmbus.h"
4041

@@ -2262,26 +2263,43 @@ static int vmbus_acpi_remove(struct acpi_device *device)
22622263

22632264
static void vmbus_reserve_fb(void)
22642265
{
2265-
int size;
2266+
resource_size_t start = 0, size;
2267+
struct pci_dev *pdev;
2268+
2269+
if (efi_enabled(EFI_BOOT)) {
2270+
/* Gen2 VM: get FB base from EFI framebuffer */
2271+
start = screen_info.lfb_base;
2272+
size = max_t(__u32, screen_info.lfb_size, 0x800000);
2273+
} else {
2274+
/* Gen1 VM: get FB base from PCI */
2275+
pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT,
2276+
PCI_DEVICE_ID_HYPERV_VIDEO, NULL);
2277+
if (!pdev)
2278+
return;
2279+
2280+
if (pdev->resource[0].flags & IORESOURCE_MEM) {
2281+
start = pci_resource_start(pdev, 0);
2282+
size = pci_resource_len(pdev, 0);
2283+
}
2284+
2285+
/*
2286+
* Release the PCI device so hyperv_drm or hyperv_fb driver can
2287+
* grab it later.
2288+
*/
2289+
pci_dev_put(pdev);
2290+
}
2291+
2292+
if (!start)
2293+
return;
2294+
22662295
/*
22672296
* Make a claim for the frame buffer in the resource tree under the
22682297
* first node, which will be the one below 4GB. The length seems to
22692298
* be underreported, particularly in a Generation 1 VM. So start out
22702299
* reserving a larger area and make it smaller until it succeeds.
22712300
*/
2272-
2273-
if (screen_info.lfb_base) {
2274-
if (efi_enabled(EFI_BOOT))
2275-
size = max_t(__u32, screen_info.lfb_size, 0x800000);
2276-
else
2277-
size = max_t(__u32, screen_info.lfb_size, 0x4000000);
2278-
2279-
for (; !fb_mmio && (size >= 0x100000); size >>= 1) {
2280-
fb_mmio = __request_region(hyperv_mmio,
2281-
screen_info.lfb_base, size,
2282-
fb_mmio_name, 0);
2283-
}
2284-
}
2301+
for (; !fb_mmio && (size >= 0x100000); size >>= 1)
2302+
fb_mmio = __request_region(hyperv_mmio, start, size, fb_mmio_name, 0);
22852303
}
22862304

22872305
/**
@@ -2313,7 +2331,7 @@ int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj,
23132331
bool fb_overlap_ok)
23142332
{
23152333
struct resource *iter, *shadow;
2316-
resource_size_t range_min, range_max, start;
2334+
resource_size_t range_min, range_max, start, end;
23172335
const char *dev_n = dev_name(&device_obj->device);
23182336
int retval;
23192337

@@ -2348,6 +2366,14 @@ int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj,
23482366
range_max = iter->end;
23492367
start = (range_min + align - 1) & ~(align - 1);
23502368
for (; start + size - 1 <= range_max; start += align) {
2369+
end = start + size - 1;
2370+
2371+
/* Skip the whole fb_mmio region if not fb_overlap_ok */
2372+
if (!fb_overlap_ok && fb_mmio &&
2373+
(((start >= fb_mmio->start) && (start <= fb_mmio->end)) ||
2374+
((end >= fb_mmio->start) && (end <= fb_mmio->end))))
2375+
continue;
2376+
23512377
shadow = __request_region(iter, start, size, NULL,
23522378
IORESOURCE_BUSY);
23532379
if (!shadow)

drivers/net/ethernet/microsoft/mana/gdma_main.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,10 +1465,6 @@ static void mana_gd_shutdown(struct pci_dev *pdev)
14651465
pci_disable_device(pdev);
14661466
}
14671467

1468-
#ifndef PCI_VENDOR_ID_MICROSOFT
1469-
#define PCI_VENDOR_ID_MICROSOFT 0x1414
1470-
#endif
1471-
14721468
static const struct pci_device_id mana_id_table[] = {
14731469
{ PCI_DEVICE(PCI_VENDOR_ID_MICROSOFT, MANA_PF_DEVICE_ID) },
14741470
{ PCI_DEVICE(PCI_VENDOR_ID_MICROSOFT, MANA_VF_DEVICE_ID) },

drivers/video/fbdev/hyperv_fb.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@
7474
#define SYNTHVID_DEPTH_WIN8 32
7575
#define SYNTHVID_FB_SIZE_WIN8 (8 * 1024 * 1024)
7676

77-
#define PCI_VENDOR_ID_MICROSOFT 0x1414
78-
#define PCI_DEVICE_ID_HYPERV_VIDEO 0x5353
79-
80-
8177
enum pipe_msg_type {
8278
PIPE_MSG_INVALID,
8379
PIPE_MSG_DATA,

include/linux/pci_ids.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,6 +2079,9 @@
20792079
#define PCI_DEVICE_ID_ICE_1712 0x1712
20802080
#define PCI_DEVICE_ID_VT1724 0x1724
20812081

2082+
#define PCI_VENDOR_ID_MICROSOFT 0x1414
2083+
#define PCI_DEVICE_ID_HYPERV_VIDEO 0x5353
2084+
20822085
#define PCI_VENDOR_ID_OXSEMI 0x1415
20832086
#define PCI_DEVICE_ID_OXSEMI_12PCI840 0x8403
20842087
#define PCI_DEVICE_ID_OXSEMI_PCIe840 0xC000

tools/hv/hv_kvp_daemon.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
/*
4646
* KVP protocol: The user mode component first registers with the
47-
* the kernel component. Subsequently, the kernel component requests, data
47+
* kernel component. Subsequently, the kernel component requests, data
4848
* for the specified keys. In response to this message the user mode component
4949
* fills in the value corresponding to the specified key. We overload the
5050
* sequence field in the cn_msg header to define our KVP message types.
@@ -772,11 +772,11 @@ static int kvp_process_ip_address(void *addrp,
772772
const char *str;
773773

774774
if (family == AF_INET) {
775-
addr = (struct sockaddr_in *)addrp;
775+
addr = addrp;
776776
str = inet_ntop(family, &addr->sin_addr, tmp, 50);
777777
addr_length = INET_ADDRSTRLEN;
778778
} else {
779-
addr6 = (struct sockaddr_in6 *)addrp;
779+
addr6 = addrp;
780780
str = inet_ntop(family, &addr6->sin6_addr.s6_addr, tmp, 50);
781781
addr_length = INET6_ADDRSTRLEN;
782782
}

0 commit comments

Comments
 (0)