File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3369,12 +3369,16 @@ void uvm_pmm_gpu_device_p2p_init(uvm_parent_gpu_t *parent_gpu)
33693369
33703370void uvm_pmm_gpu_device_p2p_deinit (uvm_parent_gpu_t * parent_gpu )
33713371{
3372- unsigned long pci_start_pfn = pci_resource_start (parent_gpu -> pci_dev ,
3373- uvm_device_p2p_static_bar (parent_gpu )) >> PAGE_SHIFT ;
3374- struct page * p2p_page ;
3372+ // Check device_p2p_initialised first before accessing pci_dev.
3373+ // During partial GPU init/deinit, pci_dev may be NULL or P2P was never initialized.
3374+ if (!parent_gpu -> device_p2p_initialised ) {
3375+ return ;
3376+ }
33753377
3376- if (parent_gpu -> device_p2p_initialised && !uvm_parent_gpu_is_coherent (parent_gpu )) {
3377- p2p_page = pfn_to_page (pci_start_pfn );
3378+ if (!uvm_parent_gpu_is_coherent (parent_gpu ) && parent_gpu -> pci_dev != NULL ) {
3379+ unsigned long pci_start_pfn = pci_resource_start (parent_gpu -> pci_dev ,
3380+ uvm_device_p2p_static_bar (parent_gpu )) >> PAGE_SHIFT ;
3381+ struct page * p2p_page = pfn_to_page (pci_start_pfn );
33783382 devm_memunmap_pages (& parent_gpu -> pci_dev -> dev , page_pgmap (p2p_page ));
33793383 }
33803384
You can’t perform that action at this time.
0 commit comments