From patchwork Fri May 26 09:07:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 767336 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wZ0fl1zTyz9s8P for ; Fri, 26 May 2017 19:08:31 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3wZ0fl0n0VzDqW0 for ; Fri, 26 May 2017 19:08:31 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org 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 3wZ0fc6ywxzDqTN for ; Fri, 26 May 2017 19:08:24 +1000 (AEST) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4Q93hfp106654 for ; Fri, 26 May 2017 05:08:20 -0400 Received: from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148]) by mx0a-001b2d01.pphosted.com with ESMTP id 2apbxruskm-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 26 May 2017 05:08:19 -0400 Received: from localhost by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 26 May 2017 19:08:17 +1000 Received: from d23relay08.au.ibm.com (202.81.31.227) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 26 May 2017 19:08:15 +1000 Received: from d23av05.au.ibm.com (d23av05.au.ibm.com [9.190.234.119]) by d23relay08.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4Q986aV59637878 for ; Fri, 26 May 2017 19:08:14 +1000 Received: from d23av05.au.ibm.com (localhost [127.0.0.1]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v4Q97gRU019654 for ; Fri, 26 May 2017 19:07:42 +1000 Received: from hegdevasant.in.ibm.com ([9.109.223.42]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v4Q97eRY019227; Fri, 26 May 2017 19:07:41 +1000 From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Fri, 26 May 2017 14:37:05 +0530 X-Mailer: git-send-email 2.9.3 X-TM-AS-MML: disable x-cbid: 17052609-0040-0000-0000-0000031EC717 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17052609-0041-0000-0000-00000C97AA60 Message-Id: <20170526090706.16922-1-hegdevasant@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-26_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705260166 Subject: [Skiboot] [PATCH v2 1/2] SBE: Add passthrough command support X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 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" SBE sends passthrough command. We have to capture this interrupt and send event to HBRT via opal-prd (user space daemon). This patch adds minimal SBE code to capture SBE interrupt and send event to opal-prd. Next patch will add opal-prd (user space) support. CC: Jeremy Kerr Signed-off-by: Vasant Hegde --- @Stewart, Jeremy, This patchset is based on top of opal-prd P9 updae patchset [1] [1] https://lists.ozlabs.org/pipermail/skiboot/2017-May/007449.html Also note that I've removed dependency on SBE patchset. Instead I've added minimal SBE support in this patch itself. This is tested and works fine. -Vasant hw/Makefile.inc | 2 +- hw/prd.c | 13 ++++++++++++ hw/psi.c | 3 ++- hw/sbe-p9.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/opal-api.h | 4 ++++ include/sbe-p9.h | 34 ++++++++++++++++++++++++++++++ include/skiboot.h | 1 + 7 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 hw/sbe-p9.c create mode 100644 include/sbe-p9.h diff --git a/hw/Makefile.inc b/hw/Makefile.inc index 97080aa..a9df78b 100644 --- a/hw/Makefile.inc +++ b/hw/Makefile.inc @@ -7,7 +7,7 @@ HW_OBJS += p7ioc.o p7ioc-inits.o p7ioc-phb.o HW_OBJS += phb3.o sfc-ctrl.o fake-rtc.o bt.o p8-i2c.o prd.o HW_OBJS += dts.o lpc-rtc.o npu.o npu-hw-procedures.o xive.o phb4.o HW_OBJS += fake-nvram.o lpc-mbox.o npu2.o npu2-hw-procedures.o -HW_OBJS += phys-map.o +HW_OBJS += phys-map.o sbe-p9.o HW=hw/built-in.o # FIXME hack this for now diff --git a/hw/prd.c b/hw/prd.c index da38e3a..9071bd1 100644 --- a/hw/prd.c +++ b/hw/prd.c @@ -28,6 +28,7 @@ enum events { EVENT_ATTN = 1 << 0, EVENT_OCC_ERROR = 1 << 1, EVENT_OCC_RESET = 1 << 2, + EVENT_SBE_PASSTHROUGH = 1 << 3, }; static uint8_t events[MAX_CHIPS]; @@ -109,6 +110,10 @@ static void prd_msg_consumed(void *data) break; case OPAL_PRD_MSG_TYPE_FIRMWARE_RESPONSE: break; + case OPAL_PRD_MSG_TYPE_SBE_PASSTHROUGH: + proc = msg->sbe_passthrough.chip; + event = EVENT_SBE_PASSTHROUGH; + break; default: prlog(PR_ERR, "PRD: invalid msg consumed, type: 0x%x\n", msg->hdr.type); @@ -180,6 +185,9 @@ static void send_next_pending_event(void) prd_msg->hdr.type = OPAL_PRD_MSG_TYPE_OCC_RESET; prd_msg->occ_reset.chip = proc; occ_msg_queue_occ_reset(); + } else if (event & EVENT_SBE_PASSTHROUGH) { + prd_msg->hdr.type = OPAL_PRD_MSG_TYPE_SBE_PASSTHROUGH; + prd_msg->sbe_passthrough.chip = proc; } /* @@ -266,6 +274,11 @@ void prd_occ_reset(uint32_t proc) prd_event(proc, EVENT_OCC_RESET); } +void prd_sbe_passthrough(uint32_t proc) +{ + prd_event(proc, EVENT_SBE_PASSTHROUGH); +} + /* incoming message handlers */ static int prd_msg_handle_attn_ack(struct opal_prd_msg *msg) { diff --git a/hw/psi.c b/hw/psi.c index cc7db44..ccc3578 100644 --- a/hw/psi.c +++ b/hw/psi.c @@ -33,6 +33,7 @@ #include #include #include +#include static LIST_HEAD(psis); static u64 psi_link_timer; @@ -603,7 +604,7 @@ static void psihb_p9_interrupt(struct irq_source *is, uint32_t isn) printf("PSI: DIO irq received\n"); break; case P9_PSI_IRQ_PSU: - printf("PSI: PSU irq received\n"); + sbe_interrupt(psi->chip_id); break; } } diff --git a/hw/sbe-p9.c b/hw/sbe-p9.c new file mode 100644 index 0000000..c9c3feb --- /dev/null +++ b/hw/sbe-p9.c @@ -0,0 +1,61 @@ +/* Copyright 2017 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define pr_fmt(fmt) "SBE: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void sbe_interrupt(uint32_t chip_id) +{ + int rc; + u64 data; + struct proc_chip *chip; + + chip = get_chip(chip_id); + if (chip == NULL) + return; + + /* Read doorbell register */ + rc = xscom_read(chip_id, PSU_HOST_DOORBELL_REG_RW, &data); + if (rc) { + prlog(PR_ERR, "Failed to read SBE to Host doorbell register " + "[chip id = %x]\n", chip_id); + goto clr_interrupt; + } + + /* SBE passtrhough command, call prd handler */ + if (data & SBE_HOST_PASSTHROUGH) { + prd_sbe_passthrough(chip_id); + } + +clr_interrupt: + /* Clears all the bits */ + rc = xscom_write(chip_id, PSU_HOST_DOORBELL_REG_AND, + SBE_HOST_RESPONSE_CLEAR); + if (rc) { + prlog(PR_ERR, "Failed to clear SBE to Host doorbell " + "register [chip id = %x]\n", chip_id); + } +} diff --git a/include/opal-api.h b/include/opal-api.h index 4d5b1eb..37af5f7 100644 --- a/include/opal-api.h +++ b/include/opal-api.h @@ -1032,6 +1032,7 @@ enum opal_prd_msg_type { OPAL_PRD_MSG_TYPE_FIRMWARE_REQUEST, /* HBRT --> OPAL */ OPAL_PRD_MSG_TYPE_FIRMWARE_RESPONSE, /* HBRT <-- OPAL */ OPAL_PRD_MSG_TYPE_FIRMWARE_NOTIFY, /* HBRT <-- OPAL */ + OPAL_PRD_MSG_TYPE_SBE_PASSTHROUGH, /* HBRT <-- OPAL */ }; struct opal_prd_msg_header { @@ -1076,6 +1077,9 @@ struct opal_prd_msg { __be64 len; char data[]; } fw_notify; + struct { + __be64 chip; + } sbe_passthrough; }; }; diff --git a/include/sbe-p9.h b/include/sbe-p9.h new file mode 100644 index 0000000..cca2100 --- /dev/null +++ b/include/sbe-p9.h @@ -0,0 +1,34 @@ +/* Copyright 2017 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __SBE_P9_H +#define __SBE_P9_H + +#include +#include +#include + +#define PSU_HOST_DOORBELL_REG_RW 0x000D0063 +#define PSU_HOST_DOORBELL_REG_AND 0x000D0064 +#define PSU_HOST_DOORBELL_REG_OR 0x000D0065 + +#define SBE_HOST_PASSTHROUGH PPC_BIT(4) +#define SBE_HOST_RESPONSE_CLEAR 0x00 + +/* SBE interrupt */ +extern void sbe_interrupt(uint32_t chip_id); + +#endif /* __SBE_P9_H */ diff --git a/include/skiboot.h b/include/skiboot.h index 5c8b0c8..5790f7e 100644 --- a/include/skiboot.h +++ b/include/skiboot.h @@ -277,6 +277,7 @@ extern void occ_pnor_set_owner(enum pnor_owner owner); extern void prd_psi_interrupt(uint32_t proc); extern void prd_tmgt_interrupt(uint32_t proc); extern void prd_occ_reset(uint32_t proc); +extern void prd_sbe_passthrough(uint32_t proc); extern void prd_init(void); extern void prd_register_reserved_memory(void);