All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH qemu aspeed-3.1 0/2] aspeed: Guest to exit on shutdown
@ 2018-11-13  3:04 Joel Stanley
  2018-11-13  3:04 ` [PATCH qemu aspeed-3.1 1/2] aspeed: Add syscon-poweroff to system Joel Stanley
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Joel Stanley @ 2018-11-13  3:04 UTC (permalink / raw)
  To: openbmc, Cédric Le Goater

With this change to qemu and CONFIG_POWER_RESET_SYSCON_POWEROFF=y
enabled in the kernel, the guest will cause qemu to exit when performing
a shutdown. This is useful for detecting the end of a successful CI job.

This is only relevant when passing the device tree to Qemu with the -dtb
option.

It only supports the ast2500 so far.

Joel Stanley (2):
  aspeed: Add syscon-poweroff to system
  aspeed/scu: Implement power off command

 hw/arm/aspeed.c      | 35 +++++++++++++++++++++++++++++++++++
 hw/misc/aspeed_scu.c |  5 +++++
 2 files changed, 40 insertions(+)

-- 
2.19.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH qemu aspeed-3.1 1/2] aspeed: Add syscon-poweroff to system
  2018-11-13  3:04 [PATCH qemu aspeed-3.1 0/2] aspeed: Guest to exit on shutdown Joel Stanley
@ 2018-11-13  3:04 ` Joel Stanley
  2018-11-13  7:36   ` Cédric Le Goater
  2018-11-13  3:04 ` [PATCH qemu aspeed-3.1 2/2] aspeed/scu: Implement power off command Joel Stanley
  2018-11-13  7:27 ` [PATCH qemu aspeed-3.1 0/2] aspeed: Guest to exit on shutdown Cédric Le Goater
  2 siblings, 1 reply; 5+ messages in thread
From: Joel Stanley @ 2018-11-13  3:04 UTC (permalink / raw)
  To: openbmc, Cédric Le Goater

Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 hw/arm/aspeed.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index e7b87e355f12..66d6e9ed4551 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -21,8 +21,10 @@
 #include "hw/i2c/smbus.h"
 #include "qemu/log.h"
 #include "sysemu/block-backend.h"
+#include "sysemu/device_tree.h"
 #include "hw/loader.h"
 #include "qemu/error-report.h"
+#include <libfdt.h>
 
 static struct arm_boot_info aspeed_board_binfo = {
     .board_id = -1, /* device-tree-only board */
@@ -126,6 +128,38 @@ static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size,
     g_free(storage);
 }
 
+static void fdt_add_shutdown_node(void *fdt)
+{
+    /* TODO: Support 2400 */
+    const char *scu = "aspeed,ast2500-scu";
+    const char *nodename = "/syscon-poweroff";
+    uint32_t phandle;
+    int offset;
+
+    /* Find the scu phandle */
+    offset = fdt_node_offset_by_compatible(fdt, -1, scu);
+    if (offset < 0) {
+        error_report("%s couldn't find %s, guest shutdown unavailable: %s",
+                     __func__, scu, fdt_strerror(offset));
+        return;
+    }
+    phandle = fdt_get_phandle(fdt, offset);
+
+    /* Add syscon-poweroff node and use 0x1A0, an un-used SCU register */
+    qemu_fdt_add_subnode(fdt, nodename);
+    qemu_fdt_setprop_string(fdt, nodename, "compatible", "syscon-poweroff");
+    qemu_fdt_setprop_cells(fdt, nodename, "regmap", phandle);
+    qemu_fdt_setprop_cells(fdt, nodename, "offset", 0x1A0);
+    qemu_fdt_setprop_cells(fdt, nodename, "value", 1);
+}
+
+static void aspeed_board_modify_dtb(const struct arm_boot_info *binfo,
+                                    void *fdt)
+{
+    fdt_add_shutdown_node(fdt);
+}
+
+
 static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
                                       Error **errp)
 {
@@ -235,6 +269,7 @@ static void aspeed_board_init(MachineState *machine,
     aspeed_board_binfo.kernel_cmdline = machine->kernel_cmdline;
     aspeed_board_binfo.ram_size = ram_size;
     aspeed_board_binfo.loader_start = sc->info->sdram_base;
+    aspeed_board_binfo.modify_dtb = aspeed_board_modify_dtb;
 
     if (cfg->i2c_init) {
         cfg->i2c_init(bmc);
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH qemu aspeed-3.1 2/2] aspeed/scu: Implement power off command
  2018-11-13  3:04 [PATCH qemu aspeed-3.1 0/2] aspeed: Guest to exit on shutdown Joel Stanley
  2018-11-13  3:04 ` [PATCH qemu aspeed-3.1 1/2] aspeed: Add syscon-poweroff to system Joel Stanley
@ 2018-11-13  3:04 ` Joel Stanley
  2018-11-13  7:27 ` [PATCH qemu aspeed-3.1 0/2] aspeed: Guest to exit on shutdown Cédric Le Goater
  2 siblings, 0 replies; 5+ messages in thread
From: Joel Stanley @ 2018-11-13  3:04 UTC (permalink / raw)
  To: openbmc, Cédric Le Goater

Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 hw/misc/aspeed_scu.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c
index 51498ce70be6..257f9a6c6b8a 100644
--- a/hw/misc/aspeed_scu.c
+++ b/hw/misc/aspeed_scu.c
@@ -16,6 +16,7 @@
 #include "qapi/visitor.h"
 #include "qemu/bitops.h"
 #include "qemu/log.h"
+#include "sysemu/sysemu.h"
 #include "crypto/random.h"
 #include "trace.h"
 
@@ -84,6 +85,7 @@
 #define SRAM_DECODE_BASE1    TO_REG(0x194)
 #define SRAM_DECODE_BASE2    TO_REG(0x198)
 #define BMC_REV              TO_REG(0x19C)
+#define POWEROFF             TO_REG(0x1A0)
 #define BMC_DEV_ID           TO_REG(0x1A4)
 
 #define SCU_IO_REGION_SIZE 0x1000
@@ -263,6 +265,9 @@ static void aspeed_scu_write(void *opaque, hwaddr offset, uint64_t data,
         }
         /* Avoid assignment below, we've handled everything */
         return;
+    case POWEROFF:
+        qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
+        break;
     case FREQ_CNTR_EVAL:
     case VGA_SCRATCH1 ... VGA_SCRATCH8:
     case RNG_DATA:
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH qemu aspeed-3.1 0/2] aspeed: Guest to exit on shutdown
  2018-11-13  3:04 [PATCH qemu aspeed-3.1 0/2] aspeed: Guest to exit on shutdown Joel Stanley
  2018-11-13  3:04 ` [PATCH qemu aspeed-3.1 1/2] aspeed: Add syscon-poweroff to system Joel Stanley
  2018-11-13  3:04 ` [PATCH qemu aspeed-3.1 2/2] aspeed/scu: Implement power off command Joel Stanley
@ 2018-11-13  7:27 ` Cédric Le Goater
  2 siblings, 0 replies; 5+ messages in thread
From: Cédric Le Goater @ 2018-11-13  7:27 UTC (permalink / raw)
  To: Joel Stanley, openbmc

On 11/13/18 4:04 AM, Joel Stanley wrote:
> With this change to qemu and CONFIG_POWER_RESET_SYSCON_POWEROFF=y
> enabled in the kernel, the guest will cause qemu to exit when performing
> a shutdown. This is useful for detecting the end of a successful CI job.

Excellent !

> This is only relevant when passing the device tree to Qemu with the -dtb
> option.

Can't we find a way to inform Linux that it's running on a "virtual" 
QEMU Aspeed machine ? 

> It only supports the ast2500 so far.

I pushed the patches in aspeed-3.1

Thanks,

C. 

> 
> Joel Stanley (2):
>   aspeed: Add syscon-poweroff to system
>   aspeed/scu: Implement power off command
> 
>  hw/arm/aspeed.c      | 35 +++++++++++++++++++++++++++++++++++
>  hw/misc/aspeed_scu.c |  5 +++++
>  2 files changed, 40 insertions(+)
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH qemu aspeed-3.1 1/2] aspeed: Add syscon-poweroff to system
  2018-11-13  3:04 ` [PATCH qemu aspeed-3.1 1/2] aspeed: Add syscon-poweroff to system Joel Stanley
@ 2018-11-13  7:36   ` Cédric Le Goater
  0 siblings, 0 replies; 5+ messages in thread
From: Cédric Le Goater @ 2018-11-13  7:36 UTC (permalink / raw)
  To: Joel Stanley, openbmc

On 11/13/18 4:04 AM, Joel Stanley wrote:
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
>  hw/arm/aspeed.c | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index e7b87e355f12..66d6e9ed4551 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -21,8 +21,10 @@
>  #include "hw/i2c/smbus.h"
>  #include "qemu/log.h"
>  #include "sysemu/block-backend.h"
> +#include "sysemu/device_tree.h"
>  #include "hw/loader.h"
>  #include "qemu/error-report.h"
> +#include <libfdt.h>
>  
>  static struct arm_boot_info aspeed_board_binfo = {
>      .board_id = -1, /* device-tree-only board */
> @@ -126,6 +128,38 @@ static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size,
>      g_free(storage);
>  }
>  
> +static void fdt_add_shutdown_node(void *fdt)
> +{
> +    /* TODO: Support 2400 */

You could add a 'const char* property' parameter to fdt_add_shutdown_node()
and use a AspeedBoardConfig.modify_dtb() method to call it.

> +    const char *scu = "aspeed,ast2500-scu";
> +    const char *nodename = "/syscon-poweroff";
> +    uint32_t phandle;
> +    int offset;
> +
> +    /* Find the scu phandle */
> +    offset = fdt_node_offset_by_compatible(fdt, -1, scu);
> +    if (offset < 0) {
> +        error_report("%s couldn't find %s, guest shutdown unavailable: %s",
> +                     __func__, scu, fdt_strerror(offset));
> +        return;
> +    }
> +    phandle = fdt_get_phandle(fdt, offset);
> +
> +    /* Add syscon-poweroff node and use 0x1A0, an un-used SCU register */
> +    qemu_fdt_add_subnode(fdt, nodename);
> +    qemu_fdt_setprop_string(fdt, nodename, "compatible", "syscon-poweroff");
> +    qemu_fdt_setprop_cells(fdt, nodename, "regmap", phandle);
> +    qemu_fdt_setprop_cells(fdt, nodename, "offset", 0x1A0);
> +    qemu_fdt_setprop_cells(fdt, nodename, "value", 1);
> +}
> +
> +static void aspeed_board_modify_dtb(const struct arm_boot_info *binfo,
> +                                    void *fdt)
> +{
> +    fdt_add_shutdown_node(fdt);
> +}
> +
> +
>  static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
>                                        Error **errp)
>  {
> @@ -235,6 +269,7 @@ static void aspeed_board_init(MachineState *machine,
>      aspeed_board_binfo.kernel_cmdline = machine->kernel_cmdline;
>      aspeed_board_binfo.ram_size = ram_size;
>      aspeed_board_binfo.loader_start = sc->info->sdram_base;
> +    aspeed_board_binfo.modify_dtb = aspeed_board_modify_dtb;
>  
>      if (cfg->i2c_init) {
>          cfg->i2c_init(bmc);
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-11-13  8:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-13  3:04 [PATCH qemu aspeed-3.1 0/2] aspeed: Guest to exit on shutdown Joel Stanley
2018-11-13  3:04 ` [PATCH qemu aspeed-3.1 1/2] aspeed: Add syscon-poweroff to system Joel Stanley
2018-11-13  7:36   ` Cédric Le Goater
2018-11-13  3:04 ` [PATCH qemu aspeed-3.1 2/2] aspeed/scu: Implement power off command Joel Stanley
2018-11-13  7:27 ` [PATCH qemu aspeed-3.1 0/2] aspeed: Guest to exit on shutdown Cédric Le Goater

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.