Patchwork [3/4] ich9: add notifer for ec to generate sci

login
register
mail settings
Submitter liguang
Date May 22, 2013, 3:46 a.m.
Message ID <1369194397-608-4-git-send-email-lig.fnst@cn.fujitsu.com>
Download mbox | patch
Permalink /patch/245500/
State New
Headers show

Comments

liguang - May 22, 2013, 3:46 a.m.
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
 hw/acpi/ich9.c         |   15 +++++++++++++++
 include/hw/acpi/ich9.h |    1 +
 2 files changed, 16 insertions(+), 0 deletions(-)
Michael S. Tsirkin - May 27, 2013, 8:21 p.m.
On Wed, May 22, 2013 at 11:46:36AM +0800, liguang wrote:
> Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
> ---
>  hw/acpi/ich9.c         |   15 +++++++++++++++
>  include/hw/acpi/ich9.h |    1 +
>  2 files changed, 16 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
> index 582dbec..2ecde32 100644
> --- a/hw/acpi/ich9.c
> +++ b/hw/acpi/ich9.c
> @@ -33,6 +33,7 @@
>  #include "exec/address-spaces.h"
>  
>  #include "hw/i386/ich9.h"
> +#include "hw/acpi/ec.h"
>  
>  //#define DEBUG
>  

Which symbols does this patch use from ec.h?

> @@ -43,6 +44,8 @@ do { printf("%s "fmt, __func__, ## __VA_ARGS__); } while (0)
>  #define ICH9_DEBUG(fmt, ...)    do { } while (0)
>  #endif
>  
> +#define GPE_EC_SCI_STATUS (0x1 << (16 + 1))
> +
>  static void pm_update_sci(ICH9LPCPMRegs *pm)
>  {
>      int sci_level, pm1a_sts;
> @@ -202,6 +205,15 @@ static void pm_powerdown_req(Notifier *n, void *opaque)
>      acpi_pm1_evt_power_down(&pm->acpi_regs);
>  }
>  
> +static void pm_ec_sci_req(Notifier *n, void *opaque)
> +{
> +    ICH9LPCPMRegs *pm = container_of(n, ICH9LPCPMRegs, ec_sci_notifier);
> +    ACPIGPE *gpe = &pm->acpi_regs.gpe;
> +
> +    *gpe->sts |= GPE_EC_SCI_STATUS;
> +    pm_update_sci(pm);
> +}
> +
>  void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
>                    qemu_irq sci_irq)
>  {
> @@ -227,4 +239,7 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
>      qemu_register_reset(pm_reset, pm);
>      pm->powerdown_notifier.notify = pm_powerdown_req;
>      qemu_register_powerdown_notifier(&pm->powerdown_notifier);
> +
> +    pm->ec_sci_notifier.notify = pm_ec_sci_req;
> +    qemu_register_ec_sci_notifier(&pm->ec_sci_notifier);
>  }
> diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
> index b1fe71f..f358deb 100644
> --- a/include/hw/acpi/ich9.h
> +++ b/include/hw/acpi/ich9.h
> @@ -42,6 +42,7 @@ typedef struct ICH9LPCPMRegs {
>  
>      uint32_t pm_io_base;
>      Notifier powerdown_notifier;
> +    Notifier ec_sci_notifier;
>  } ICH9LPCPMRegs;
>  
>  void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
> -- 
> 1.7.2.5
liguang - May 28, 2013, 12:23 a.m.
在 2013-05-27一的 23:21 +0300,Michael S. Tsirkin写道:
> On Wed, May 22, 2013 at 11:46:36AM +0800, liguang wrote:
> > Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
> > ---
> >  hw/acpi/ich9.c         |   15 +++++++++++++++
> >  include/hw/acpi/ich9.h |    1 +
> >  2 files changed, 16 insertions(+), 0 deletions(-)
> > 
> > diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
> > index 582dbec..2ecde32 100644
> > --- a/hw/acpi/ich9.c
> > +++ b/hw/acpi/ich9.c
> > @@ -33,6 +33,7 @@
> >  #include "exec/address-spaces.h"
> >  
> >  #include "hw/i386/ich9.h"
> > +#include "hw/acpi/ec.h"
> >  
> >  //#define DEBUG
> >  
> 
> Which symbols does this patch use from ec.h?

qemu_register_ec_sci_notifier

> 
> > @@ -43,6 +44,8 @@ do { printf("%s "fmt, __func__, ## __VA_ARGS__); } while (0)
> >  #define ICH9_DEBUG(fmt, ...)    do { } while (0)
> >  #endif
> >  
> > +#define GPE_EC_SCI_STATUS (0x1 << (16 + 1))
> > +
> >  static void pm_update_sci(ICH9LPCPMRegs *pm)
> >  {
> >      int sci_level, pm1a_sts;
> > @@ -202,6 +205,15 @@ static void pm_powerdown_req(Notifier *n, void *opaque)
> >      acpi_pm1_evt_power_down(&pm->acpi_regs);
> >  }
> >  
> > +static void pm_ec_sci_req(Notifier *n, void *opaque)
> > +{
> > +    ICH9LPCPMRegs *pm = container_of(n, ICH9LPCPMRegs, ec_sci_notifier);
> > +    ACPIGPE *gpe = &pm->acpi_regs.gpe;
> > +
> > +    *gpe->sts |= GPE_EC_SCI_STATUS;
> > +    pm_update_sci(pm);
> > +}
> > +
> >  void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
> >                    qemu_irq sci_irq)
> >  {
> > @@ -227,4 +239,7 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
> >      qemu_register_reset(pm_reset, pm);
> >      pm->powerdown_notifier.notify = pm_powerdown_req;
> >      qemu_register_powerdown_notifier(&pm->powerdown_notifier);
> > +
> > +    pm->ec_sci_notifier.notify = pm_ec_sci_req;
> > +    qemu_register_ec_sci_notifier(&pm->ec_sci_notifier);
> >  }
> > diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
> > index b1fe71f..f358deb 100644
> > --- a/include/hw/acpi/ich9.h
> > +++ b/include/hw/acpi/ich9.h
> > @@ -42,6 +42,7 @@ typedef struct ICH9LPCPMRegs {
> >  
> >      uint32_t pm_io_base;
> >      Notifier powerdown_notifier;
> > +    Notifier ec_sci_notifier;
> >  } ICH9LPCPMRegs;
> >  
> >  void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
> > -- 
> > 1.7.2.5
Michael S. Tsirkin - May 28, 2013, 6:40 a.m.
On Wed, May 22, 2013 at 11:46:36AM +0800, liguang wrote:
> Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
> ---
>  hw/acpi/ich9.c         |   15 +++++++++++++++
>  include/hw/acpi/ich9.h |    1 +
>  2 files changed, 16 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
> index 582dbec..2ecde32 100644
> --- a/hw/acpi/ich9.c
> +++ b/hw/acpi/ich9.c
> @@ -33,6 +33,7 @@
>  #include "exec/address-spaces.h"
>  
>  #include "hw/i386/ich9.h"
> +#include "hw/acpi/ec.h"
>  
>  //#define DEBUG
>  
> @@ -43,6 +44,8 @@ do { printf("%s "fmt, __func__, ## __VA_ARGS__); } while (0)
>  #define ICH9_DEBUG(fmt, ...)    do { } while (0)
>  #endif
>  
> +#define GPE_EC_SCI_STATUS (0x1 << (16 + 1))
> +
>  static void pm_update_sci(ICH9LPCPMRegs *pm)
>  {
>      int sci_level, pm1a_sts;
> @@ -202,6 +205,15 @@ static void pm_powerdown_req(Notifier *n, void *opaque)
>      acpi_pm1_evt_power_down(&pm->acpi_regs);
>  }
>  
> +static void pm_ec_sci_req(Notifier *n, void *opaque)
> +{
> +    ICH9LPCPMRegs *pm = container_of(n, ICH9LPCPMRegs, ec_sci_notifier);
> +    ACPIGPE *gpe = &pm->acpi_regs.gpe;
> +
> +    *gpe->sts |= GPE_EC_SCI_STATUS;
> +    pm_update_sci(pm);
> +}
> +
>  void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
>                    qemu_irq sci_irq)
>  {
> @@ -227,4 +239,7 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
>      qemu_register_reset(pm_reset, pm);
>      pm->powerdown_notifier.notify = pm_powerdown_req;
>      qemu_register_powerdown_notifier(&pm->powerdown_notifier);
> +
> +    pm->ec_sci_notifier.notify = pm_ec_sci_req;
> +    qemu_register_ec_sci_notifier(&pm->ec_sci_notifier);
>  }

So an EC is using ICH9 to send SCI to guest,
but ICH9 should not worry about EC that's connected to it.
So it should be something like
qemu_register_sci_notifier
and not make ich9 depend on ec.

> diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
> index b1fe71f..f358deb 100644
> --- a/include/hw/acpi/ich9.h
> +++ b/include/hw/acpi/ich9.h
> @@ -42,6 +42,7 @@ typedef struct ICH9LPCPMRegs {
>  
>      uint32_t pm_io_base;
>      Notifier powerdown_notifier;
> +    Notifier ec_sci_notifier;
>  } ICH9LPCPMRegs;
>  
>  void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
> -- 
> 1.7.2.5
liguang - May 28, 2013, 6:44 a.m.
在 2013-05-28二的 09:40 +0300,Michael S. Tsirkin写道:
> On Wed, May 22, 2013 at 11:46:36AM +0800, liguang wrote:
> > Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
> > ---
> >  hw/acpi/ich9.c         |   15 +++++++++++++++
> >  include/hw/acpi/ich9.h |    1 +
> >  2 files changed, 16 insertions(+), 0 deletions(-)
> > 
> > diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
> > index 582dbec..2ecde32 100644
> > --- a/hw/acpi/ich9.c
> > +++ b/hw/acpi/ich9.c
> > @@ -33,6 +33,7 @@
> >  #include "exec/address-spaces.h"
> >  
> >  #include "hw/i386/ich9.h"
> > +#include "hw/acpi/ec.h"
> >  
> >  //#define DEBUG
> >  
> > @@ -43,6 +44,8 @@ do { printf("%s "fmt, __func__, ## __VA_ARGS__); } while (0)
> >  #define ICH9_DEBUG(fmt, ...)    do { } while (0)
> >  #endif
> >  
> > +#define GPE_EC_SCI_STATUS (0x1 << (16 + 1))
> > +
> >  static void pm_update_sci(ICH9LPCPMRegs *pm)
> >  {
> >      int sci_level, pm1a_sts;
> > @@ -202,6 +205,15 @@ static void pm_powerdown_req(Notifier *n, void *opaque)
> >      acpi_pm1_evt_power_down(&pm->acpi_regs);
> >  }
> >  
> > +static void pm_ec_sci_req(Notifier *n, void *opaque)
> > +{
> > +    ICH9LPCPMRegs *pm = container_of(n, ICH9LPCPMRegs, ec_sci_notifier);
> > +    ACPIGPE *gpe = &pm->acpi_regs.gpe;
> > +
> > +    *gpe->sts |= GPE_EC_SCI_STATUS;
> > +    pm_update_sci(pm);
> > +}
> > +
> >  void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
> >                    qemu_irq sci_irq)
> >  {
> > @@ -227,4 +239,7 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
> >      qemu_register_reset(pm_reset, pm);
> >      pm->powerdown_notifier.notify = pm_powerdown_req;
> >      qemu_register_powerdown_notifier(&pm->powerdown_notifier);
> > +
> > +    pm->ec_sci_notifier.notify = pm_ec_sci_req;
> > +    qemu_register_ec_sci_notifier(&pm->ec_sci_notifier);
> >  }
> 
> So an EC is using ICH9 to send SCI to guest,
> but ICH9 should not worry about EC that's connected to it.
> So it should be something like
> qemu_register_sci_notifier
> and not make ich9 depend on ec.

OK, let me think about it.

Thanks!

> 
> > diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
> > index b1fe71f..f358deb 100644
> > --- a/include/hw/acpi/ich9.h
> > +++ b/include/hw/acpi/ich9.h
> > @@ -42,6 +42,7 @@ typedef struct ICH9LPCPMRegs {
> >  
> >      uint32_t pm_io_base;
> >      Notifier powerdown_notifier;
> > +    Notifier ec_sci_notifier;
> >  } ICH9LPCPMRegs;
> >  
> >  void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
> > -- 
> > 1.7.2.5

Patch

diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 582dbec..2ecde32 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -33,6 +33,7 @@ 
 #include "exec/address-spaces.h"
 
 #include "hw/i386/ich9.h"
+#include "hw/acpi/ec.h"
 
 //#define DEBUG
 
@@ -43,6 +44,8 @@  do { printf("%s "fmt, __func__, ## __VA_ARGS__); } while (0)
 #define ICH9_DEBUG(fmt, ...)    do { } while (0)
 #endif
 
+#define GPE_EC_SCI_STATUS (0x1 << (16 + 1))
+
 static void pm_update_sci(ICH9LPCPMRegs *pm)
 {
     int sci_level, pm1a_sts;
@@ -202,6 +205,15 @@  static void pm_powerdown_req(Notifier *n, void *opaque)
     acpi_pm1_evt_power_down(&pm->acpi_regs);
 }
 
+static void pm_ec_sci_req(Notifier *n, void *opaque)
+{
+    ICH9LPCPMRegs *pm = container_of(n, ICH9LPCPMRegs, ec_sci_notifier);
+    ACPIGPE *gpe = &pm->acpi_regs.gpe;
+
+    *gpe->sts |= GPE_EC_SCI_STATUS;
+    pm_update_sci(pm);
+}
+
 void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
                   qemu_irq sci_irq)
 {
@@ -227,4 +239,7 @@  void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
     qemu_register_reset(pm_reset, pm);
     pm->powerdown_notifier.notify = pm_powerdown_req;
     qemu_register_powerdown_notifier(&pm->powerdown_notifier);
+
+    pm->ec_sci_notifier.notify = pm_ec_sci_req;
+    qemu_register_ec_sci_notifier(&pm->ec_sci_notifier);
 }
diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
index b1fe71f..f358deb 100644
--- a/include/hw/acpi/ich9.h
+++ b/include/hw/acpi/ich9.h
@@ -42,6 +42,7 @@  typedef struct ICH9LPCPMRegs {
 
     uint32_t pm_io_base;
     Notifier powerdown_notifier;
+    Notifier ec_sci_notifier;
 } ICH9LPCPMRegs;
 
 void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,