[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190816133511.GC3632@kadam>
Date: Fri, 16 Aug 2019 16:39:46 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Zhao Yakui <yakui.zhao@...el.com>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org,
devel@...verdev.osuosl.org, Yin FengWei <fengwei.yin@...el.com>,
Jason Chen CJ <jason.cj.chen@...el.com>,
Liu Shuo <shuo.a.liu@...el.com>
Subject: Re: [RFC PATCH 11/15] drivers/acrn: add the support of handling
emulated ioreq
On Fri, Aug 16, 2019 at 10:25:52AM +0800, Zhao Yakui wrote:
> +int acrn_ioreq_create_client(unsigned short vmid,
> + ioreq_handler_t handler,
> + void *client_priv,
> + char *name)
> +{
> + struct acrn_vm *vm;
> + struct ioreq_client *client;
> + int client_id;
> +
> + might_sleep();
> +
> + vm = find_get_vm(vmid);
> + if (unlikely(!vm || !vm->req_buf)) {
> + pr_err("acrn-ioreq: failed to find vm from vmid %d\n", vmid);
> + put_vm(vm);
> + return -EINVAL;
> + }
> +
> + client_id = alloc_client();
> + if (unlikely(client_id < 0)) {
> + pr_err("acrn-ioreq: vm[%d] failed to alloc ioreq client\n",
> + vmid);
> + put_vm(vm);
> + return -EINVAL;
> + }
> +
> + client = acrn_ioreq_get_client(client_id);
> + if (unlikely(!client)) {
> + pr_err("failed to get the client.\n");
> + put_vm(vm);
> + return -EINVAL;
Do we need to clean up the alloc_client() allocation?
regards,
dan carpenter
> + }
> +
> + if (handler) {
> + client->handler = handler;
> + client->acrn_create_kthread = true;
> + }
> +
> + client->ref_vm = vm;
> + client->vmid = vmid;
> + client->client_priv = client_priv;
> + if (name)
> + strncpy(client->name, name, sizeof(client->name) - 1);
> + rwlock_init(&client->range_lock);
> + INIT_LIST_HEAD(&client->range_list);
> + init_waitqueue_head(&client->wq);
> +
> + /* When it is added to ioreq_client_list, the refcnt is increased */
> + spin_lock_bh(&vm->ioreq_client_lock);
> + list_add(&client->list, &vm->ioreq_client_list);
> + spin_unlock_bh(&vm->ioreq_client_lock);
> +
> + pr_info("acrn-ioreq: created ioreq client %d\n", client_id);
> +
> + return client_id;
> +}
Powered by blists - more mailing lists