From patchwork Mon Jan 6 19:21:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deb McLemore X-Patchwork-Id: 1218449 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47s5tf5s4wz9sNH for ; Tue, 7 Jan 2020 06:59:06 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47s5tf4lPlzDqHJ for ; Tue, 7 Jan 2020 06:59:06 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=debmc@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 47s5lB3r2mzDqG8 for ; Tue, 7 Jan 2020 06:52:38 +1100 (AEDT) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 006JqKY9025162 for ; Mon, 6 Jan 2020 14:52:35 -0500 Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xb92mdguj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 06 Jan 2020 14:52:35 -0500 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 006Jo901020937 for ; Mon, 6 Jan 2020 19:52:34 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma01dal.us.ibm.com with ESMTP id 2xajb6a2ft-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 06 Jan 2020 19:52:34 +0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 006JqXcv51446210 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 6 Jan 2020 19:52:33 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ADE98AE063 for ; Mon, 6 Jan 2020 19:52:33 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 922A2AE05C for ; Mon, 6 Jan 2020 19:52:33 +0000 (GMT) Received: from oc4402612711.ibm.com (unknown [9.41.175.242]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP for ; Mon, 6 Jan 2020 19:52:33 +0000 (GMT) Received: by oc4402612711.ibm.com (Postfix, from userid 1000) id 3A683AE0436; Mon, 6 Jan 2020 13:22:39 -0600 (CST) From: Deb McLemore To: skiboot@lists.ozlabs.org Date: Mon, 6 Jan 2020 13:21:42 -0600 Message-Id: <1578338508-13424-8-git-send-email-debmc@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1578338508-13424-1-git-send-email-debmc@linux.ibm.com> References: <1578338508-13424-1-git-send-email-debmc@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95, 18.0.572 definitions=2020-01-06_06:2020-01-06, 2020-01-06 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 lowpriorityscore=0 spamscore=0 phishscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 malwarescore=0 mlxlogscore=884 suspectscore=1 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001060165 Subject: [Skiboot] [PATCH v3 07/13] lpc: Fix lpc probe irqmask handling X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" 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 --- hw/lpc.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) 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;