[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/5] libqos/ahci: simplify ahci_port_check_error()
From: |
Niklas Cassel |
Subject: |
[PATCH 3/5] libqos/ahci: simplify ahci_port_check_error() |
Date: |
Thu, 8 Jun 2023 17:15:26 +0200 |
From: Niklas Cassel <niklas.cassel@wdc.com>
Modify ahci_port_check_error() to simply take a struct AHCICommand.
This way, the conditionals are in line which the existing code,
e.g. ahci_port_check_nonbusy(), which checks for cmd->errors.
This makes the code easier to reason with, we don't want to use
cmd->errors in some functions and emask in some functions.
No functional changes intended.
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
---
tests/qtest/libqos/ahci.c | 14 +++++++-------
tests/qtest/libqos/ahci.h | 3 +--
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/tests/qtest/libqos/ahci.c b/tests/qtest/libqos/ahci.c
index 2d4981dae4..644ed7e79f 100644
--- a/tests/qtest/libqos/ahci.c
+++ b/tests/qtest/libqos/ahci.c
@@ -404,14 +404,14 @@ void ahci_port_clear(AHCIQState *ahci, uint8_t port)
/**
* Check a port for errors.
*/
-void ahci_port_check_error(AHCIQState *ahci, uint8_t port,
- uint32_t imask, uint8_t emask)
+void ahci_port_check_error(AHCIQState *ahci, AHCICommand *cmd)
{
+ uint8_t port = cmd->port;
uint32_t reg;
/* The upper 9 bits of the IS register all indicate errors. */
reg = ahci_px_rreg(ahci, port, AHCI_PX_IS);
- reg &= ~imask;
+ reg &= ~cmd->interrupts;
reg >>= 23;
g_assert_cmphex(reg, ==, 0);
@@ -421,13 +421,13 @@ void ahci_port_check_error(AHCIQState *ahci, uint8_t port,
/* The TFD also has two error sections. */
reg = ahci_px_rreg(ahci, port, AHCI_PX_TFD);
- if (!emask) {
+ if (!cmd->errors) {
ASSERT_BIT_CLEAR(reg, AHCI_PX_TFD_STS_ERR);
} else {
ASSERT_BIT_SET(reg, AHCI_PX_TFD_STS_ERR);
}
- ASSERT_BIT_CLEAR(reg, AHCI_PX_TFD_ERR & (~emask << 8));
- ASSERT_BIT_SET(reg, AHCI_PX_TFD_ERR & (emask << 8));
+ ASSERT_BIT_CLEAR(reg, AHCI_PX_TFD_ERR & (~cmd->errors << 8));
+ ASSERT_BIT_SET(reg, AHCI_PX_TFD_ERR & (cmd->errors << 8));
}
void ahci_port_check_interrupts(AHCIQState *ahci, uint8_t port,
@@ -1242,7 +1242,7 @@ void ahci_command_verify(AHCIQState *ahci, AHCICommand
*cmd)
uint8_t slot = cmd->slot;
uint8_t port = cmd->port;
- ahci_port_check_error(ahci, port, cmd->interrupts, cmd->errors);
+ ahci_port_check_error(ahci, cmd);
ahci_port_check_interrupts(ahci, port, cmd->interrupts);
ahci_port_check_nonbusy(ahci, cmd);
ahci_port_check_cmd_sanity(ahci, cmd);
diff --git a/tests/qtest/libqos/ahci.h b/tests/qtest/libqos/ahci.h
index 2234f46862..137858d79c 100644
--- a/tests/qtest/libqos/ahci.h
+++ b/tests/qtest/libqos/ahci.h
@@ -590,8 +590,7 @@ void ahci_set_command_header(AHCIQState *ahci, uint8_t port,
void ahci_destroy_command(AHCIQState *ahci, uint8_t port, uint8_t slot);
/* AHCI sanity check routines */
-void ahci_port_check_error(AHCIQState *ahci, uint8_t port,
- uint32_t imask, uint8_t emask);
+void ahci_port_check_error(AHCIQState *ahci, AHCICommand *cmd);
void ahci_port_check_interrupts(AHCIQState *ahci, uint8_t port,
uint32_t intr_mask);
void ahci_port_check_nonbusy(AHCIQState *ahci, AHCICommand *cmd);
--
2.40.1
- [PATCH 0/5] improve ahci test suite, Niklas Cassel, 2023/06/08
- [PATCH 1/5] libqos/ahci: fix ahci_command_wait(), Niklas Cassel, 2023/06/08
- [PATCH 2/5] libqos/ahci: fix ahci_port_check_nonbusy(), Niklas Cassel, 2023/06/08
- [PATCH 3/5] libqos/ahci: simplify ahci_port_check_error(),
Niklas Cassel <=
- [PATCH 4/5] libqos/ahci: improve ahci_port_check_error(), Niklas Cassel, 2023/06/08
- [PATCH 5/5] libqos/ahci: perform mandatory error recovery on error, Niklas Cassel, 2023/06/08
- Re: [PATCH 0/5] improve ahci test suite, John Snow, 2023/06/08