Re: [PATCH v3 05/30] drivers: hv: dxgkrnl: Opening of /dev/dxg device and dxgprocess creation

Wei Liu
2022-03-01T23:47:51Z

On Tue, Mar 01, 2022 at 11:45:52AM -0800, Iouri Tarassov wrote:
> - Implement opening of the device (/dev/dxg) file object and creation of
> dxgprocess objects.
[...]
> static int dxgk_open(struct inode *n, struct file *f)
> {
> - return 0;
> + int ret = 0;
> + struct dxgprocess *process;
> +
> + pr_debug("%s %p %d %d",
> + __func__, f, current->pid, current->tgid);
> +
> +
> + /* Find/create a dxgprocess structure for this process */
> + process = dxgglobal_get_current_process();
> +
> + if (process) {
> + f->private_data = process;
> + } else {
> + pr_debug("cannot create dxgprocess for open\n");
> + ret = -EBADF;
> + }
> +
> + pr_debug("%s end %x", __func__, ret);

I would normally remove pr_deubg's like this when submitting. It doesn't
provide much information.

> + return ret;
> }
>
[...]
>
> +int dxgvmb_send_create_process(struct dxgprocess *process)
> +{
> + int ret;
> + struct dxgkvmb_command_createprocess *command;
> + struct dxgkvmb_command_createprocess_return result = { 0 };
> + struct dxgvmbusmsg msg;
> + char s[WIN_MAX_PATH];
> + int i;
> +
> + ret = init_message(&msg, NULL, process, sizeof(*command));
> + if (ret)
> + return ret;
> + command = (void *)msg.msg;
> +
> + ret = dxgglobal_acquire_channel_lock();
> + if (ret < 0)
> + goto cleanup;
> +
> + command_vm_to_host_init1(&command->hdr, DXGK_VMBCOMMAND_CREATEPROCESS);
> + command->process = process;
> + command->process_id = process->process->pid;
> + command->linux_process = 1;
> + s[0] = 0;
> + __get_task_comm(s, WIN_MAX_PATH, process->process);
> + for (i = 0; i < WIN_MAX_PATH; i++) {
> + command->process_name[i] = s[i];
> + if (s[i] == 0)
> + break;
> + }

What's wrong with doing

__get_task_comm(command->process_name, WIN_MAX_PATH, process->process);

here?

That saves you many bytes on stack.

[...]
> +static char *errorstr(int ret)
> +{
> + return ret < 0 ? "err" : "";
> +}
> +

This is not used in this patch.

[...]
> diff --git a/drivers/hv/dxgkrnl/misc.h b/drivers/hv/dxgkrnl/misc.h
> index 1ff0c0e28332..433b59d3eb23 100644
> --- a/drivers/hv/dxgkrnl/misc.h
> +++ b/drivers/hv/dxgkrnl/misc.h
> @@ -31,7 +31,6 @@ extern const struct d3dkmthandle zerohandle;
> * table_lock
> * core_lock
> * device_lock
> - * process->process_mutex

Why is this deleted?

Thanks,
Wei.