diff mbox series

[v3,07/13] lpc: Fix lpc probe irqmask handling

Message ID 1573060953-6464-8-git-send-email-debmc@linux.ibm.com
State Changes Requested
Headers show
Series ipmi-hiomap: Enablement for Async opal_flash_op's | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (d75e82dbfbb9443efeb3f9a5921ac23605aab469)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot fail Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Deb McLemore Nov. 6, 2019, 5:22 p.m. UTC
Properly handle the irqmask from the callers
of lpc_probe_prepare and lpc_probe_test.

lpc_probe_prepare reads the existing irqmask
which is then later used to restore after
lpc_probe_test clears the irqmask.

Signed-off-by: Deb McLemore <debmc@linux.ibm.com>
---
 hw/lpc.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/hw/lpc.c b/hw/lpc.c
index 354d2b4..fedceb4 100644
--- a/hw/lpc.c
+++ b/hw/lpc.c
@@ -461,30 +461,28 @@  static const struct lpc_error_entry lpc_error_table[] = {
 	LPC_ERROR(LPC_HC_IRQ_SYNC_ABNORM_ERR, OPAL_WRONG_STATE, "Got SYNC abnormal error."),
 };
 
-static int64_t lpc_probe_prepare(struct lpcm *lpc)
+static int64_t lpc_probe_prepare(struct lpcm *lpc, uint32_t *irqmask)
 {
 	const uint32_t irqmask_addr = lpc_reg_opb_base + LPC_HC_IRQMASK;
 	const uint32_t irqstat_addr = lpc_reg_opb_base + LPC_HC_IRQSTAT;
-	uint32_t irqmask;
 	int rc;
 
-	rc = opb_read(lpc, irqmask_addr, &irqmask, 4);
+	rc = opb_read(lpc, irqmask_addr, irqmask, 4);
 	if (rc)
 		return rc;
 
-	irqmask &= ~LPC_HC_IRQ_SYNC_NORESP_ERR;
-	rc = opb_write(lpc, irqmask_addr, irqmask, 4);
+	rc = opb_write(lpc, irqmask_addr, 0, 4);
 	if (rc)
 		return rc;
 
 	return opb_write(lpc, irqstat_addr, LPC_HC_IRQ_SYNC_NORESP_ERR, 4);
 }
 
-static int64_t lpc_probe_test(struct lpcm *lpc)
+static int64_t lpc_probe_test(struct lpcm *lpc, uint32_t irqmask)
 {
 	const uint32_t irqmask_addr = lpc_reg_opb_base + LPC_HC_IRQMASK;
 	const uint32_t irqstat_addr = lpc_reg_opb_base + LPC_HC_IRQSTAT;
-	uint32_t irqmask, irqstat;
+	uint32_t irqstat;
 	int64_t idx;
 	int rc;
 
@@ -496,11 +494,6 @@  static int64_t lpc_probe_test(struct lpcm *lpc)
 	if (rc)
 		return rc;
 
-	rc = opb_read(lpc, irqmask_addr, &irqmask, 4);
-	if (rc)
-		return rc;
-
-	irqmask |= LPC_HC_IRQ_SYNC_NORESP_ERR;
 	rc = opb_write(lpc, irqmask_addr, irqmask, 4);
 	if (rc)
 		return rc;
@@ -525,11 +518,12 @@  static int64_t __lpc_write(struct lpcm *lpc, enum OpalLPCAddressType addr_type,
 			   bool probe)
 {
 	uint32_t opb_base;
+	uint32_t irqmask;
 	int64_t rc;
 
 	lock(&lpc->lock);
 	if (probe) {
-		rc = lpc_probe_prepare(lpc);
+		rc = lpc_probe_prepare(lpc, &irqmask);
 		if (rc)
 			goto bail;
 	}
@@ -548,7 +542,7 @@  static int64_t __lpc_write(struct lpcm *lpc, enum OpalLPCAddressType addr_type,
 		goto bail;
 
 	if (probe)
-		rc = lpc_probe_test(lpc);
+		rc = lpc_probe_test(lpc, irqmask);
  bail:
 	unlock(&lpc->lock);
 	return rc;
@@ -612,11 +606,12 @@  static int64_t __lpc_read(struct lpcm *lpc, enum OpalLPCAddressType addr_type,
 			  bool probe)
 {
 	uint32_t opb_base;
+	uint32_t irqmask;
 	int64_t rc;
 
 	lock(&lpc->lock);
 	if (probe) {
-		rc = lpc_probe_prepare(lpc);
+		rc = lpc_probe_prepare(lpc, &irqmask);
 		if (rc)
 			goto bail;
 	}
@@ -635,7 +630,7 @@  static int64_t __lpc_read(struct lpcm *lpc, enum OpalLPCAddressType addr_type,
 		goto bail;
 
 	if (probe)
-		rc = lpc_probe_test(lpc);
+		rc = lpc_probe_test(lpc, irqmask);
  bail:
 	unlock(&lpc->lock);
 	return rc;