Unable to use when reconnect egpu

Hi, I use ubuntu 21.04 with a intel cpu and a nvidia egpu connected to thunderbolt3.
hotplug works fine when i connect egpu through thunderbolt. I noticed the nvidia-drm etc. were loaded. When I remove egpu by

echo 1 | sudo tee /sys/bus/pci/devices/0000:00:07.0/remove

i can see there is only one gpu left.

lspci | grep -E ‘VGA|3D’

give me

0000:00:02.0 VGA compatible controller: Intel Corporation TigerLake GT2 [Iris Xe Graphics] (rev 01)

and the nvidia module are still loaded. and i can’t remove it by calling

sudo modprobe -r nvidia-drm

when i reconnect my egpu

i can get two gpu by calling

echo 1 | sudo tee /sys/bus/pci/rescan and

lspci | grep -E ‘VGA|3D’

gives me

0000:00:02.0 VGA compatible controller: Intel Corporation TigerLake GT2 [Iris Xe Graphics] (rev 01)
0000:03:00.0 VGA compatible controller: NVIDIA Corporation GA102 [GeForce RTX 3080] (rev a1)

but i can’t use egpu

nvidia-settings gives me

ERROR: An internal driver error occurred
ERROR: Unable to load info from any available system

how can i hotplug my egpu

can i do it without quit xserver i ran it in on-demand mode.

many many thanks.

nvidia-bug-report.log.gz (374.3 KB)