From: Alex Williamson <alex.williamson@redhat.com>
To: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Cc: izumi.taku@jp.fujitsu.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC v3 03/10] aer: introduce pcie_aer_setup to setup aer related bits
Date: Tue, 10 Feb 2015 09:39:47 -0700 [thread overview]
Message-ID: <1423586387.22865.814.camel@redhat.com> (raw)
In-Reply-To: <f9718ba558ffc65718b4814ad54681b711544ab7.1423551266.git.chen.fan.fnst@cn.fujitsu.com>
On Tue, 2015-02-10 at 15:03 +0800, Chen Fan wrote:
> because function pcie_aer_init() is for adding a new aer capability,
> but for vfio device, we only need to capture the aer capability from
> vfio device configuration space, so here we introduce pcie_aer_setup()
> to init all raw devices.
I don't see why pcie_add_capability is split out, see for instance
msix_init() where the call still includes a call to
pci_add_capability().
> Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
> ---
> hw/pci/pcie_aer.c | 63 +++++++++++++++++++++++++++++------------------
> include/hw/pci/pcie_aer.h | 1 +
> 2 files changed, 40 insertions(+), 24 deletions(-)
>
> diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c
> index ece1487..18caf43 100644
> --- a/hw/pci/pcie_aer.c
> +++ b/hw/pci/pcie_aer.c
> @@ -94,53 +94,31 @@ static void aer_log_clear_all_err(PCIEAERLog *aer_log)
> aer_log->log_num = 0;
> }
>
> -int pcie_aer_init(PCIDevice *dev, uint16_t offset)
> +void pcie_aer_setup(PCIDevice *dev, uint16_t offset, uint16_t log_max)
> {
> PCIExpressDevice *exp;
>
> - pcie_add_capability(dev, PCI_EXT_CAP_ID_ERR, PCI_ERR_VER,
> - offset, PCI_ERR_SIZEOF);
> exp = &dev->exp;
> exp->aer_cap = offset;
>
> - /* log_max is property */
> - if (dev->exp.aer_log.log_max == PCIE_AER_LOG_MAX_UNSET) {
> - dev->exp.aer_log.log_max = PCIE_AER_LOG_MAX_DEFAULT;
> - }
> - /* clip down the value to avoid unreasobale memory usage */
> - if (dev->exp.aer_log.log_max > PCIE_AER_LOG_MAX_LIMIT) {
> - return -EINVAL;
> - }
> - dev->exp.aer_log.log = g_malloc0(sizeof dev->exp.aer_log.log[0] *
> - dev->exp.aer_log.log_max);
>
> pci_set_long(dev->w1cmask + offset + PCI_ERR_UNCOR_STATUS,
> PCI_ERR_UNC_SUPPORTED);
>
> - pci_set_long(dev->config + offset + PCI_ERR_UNCOR_SEVER,
> - PCI_ERR_UNC_SEVERITY_DEFAULT);
> pci_set_long(dev->wmask + offset + PCI_ERR_UNCOR_SEVER,
> PCI_ERR_UNC_SUPPORTED);
>
> pci_long_test_and_set_mask(dev->w1cmask + offset + PCI_ERR_COR_STATUS,
> PCI_ERR_COR_SUPPORTED);
>
> - pci_set_long(dev->config + offset + PCI_ERR_COR_MASK,
> - PCI_ERR_COR_MASK_DEFAULT);
> pci_set_long(dev->wmask + offset + PCI_ERR_COR_MASK,
> PCI_ERR_COR_SUPPORTED);
>
> - /* capabilities and control. multiple header logging is supported */
> - if (dev->exp.aer_log.log_max > 0) {
> - pci_set_long(dev->config + offset + PCI_ERR_CAP,
> - PCI_ERR_CAP_ECRC_GENC | PCI_ERR_CAP_ECRC_CHKC |
> - PCI_ERR_CAP_MHRC);
> + if (log_max > 0) {
> pci_set_long(dev->wmask + offset + PCI_ERR_CAP,
> PCI_ERR_CAP_ECRC_GENE | PCI_ERR_CAP_ECRC_CHKE |
> PCI_ERR_CAP_MHRE);
> } else {
> - pci_set_long(dev->config + offset + PCI_ERR_CAP,
> - PCI_ERR_CAP_ECRC_GENC | PCI_ERR_CAP_ECRC_CHKC);
> pci_set_long(dev->wmask + offset + PCI_ERR_CAP,
> PCI_ERR_CAP_ECRC_GENE | PCI_ERR_CAP_ECRC_CHKE);
> }
> @@ -160,6 +138,43 @@ int pcie_aer_init(PCIDevice *dev, uint16_t offset)
> /* nothing */
> break;
> }
> +}
> +
> +int pcie_aer_init(PCIDevice *dev, uint16_t offset)
> +{
> +
> + pcie_add_capability(dev, PCI_EXT_CAP_ID_ERR, PCI_ERR_VER,
> + offset, PCI_ERR_SIZEOF);
> +
> + /* log_max is property */
> + if (dev->exp.aer_log.log_max == PCIE_AER_LOG_MAX_UNSET) {
> + dev->exp.aer_log.log_max = PCIE_AER_LOG_MAX_DEFAULT;
> + }
> + /* clip down the value to avoid unreasobale memory usage */
> + if (dev->exp.aer_log.log_max > PCIE_AER_LOG_MAX_LIMIT) {
> + return -EINVAL;
> + }
> +
> + dev->exp.aer_log.log = g_malloc0(sizeof dev->exp.aer_log.log[0] *
> + dev->exp.aer_log.log_max);
> +
> + /* capabilities and control. multiple header logging is supported */
> + if (dev->exp.aer_log.log_max > 0) {
> + pci_set_long(dev->config + offset + PCI_ERR_CAP,
> + PCI_ERR_CAP_ECRC_GENC | PCI_ERR_CAP_ECRC_CHKC |
> + PCI_ERR_CAP_MHRC);
> + } else {
> + pci_set_long(dev->config + offset + PCI_ERR_CAP,
> + PCI_ERR_CAP_ECRC_GENC | PCI_ERR_CAP_ECRC_CHKC);
> + }
> +
> + pci_set_long(dev->config + offset + PCI_ERR_UNCOR_SEVER,
> + PCI_ERR_UNC_SEVERITY_DEFAULT);
> + pci_set_long(dev->config + offset + PCI_ERR_COR_MASK,
> + PCI_ERR_COR_MASK_DEFAULT);
> +
> + pcie_aer_setup(dev, offset, dev->exp.aer_log.log_max);
> +
> return 0;
> }
>
> diff --git a/include/hw/pci/pcie_aer.h b/include/hw/pci/pcie_aer.h
> index bcac80a..e675c7d 100644
> --- a/include/hw/pci/pcie_aer.h
> +++ b/include/hw/pci/pcie_aer.h
> @@ -87,6 +87,7 @@ struct PCIEAERErr {
>
> extern const VMStateDescription vmstate_pcie_aer_log;
>
> +void pcie_aer_setup(PCIDevice *dev, uint16_t offset, uint16_t log_max);
> int pcie_aer_init(PCIDevice *dev, uint16_t offset);
> void pcie_aer_exit(PCIDevice *dev);
> void pcie_aer_write_config(PCIDevice *dev,
next prev parent reply other threads:[~2015-02-10 16:39 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-10 7:03 [Qemu-devel] [RFC v3 00/10] pass aer error to guest for vfio device Chen Fan
2015-02-10 7:03 ` [Qemu-devel] [RFC v3 01/10] pcie_aer: fix typos in pcie_aer_inject_error comment Chen Fan
2015-02-10 7:03 ` [Qemu-devel] [RFC v3 02/10] aer: fix a wrong init PCI_ERR_COR_STATUS w1cmask type register Chen Fan
2015-02-10 7:03 ` [Qemu-devel] [RFC v3 03/10] aer: introduce pcie_aer_setup to setup aer related bits Chen Fan
2015-02-10 16:39 ` Alex Williamson [this message]
2015-02-10 7:03 ` [Qemu-devel] [RFC v3 04/10] vfio: add pcie extanded capability support Chen Fan
2015-02-10 16:39 ` Alex Williamson
2015-02-26 9:37 ` Chen Fan
2015-02-26 22:28 ` Alex Williamson
2015-02-10 7:03 ` [Qemu-devel] [RFC v3 05/10] pcie_aer: expose pcie_aer_msg() interface Chen Fan
2015-02-10 7:03 ` [Qemu-devel] [RFC v3 06/10] piix: disable all vfio device aercap property Chen Fan
2015-02-10 16:39 ` Alex Williamson
2015-02-10 7:03 ` [Qemu-devel] [RFC v3 07/10] vfio_pci: change vfio device features bit macro to enum definition Chen Fan
2015-02-10 16:39 ` Alex Williamson
2015-02-10 7:03 ` [Qemu-devel] [RFC v3 08/10] vfio-pci: add VFIO_FEATURE_ENABLE_AER_CAP feature Chen Fan
2015-02-10 16:39 ` Alex Williamson
2015-02-26 6:46 ` Chen Fan
2015-02-26 22:18 ` Alex Williamson
2015-03-02 7:23 ` Chen Fan
2015-02-10 7:03 ` [Qemu-devel] [RFC v3 09/10] vfio-pci: pass the aer error to guest Chen Fan
2015-02-10 7:03 ` [Qemu-devel] [RFC v3 10/10] pcie_aer: fix a trivial typo in PCIEAERMsg comments Chen Fan
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=1423586387.22865.814.camel@redhat.com \
--to=alex.williamson@redhat.com \
--cc=chen.fan.fnst@cn.fujitsu.com \
--cc=izumi.taku@jp.fujitsu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.