qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: qemu-stable@nongnu.org, Zheng Xiang <zhengxiang9@huawei.com>,
	Zheng Xiang <xiang.zheng@linaro.org>,
	Wang Haibin <wanghaibin.wang@huawei.com>,
	"Michael S . Tsirkin" <mst@redhat.com>
Subject: [Qemu-devel] [PATCH 76/97] pcie: set link state inactive/active after hot unplug/plug
Date: Mon,  1 Apr 2019 15:59:50 -0500	[thread overview]
Message-ID: <20190401210011.16009-77-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <20190401210011.16009-1-mdroth@linux.vnet.ibm.com>

From: Zheng Xiang <zhengxiang9@huawei.com>

When VM boots from the latest version of linux kernel, after
hot-unpluging virtio-blk disks which are hotplugged into
pcie-root-port, the VM's dmesg log shows:

[  151.046242] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0001 from Slot Status
[  151.046365] pciehp 0000:00:05.0:pcie004: Slot(0-3): Attention button pressed
[  151.046369] pciehp 0000:00:05.0:pcie004: Slot(0-3): Powering off due to button press
[  151.046420] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
[  151.046425] pciehp 0000:00:05.0:pcie004: pciehp_green_led_blink: SLOTCTRL a8 write cmd 200
[  151.046464] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
[  151.046468] pciehp 0000:00:05.0:pcie004: pciehp_set_attention_status: SLOTCTRL a8 write cmd c0
[  156.163421] pciehp 0000:00:05.0:pcie004: pciehp_get_power_status: SLOTCTRL a8 value read 2f1
[  156.163427] pciehp 0000:00:05.0:pcie004: pciehp_unconfigure_device: domain:bus:dev = 0000:06:00
[  156.198736] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
[  156.198772] pciehp 0000:00:05.0:pcie004: pciehp_power_off_slot: SLOTCTRL a8 write cmd 400
[  157.224124] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0018 from Slot Status
[  157.224194] pciehp 0000:00:05.0:pcie004: pciehp_green_led_off: SLOTCTRL a8 write cmd 300
[  157.224220] pciehp 0000:00:05.0:pcie004: pciehp_check_link_active: lnk_status = 2011
[  157.224223] pciehp 0000:00:05.0:pcie004: Slot(0-3): Link Up
[  157.224233] pciehp 0000:00:05.0:pcie004: pciehp_get_power_status: SLOTCTRL a8 value read 7f1
[  157.224281] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
[  157.224285] pciehp 0000:00:05.0:pcie004: pciehp_power_on_slot: SLOTCTRL a8 write cmd 0
[  157.224300] pciehp 0000:00:05.0:pcie004: __pciehp_link_set: lnk_ctrl = 0
[  157.224336] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
[  157.224339] pciehp 0000:00:05.0:pcie004: pciehp_green_led_blink: SLOTCTRL a8 write cmd 200
[  159.739294] pci 0000:06:00.0 id reading try 50 times with interval 20 ms to get ffffffff
[  159.739315] pciehp 0000:00:05.0:pcie004: pciehp_check_link_status: lnk_status = 2011
[  159.739318] pciehp 0000:00:05.0:pcie004: Failed to check link status
[  159.739371] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
[  159.739394] pciehp 0000:00:05.0:pcie004: pciehp_power_off_slot: SLOTCTRL a8 write cmd 400
[  160.771426] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
[  160.771452] pciehp 0000:00:05.0:pcie004: pciehp_green_led_off: SLOTCTRL a8 write cmd 300
[  160.771495] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
[  160.771499] pciehp 0000:00:05.0:pcie004: pciehp_set_attention_status: SLOTCTRL a8 write cmd 40
[  160.771535] pciehp 0000:00:05.0:pcie004: pending interrupts 0x0010 from Slot Status
[  160.771539] pciehp 0000:00:05.0:pcie004: pciehp_green_led_off: SLOTCTRL a8 write cmd 300

After analyzing the log information, it seems that qemu doesn't
change the Link Status from active to inactive after hot-unplug.
This results in the abnormal log after the linux kernel commit
d331710ea78fea merged.

Furthermore, If I hotplug the same virtio-blk disk after hot-unplug,
the virtio-blk would turn on and then back off.

So this patch set the Link Status inactive after hot-unplug and
active after hot-plug.

Signed-off-by: Zheng Xiang <zhengxiang9@huawei.com>
Signed-off-by: Zheng Xiang <xiang.zheng@linaro.org>
Cc: Wang Haibin <wanghaibin.wang@huawei.com>
Cc: qemu-stable@nongnu.org
Reviewed-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 2f2b18f60bf17453b4c01197a9316615a3c1f1de)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 hw/pci/pcie.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index 6c91bd44a0..66b73b87c8 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -345,6 +345,10 @@ void pcie_cap_slot_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
     if (!dev->hotplugged) {
         pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA,
                                    PCI_EXP_SLTSTA_PDS);
+        if (pci_dev->cap_present & QEMU_PCIE_LNKSTA_DLLLA) {
+            pci_word_test_and_set_mask(exp_cap + PCI_EXP_LNKSTA,
+                                       PCI_EXP_LNKSTA_DLLLA);
+        }
         return;
     }
 
@@ -355,6 +359,10 @@ void pcie_cap_slot_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
     if (pci_get_function_0(pci_dev)) {
         pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA,
                                    PCI_EXP_SLTSTA_PDS);
+        if (pci_dev->cap_present & QEMU_PCIE_LNKSTA_DLLLA) {
+            pci_word_test_and_set_mask(exp_cap + PCI_EXP_LNKSTA,
+                                       PCI_EXP_LNKSTA_DLLLA);
+        }
         pcie_cap_slot_event(PCI_DEVICE(hotplug_dev),
                             PCI_EXP_HP_EV_PDC | PCI_EXP_HP_EV_ABP);
     }
@@ -531,6 +539,10 @@ void pcie_cap_slot_write_config(PCIDevice *dev,
 
         pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA,
                                      PCI_EXP_SLTSTA_PDS);
+        if (dev->cap_present & QEMU_PCIE_LNKSTA_DLLLA) {
+            pci_word_test_and_clear_mask(exp_cap + PCI_EXP_LNKSTA,
+                                         PCI_EXP_LNKSTA_DLLLA);
+        }
         pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA,
                                        PCI_EXP_SLTSTA_PDC);
     }
-- 
2.17.1

  parent reply	other threads:[~2019-04-01 21:04 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-01 20:58 [Qemu-devel] [PATCH 00/97] Patch Round-up for stable 3.0.1, freeze on 2019-04-08 Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 01/97] target/arm: Fix sign of sve_cmpeq_ppzw/sve_cmpne_ppzw Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 02/97] target/arm: Fix typo in do_sat_addsub_64 Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 03/97] target/arm: Reorganize SVE WHILE Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 04/97] target/arm: Fix typo in helper_sve_movz_d Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 05/97] target/arm: Fix typo in helper_sve_ld1hss_r Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 06/97] target/arm: Fix sign-extension in sve do_ldr/do_str Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 07/97] target/arm: Fix offset for LD1R instructions Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 08/97] target/arm: Fix offset scaling for LD_zprr and ST_zprr Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 09/97] target/arm: Reformat integer register dump Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 10/97] target/arm: Dump SVE state if enabled Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 11/97] target/arm: Add sve-max-vq cpu property to -cpu max Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 12/97] spapr_cpu_core: vmstate_[un]register per-CPU data from (un)realizefn Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 13/97] target/arm: Adjust FPCR_MASK for FZ16 Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 14/97] target/arm: Ignore float_flag_input_denormal from fp_status_f16 Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 15/97] target/arm: Use fp_status_fp16 for do_fmpa_zpzzz_h Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 16/97] target/arm: Use FZ not FZ16 for SVE FCVT single-half and double-half Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 17/97] block/qapi: Fix memory leak in qmp_query_blockstats() Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 18/97] mirror: Fail gracefully for source == target Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 19/97] qemu-img: fix regression copying secrets during convert Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 20/97] nvme: Fix nvme_init error handling Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 21/97] aio-posix: Don't count ctx->notifier as progress when polling Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 22/97] aio: Do aio_notify_accept only during blocking aio_poll Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 23/97] monitor: fix oob command leak Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 24/97] vnc: fix memleak of the "vnc-worker-output" name Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 25/97] i386: Disable TOPOEXT by default on "-cpu host" Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 26/97] block: for jobs, do not clear user_paused until after the resume Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 27/97] block: iotest to catch abort on forced blockjob cancel Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 28/97] virtio: update MemoryRegionCaches when guest negotiates features Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 29/97] target/xtensa: fix FPU2000 bugs Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 30/97] kvm: add call to qemu_add_opts() for -overcommit option Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 31/97] slirp: Add sanity check for str option length Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 32/97] vhost: fix invalid downcast Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 33/97] pc: acpi: revert back to 1 SRAT entry for hotpluggable area Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 34/97] tests: update acpi expected files Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 35/97] block: Fix use after free error in bdrv_open_inherit() Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 36/97] job: Fix nested aio_poll() hanging in job_txn_apply Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 37/97] target/xtensa: fix s32c1i TCGMemOp flags Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 38/97] nbd/server: fix bitmap export Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 39/97] clean up callback when del virtqueue Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 40/97] block/rbd: pull out qemu_rbd_convert_options Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 41/97] block/rbd: Attempt to parse legacy filenames Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 42/97] block/rbd: add iotest for rbd legacy keyvalue filename parsing Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 43/97] block/rbd: add deprecation documentation for filename keyvalue pairs Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 44/97] target/arm: Fix cpu_get_tb_cpu_state() for non-SVE CPUs Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 45/97] ne2000: fix possible out of bound access in ne2000_receive Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 46/97] rtl8139: fix possible out of bound access Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 47/97] pcnet: fix possible buffer overflow Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 48/97] net: ignore packet size greater than INT_MAX Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 49/97] virt: Suppress external aborts on virt-2.10 and earlier Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 50/97] virtio: do not take address of packed members Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 51/97] block-backend: Set werror/rerror defaults in blk_new() Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 52/97] target/arm: Correct condition for v8M callee stack push Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 53/97] nbd/server: fix NBD_CMD_CACHE Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 54/97] intel_iommu: introduce vtd_reset_caches() Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 55/97] intel_iommu: better handling of dmar state switch Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 56/97] nbd: fix NBD_FLAG_SEND_CACHE value Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 57/97] migration: Stop postcopy fault thread before notifying Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 58/97] vhost-scsi: prevent using uninitialized vqs Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 59/97] target/xtensa: drop num_[core_]regs from dc232b/dc233c configs Michael Roth
2019-04-01 21:19   ` Max Filippov
2019-04-01 23:28     ` Michael Roth
2019-04-01 23:42       ` Max Filippov
2019-04-01 20:59 ` [Qemu-devel] [PATCH 60/97] make-release: add skiboot .version file Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 61/97] net: drop too large packet early Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 62/97] fdc: fix segfault in fdctrl_stop_transfer() when DMA is disabled Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 63/97] qemu-img: Fix typo Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 64/97] qemu-img: Fix leak Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 65/97] fmops: fix off-by-one in AR_TABLE and DR_TABLE array size Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 66/97] vfio-helpers: Fix qemu_vfio_open_pci() crash Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 67/97] i2c: Move typedef of bitbang_i2c_interface to i2c.h Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 68/97] i2c: Add a length check to the SMBus write handling Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 69/97] nbd/server: Advertise all contexts in response to bare LIST Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 70/97] nbd/client: Make x-dirty-bitmap more reliable Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 71/97] nbd/client: Send NBD_CMD_DISC if open fails after connect Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 72/97] mirror: fix dead-lock Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 73/97] iotests: simple mirror test with kvm on 1G image Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 74/97] iotests: make 235 work on s390 (and others) Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 75/97] Changes requirement for "vsubsbs" instruction Michael Roth
2019-04-01 20:59 ` Michael Roth [this message]
2019-04-01 20:59 ` [Qemu-devel] [PATCH 77/97] pc:piix4: Update smbus I/O space after a migration Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 78/97] hw/s390x: Fix bad mask in time2tod() Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 79/97] linux-user: write(fd, NULL, 0) parity with linux's treatment of same Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 80/97] linux-user: make pwrite64/pread64(fd, NULL, 0, offset) return 0 Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 81/97] s390x: Return specification exception for unimplemented diag 308 subcodes Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 82/97] exec.c: Don't reallocate IOMMUNotifiers that are in use Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 83/97] tpm: Zero-init structure to avoid uninitialized variables in valgrind log Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 84/97] tpm: use loop iterator to set sts data field Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 85/97] tpm: Make sure new locality passed to tpm_tis_prep_abort() is valid Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 86/97] tpm: Make sure the locality received from backend " Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 87/97] block: Fix invalidate_cache error path for parent activation Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 88/97] acpi: Make TPM 2.0 with TIS available as MSFT0101 Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 89/97] hw/rdma: another clang compilation fix Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 90/97] slirp: check sscanf result when emulating ident Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 91/97] tpm_tis: fix loop that cancels any seizure by a lower locality Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 92/97] bitmap: Update count after a merge Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 93/97] qga: update docs with systemd suspend support info Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 94/97] nvme: fix out-of-bounds access to the CMB Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 95/97] 9p: fix QEMU crash when renaming files Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 96/97] usb-mtp: outlaw slashes in filenames Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 97/97] usb-mtp: use O_NOFOLLOW and O_CLOEXEC Michael Roth
2019-04-02 16:22 ` [Qemu-devel] [Qemu-stable] [PATCH 00/97] Patch Round-up for stable 3.0.1, freeze on 2019-04-08 Cole Robinson
2019-04-04 21:28   ` Michael Roth
2019-04-04 22:31 ` [Qemu-devel] " Philippe Mathieu-Daudé
2019-04-04 22:31   ` Philippe Mathieu-Daudé
2019-04-05 20:28   ` Michael Roth
2019-04-05 20:28     ` Michael Roth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190401210011.16009-77-mdroth@linux.vnet.ibm.com \
    --to=mdroth@linux.vnet.ibm.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=wanghaibin.wang@huawei.com \
    --cc=xiang.zheng@linaro.org \
    --cc=zhengxiang9@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).