@@ -1925,6 +1925,70 @@ int dxgvmb_send_query_alloc_residency(struct dxgprocess *process,
19251925 return ret ;
19261926}
19271927
1928+ int dxgvmb_send_query_vidmem_info (struct dxgprocess * process ,
1929+ struct dxgadapter * adapter ,
1930+ struct d3dkmt_queryvideomemoryinfo * args ,
1931+ struct d3dkmt_queryvideomemoryinfo * __user
1932+ output )
1933+ {
1934+ int ret ;
1935+ struct dxgkvmb_command_queryvideomemoryinfo * command ;
1936+ struct dxgkvmb_command_queryvideomemoryinfo_return result = { };
1937+ struct dxgvmbusmsg msg = {.hdr = NULL };
1938+
1939+ ret = init_message (& msg , adapter , process , sizeof (* command ));
1940+ if (ret )
1941+ goto cleanup ;
1942+ command = (void * )msg .msg ;
1943+ command_vgpu_to_host_init2 (& command -> hdr ,
1944+ dxgk_vmbcommand_queryvideomemoryinfo ,
1945+ process -> host_handle );
1946+ command -> adapter = args -> adapter ;
1947+ command -> memory_segment_group = args -> memory_segment_group ;
1948+ command -> physical_adapter_index = args -> physical_adapter_index ;
1949+
1950+ ret = dxgvmb_send_sync_msg (msg .channel , msg .hdr , msg .size ,
1951+ & result , sizeof (result ));
1952+ if (ret < 0 )
1953+ goto cleanup ;
1954+
1955+ ret = copy_to_user (& output -> budget , & result .budget ,
1956+ sizeof (output -> budget ));
1957+ if (ret ) {
1958+ pr_err ("%s failed to copy budget" , __func__ );
1959+ ret = - EINVAL ;
1960+ goto cleanup ;
1961+ }
1962+ ret = copy_to_user (& output -> current_usage , & result .current_usage ,
1963+ sizeof (output -> current_usage ));
1964+ if (ret ) {
1965+ pr_err ("%s failed to copy current usage" , __func__ );
1966+ ret = - EINVAL ;
1967+ goto cleanup ;
1968+ }
1969+ ret = copy_to_user (& output -> current_reservation ,
1970+ & result .current_reservation ,
1971+ sizeof (output -> current_reservation ));
1972+ if (ret ) {
1973+ pr_err ("%s failed to copy reservation" , __func__ );
1974+ ret = - EINVAL ;
1975+ goto cleanup ;
1976+ }
1977+ ret = copy_to_user (& output -> available_for_reservation ,
1978+ & result .available_for_reservation ,
1979+ sizeof (output -> available_for_reservation ));
1980+ if (ret ) {
1981+ pr_err ("%s failed to copy avail reservation" , __func__ );
1982+ ret = - EINVAL ;
1983+ }
1984+
1985+ cleanup :
1986+ free_message (& msg , process );
1987+ if (ret )
1988+ dev_dbg (DXGDEV , "err: %d" , ret );
1989+ return ret ;
1990+ }
1991+
19281992int dxgvmb_send_get_device_state (struct dxgprocess * process ,
19291993 struct dxgadapter * adapter ,
19301994 struct d3dkmt_getdevicestate * args ,
0 commit comments