qvm: resize vm during kernel boot

Resize the vm during kernel boot.

Change-Id: Ibef1819793ef7aab3d969d102b9a37871cec9a3e
Signed-off-by: Sudarshan Rajagopalan <quic_sudaraja@quicinc.com>
This commit is contained in:
Sudarshan Rajagopalan 2023-06-15 04:49:07 -07:00
parent f677f7b5ac
commit d83c70b503
5 changed files with 30 additions and 4 deletions

View File

@ -21,6 +21,7 @@
static dev_t mem_buf_dev_no;
static struct class *mem_buf_class;
static struct cdev mem_buf_char_dev;
static bool mem_buf_ready;
union mem_buf_ioctl_arg {
struct mem_buf_alloc_ioctl_arg allocation;
@ -331,6 +332,11 @@ static const struct file_operations mem_buf_dev_fops = {
.compat_ioctl = compat_ptr_ioctl,
};
bool mem_buf_probe_complete(void)
{
return mem_buf_ready;
}
static int mem_buf_msgq_probe(struct platform_device *pdev)
{
int ret;
@ -356,6 +362,7 @@ static int mem_buf_msgq_probe(struct platform_device *pdev)
goto err_dev_create;
}
mem_buf_ready = true;
return 0;
err_dev_create:

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#define pr_fmt(fmt) "qti_virtio_mem: %s: " fmt, __func__
@ -32,6 +32,11 @@ static LIST_HEAD(qvm_list);
/* Sum of all hints */
static s64 qvm_hint_total;
void qvm_update_plugged_size(uint64_t size)
{
qvm_hint_total = (s64)size;
}
static int qti_virtio_mem_hint_update(struct qti_virtio_mem_hint *hint,
s64 new_size, bool sync)
{

View File

@ -1,10 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef QTI_VIRTIO_MEM_PRIVATE_H
#define QTI_VIRTIO_MEM_PRIVATE_H
int virtio_mem_update_config_size(s64 size, bool sync);
void qvm_update_plugged_size(uint64_t size);
#endif

View File

@ -3,7 +3,7 @@
* Virtio-mem device driver.
*
* Copyright Red Hat, Inc. 2020
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Author(s): David Hildenbrand <david@redhat.com>
*/
@ -27,6 +27,7 @@
#include <linux/bitmap.h>
#include <linux/lockdep.h>
#include <linux/log2.h>
#include "qti_virtio_mem.h"
#include <acpi/acpi_numa.h>
@ -279,6 +280,8 @@ struct virtio_mem {
static struct virtio_mem *virtio_mem_dev;
static DEFINE_XARRAY(xa_membuf);
#define NUM_BLOCKS_ADD_STARTUP 16
/*
* We have to share a single online_page callback among all virtio-mem
* devices. We use RCU to iterate the list in the callback.
@ -2746,6 +2749,7 @@ static int virtio_mem_init(struct virtio_mem *vm)
return -EINVAL;
}
vm->device_block_size = device_block_size;
vm->new_requested_size = vm->device_block_size * NUM_BLOCKS_ADD_STARTUP;
node_id = NUMA_NO_NODE;
vm->nid = virtio_mem_translate_node_id(vm, node_id);
@ -2843,6 +2847,9 @@ static int virtio_mem_probe(struct platform_device *vdev)
BUILD_BUG_ON(sizeof(struct virtio_mem_req) != 24);
BUILD_BUG_ON(sizeof(struct virtio_mem_resp) != 10);
if (!mem_buf_probe_complete())
return -EPROBE_DEFER;
vm = kzalloc(sizeof(*vm), GFP_KERNEL);
if (!vm)
return -ENOMEM;
@ -2871,8 +2878,10 @@ static int virtio_mem_probe(struct platform_device *vdev)
if (!vm->in_kdump) {
atomic_set(&vm->config_changed, 1);
queue_work(system_freezable_wq, &vm->wq);
flush_work(&vm->wq);
}
qvm_update_plugged_size(vm->plugged_size);
return 0;
out_free_vm:

View File

@ -118,6 +118,7 @@ void *mem_buf_alloc(struct mem_buf_allocation_data *alloc_data);
void mem_buf_free(void *membuf);
struct gh_sgl_desc *mem_buf_get_sgl(void *membuf);
int mem_buf_current_vmid(void);
bool mem_buf_probe_complete(void);
#else
static inline void *mem_buf_alloc(struct mem_buf_allocation_data *alloc_data)
@ -135,6 +136,10 @@ static inline int mem_buf_current_vmid(void)
{
return -EINVAL;
}
static inline bool mem_buf_probe_complete(void)
{
return false;
}
#endif /* CONFIG_QCOM_MEM_BUF */