On 7/28/2018 11:31 AM, Lukas Wunner wrote:
The knowledge whether a surprise removal or a safe removal is at hand does exist further up in the call stack: A surprise removal is initiated by pciehp_handle_presence_or_link_change(), a safe removal by pciehp_handle_disable_request().
Can you also check if platform supports surprise link down error reporting (Link Capabilities Register) and reports a surprise link down event in AER Uncorrectable Error Status Register for the hotplug code to make it more reliable?