From: Marcel Apfelbaum <marcel.a@redhat.com>
To: qemu-devel@nongnu.org
Cc: mst@redhat.com
Subject: [Qemu-devel] [PATCH 2/3] hw/pcie: implement power controller functionality
Date: Thu, 19 Jun 2014 16:52:20 +0300 [thread overview]
Message-ID: <1403185941-19561-3-git-send-email-marcel.a@redhat.com> (raw)
In-Reply-To: <1403185941-19561-1-git-send-email-marcel.a@redhat.com>
It is needed by hot-unplug in order to get an indication
from the OS when the device can be physically detached.
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
hw/pci/pcie.c | 15 ++++++++++++++-
include/hw/pci/pcie_regs.h | 2 ++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index ae92f00..f8bf515 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -292,16 +292,19 @@ void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot)
PCI_EXP_SLTCAP_HPC |
PCI_EXP_SLTCAP_PIP |
PCI_EXP_SLTCAP_AIP |
+ PCI_EXP_SLTCAP_PCP |
PCI_EXP_SLTCAP_ABP);
pci_word_test_and_clear_mask(dev->config + pos + PCI_EXP_SLTCTL,
PCI_EXP_SLTCTL_PIC |
+ PCI_EXP_SLTCTL_PCC |
PCI_EXP_SLTCTL_AIC);
pci_word_test_and_set_mask(dev->config + pos + PCI_EXP_SLTCTL,
PCI_EXP_SLTCTL_PIC_OFF |
PCI_EXP_SLTCTL_AIC_OFF);
pci_word_test_and_set_mask(dev->wmask + pos + PCI_EXP_SLTCTL,
PCI_EXP_SLTCTL_PIC |
+ PCI_EXP_SLTCTL_PCC |
PCI_EXP_SLTCTL_AIC |
PCI_EXP_SLTCTL_HPIE |
PCI_EXP_SLTCTL_CCIE |
@@ -327,21 +330,31 @@ void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot)
void pcie_cap_slot_reset(PCIDevice *dev)
{
uint8_t *exp_cap = dev->config + dev->exp.exp_cap;
+ PCIDevice *slot_dev = pci_bridge_get_sec_bus(PCI_BRIDGE(dev))->devices[0];
+ int pic;
+
+ pic = slot_dev ? PCI_EXP_SLTCTL_PIC_ON : PCI_EXP_SLTCTL_PIC_OFF;
PCIE_DEV_PRINTF(dev, "reset\n");
pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTCTL,
PCI_EXP_SLTCTL_EIC |
PCI_EXP_SLTCTL_PIC |
+ PCI_EXP_SLTCTL_PCC |
PCI_EXP_SLTCTL_AIC |
PCI_EXP_SLTCTL_HPIE |
PCI_EXP_SLTCTL_CCIE |
PCI_EXP_SLTCTL_PDCE |
PCI_EXP_SLTCTL_ABPE);
pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTCTL,
- PCI_EXP_SLTCTL_PIC_OFF |
+ pic |
PCI_EXP_SLTCTL_AIC_OFF);
+ if (!slot_dev) {
+ pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTCTL,
+ PCI_EXP_SLTCTL_PCC);
+ }
+
pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA,
PCI_EXP_SLTSTA_EIS |/* on reset,
the lock is released */
diff --git a/include/hw/pci/pcie_regs.h b/include/hw/pci/pcie_regs.h
index 4d123d9..652d9fc 100644
--- a/include/hw/pci/pcie_regs.h
+++ b/include/hw/pci/pcie_regs.h
@@ -57,6 +57,8 @@
#define PCI_EXP_SLTCTL_PIC_SHIFT (ffs(PCI_EXP_SLTCTL_PIC) - 1)
#define PCI_EXP_SLTCTL_PIC_OFF \
(PCI_EXP_SLTCTL_IND_OFF << PCI_EXP_SLTCTL_PIC_SHIFT)
+#define PCI_EXP_SLTCTL_PIC_ON \
+ (PCI_EXP_SLTCTL_IND_ON << PCI_EXP_SLTCTL_PIC_SHIFT)
#define PCI_EXP_SLTCTL_SUPPORTED \
(PCI_EXP_SLTCTL_ABPE | \
--
1.8.3.1
next prev parent reply other threads:[~2014-06-19 13:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-19 13:52 [Qemu-devel] [PATCH 0/3] hw/pcie: better hotplug/hotunplug support Marcel Apfelbaum
2014-06-19 13:52 ` [Qemu-devel] [PATCH 1/3] hw/pcie: corrected a debug message Marcel Apfelbaum
2014-06-19 13:52 ` Marcel Apfelbaum [this message]
2014-06-19 14:39 ` [Qemu-devel] [PATCH 2/3] hw/pcie: implement power controller functionality Michael S. Tsirkin
2014-06-19 20:56 ` Paolo Bonzini
2014-06-22 10:47 ` Marcel Apfelbaum
2014-06-22 10:52 ` Michael S. Tsirkin
2014-06-22 11:11 ` Michael S. Tsirkin
2014-06-22 11:17 ` Marcel Apfelbaum
2014-06-19 13:52 ` [Qemu-devel] [PATCH 3/3] hw/pcie: better hotplug/hotunplug support Marcel Apfelbaum
2014-06-19 14:43 ` Michael S. Tsirkin
2014-06-22 10:54 ` Marcel Apfelbaum
2014-06-22 11:03 ` Michael S. Tsirkin
2014-06-22 11:11 ` Marcel Apfelbaum
2014-06-22 11:12 ` Michael S. Tsirkin
2014-06-22 11:24 ` Marcel Apfelbaum
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=1403185941-19561-3-git-send-email-marcel.a@redhat.com \
--to=marcel.a@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).