From patchwork Wed Apr 10 08:08:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1083245 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 44fGyt6bb5z9s70 for ; Wed, 10 Apr 2019 18:09:26 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="QBfjaRrE"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44fGyt4RGJzDqJh for ; Wed, 10 Apr 2019 18:09:26 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44fGyR1D05zDqMn for ; Wed, 10 Apr 2019 18:09:03 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="QBfjaRrE"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 44fGyQ53Csz9sBV; Wed, 10 Apr 2019 18:09:02 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1554883742; bh=1abEUyjG+X1oMuZSFgRlV3NhO6mjtf4U0c28YAc/WWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QBfjaRrEDxyhWWIpNNcBYw5zNKJDEgRipzq7DfAGtVM1fxOBXt7Z7KujDcLhQZx/r rSYl9ZhnHyPh/LvE7oyNqLeKtexS2Auz2saIgnGEfhAgCmQbNDMRmfLedqEgCZisat tBYDT+CjS+4L42pBM4h2iDE7Ndf5sV9T6dWL9iXyQMdGxiQhGAXTtgCKqtc5uW/mkj At6G4ph8QZImF9g8BtOKkMSFkjQhZ9d4pPIW4ggtISNzkqMUSWMZtLraCHqRF+00oI 41Tiy+84E4PuEbPdfJ+IomjS0g3VeYUdP4r9O080wW09pLRgsO9XQF6cWnk1RHA/Cx 1u7vZQbmM8KMw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Wed, 10 Apr 2019 18:08:52 +1000 Message-Id: <20190410080854.430335-6-amitay@ozlabs.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190410080854.430335-1-amitay@ozlabs.org> References: <20190410080854.430335-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 5/7] libpdbg: Add bmc /dev/scom* backend X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Benjamin Herrenschmidt Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" From: Benjamin Herrenschmidt Avoid using the CFAM in raw mode, thus avoiding racing with other users of the CFAM PIB bridge. Also a bit faster. Signed-off-by: Benjamin Herrenschmidt --- libpdbg/kernel.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ p9-kernel.dts.m4 | 6 ++++-- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/libpdbg/kernel.c b/libpdbg/kernel.c index 9ff0174..a759c3c 100644 --- a/libpdbg/kernel.c +++ b/libpdbg/kernel.c @@ -149,3 +149,59 @@ static struct fsi kernel_fsi = { .write = kernel_fsi_putcfam, }; DECLARE_HW_UNIT(kernel_fsi); + +static int kernel_pib_getscom(struct pib *pib, uint64_t addr, uint64_t *value) +{ + int rc; + + rc = pread(pib->fd, value, 8, addr); + if (rc < 0) { + rc = errno; + PR_ERROR("Failed to read scom"); + return rc; + } + return 0; +} + +static int kernel_pib_putscom(struct pib *pib, uint64_t addr, uint64_t value) +{ + int rc; + + rc = pwrite(pib->fd, &value, 8, addr); + if (rc < 0) { + rc = errno; + PR_ERROR("Failed to write scom"); + return rc; + } + return 0; +} + +static int kernel_pib_probe(struct pdbg_target *target) +{ + struct pib *pib = target_to_pib(target); + const char *scom_path; + + scom_path = pdbg_target_property(target, "device-path", NULL); + assert(scom_path); + + pib->fd = open(scom_path, O_RDWR | O_SYNC); + if (pib->fd < 0) { + PR_ERROR("Unable to open %s\n", scom_path); + return -1; + } + + lseek(pib->fd, 0, SEEK_SET); + return 0; +} + +struct pib kernel_pib = { + .target = { + .name = "Kernel based FSI SCOM", + .compatible = "ibm,kernel-pib", + .class = "pib", + .probe = kernel_pib_probe, + }, + .read = kernel_pib_getscom, + .write = kernel_pib_putscom, +}; +DECLARE_HW_UNIT(kernel_pib); diff --git a/p9-kernel.dts.m4 b/p9-kernel.dts.m4 index 195be59..aec0881 100644 --- a/p9-kernel.dts.m4 +++ b/p9-kernel.dts.m4 @@ -18,7 +18,8 @@ #size-cells = <0x1>; reg = <0x0 0x1000 0x7>; index = <0x0>; - compatible = "ibm,fsi-pib", "ibm,power9-fsi-pib"; + compatible = "ibm,kernel-pib"; + device-path = "/dev/scom1"; include(p9-pib.dts.m4)dnl }; @@ -35,7 +36,8 @@ #size-cells = <0x1>; reg = <0x0 0x1000 0x7>; index = <0x1>; - compatible = "ibm,fsi-pib", "ibm,power9-fsi-pib"; + compatible = "ibm,kernel-pib"; + device-path = "/dev/scom2"; include(p9-pib.dts.m4)dnl }; };