[PATCH v3 8/8] arm/aspeed: Replace mx25l25635e chip model
A mx25l25635f chip model is generally found on these machines. It's newer and uses 4B opcodes which is better to exercise the support in the Linux kernel. Signed-off-by: Cédric Le Goater --- hw/arm/aspeed.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 1c611284819d..7e95abc55b09 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -1157,7 +1157,7 @@ static void aspeed_machine_palmetto_class_init(ObjectClass *oc, void *data) amc->soc_name = "ast2400-a1"; amc->hw_strap1 = PALMETTO_BMC_HW_STRAP1; amc->fmc_model = "n25q256a"; -amc->spi_model = "mx25l25635e"; +amc->spi_model = "mx25l25635f"; amc->num_cs= 1; amc->i2c_init = palmetto_bmc_i2c_init; mc->default_ram_size = 256 * MiB; @@ -1208,7 +1208,7 @@ static void aspeed_machine_ast2500_evb_class_init(ObjectClass *oc, void *data) amc->soc_name = "ast2500-a1"; amc->hw_strap1 = AST2500_EVB_HW_STRAP1; amc->fmc_model = "mx25l25635e"; -amc->spi_model = "mx25l25635e"; +amc->spi_model = "mx25l25635f"; amc->num_cs= 1; amc->i2c_init = ast2500_evb_i2c_init; mc->default_ram_size = 512 * MiB; @@ -1258,7 +1258,7 @@ static void aspeed_machine_witherspoon_class_init(ObjectClass *oc, void *data) mc->desc = "OpenPOWER Witherspoon BMC (ARM1176)"; amc->soc_name = "ast2500-a1"; amc->hw_strap1 = WITHERSPOON_BMC_HW_STRAP1; -amc->fmc_model = "mx25l25635e"; +amc->fmc_model = "mx25l25635f"; amc->spi_model = "mx66l1g45g"; amc->num_cs= 2; amc->i2c_init = witherspoon_bmc_i2c_init; -- 2.35.3
[PATCH v3 6/8] m25p80: Add the w25q256 SFPD table
The SFDP table size is 0x100 bytes long. Only the mandatory table for basic features is available at byte 0x80. Signed-off-by: Cédric Le Goater --- hw/block/m25p80_sfdp.h | 2 ++ hw/block/m25p80.c | 3 ++- hw/block/m25p80_sfdp.c | 40 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h index 468e3434151b..f60429ab8542 100644 --- a/hw/block/m25p80_sfdp.h +++ b/hw/block/m25p80_sfdp.h @@ -21,4 +21,6 @@ extern uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr); extern uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr); extern uint8_t m25p80_sfdp_mx66l1g45g(uint32_t addr); +extern uint8_t m25p80_sfdp_w25q256(uint32_t addr); + #endif diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 52df24d24751..220dbc8fb327 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -345,7 +345,8 @@ static const FlashPartInfo known_devices[] = { { INFO("w25q64", 0xef4017, 0, 64 << 10, 128, ER_4K) }, { INFO("w25q80", 0xef5014, 0, 64 << 10, 16, ER_4K) }, { INFO("w25q80bl",0xef4014, 0, 64 << 10, 16, ER_4K) }, -{ INFO("w25q256", 0xef4019, 0, 64 << 10, 512, ER_4K) }, +{ INFO("w25q256", 0xef4019, 0, 64 << 10, 512, ER_4K), + .sfdp_read = m25p80_sfdp_w25q256 }, { INFO("w25q512jv", 0xef4020, 0, 64 << 10, 1024, ER_4K) }, { INFO("w25q01jvq", 0xef4021, 0, 64 << 10, 2048, ER_4K) }, }; diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c index 38c3ced34d2e..5b011559d43d 100644 --- a/hw/block/m25p80_sfdp.c +++ b/hw/block/m25p80_sfdp.c @@ -218,3 +218,43 @@ static const uint8_t sfdp_mx66l1g45g[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; define_sfdp_read(mx66l1g45g); + +/* + * Windbond + */ + +static const uint8_t sfdp_w25q256[] = { +0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x00, 0xff, +0x00, 0x00, 0x01, 0x09, 0x80, 0x00, 0x00, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xe5, 0x20, 0xf3, 0xff, 0xff, 0xff, 0xff, 0x0f, +0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x42, 0xbb, +0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, +0xff, 0xff, 0x21, 0xeb, 0x0c, 0x20, 0x0f, 0x52, +0x10, 0xd8, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +}; +define_sfdp_read(w25q256); -- 2.35.3
[PATCH v3 5/8] m25p80: Add the mx66l1g45g SFDP table
The SFDP table size is 0x200 bytes long. The mandatory table for basic features is available at byte 0x30 plus some more Macronix specific tables. Signed-off-by: Cédric Le Goater --- hw/block/m25p80_sfdp.h | 2 +- hw/block/m25p80.c | 3 +- hw/block/m25p80_sfdp.c | 68 ++ 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h index 87690a173c78..468e3434151b 100644 --- a/hw/block/m25p80_sfdp.h +++ b/hw/block/m25p80_sfdp.h @@ -19,6 +19,6 @@ extern uint8_t m25p80_sfdp_n25q256a(uint32_t addr); extern uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr); extern uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr); - +extern uint8_t m25p80_sfdp_mx66l1g45g(uint32_t addr); #endif diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 6b120ce65212..52df24d24751 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -240,7 +240,8 @@ static const FlashPartInfo known_devices[] = { { INFO("mx66l51235f", 0xc2201a, 0, 64 << 10, 1024, ER_4K | ER_32K) }, { INFO("mx66u51235f", 0xc2253a, 0, 64 << 10, 1024, ER_4K | ER_32K) }, { INFO("mx66u1g45g", 0xc2253b, 0, 64 << 10, 2048, ER_4K | ER_32K) }, -{ INFO("mx66l1g45g", 0xc2201b, 0, 64 << 10, 2048, ER_4K | ER_32K) }, +{ INFO("mx66l1g45g", 0xc2201b, 0, 64 << 10, 2048, ER_4K | ER_32K), + .sfdp_read = m25p80_sfdp_mx66l1g45g }, /* Micron */ { INFO("n25q032a11", 0x20bb16, 0, 64 << 10, 64, ER_4K) }, diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c index 70c13aea7c63..38c3ced34d2e 100644 --- a/hw/block/m25p80_sfdp.c +++ b/hw/block/m25p80_sfdp.c @@ -150,3 +150,71 @@ static const uint8_t sfdp_mx25l25635f[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; define_sfdp_read(mx25l25635f); + +static const uint8_t sfdp_mx66l1g45g[] = { +0x53, 0x46, 0x44, 0x50, 0x06, 0x01, 0x02, 0xff, +0x00, 0x06, 0x01, 0x10, 0x30, 0x00, 0x00, 0xff, +0xc2, 0x00, 0x01, 0x04, 0x10, 0x01, 0x00, 0xff, +0x84, 0x00, 0x01, 0x02, 0xc0, 0x00, 0x00, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x3f, +0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x04, 0xbb, +0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, +0xff, 0xff, 0x44, 0xeb, 0x0c, 0x20, 0x0f, 0x52, +0x10, 0xd8, 0x00, 0xff, 0xd6, 0x49, 0xc5, 0x00, +0x85, 0xdf, 0x04, 0xe3, 0x44, 0x03, 0x67, 0x38, +0x30, 0xb0, 0x30, 0xb0, 0xf7, 0xbd, 0xd5, 0x5c, +0x4a, 0x9e, 0x29, 0xff, 0xf0, 0x50, 0xf9, 0x85, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0x7f, 0xef, 0xff, 0xff, 0x21, 0x5c, 0xdc, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0x00, 0x36, 0x00, 0x27, 0x9d, 0xf9, 0xc0, 0x64, +0x85, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0x
[PATCH v3 2/8] m25p80: Add the n25q256a SFDP table
The same values were collected on 4 differents OpenPower systems, palmettos, romulus and tacoma. The SFDP table size is defined as being 0x100 bytes but it could be bigger. Only the mandatory table for basic features is available at byte 0x30. Signed-off-by: Cédric Le Goater --- hw/block/m25p80_sfdp.h | 2 ++ hw/block/m25p80.c | 8 +++--- hw/block/m25p80_sfdp.c | 58 ++ hw/block/meson.build | 1 + 4 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 hw/block/m25p80_sfdp.c diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h index 230b07ef3308..d3a0a778ae84 100644 --- a/hw/block/m25p80_sfdp.h +++ b/hw/block/m25p80_sfdp.h @@ -15,4 +15,6 @@ */ #define M25P80_SFDP_MAX_SIZE (1 << 24) +extern uint8_t m25p80_sfdp_n25q256a(uint32_t addr); + #endif diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index abdc4c0b0da7..13e7b28fd2b0 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -247,13 +247,15 @@ static const FlashPartInfo known_devices[] = { { INFO("n25q128a11", 0x20bb18, 0, 64 << 10, 256, ER_4K) }, { INFO("n25q128a13", 0x20ba18, 0, 64 << 10, 256, ER_4K) }, { INFO("n25q256a11", 0x20bb19, 0, 64 << 10, 512, ER_4K) }, -{ INFO("n25q256a13", 0x20ba19, 0, 64 << 10, 512, ER_4K) }, +{ INFO("n25q256a13", 0x20ba19, 0, 64 << 10, 512, ER_4K), + .sfdp_read = m25p80_sfdp_n25q256a }, { INFO("n25q512a11", 0x20bb20, 0, 64 << 10, 1024, ER_4K) }, { INFO("n25q512a13", 0x20ba20, 0, 64 << 10, 1024, ER_4K) }, { INFO("n25q128", 0x20ba18, 0, 64 << 10, 256, 0) }, { INFO("n25q256a",0x20ba19, 0, 64 << 10, 512, - ER_4K | HAS_SR_BP3_BIT6 | HAS_SR_TB) }, -{ INFO("n25q512a",0x20ba20, 0, 64 << 10, 1024, ER_4K) }, + ER_4K | HAS_SR_BP3_BIT6 | HAS_SR_TB), + .sfdp_read = m25p80_sfdp_n25q256a }, + { INFO("n25q512a",0x20ba20, 0, 64 << 10, 1024, ER_4K) }, { INFO("n25q512ax3", 0x20ba20, 0x1000, 64 << 10, 1024, ER_4K) }, { INFO("mt25ql512ab", 0x20ba20, 0x1044, 64 << 10, 1024, ER_4K | ER_32K) }, { INFO_STACKED("mt35xu01g", 0x2c5b1b, 0x104100, 128 << 10, 1024, diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c new file mode 100644 index ..24ec05de79a1 --- /dev/null +++ b/hw/block/m25p80_sfdp.c @@ -0,0 +1,58 @@ +/* + * M25P80 Serial Flash Discoverable Parameter (SFDP) + * + * Copyright (c) 2020, IBM Corporation. + * + * This code is licensed under the GPL version 2 or later. See the + * COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/host-utils.h" +#include "m25p80_sfdp.h" + +#define define_sfdp_read(model) \ +uint8_t m25p80_sfdp_##model(uint32_t addr)\ +{ \ +assert(is_power_of_2(sizeof(sfdp_##model))); \ +return sfdp_##model[addr & (sizeof(sfdp_##model) - 1)]; \ +} + +/* + * Micron + */ +static const uint8_t sfdp_n25q256a[] = { +0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x00, 0xff, +0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x0f, +0x29, 0xeb, 0x27, 0x6b, 0x08, 0x3b, 0x27, 0xbb, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x27, 0xbb, +0xff, 0xff, 0x29, 0xeb, 0x0c, 0x20, 0x10, 0xd8, +0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +}; +define_sfdp_read(n25q256a); diff --git a/hw/block/meson.build b/hw/block/meson.build index 2389326112ae..3129ca4c52eb 100644 --- a/hw/block/meson.build
[PATCH v3 7/8] m25p80: Add the w25q512jv SFPD table
The SFDP table size is 0x100 bytes long. The mandatory table for basic features is available at byte 0x80 and two extra Winbond specifics table are available at 0xC0 and 0xF0. Signed-off-by: Cédric Le Goater --- hw/block/m25p80_sfdp.h | 1 + hw/block/m25p80.c | 3 ++- hw/block/m25p80_sfdp.c | 36 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h index f60429ab8542..62f140a2fcef 100644 --- a/hw/block/m25p80_sfdp.h +++ b/hw/block/m25p80_sfdp.h @@ -22,5 +22,6 @@ extern uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr); extern uint8_t m25p80_sfdp_mx66l1g45g(uint32_t addr); extern uint8_t m25p80_sfdp_w25q256(uint32_t addr); +extern uint8_t m25p80_sfdp_w25q512jv(uint32_t addr); #endif diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 220dbc8fb327..8ba9d732a323 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -347,7 +347,8 @@ static const FlashPartInfo known_devices[] = { { INFO("w25q80bl",0xef4014, 0, 64 << 10, 16, ER_4K) }, { INFO("w25q256", 0xef4019, 0, 64 << 10, 512, ER_4K), .sfdp_read = m25p80_sfdp_w25q256 }, -{ INFO("w25q512jv", 0xef4020, 0, 64 << 10, 1024, ER_4K) }, +{ INFO("w25q512jv", 0xef4020, 0, 64 << 10, 1024, ER_4K), + .sfdp_read = m25p80_sfdp_w25q512jv }, { INFO("w25q01jvq", 0xef4021, 0, 64 << 10, 2048, ER_4K) }, }; diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c index 5b011559d43d..dad3d7e64f9f 100644 --- a/hw/block/m25p80_sfdp.c +++ b/hw/block/m25p80_sfdp.c @@ -258,3 +258,39 @@ static const uint8_t sfdp_w25q256[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; define_sfdp_read(w25q256); + +static const uint8_t sfdp_w25q512jv[] = { +0x53, 0x46, 0x44, 0x50, 0x06, 0x01, 0x01, 0xff, +0x00, 0x06, 0x01, 0x10, 0x80, 0x00, 0x00, 0xff, +0x84, 0x00, 0x01, 0x02, 0xd0, 0x00, 0x00, 0xff, +0x03, 0x00, 0x01, 0x02, 0xf0, 0x00, 0x00, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x1f, +0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x42, 0xbb, +0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, +0xff, 0xff, 0x40, 0xeb, 0x0c, 0x20, 0x0f, 0x52, +0x10, 0xd8, 0x00, 0x00, 0x36, 0x02, 0xa6, 0x00, +0x82, 0xea, 0x14, 0xe2, 0xe9, 0x63, 0x76, 0x33, +0x7a, 0x75, 0x7a, 0x75, 0xf7, 0xa2, 0xd5, 0x5c, +0x19, 0xf7, 0x4d, 0xff, 0xe9, 0x70, 0xf9, 0xa5, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0x0a, 0xf0, 0xff, 0x21, 0xff, 0xdc, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +}; +define_sfdp_read(w25q512jv); -- 2.35.3
[PATCH v3 4/8] m25p80: Add the mx25l25635f SFPD table
The mx25l25635e and mx25l25635f chips have the same JEDEC id but the mx25l25635f has more capabilities reported in the SFDP table. Support for 4B opcodes is of interest because it is exploited by the Linux kernel. The SFDP table size is 0x200 bytes long. The mandatory table for basic features is available at byte 0x30 and an extra Macronix specific table is available at 0x60. Signed-off-by: Cédric Le Goater --- hw/block/m25p80_sfdp.h | 1 + hw/block/m25p80.c | 2 ++ hw/block/m25p80_sfdp.c | 68 ++ 3 files changed, 71 insertions(+) diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h index 0c46e669b335..87690a173c78 100644 --- a/hw/block/m25p80_sfdp.h +++ b/hw/block/m25p80_sfdp.h @@ -18,6 +18,7 @@ extern uint8_t m25p80_sfdp_n25q256a(uint32_t addr); extern uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr); +extern uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr); #endif diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 028b026d8ba2..6b120ce65212 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -234,6 +234,8 @@ static const FlashPartInfo known_devices[] = { { INFO("mx25l12855e", 0xc22618, 0, 64 << 10, 256, 0) }, { INFO6("mx25l25635e", 0xc22019, 0xc22019, 64 << 10, 512, 0), .sfdp_read = m25p80_sfdp_mx25l25635e }, +{ INFO6("mx25l25635f", 0xc22019, 0xc22019, 64 << 10, 512, 0), + .sfdp_read = m25p80_sfdp_mx25l25635f }, { INFO("mx25l25655e", 0xc22619, 0, 64 << 10, 512, 0) }, { INFO("mx66l51235f", 0xc2201a, 0, 64 << 10, 1024, ER_4K | ER_32K) }, { INFO("mx66u51235f", 0xc2253a, 0, 64 << 10, 1024, ER_4K | ER_32K) }, diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c index 6499c4c39954..70c13aea7c63 100644 --- a/hw/block/m25p80_sfdp.c +++ b/hw/block/m25p80_sfdp.c @@ -82,3 +82,71 @@ static const uint8_t sfdp_mx25l25635e[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; define_sfdp_read(mx25l25635e) + +static const uint8_t sfdp_mx25l25635f[] = { +0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x01, 0xff, +0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff, +0xc2, 0x00, 0x01, 0x04, 0x60, 0x00, 0x00, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xe5, 0x20, 0xf3, 0xff, 0xff, 0xff, 0xff, 0x0f, +0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x04, 0xbb, +0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, +0xff, 0xff, 0x44, 0xeb, 0x0c, 0x20, 0x0f, 0x52, +0x10, 0xd8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0x00, 0x36, 0x00, 0x27, 0x9d, 0xf9, 0xc0, 0x64, +0x85, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xc2, 0xf5, 0x08, 0x0a, +0x08, 0x04, 0x03, 0x06, 0x00, 0x00, 0x07, 0x29, +0x17, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0
[PATCH v3 3/8] m25p80: Add the mx25l25635e SFPD table
The SFDP table is 0x80 bytes long. The mandatory table for basic features is available at byte 0x30 and an extra Macronix specific table is available at 0x60. 4B opcodes are not supported. Signed-off-by: Cédric Le Goater --- hw/block/m25p80_sfdp.h | 3 +++ hw/block/m25p80.c | 3 ++- hw/block/m25p80_sfdp.c | 26 ++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h index d3a0a778ae84..0c46e669b335 100644 --- a/hw/block/m25p80_sfdp.h +++ b/hw/block/m25p80_sfdp.h @@ -17,4 +17,7 @@ extern uint8_t m25p80_sfdp_n25q256a(uint32_t addr); +extern uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr); + + #endif diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 13e7b28fd2b0..028b026d8ba2 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -232,7 +232,8 @@ static const FlashPartInfo known_devices[] = { { INFO("mx25l6405d", 0xc22017, 0, 64 << 10, 128, 0) }, { INFO("mx25l12805d", 0xc22018, 0, 64 << 10, 256, 0) }, { INFO("mx25l12855e", 0xc22618, 0, 64 << 10, 256, 0) }, -{ INFO6("mx25l25635e", 0xc22019, 0xc22019, 64 << 10, 512, 0) }, +{ INFO6("mx25l25635e", 0xc22019, 0xc22019, 64 << 10, 512, 0), + .sfdp_read = m25p80_sfdp_mx25l25635e }, { INFO("mx25l25655e", 0xc22619, 0, 64 << 10, 512, 0) }, { INFO("mx66l51235f", 0xc2201a, 0, 64 << 10, 1024, ER_4K | ER_32K) }, { INFO("mx66u51235f", 0xc2253a, 0, 64 << 10, 1024, ER_4K | ER_32K) }, diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c index 24ec05de79a1..6499c4c39954 100644 --- a/hw/block/m25p80_sfdp.c +++ b/hw/block/m25p80_sfdp.c @@ -56,3 +56,29 @@ static const uint8_t sfdp_n25q256a[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; define_sfdp_read(n25q256a); + + +/* + * Matronix + */ + +/* mx25l25635e. No 4B opcodes */ +static const uint8_t sfdp_mx25l25635e[] = { +0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x01, 0xff, +0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff, +0xc2, 0x00, 0x01, 0x04, 0x60, 0x00, 0x00, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xe5, 0x20, 0xf3, 0xff, 0xff, 0xff, 0xff, 0x0f, +0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x04, 0xbb, +0xee, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, +0xff, 0xff, 0x00, 0xff, 0x0c, 0x20, 0x0f, 0x52, +0x10, 0xd8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0x00, 0x36, 0x00, 0x27, 0xf7, 0x4f, 0xff, 0xff, +0xd9, 0xc8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +}; +define_sfdp_read(mx25l25635e) -- 2.35.3
[PATCH v3 1/8] m25p80: Add basic support for the SFDP command
JEDEC STANDARD JESD216 for Serial Flash Discovery Parameters (SFDP) provides a mean to describe the features of a serial flash device using a set of internal parameter tables. This is the initial framework for the RDSFDP command giving access to a private SFDP area under the flash. This area now needs to be populated with the flash device characteristics, using a new 'sfdp_read' handler under FlashPartInfo. Signed-off-by: Cédric Le Goater --- hw/block/m25p80_sfdp.h | 18 ++ hw/block/m25p80.c | 27 +++ MAINTAINERS| 2 +- hw/block/trace-events | 1 + 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 hw/block/m25p80_sfdp.h diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h new file mode 100644 index ..230b07ef3308 --- /dev/null +++ b/hw/block/m25p80_sfdp.h @@ -0,0 +1,18 @@ +/* + * M25P80 SFDP + * + * Copyright (c) 2020, IBM Corporation. + * + * This code is licensed under the GPL version 2 or later. See the + * COPYING file in the top-level directory. + */ + +#ifndef HW_M25P80_SFDP_H +#define HW_M25P80_SFDP_H + +/* + * SFDP area has a 3 bytes address space. + */ +#define M25P80_SFDP_MAX_SIZE (1 << 24) + +#endif diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index a8d2519141f7..abdc4c0b0da7 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -35,6 +35,7 @@ #include "qapi/error.h" #include "trace.h" #include "qom/object.h" +#include "m25p80_sfdp.h" /* 16 MiB max in 3 byte address mode */ #define MAX_3BYTES_SIZE 0x100 @@ -72,6 +73,7 @@ typedef struct FlashPartInfo { * This field inform how many die is in the chip. */ uint8_t die_cnt; +uint8_t (*sfdp_read)(uint32_t sfdp_addr); } FlashPartInfo; /* adapted from linux */ @@ -355,6 +357,7 @@ typedef enum { BULK_ERASE = 0xc7, READ_FSR = 0x70, RDCR = 0x15, +RDSFDP = 0x5a, READ = 0x03, READ4 = 0x13, @@ -421,6 +424,7 @@ typedef enum { STATE_COLLECTING_DATA, STATE_COLLECTING_VAR_LEN_DATA, STATE_READING_DATA, +STATE_READING_SFDP, } CMDState; typedef enum { @@ -679,6 +683,8 @@ static inline int get_addr_length(Flash *s) } switch (s->cmd_in_progress) { + case RDSFDP: + return 3; case PP4: case PP4_4: case QPP_4: @@ -823,6 +829,11 @@ static void complete_collecting_data(Flash *s) " by device\n"); } break; + +case RDSFDP: +s->state = STATE_READING_SFDP; +break; + default: break; } @@ -1431,6 +1442,16 @@ static void decode_new_cmd(Flash *s, uint32_t value) qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Unknown cmd %x\n", value); } break; +case RDSFDP: +if (s->pi->sfdp_read) { +s->needed_bytes = get_addr_length(s) + 1; /* SFDP addr + dummy */ +s->pos = 0; +s->len = 0; +s->state = STATE_COLLECTING_DATA; +break; +} +/* Fallthrough */ + default: s->pos = 0; s->len = 1; @@ -1538,6 +1559,12 @@ static uint32_t m25p80_transfer8(SSIPeripheral *ss, uint32_t tx) } } break; +case STATE_READING_SFDP: +assert(s->pi->sfdp_read); +r = s->pi->sfdp_read(s->cur_addr); +trace_m25p80_read_sfdp(s, s->cur_addr, (uint8_t)r); +s->cur_addr = (s->cur_addr + 1) & (M25P80_SFDP_MAX_SIZE - 1); +break; default: case STATE_IDLE: diff --git a/MAINTAINERS b/MAINTAINERS index 6af9cd985cea..92f232f01e3c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1915,7 +1915,7 @@ SSI M: Alistair Francis S: Maintained F: hw/ssi/* -F: hw/block/m25p80.c +F: hw/block/m25p80* F: include/hw/ssi/ssi.h X: hw/ssi/xilinx_* F: tests/qtest/m25p80-test.c diff --git a/hw/block/trace-events b/hw/block/trace-events index d86b53520cc5..2c45a62bd59c 100644 --- a/hw/block/trace-events +++ b/hw/block/trace-events @@ -80,5 +80,6 @@ m25p80_page_program(void *s, uint32_t addr, uint8_t tx) "[%p] page program cur_a m25p80_transfer(void *s, uint8_t state, uint32_t len, uint8_t needed, uint32_t pos, uint32_t cur_addr, uint8_t t) "[%p] Transfer state 0x%"PRIx8" len 0x%"PRIx32" needed 0x%"PRIx8" pos 0x%"PRIx32" addr 0x%"PRIx32" tx 0x%"PRIx8 m25p80_read_byte(void *s, uint32_t addr, uint8_t v) "[%p] Read byte 0x%"PRIx32"=0x%"PRIx8 m25p80_read_data(void *s, uint32_t pos, uint8_t v) "[%p] Read data 0x%"PRIx32"=0x%"PRIx8 +m25p80_read_sfdp(void *s, uint32_t addr, uint8_t v) "[%p] Read SFDP 0x%"PRIx32"=0x%"PRIx8 m25p80_binding(void *s) "[%p] Binding to IF_MTD drive" m25p80_binding_no_bdrv(void *s) "[%p] No BDRV - binding to RAM" -- 2.35.3
[PATCH v3 0/8] m25p80: Add SFDP support
Hello, This is a refresh of a patchset sent long ago [1] adding support for JEDEC STANDARD JESD216 Serial Flash Discovery Parameters (SFDP). SFDP describes the features of a serial flash device using a set of internal parameter tables. Support in Linux has been added some time ago and the spi-nor driver is using it more often to detect the flash settings and even flash models. Francisco and I are not entirely satisfied with the way the tables are defined. We add some private discussion on how to resolve that but neither of us had the time to pursue the study. Latest Francisco proposal was : #define define_sfdp_read_wrap(model, wrap_sz)\ uint8_t m25p80_sdfp_read_##model(SFDPTable t, uint32_t addr) \ {\ return m25p80_sdfp_read(t, addr & (wrap_sz-1)); \ } ... define_sfdp_read_wrap(mt25ql512ab, SZ_256) A new variable in the section would solve it aswell but not convinced at the moment if it is clear enough: typedef struct SFDPSection { const uint32_t addr; const uint32_t size; const uint32_t wrap_sz; const uint8_t *data; } SFDPSection; #define SFDP_RAW(start_addr, vals...) \ { \ .addr = start_addr, \ .size = sizeof((uint8_t[]){vals}), \ .data = (const uint8_t[]){vals} \ } #define SFDP_RAW_WRAP(start_addr, _wrap_sz, vals...) \ { \ .addr = start_addr, \ .size = sizeof((uint8_t[]){vals}), \ .wrap_sz = _wrap_sz,\ .data = (const uint8_t[]){vals} \ } #define SFDP_TABLE_END() { 0 } #define IS_SFDP_END(x) (x.size == 0) #define M35T4545_WRAP_SZ 0x100 static const SFDPTable m35t4545 = { SFDP_RAW_WRAP(0, M35T4545_WRAP_SZ, 0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x00, 0xff, 0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff), SFDP_RAW(0x38, 0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x29, 0xeb, 0x27, 0x6b, 0x08, 0x3b, 0x27, 0xbb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x27, 0xbb, 0xff, 0xff, 0x29, 0xeb, 0x0c, 0x20, 0x10, 0xd8, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff), SFDP_TABLE_END() }; uint8_t m25p80_sfdp_read(SFDPTable t, uint32_t addr) { if (t[0].wrap_sz) { addr &= (t.wrap_sz-1); } for (int i = 0; !IS_SFDP_END(t[i]); i++) { if (addr >= t[i].addr && addr < (t[i].addr + t[i].size)) { return t[i].data[addr]; } } return 0xFF; } Since there is a need, we have been using these patches in OpenBMC for some time now and other projects/companies have requested it, I am resending the patchset as it is to restart the discussion. Thanks, C. Cédric Le Goater (8): m25p80: Add basic support for the SFDP command m25p80: Add the n25q256a SFDP table m25p80: Add the mx25l25635e SFPD table m25p80: Add the mx25l25635f SFPD table m25p80: Add the mx66l1g45g SFDP table m25p80: Add the w25q256 SFPD table m25p80: Add the w25q512jv SFPD table arm/aspeed: Replace mx25l25635e chip model hw/block/m25p80_sfdp.h | 27 hw/arm/aspeed.c| 6 +- hw/block/m25p80.c | 49 ++- hw/block/m25p80_sfdp.c | 296 + MAINTAINERS| 2 +- hw/block/meson.build | 1 + hw/block/trace-events | 1 + 7 files changed, 371 insertions(+), 11 deletions(-) create mode 100644 hw/block/m25p80_sfdp.h create mode 100644 hw/block/m25p80_sfdp.c -- 2.35.3
[PATCH qemu] hw/block/m25p80: correct dummy bytes for GD flash
From: Martin Johnson Gigadevice flash chips supported in m25p80.c (GD25Q32, GD25Q64) require a dummy bytes in DIO and QIO modes, similar to Winbond W25Q32 and W25Q64. This patch fixes this behavior. Signed-off-by: Ivan Grokhotkov Signed-off-by: Martin Johnson --- This patch was submitted into our fork at https://github.com/espressif/qemu/pull/18. The patch seems applicable to the upstream project, so I am submitting it on behalf of the author. hw/block/m25p80.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index a8d2519141..72a209b031 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -168,6 +168,7 @@ typedef struct FlashPartInfo { #define SPANSION_CONTINUOUS_READ_MODE_CMD_LEN 1 #define WINBOND_CONTINUOUS_READ_MODE_CMD_LEN 1 +#define GIGADEVICE_CONTINUOUS_READ_MODE_CMD_LEN 1 static const FlashPartInfo known_devices[] = { /* Atmel -- some are (confusingly) marketed as "DataFlash" */ @@ -430,6 +431,7 @@ typedef enum { MAN_WINBOND, MAN_SST, MAN_ISSI, +MAN_GIGADEVICE, MAN_GENERIC, } Manufacturer; @@ -514,6 +516,8 @@ static inline Manufacturer get_man(Flash *s) return MAN_SST; case 0x9D: return MAN_ISSI; +case 0xC8: +return MAN_GIGADEVICE; default: return MAN_GENERIC; } @@ -992,6 +996,9 @@ static void decode_dio_read_cmd(Flash *s) case MAN_WINBOND: s->needed_bytes += WINBOND_CONTINUOUS_READ_MODE_CMD_LEN; break; +case MAN_GIGADEVICE: +s->needed_bytes += GIGADEVICE_CONTINUOUS_READ_MODE_CMD_LEN; +break; case MAN_SPANSION: s->needed_bytes += SPANSION_CONTINUOUS_READ_MODE_CMD_LEN; s->needed_bytes += extract32(s->spansion_cr2v, @@ -1042,6 +1049,10 @@ static void decode_qio_read_cmd(Flash *s) s->needed_bytes += WINBOND_CONTINUOUS_READ_MODE_CMD_LEN; s->needed_bytes += 4; break; +case MAN_GIGADEVICE: +s->needed_bytes += GIGADEVICE_CONTINUOUS_READ_MODE_CMD_LEN; +s->needed_bytes += 4; +break; case MAN_SPANSION: s->needed_bytes += SPANSION_CONTINUOUS_READ_MODE_CMD_LEN; s->needed_bytes += extract32(s->spansion_cr2v, -- 2.34.2
Re: [PATCH v2 08/10] iotests/264: add mirror-cancel test-case
On 7/21/22 11:50, Thomas Huth wrote: On 05/02/2021 17.37, Vladimir Sementsov-Ogievskiy wrote: Check that cancel doesn't wait for 10s of nbd reconnect timeout. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- tests/qemu-iotests/264 | 38 ++ tests/qemu-iotests/264.out | 4 ++-- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/tests/qemu-iotests/264 b/tests/qemu-iotests/264 index 6feeaa4056..347e53add5 100755 --- a/tests/qemu-iotests/264 +++ b/tests/qemu-iotests/264 @@ -27,25 +27,26 @@ from iotests import qemu_img_create, file_path, qemu_nbd_popen disk_a, disk_b, nbd_sock = file_path('disk_a', 'disk_b', 'nbd-sock') nbd_uri = 'nbd+unix:///?socket=' + nbd_sock -size = 5 * 1024 * 1024 wait_limit = 3.0 wait_step = 0.2 class TestNbdReconnect(iotests.QMPTestCase): - def setUp(self): - qemu_img_create('-f', iotests.imgfmt, disk_a, str(size)) - qemu_img_create('-f', iotests.imgfmt, disk_b, str(size)) + def init_vm(self, disk_size): + qemu_img_create('-f', iotests.imgfmt, disk_a, str(disk_size)) + qemu_img_create('-f', iotests.imgfmt, disk_b, str(disk_size)) self.vm = iotests.VM().add_drive(disk_a) self.vm.launch() - self.vm.hmp_qemu_io('drive0', 'write 0 {}'.format(size)) + self.vm.hmp_qemu_io('drive0', 'write 0 {}'.format(disk_size)) def tearDown(self): self.vm.shutdown() os.remove(disk_a) os.remove(disk_b) - def test(self): + def start_job(self, job): + """Stat job with nbd target and kill the server""" + assert job in ('blockdev-backup', 'blockdev-mirror') with qemu_nbd_popen('-k', nbd_sock, '-f', iotests.imgfmt, disk_b): result = self.vm.qmp('blockdev-add', **{'node_name': 'backup0', @@ -55,7 +56,7 @@ class TestNbdReconnect(iotests.QMPTestCase): 'path': nbd_sock}, 'reconnect-delay': 10}}) self.assert_qmp(result, 'return', {}) - result = self.vm.qmp('blockdev-backup', device='drive0', + result = self.vm.qmp(job, device='drive0', sync='full', target='backup0', speed=(1 * 1024 * 1024)) self.assert_qmp(result, 'return', {}) @@ -73,7 +74,8 @@ class TestNbdReconnect(iotests.QMPTestCase): jobs = self.vm.qmp('query-block-jobs')['return'] # Check that job is still in progress - self.assertTrue(jobs and jobs[0]['offset'] < jobs[0]['len']) + self.assertTrue(jobs) + self.assertTrue(jobs[0]['offset'] < jobs[0]['len']) result = self.vm.qmp('block-job-set-speed', device='drive0', speed=0) self.assert_qmp(result, 'return', {}) @@ -81,12 +83,32 @@ class TestNbdReconnect(iotests.QMPTestCase): # Emulate server down time for 1 second time.sleep(1) + def test_backup(self): + size = 5 * 1024 * 1024 + self.init_vm(size) + self.start_job('blockdev-backup') + with qemu_nbd_popen('-k', nbd_sock, '-f', iotests.imgfmt, disk_b): e = self.vm.event_wait('BLOCK_JOB_COMPLETED') self.assertEqual(e['data']['offset'], size) result = self.vm.qmp('blockdev-del', node_name='backup0') self.assert_qmp(result, 'return', {}) + def test_mirror_cancel(self): + # Mirror speed limit doesn't work well enough, it seems that mirror + # will run many parallel requests anyway. MAX_IN_FLIGHT is 16 and + # MAX_IO_BYTES is 1M in mirror.c, so let's use 20M disk. + self.init_vm(20 * 1024 * 1024) + self.start_job('blockdev-mirror') + + result = self.vm.qmp('block-job-cancel', device='drive0') + self.assert_qmp(result, 'return', {}) + + start_t = time.time() + self.vm.event_wait('BLOCK_JOB_CANCELLED') + delta_t = time.time() - start_t + self.assertTrue(delta_t < 2.0) Hi! For what it's worth, I've just run into this assert while running "make check -j8 SPEED=slow": --- /home/thuth/devel/qemu/tests/qemu-iotests/264.out +++ /home/thuth/tmp/qemu-build/tests/qemu-iotests/scratch/264/264.out.bad @@ -1,5 +1,15 @@ -... +..F +== +FAIL: test_mirror_cancel (__main__.TestNbdReconnect) +-- +Traceback (most recent call last): + File "/home/thuth/devel/qemu/tests/qemu-iotests/264", line 112, in test_mirror_cancel + self.cancel_job() + File "/home/thuth/devel/qemu/tests/qemu-iotests/264", line 104, in cancel_job + self.assertTrue(delta_t < 2.0) +AssertionError: False is not true + -- Ran 3 tests -OK +FAILED (failures=1)
Re: [PATCH 2/2] migration: Define BLK_MIG_BLOCK_SIZE as unsigned long long
* Peter Maydell (peter.mayd...@linaro.org) wrote: > On Thu, 21 Jul 2022 at 13:07, Dr. David Alan Gilbert > wrote: > > > > * Peter Maydell (peter.mayd...@linaro.org) wrote: > > > When we use BLK_MIG_BLOCK_SIZE in expressions like > > > block_mig_state.submitted * BLK_MIG_BLOCK_SIZE, this multiplication > > > is done as 32 bits, because both operands are 32 bits. Coverity > > > complains about possible overflows because we then accumulate that > > > into a 64 bit variable. > > > > > > Define BLK_MIG_BLOCK_SIZE as unsigned long long using the ULL suffix. > > > The only two current uses of it with this problem are both in > > > block_save_pending(), so we could just cast to uint64_t there, but > > > using the ULL suffix is simpler and ensures that we don't > > > accidentally introduce new variants of the same issue in future. > > > > > > Resolves: Coverity CID 1487136, 1487175 > > > Signed-off-by: Peter Maydell > > > --- > > > I haven't tried to analyse the code to see if the multiplications > > > could ever actually end up overflowing, but I would assume > > > probably not. > > > > > > migration/block.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/migration/block.c b/migration/block.c > > > index 9e5aae58982..3577c815a94 100644 > > > --- a/migration/block.c > > > +++ b/migration/block.c > > > @@ -28,7 +28,7 @@ > > > #include "sysemu/block-backend.h" > > > #include "trace.h" > > > > > > -#define BLK_MIG_BLOCK_SIZE (1 << 20) > > > +#define BLK_MIG_BLOCK_SIZE (1ULL << 20) > > > > Is it a problem that this is passed to bdrv_create_dirty_bitmap that > > takes a uint32_t ? > > Shouldn't be -- the constant value still fits within 32 bits. Hmm OK, lets keep an eye out for build problems on any odd combos Reviewed-by: Dr. David Alan Gilbert > -- PMM > -- Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK
Re: [PATCH 2/2] migration: Define BLK_MIG_BLOCK_SIZE as unsigned long long
On Thu, 21 Jul 2022 at 13:07, Dr. David Alan Gilbert wrote: > > * Peter Maydell (peter.mayd...@linaro.org) wrote: > > When we use BLK_MIG_BLOCK_SIZE in expressions like > > block_mig_state.submitted * BLK_MIG_BLOCK_SIZE, this multiplication > > is done as 32 bits, because both operands are 32 bits. Coverity > > complains about possible overflows because we then accumulate that > > into a 64 bit variable. > > > > Define BLK_MIG_BLOCK_SIZE as unsigned long long using the ULL suffix. > > The only two current uses of it with this problem are both in > > block_save_pending(), so we could just cast to uint64_t there, but > > using the ULL suffix is simpler and ensures that we don't > > accidentally introduce new variants of the same issue in future. > > > > Resolves: Coverity CID 1487136, 1487175 > > Signed-off-by: Peter Maydell > > --- > > I haven't tried to analyse the code to see if the multiplications > > could ever actually end up overflowing, but I would assume > > probably not. > > > > migration/block.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/migration/block.c b/migration/block.c > > index 9e5aae58982..3577c815a94 100644 > > --- a/migration/block.c > > +++ b/migration/block.c > > @@ -28,7 +28,7 @@ > > #include "sysemu/block-backend.h" > > #include "trace.h" > > > > -#define BLK_MIG_BLOCK_SIZE (1 << 20) > > +#define BLK_MIG_BLOCK_SIZE (1ULL << 20) > > Is it a problem that this is passed to bdrv_create_dirty_bitmap that > takes a uint32_t ? Shouldn't be -- the constant value still fits within 32 bits. -- PMM
Re: [PATCH 2/2] migration: Define BLK_MIG_BLOCK_SIZE as unsigned long long
* Peter Maydell (peter.mayd...@linaro.org) wrote: > When we use BLK_MIG_BLOCK_SIZE in expressions like > block_mig_state.submitted * BLK_MIG_BLOCK_SIZE, this multiplication > is done as 32 bits, because both operands are 32 bits. Coverity > complains about possible overflows because we then accumulate that > into a 64 bit variable. > > Define BLK_MIG_BLOCK_SIZE as unsigned long long using the ULL suffix. > The only two current uses of it with this problem are both in > block_save_pending(), so we could just cast to uint64_t there, but > using the ULL suffix is simpler and ensures that we don't > accidentally introduce new variants of the same issue in future. > > Resolves: Coverity CID 1487136, 1487175 > Signed-off-by: Peter Maydell > --- > I haven't tried to analyse the code to see if the multiplications > could ever actually end up overflowing, but I would assume > probably not. > > migration/block.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/migration/block.c b/migration/block.c > index 9e5aae58982..3577c815a94 100644 > --- a/migration/block.c > +++ b/migration/block.c > @@ -28,7 +28,7 @@ > #include "sysemu/block-backend.h" > #include "trace.h" > > -#define BLK_MIG_BLOCK_SIZE (1 << 20) > +#define BLK_MIG_BLOCK_SIZE (1ULL << 20) Is it a problem that this is passed to bdrv_create_dirty_bitmap that takes a uint32_t ? Dave > #define BDRV_SECTORS_PER_DIRTY_CHUNK (BLK_MIG_BLOCK_SIZE >> BDRV_SECTOR_BITS) > > #define BLK_MIG_FLAG_DEVICE_BLOCK 0x01 > -- > 2.25.1 > -- Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK
Re: [PATCH 1/2] migration: Assert that migrate_multifd_compression() returns an in-range value
* Peter Maydell (peter.mayd...@linaro.org) wrote: > Coverity complains that when we use the return value from > migrate_multifd_compression() as an array index: > multifd_recv_state->ops = multifd_ops[migrate_multifd_compression()]; > > that this might overrun the array (which is declared to have size > MULTIFD_COMPRESSION__MAX). This is because the function return type > is MultiFDCompression, which is an autogenerated enum. The code > generator includes the "one greater than the maximum possible value" > MULTIFD_COMPRESSION__MAX in the enum, even though this is not > actually a valid value for the enum, and this makes Coverity think > that migrate_multifd_compression() could return that __MAX value and > index off the end of the array. > > Suppress the Coverity error by asserting that the value we're going > to return is within range. > > Resolves: Coverity CID 1487239, 1487254 > Signed-off-by: Peter Maydell Reviewed-by: Dr. David Alan Gilbert > --- > migration/migration.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/migration/migration.c b/migration/migration.c > index e03f698a3ca..befd4c58a69 100644 > --- a/migration/migration.c > +++ b/migration/migration.c > @@ -2617,6 +2617,7 @@ MultiFDCompression migrate_multifd_compression(void) > > s = migrate_get_current(); > > +assert(s->parameters.multifd_compression < MULTIFD_COMPRESSION__MAX); > return s->parameters.multifd_compression; > } > > -- > 2.25.1 > -- Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK
[PATCH 0/2] migration: fix coverity nits
This patchset fixes four Coverity nits in the migration code. The first patch is just adding an assert() to clue coverity in that an array index must be in-bounds. The second adds an ULL suffix to force a multiplication to be done at 64 bits. thanks -- PMM Peter Maydell (2): migration: Assert that migrate_multifd_compression() returns an in-range value migration: Define BLK_MIG_BLOCK_SIZE as unsigned long long migration/block.c | 2 +- migration/migration.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) -- 2.25.1
[PATCH 1/2] migration: Assert that migrate_multifd_compression() returns an in-range value
Coverity complains that when we use the return value from migrate_multifd_compression() as an array index: multifd_recv_state->ops = multifd_ops[migrate_multifd_compression()]; that this might overrun the array (which is declared to have size MULTIFD_COMPRESSION__MAX). This is because the function return type is MultiFDCompression, which is an autogenerated enum. The code generator includes the "one greater than the maximum possible value" MULTIFD_COMPRESSION__MAX in the enum, even though this is not actually a valid value for the enum, and this makes Coverity think that migrate_multifd_compression() could return that __MAX value and index off the end of the array. Suppress the Coverity error by asserting that the value we're going to return is within range. Resolves: Coverity CID 1487239, 1487254 Signed-off-by: Peter Maydell --- migration/migration.c | 1 + 1 file changed, 1 insertion(+) diff --git a/migration/migration.c b/migration/migration.c index e03f698a3ca..befd4c58a69 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2617,6 +2617,7 @@ MultiFDCompression migrate_multifd_compression(void) s = migrate_get_current(); +assert(s->parameters.multifd_compression < MULTIFD_COMPRESSION__MAX); return s->parameters.multifd_compression; } -- 2.25.1
[PATCH 2/2] migration: Define BLK_MIG_BLOCK_SIZE as unsigned long long
When we use BLK_MIG_BLOCK_SIZE in expressions like block_mig_state.submitted * BLK_MIG_BLOCK_SIZE, this multiplication is done as 32 bits, because both operands are 32 bits. Coverity complains about possible overflows because we then accumulate that into a 64 bit variable. Define BLK_MIG_BLOCK_SIZE as unsigned long long using the ULL suffix. The only two current uses of it with this problem are both in block_save_pending(), so we could just cast to uint64_t there, but using the ULL suffix is simpler and ensures that we don't accidentally introduce new variants of the same issue in future. Resolves: Coverity CID 1487136, 1487175 Signed-off-by: Peter Maydell --- I haven't tried to analyse the code to see if the multiplications could ever actually end up overflowing, but I would assume probably not. migration/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/block.c b/migration/block.c index 9e5aae58982..3577c815a94 100644 --- a/migration/block.c +++ b/migration/block.c @@ -28,7 +28,7 @@ #include "sysemu/block-backend.h" #include "trace.h" -#define BLK_MIG_BLOCK_SIZE (1 << 20) +#define BLK_MIG_BLOCK_SIZE (1ULL << 20) #define BDRV_SECTORS_PER_DIRTY_CHUNK (BLK_MIG_BLOCK_SIZE >> BDRV_SECTOR_BITS) #define BLK_MIG_FLAG_DEVICE_BLOCK 0x01 -- 2.25.1
Re: [PULL 06/18] vfio-user: build library
Hi Jay / Stefan, We've got a non-determinsitic hang in QEMU CI since this series merged, which we tracked down to a libvfio-user test that is flakey: https://gitlab.com/qemu-project/qemu/-/issues/1114 John Levon has proposed a PR to libvfio-user to turn off the test, but we'll need one of you to update the git submodule for libvfio-user on the QEMU side, as I can't find a nice way to selectively skip the test from QEMU side alone. With regards Daniel On Wed, Jun 15, 2022 at 04:51:17PM +0100, Stefan Hajnoczi wrote: > From: Jagannathan Raman > > add the libvfio-user library as a submodule. build it as a meson > subproject. > > libvfio-user is distributed with BSD 3-Clause license and > json-c with MIT (Expat) license > > Signed-off-by: Elena Ufimtseva > Signed-off-by: John G Johnson > Signed-off-by: Jagannathan Raman > Reviewed-by: Stefan Hajnoczi > Message-id: > c2adec87958b081d1dc8775d4aa05c897912f025.1655151679.git.jag.ra...@oracle.com > > [Changed submodule URL to QEMU's libvfio-user mirror on GitLab. The QEMU > project mirrors its dependencies so that it can provide full source code > even in the event that its dependencies become unavailable. Note that > the mirror repo is manually updated, so please contact me to make newer > libvfio-user commits available. If I become a bottleneck we can set up a > cronjob. > > Updated scripts/meson-buildoptions.sh to match the meson_options.txt > change. Failure to do so can result in scripts/meson-buildoptions.sh > being modified by the build system later on and you end up with a dirty > working tree. > --Stefan] > > Signed-off-by: Stefan Hajnoczi > --- > MAINTAINERS | 1 + > meson_options.txt | 2 ++ > configure | 17 + > meson.build | 23 ++- > .gitlab-ci.d/buildtest.yml | 1 + > .gitmodules | 3 +++ > Kconfig.host| 4 > hw/remote/Kconfig | 4 > hw/remote/meson.build | 2 ++ > scripts/meson-buildoptions.sh | 4 > subprojects/libvfio-user| 1 + > tests/docker/dockerfiles/centos8.docker | 2 ++ > 12 files changed, 63 insertions(+), 1 deletion(-) > create mode 16 subprojects/libvfio-user > > diff --git a/MAINTAINERS b/MAINTAINERS > index 5ba93348aa..d0fcaf0edb 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -3642,6 +3642,7 @@ F: hw/remote/proxy-memory-listener.c > F: include/hw/remote/proxy-memory-listener.h > F: hw/remote/iohub.c > F: include/hw/remote/iohub.h > +F: subprojects/libvfio-user > > EBPF: > M: Jason Wang > diff --git a/meson_options.txt b/meson_options.txt > index 0e8197386b..f3e2f22c1e 100644 > --- a/meson_options.txt > +++ b/meson_options.txt > @@ -88,6 +88,8 @@ option('cfi_debug', type: 'boolean', value: 'false', > description: 'Verbose errors in case of CFI violation') > option('multiprocess', type: 'feature', value: 'auto', > description: 'Out of process device emulation support') > +option('vfio_user_server', type: 'feature', value: 'disabled', > + description: 'vfio-user server support') > option('dbus_display', type: 'feature', value: 'auto', > description: '-display dbus support') > option('tpm', type : 'feature', value : 'auto', > diff --git a/configure b/configure > index 4b12a8094c..c14e7f590a 100755 > --- a/configure > +++ b/configure > @@ -315,6 +315,7 @@ meson_args="" > ninja="" > bindir="bin" > skip_meson=no > +vfio_user_server="disabled" > > # The following Meson options are handled manually (still they > # are included in the automatically generated help message) > @@ -909,6 +910,10 @@ for opt do >;; >--disable-blobs) meson_option_parse --disable-install-blobs "" >;; > + --enable-vfio-user-server) vfio_user_server="enabled" > + ;; > + --disable-vfio-user-server) vfio_user_server="disabled" > + ;; >--enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc >;; >--enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc > @@ -2132,6 +2137,17 @@ write_container_target_makefile() { > > > > +## > +# check for vfio_user_server > + > +case "$vfio_user_server" in > + enabled ) > +if test "$git_submodules_action" != "ignore"; then > + git_submodules="${git_submodules} subprojects/libvfio-user" > +fi > +;; > +esac > + > ## > # End of CC checks > # After here, no more $cc or $ld runs > @@ -2672,6 +2688,7 @@ if test "$skip_meson" = no; then >test "$slirp" != auto && meson_option_add "-Dslirp=$slirp" >test "$smbd" != '' && meson_option_add "-Dsmbd=$smbd" >test "$tcg" != enabled && meson_option_add "-Dtcg=$tcg" > + test "$vfio_user_server" != auto && meson_option_add > "-Dvfio_user_server=$vfio_user_se
Re: Failure in iotest 183
On 05/07/2022 12.20, Thomas Huth wrote: On 05/07/2022 11.58, Hanna Reitz wrote: On 05.07.22 11:35, Thomas Huth wrote: Hi! I've just hit a failure in iotest 183: --- /home/thuth/devel/qemu/tests/qemu-iotests/183.out +++ /home/thuth/tmp/qemu-build/tests/qemu-iotests/scratch/183/183.out.bad @@ -30,7 +30,7 @@ 'arguments': { 'uri': 'unix:SOCK_DIR/migrate', 'blk': true } } {"return": {}} { 'execute': 'query-status' } -{"return": {"status": "postmigrate", "singlestep": false, "running": false}} +{"return": {"status": "completed", "setup-time": 0, "downtime": 2448, "total-time": 2872, "ram": {"total": 134750208, "postcopy-requests": 0, "dirty-sync-count": 3, "multifd-bytes": 0, "pages-per-second": 0, "downtime-bytes": 0, "page-size": 4096, "remaining": 0, "postcopy-bytes": 0, "mbps": 188.63209192200557, "transferred": 496829, "precopy-bytes": 496829, "duplicate": 32849, "dirty-pages-rate": 0, "skipped": 0, "normal-bytes": 200704, "normal": 49}}} Weird because query-status cannot return something with '"status": "completed"' in it. We can see the '"status": "postmigrate"' object somewhere below, so it seems to me like the silent=yes part for the query-migrate execution didn’t work as intended. (And it does seem to work below, when waiting for a “100 %” to appear on $dest.) It’s been a while since we’ve touched common.qemu, so nothing comes to my mind immediately that might have broken this. ... I’ve never hit this so far. The only things to try I can come up with would be to bisect, or to try adding `silent=$silent` to the `_timed_wait_for` calls in `send_qemu_cmd`... Seems also like it does not reproduce that easily, though - I've just seen it once so far while running "make -j6 check SPEED=slow", so lots of other stuff was happening at the same time. I'll keep an eye on it to see whether I can reproduce it more easily somehow. I just reproduced it by running "./check -raw -j8" directly: --- /home/thuth/devel/qemu/tests/qemu-iotests/183.out +++ /home/thuth/tmp/qemu-build/tests/qemu-iotests/scratch/183/183.out.bad @@ -30,7 +30,7 @@ 'arguments': { 'uri': 'unix:SOCK_DIR/migrate', 'blk': true } } {"return": {}} { 'execute': 'query-status' } -{"return": {"status": "postmigrate", "singlestep": false, "running": false}} +{"return": {"status": "completed", "setup-time": 0, "downtime": 1003, "total-time": 1537, "ram": {"total": 134750208, "postcopy-requests": 0, "dirty-sync-count": 3, "multifd-bytes": 0, "pages-per-second": 288578, "downtime-bytes": 0, "page-size": 4096, "remaining": 0, "postcopy-bytes": 0, "mbps": 352.48204554326611, "transferred": 497205, "precopy-bytes": 497205, "duplicate": 32849, "dirty-pages-rate": 0, "skipped": 0, "normal-bytes": 200704, "normal": 49}}} === Do some I/O on the destination === @@ -53,8 +53,16 @@ === Shut down and check image === {"execute":"quit"} +{"return": {"status": "completed", "setup-time": 0, "downtime": 1003, "total-time": 1537, "ram": {"total": 134750208, "postcopy-requests": 0, "dirty-sync-count": 3, "multifd-bytes": 0, "pages-per-second": 288578, "downtime-bytes": 0, "page-size": 4096, "remaining": 0, "postcopy-bytes": 0, "mbps": 352.48204554326611, "transferred": 497205, "precopy-bytes": 497205, "duplicate": 32849, "dirty-pages-rate": 0, "skipped": 0, "normal-bytes": 200704, "normal": 49}}} +{"execute":"quit"} {"return": {}} -{"execute":"quit"} +{"return": {"status": "completed", "setup-time": 0, "downtime": 1003, "total-time": 1537, "ram": {"total": 134750208, "postcopy-requests": 0, "dirty-sync-count": 3, "multifd-bytes": 0, "pages-per-second": 288578, "downtime-bytes": 0, "page-size": 4096, "remaining": 0, "postcopy-bytes": 0, "mbps": 352.48204554326611, "transferred": 497205, "precopy-bytes": 497205, "duplicate": 32849, "dirty-pages-rate": 0, "skipped": 0, "normal-bytes": 200704, "normal": 49}}} +{"return": {"status": "completed", "setup-time": 0, "downtime": 1003, "total-time": 1537, "ram": {"total": 134750208, "postcopy-requests": 0, "dirty-sync-count": 3, "multifd-bytes": 0, "pages-per-second": 288578, "downtime-bytes": 0, "page-size": 4096, "remaining": 0, "postcopy-bytes": 0, "mbps": 352.48204554326611, "transferred": 497205, "precopy-bytes": 497205, "duplicate": 32849, "dirty-pages-rate": 0, "skipped": 0, "normal-bytes": 200704, "normal": 49}}} +{"return": {"status": "completed", "setup-time": 0, "downtime": 1003, "total-time": 1537, "ram": {"total": 134750208, "postcopy-requests": 0, "dirty-sync-count": 3, "multifd-bytes": 0, "pages-per-second": 288578, "downtime-bytes": 0, "page-size": 4096, "remaining": 0, "postcopy-bytes": 0, "mbps": 352.48204554326611, "transferred": 497205, "precopy-bytes": 497205, "duplicate": 32849, "dirty-pages-rate": 0, "skipped": 0, "normal-bytes": 200704, "normal": 49}}} +{"return": {"status": "completed", "setup-time": 0, "downtime": 1003, "total-time": 1537, "ram": {"total": 134750208, "postcopy-requests": 0, "dirty-sync-count": 3, "m
Re: [PATCH v2 08/10] iotests/264: add mirror-cancel test-case
On 05/02/2021 17.37, Vladimir Sementsov-Ogievskiy wrote: Check that cancel doesn't wait for 10s of nbd reconnect timeout. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- tests/qemu-iotests/264 | 38 ++ tests/qemu-iotests/264.out | 4 ++-- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/tests/qemu-iotests/264 b/tests/qemu-iotests/264 index 6feeaa4056..347e53add5 100755 --- a/tests/qemu-iotests/264 +++ b/tests/qemu-iotests/264 @@ -27,25 +27,26 @@ from iotests import qemu_img_create, file_path, qemu_nbd_popen disk_a, disk_b, nbd_sock = file_path('disk_a', 'disk_b', 'nbd-sock') nbd_uri = 'nbd+unix:///?socket=' + nbd_sock -size = 5 * 1024 * 1024 wait_limit = 3.0 wait_step = 0.2 class TestNbdReconnect(iotests.QMPTestCase): -def setUp(self): -qemu_img_create('-f', iotests.imgfmt, disk_a, str(size)) -qemu_img_create('-f', iotests.imgfmt, disk_b, str(size)) +def init_vm(self, disk_size): +qemu_img_create('-f', iotests.imgfmt, disk_a, str(disk_size)) +qemu_img_create('-f', iotests.imgfmt, disk_b, str(disk_size)) self.vm = iotests.VM().add_drive(disk_a) self.vm.launch() -self.vm.hmp_qemu_io('drive0', 'write 0 {}'.format(size)) +self.vm.hmp_qemu_io('drive0', 'write 0 {}'.format(disk_size)) def tearDown(self): self.vm.shutdown() os.remove(disk_a) os.remove(disk_b) -def test(self): +def start_job(self, job): +"""Stat job with nbd target and kill the server""" +assert job in ('blockdev-backup', 'blockdev-mirror') with qemu_nbd_popen('-k', nbd_sock, '-f', iotests.imgfmt, disk_b): result = self.vm.qmp('blockdev-add', **{'node_name': 'backup0', @@ -55,7 +56,7 @@ class TestNbdReconnect(iotests.QMPTestCase): 'path': nbd_sock}, 'reconnect-delay': 10}}) self.assert_qmp(result, 'return', {}) -result = self.vm.qmp('blockdev-backup', device='drive0', +result = self.vm.qmp(job, device='drive0', sync='full', target='backup0', speed=(1 * 1024 * 1024)) self.assert_qmp(result, 'return', {}) @@ -73,7 +74,8 @@ class TestNbdReconnect(iotests.QMPTestCase): jobs = self.vm.qmp('query-block-jobs')['return'] # Check that job is still in progress -self.assertTrue(jobs and jobs[0]['offset'] < jobs[0]['len']) +self.assertTrue(jobs) +self.assertTrue(jobs[0]['offset'] < jobs[0]['len']) result = self.vm.qmp('block-job-set-speed', device='drive0', speed=0) self.assert_qmp(result, 'return', {}) @@ -81,12 +83,32 @@ class TestNbdReconnect(iotests.QMPTestCase): # Emulate server down time for 1 second time.sleep(1) +def test_backup(self): +size = 5 * 1024 * 1024 +self.init_vm(size) +self.start_job('blockdev-backup') + with qemu_nbd_popen('-k', nbd_sock, '-f', iotests.imgfmt, disk_b): e = self.vm.event_wait('BLOCK_JOB_COMPLETED') self.assertEqual(e['data']['offset'], size) result = self.vm.qmp('blockdev-del', node_name='backup0') self.assert_qmp(result, 'return', {}) +def test_mirror_cancel(self): +# Mirror speed limit doesn't work well enough, it seems that mirror +# will run many parallel requests anyway. MAX_IN_FLIGHT is 16 and +# MAX_IO_BYTES is 1M in mirror.c, so let's use 20M disk. +self.init_vm(20 * 1024 * 1024) +self.start_job('blockdev-mirror') + +result = self.vm.qmp('block-job-cancel', device='drive0') +self.assert_qmp(result, 'return', {}) + +start_t = time.time() +self.vm.event_wait('BLOCK_JOB_CANCELLED') +delta_t = time.time() - start_t +self.assertTrue(delta_t < 2.0) Hi! For what it's worth, I've just run into this assert while running "make check -j8 SPEED=slow": --- /home/thuth/devel/qemu/tests/qemu-iotests/264.out +++ /home/thuth/tmp/qemu-build/tests/qemu-iotests/scratch/264/264.out.bad @@ -1,5 +1,15 @@ -... +..F +== +FAIL: test_mirror_cancel (__main__.TestNbdReconnect) +-- +Traceback (most recent call last): + File "/home/thuth/devel/qemu/tests/qemu-iotests/264", line 112, in test_mirror_cancel +self.cancel_job() + File "/home/thuth/devel/qemu/tests/qemu-iotests/264", line 104, in cancel_job +self.assertTrue(delta_t < 2.0) +AssertionError: False is not true + -- Ran 3 tests -OK +FAILED (failures=1) (te
Re: [PATCH] block/io_uring: add missing include file
On Thu, Jul 21, 2022 at 02:56:45PM +0800, Jinhao Fan wrote: The commit "Use io_uring_register_ring_fd() to skip fd operations" uses warn_report but did not include the header file "qemu/error-report.h". This causes "error: implicit declaration of function ‘warn_report’". Include this header file. We could add: Fixes: e2848bc574 ("Use io_uring_register_ring_fd() to skip fd operations") Signed-off-by: Jinhao Fan --- block/io_uring.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/io_uring.c b/block/io_uring.c index f8a19fd97f..a1760152e0 100644 --- a/block/io_uring.c +++ b/block/io_uring.c @@ -11,6 +11,7 @@ #include "qemu/osdep.h" #include #include "block/aio.h" +#include "qemu/error-report.h" #include "qemu/queue.h" #include "block/block.h" #include "block/raw-aio.h" -- 2.25.1 Thanks for the fix: Reviewed-by: Stefano Garzarella