From patchwork Thu Mar 3 01:46:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 1600131 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=PQaqddqp; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4K8DP55f1Kz9sFq for ; Thu, 3 Mar 2022 12:46:49 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K8DP33kRwz3bd6 for ; Thu, 3 Mar 2022 12:46:47 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=PQaqddqp; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::1033; helo=mail-pj1-x1033.google.com; envelope-from=joel.stan@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=PQaqddqp; dkim-atps=neutral Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4K8DNz3C54z3bPR for ; Thu, 3 Mar 2022 12:46:43 +1100 (AEDT) Received: by mail-pj1-x1033.google.com with SMTP id p3-20020a17090a680300b001bbfb9d760eso6396219pjj.2 for ; Wed, 02 Mar 2022 17:46:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+wqldjVWo/9WwBU/Z7dwbk1VOc+HBUEOU+elundn3no=; b=PQaqddqpC2Ek3tR/ak2QQEmwY5TbIZzxrYwyGJGGc4hu0L+b/NHJ5nkxWZQvGUofnN IPenGVhZT2KDNAMTYVtKjsLO3+/M71eKSaiGQYkmlSWpddlbADSkax9uBPZYAyJWNCKs DEaxRIY+TRXRQ3dgY+J5nlxL61804DyR+AM6VL3ovfjmUkauawU3H1aJMRca+Eibt0e5 U63bdNUaVKke3e0F+nnYZpaxaGSnE8Qlvm/jTYvhc2vCvWyw3aXKBl4I+YdJgB/PxCTz JMKa++uWM8CTR0CsgIm4btAnvBXctSBCMmhtCiGOHM3Ut4KEx2WjUm9R/DjmIZCgO4se 3YEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=+wqldjVWo/9WwBU/Z7dwbk1VOc+HBUEOU+elundn3no=; b=Kr6A4dXCk8v7Qij2VaAoH/iUnUmsU+knQAezsrxb4JqZsYgEHQOFhk83SB21jOmx4n aHVcFFddlcWSknR3MFWs6zhJ1e+tpa9n5XHOrU9+uoYcOPX4BSRosSqB5PJzGxO++siq +8YphxYfZIw6cDHKg5qcZWeqsg8ewnFD4d7NSdeSwSphQuydYEduKb8eyRL7VItURH5I zlp/3kJ5A1e37PgWGHaBYv+XUPvOjjP76eGBHe0tXzSMiVFryyXW37XQ/F1GjeJWGnd2 g68s4mnstMYtRatC7My2JLTzDQ0RKXgAobeyUkNPKzMcJjvDZvZAj5i1dfRMLLjRPv5T 8Fdw== X-Gm-Message-State: AOAM532HMZSDFZ+7PfGhnThNvLl1J3CopQ1wPojks4TuinXjDbe6P9QQ 49FVxHtqoskPq6VXGJXJNpxEwjGMc3KfbQ== X-Google-Smtp-Source: ABdhPJzrNaKLiI+oxAVM88/HcAnxAPqXzBPoSLsHjPzDFMzkdxroGVrey/Iz/kSDEtCA21GltECPBA== X-Received: by 2002:a17:902:e742:b0:14f:fd2f:c8bb with SMTP id p2-20020a170902e74200b0014ffd2fc8bbmr32757569plf.43.1646272001234; Wed, 02 Mar 2022 17:46:41 -0800 (PST) Received: from localhost.localdomain ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id 23-20020a17090a0b9700b001b8f602eaeasm6334070pjr.53.2022.03.02.17.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 17:46:40 -0800 (PST) From: Joel Stanley To: pdbg@lists.ozlabs.org, Nicholas Piggin Date: Thu, 3 Mar 2022 12:16:14 +1030 Message-Id: <20220303014616.757411-2-joel@jms.id.au> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220303014616.757411-1-joel@jms.id.au> References: <20220303014616.757411-1-joel@jms.id.au> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v3 1/3] configure: Add configure check for 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: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" From: Amitay Isaacs This is required for sbefifo ioctl definition. Signed-off-by: Amitay Isaacs Signed-off-by: Joel Stanley --- configure.ac | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index 8b4a012177b2..7b5dacafd2ec 100644 --- a/configure.ac +++ b/configure.ac @@ -34,6 +34,11 @@ else AC_SUBST([LIBFDT], ["-lfdt"]) fi +AC_CHECK_HEADER([linux/fsi.h], + [AC_DEFINE([HAVE_LINUX_FSI_H], 1, + [Define to 1 if you have the header file])], + []) + AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([Makefile]) From patchwork Thu Mar 3 01:46:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 1600132 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=R0k6dDuI; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4K8DP63nWtz9sFq for ; Thu, 3 Mar 2022 12:46:50 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K8DP53dVpz3bbn for ; Thu, 3 Mar 2022 12:46:49 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=R0k6dDuI; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::102d; helo=mail-pj1-x102d.google.com; envelope-from=joel.stan@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=R0k6dDuI; dkim-atps=neutral Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4K8DP307N0z3bSh for ; Thu, 3 Mar 2022 12:46:46 +1100 (AEDT) Received: by mail-pj1-x102d.google.com with SMTP id m11-20020a17090a7f8b00b001beef6143a8so3479805pjl.4 for ; Wed, 02 Mar 2022 17:46:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UElblV6ev+eRD+Z8jlDpoRftTtpiNHqt+r2uJbHxtDI=; b=R0k6dDuIvFv2QTua1uhNNBcVpwo5FNN0uEtnzGgPJTywdd5hGjbzXyRsMVC6HpRFsg blbCKLnBPmu4xPd/M62MKeZvrabIC+2oCUqRBBCt4Si1/PqtVtm1wtZzHBpIDXLeM+vF h3lTm4bDP++7yjbIhKvjhi5zlCRd2pPxCqMPxqc33K+6hTvFtDaer/3A0VgJroDgeYC6 QbAOmKuRsbaEPE38HsWDimF8AB6+IpJIz3Hbfb8IhBCOPuHj/ZPAecH7wMttoDiDhtT5 nCjGhCSRoNEE874KBjmnd96vq9r+bGCPamTArc30MNpd4EabVvuCq0PuCcszwJGMeXQC KMDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=UElblV6ev+eRD+Z8jlDpoRftTtpiNHqt+r2uJbHxtDI=; b=nOqnolWeFxKnDEMMcGAZniCwJY1u93OBrU7zH5wWmH4M++dgmBs90S2wmB0GJCNnd2 r8HduACdLO9/5fTOhgM9N/XI94CoyYyQNT+ritYf0/iUZFXJHrxUi0MB4POQbujSIFPk 9/BQui1odobxT9W6ThE0fZ1XOVt4vaHSPDAx74ZgTzBcZl0d+gf16cgPtGirDwKok5IR 7YveTjkOhlIYNghfh2Hy08pZqdJLAsZGlHbXQMjqq4scoypIXOU4m6x2EI3B0SJzvSqd +bh3o07U1NlD1Fpny7Z8LM/1Z0t6IJynkcVfKbG8gkIjGxapOo+Y8/l2gDv7moX4AKjg wyfw== X-Gm-Message-State: AOAM532JKCEXfFFeZ/mvo2hWWGKqIyTXKqf6rJnboR+nGNtFVqg2mhAp 4O5OxgEGV+IEWWcFph33ISLzTptlXjsN5w== X-Google-Smtp-Source: ABdhPJxuhXWyarE1L9Ke9C1ZLch51DUecouJ9dlOaoIaqBbO9faoQbPNZWasiq0AqRsGCfMqdsDBnQ== X-Received: by 2002:a17:903:1c7:b0:151:5b67:27e4 with SMTP id e7-20020a17090301c700b001515b6727e4mr21659316plh.0.1646272004960; Wed, 02 Mar 2022 17:46:44 -0800 (PST) Received: from localhost.localdomain ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id 23-20020a17090a0b9700b001b8f602eaeasm6334070pjr.53.2022.03.02.17.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 17:46:43 -0800 (PST) From: Joel Stanley To: pdbg@lists.ozlabs.org, Nicholas Piggin Date: Thu, 3 Mar 2022 12:16:15 +1030 Message-Id: <20220303014616.757411-3-joel@jms.id.au> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220303014616.757411-1-joel@jms.id.au> References: <20220303014616.757411-1-joel@jms.id.au> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v3 2/3] libsbefifo: Add long read timeout API 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: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" From: Amitay Isaacs Add a function to set the long read timeout on a sbefifo context, and to reset it afterwards. This will be used by chip-ops that require a long timeout. Signed-off-by: Amitay Isaacs Signed-off-by: Joel Stanley --- libsbefifo/sbefifo_private.h | 2 ++ libsbefifo/connect.c | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/libsbefifo/sbefifo_private.h b/libsbefifo/sbefifo_private.h index 3c5ebcefb288..373f7f3c90ed 100644 --- a/libsbefifo/sbefifo_private.h +++ b/libsbefifo/sbefifo_private.h @@ -83,6 +83,8 @@ struct sbefifo_context { uint32_t ffdc_len; }; +int sbefifo_set_long_timeout(struct sbefifo_context *sctx); +int sbefifo_reset_timeout(struct sbefifo_context *sctx); void sbefifo_debug(const char *fmt, ...); void sbefifo_ffdc_clear(struct sbefifo_context *sctx); diff --git a/libsbefifo/connect.c b/libsbefifo/connect.c index 1d23af5ec896..27e8976cb2dc 100644 --- a/libsbefifo/connect.c +++ b/libsbefifo/connect.c @@ -21,6 +21,17 @@ #include #include #include +#include + +#ifdef HAVE_LINUX_FSI_H +#include +#else +#include +#endif /* HAVE_LINUX_FSI_H */ + +#ifndef FSI_SBEFIFO_READ_TIMEOUT +#define FSI_SBEFIFO_READ_TIMEOUT _IOW('s', 0x00, unsigned int) +#endif #include "libsbefifo.h" #include "sbefifo_private.h" @@ -106,6 +117,36 @@ int sbefifo_proc(struct sbefifo_context *sctx) return sctx->proc; } +int sbefifo_set_long_timeout(struct sbefifo_context *sctx) +{ + unsigned int long_timeout = 30; + int rc; + + LOG("long_timeout: %u sec\n", long_timeout); + rc = ioctl(sctx->fd, FSI_SBEFIFO_READ_TIMEOUT, &long_timeout); + if (rc == -1 && errno == ENOTTY) { + /* Do not fail if kernel does not implement ioctl */ + rc = 0; + } + + return rc; +} + +int sbefifo_reset_timeout(struct sbefifo_context *sctx) +{ + unsigned int timeout = 0; + int rc; + + LOG("reset_timeout\n"); + rc = ioctl(sctx->fd, FSI_SBEFIFO_READ_TIMEOUT, &timeout); + if (rc == -1 && errno == ENOTTY) { + /* Do not fail if kernel does not implement ioctl */ + rc = 0; + } + + return rc; +} + void sbefifo_debug(const char *fmt, ...) { va_list ap; From patchwork Thu Mar 3 01:46:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 1600133 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=YgUnwa4P; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4K8DP94C00z9sFq for ; Thu, 3 Mar 2022 12:46:53 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K8DP84CCCz3bfg for ; Thu, 3 Mar 2022 12:46:52 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=YgUnwa4P; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::102a; helo=mail-pj1-x102a.google.com; envelope-from=joel.stan@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=YgUnwa4P; dkim-atps=neutral Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4K8DP61GjPz3bYJ for ; Thu, 3 Mar 2022 12:46:50 +1100 (AEDT) Received: by mail-pj1-x102a.google.com with SMTP id gj15-20020a17090b108f00b001bef86c67c1so3352138pjb.3 for ; Wed, 02 Mar 2022 17:46:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TjvMbMmjzeLiN4uorfca2lfTbpykNgwmW9zjF5Yssuc=; b=YgUnwa4PRoEIrzgYM/6FejQ0JQdVIwuSSCBh9kHVvkeHbqKFhYXhZJGfca3VBsVlg0 vvHNIBPVbWH/fhwXSgdvTa9OgXTxajHPdo2j5el7LmU6EpweRHskq76K/G/T/hZ688hv XYs4d2ObDl/uNkIgCU5FNNcFelwmXW4XNUJwsv/q6nC3CAO5/68I0RSdCPTzCNw6u3UN 3N1lD+V7wZPj6UE6d0rH1izC/sp3kLafFzMshJW+C0OVPxDWEQxOVTcKq2bDjcyyrzEc DXNxnzZrTPsIQGXtnyPyLdI0SQ9PJXcQtNwmypcTTyxwiBpWItVFONGCXegGlWoaxIMb Q/bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=TjvMbMmjzeLiN4uorfca2lfTbpykNgwmW9zjF5Yssuc=; b=Tt4wb48jaxlRUPgEo4jRfce2HJJ1LK1FmB2Gk+UL/taW+MhgHa6KzVHmE6i2GoXitn acYCHjHHBDxhx7ILH0XHGQwf6fKmUOeLM822gPGxrQqYZPlbLDat2CJAWEQzYOW97e/l qqn0jeex4p1TKX7iDn6OspDwr4KGDE70HHFxFPra4DX+ZeGtNEjdumKrYAdvoJMXf5t2 dbhusuwUH8s60MPA1o9FIU4bMwhvbuVtQNy7ieO7Ly3Kl6YJKr9ppeSKgAmYbyw4oevp mml9n+EcsJiZbgu9SWVVsiMauoObO5NaV78gfJ1p/rnMGgxyLZkSwwvu2wAqWcNRIrPi l1Og== X-Gm-Message-State: AOAM5323mfhmrl5MRe8J7xI/m83B9F2KaQTAo485BtSjmNO844CZhzA1 EfwF7r49nxB1HUEzvm7+ji9F0T+p3jJLjg== X-Google-Smtp-Source: ABdhPJzH+P1fisTKJUT64weejalGyvyK0ksI7xqf/mD7r0pA8bk6lclS3sksakFpX+DGSYWzB75tEg== X-Received: by 2002:a17:90b:1006:b0:1be:e246:a5c7 with SMTP id gm6-20020a17090b100600b001bee246a5c7mr2746001pjb.155.1646272008346; Wed, 02 Mar 2022 17:46:48 -0800 (PST) Received: from localhost.localdomain ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id 23-20020a17090a0b9700b001b8f602eaeasm6334070pjr.53.2022.03.02.17.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 17:46:47 -0800 (PST) From: Joel Stanley To: pdbg@lists.ozlabs.org, Nicholas Piggin Date: Thu, 3 Mar 2022 12:16:16 +1030 Message-Id: <20220303014616.757411-4-joel@jms.id.au> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220303014616.757411-1-joel@jms.id.au> References: <20220303014616.757411-1-joel@jms.id.au> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v3 3/3] libsbefifo: Set long read timeout for chip-ops 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: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" From: Amitay Isaacs SBE interface specification lists several sbe chip-ops that require long read timeout as those chip-ops can take up to 30 seconds to complete. Reset the long timeout back to the default after performing the chip-op. The list of chip-ops from the spec (v2.0): 0xA1 0x01 Execute istep 0xA2 0x05 Execute multi-SCOM 0xA3 0x01 Get Ring 0x02 Set Ring 0xA4 0x01 Get Memory 0x02 Put Memory 0x03 Get SRAM 0x04 Put SRAM 0xA5 0x01 Get Architected Register 0x02 Put Architected Register 0xA6 0x01 Control Fast Array 0x02 Control Trace Array 0xA8 0x03 Quiesce SBE 0xA9 0x01 Enter MPIPL 0x02 Continue MPIPL 0x04 TI Info Signed-off-by: Amitay Isaacs Signed-off-by: Joel Stanley --- v3: Fix up error handling: don't leak msg, and ensure we reset the timeout another call fails Document long running ops in sbefifo_private.h libsbefifo/sbefifo_private.h | 37 ++++++++++++++++++++---------------- libsbefifo/cmd_array.c | 14 ++++++++++++++ libsbefifo/cmd_control.c | 7 +++++++ libsbefifo/cmd_generic.c | 7 +++++++ libsbefifo/cmd_memory.c | 29 +++++++++++++++++++++++++++- libsbefifo/cmd_mpipl.c | 21 ++++++++++++++++++++ libsbefifo/cmd_register.c | 12 ++++++++++++ libsbefifo/cmd_ring.c | 21 ++++++++++++++++++++ 8 files changed, 131 insertions(+), 17 deletions(-) diff --git a/libsbefifo/sbefifo_private.h b/libsbefifo/sbefifo_private.h index 373f7f3c90ed..e6de9e21e114 100644 --- a/libsbefifo/sbefifo_private.h +++ b/libsbefifo/sbefifo_private.h @@ -20,8 +20,13 @@ #include #include "libsbefifo.h" +/* + * Long running commands will set a long (30 second) timeout when the kernel + * supports it. + */ + #define SBEFIFO_CMD_CLASS_CONTROL 0xA100 -#define SBEFIFO_CMD_EXECUTE_ISTEP 0x01 +#define SBEFIFO_CMD_EXECUTE_ISTEP 0x01 /* long running */ #define SBEFIFO_CMD_SUSPEND_IO 0x02 #define SBEFIFO_CMD_CLASS_SCOM 0xA200 @@ -29,28 +34,28 @@ #define SBEFIFO_CMD_PUT_SCOM 0x02 #define SBEFIFO_CMD_MODIFY_SCOM 0x03 #define SBEFIFO_CMD_PUT_SCOM_MASK 0x04 -#define SBEFIFO_CMD_MULTI_SCOM 0x05 +#define SBEFIFO_CMD_MULTI_SCOM 0x05 /* long running */ #define SBEFIFO_CMD_CLASS_RING 0xA300 -#define SBEFIFO_CMD_GET_RING 0x01 -#define SBEFIFO_CMD_PUT_RING 0x02 +#define SBEFIFO_CMD_GET_RING 0x01 /* long running */ +#define SBEFIFO_CMD_PUT_RING 0x02 /* long running */ #define SBEFIFO_CMD_PUT_RING_IMAGE 0x03 #define SBEFIFO_CMD_CLASS_MEMORY 0xA400 -#define SBEFIFO_CMD_GET_MEMORY 0x01 -#define SBEFIFO_CMD_PUT_MEMORY 0x02 -#define SBEFIFO_CMD_GET_SRAM 0x03 -#define SBEFIFO_CMD_PUT_SRAM 0x04 +#define SBEFIFO_CMD_GET_MEMORY 0x01 /* long running */ +#define SBEFIFO_CMD_PUT_MEMORY 0x02 /* long running */ +#define SBEFIFO_CMD_GET_SRAM 0x03 /* long running */ +#define SBEFIFO_CMD_PUT_SRAM 0x04 /* long running */ #define SBEFIFO_CMD_CLASS_REGISTER 0xA500 -#define SBEFIFO_CMD_GET_REGISTER 0x01 -#define SBEFIFO_CMD_PUT_REGISTER 0x02 +#define SBEFIFO_CMD_GET_REGISTER 0x01 /* long running */ +#define SBEFIFO_CMD_PUT_REGISTER 0x02 /* long running */ #define SBEFIFO_CMD_GET_HW_REGISTER 0x03 #define SBEFIFO_CMD_PUT_HW_REGISTER 0x04 #define SBEFIFO_CMD_CLASS_ARRAY 0xA600 -#define SBEFIFO_CMD_FAST_ARRAY 0x01 -#define SBEFIFO_CMD_TRACE_ARRAY 0x02 +#define SBEFIFO_CMD_FAST_ARRAY 0x01 /* long running */ +#define SBEFIFO_CMD_TRACE_ARRAY 0x02 /* long running */ #define SBEFIFO_CMD_CLASS_INSTRUCTION 0xA700 #define SBEFIFO_CMD_CONTROL_INSN 0x01 @@ -58,15 +63,15 @@ #define SBEFIFO_CMD_CLASS_GENERIC 0xA800 #define SBEFIFO_CMD_GET_FFDC 0x01 #define SBEFIFO_CMD_GET_CAPABILITY 0x02 -#define SBEFIFO_CMD_QUIESCE 0x03 +#define SBEFIFO_CMD_QUIESCE 0x03 /* long running */ /* missing ids */ #define SBEFIFO_CMD_LPC_TIMEOUT 0x08 #define SBEFIFO_CMD_CLASS_MPIPL 0xA900 -#define SBEFIFO_CMD_ENTER_MPIPL 0x01 -#define SBEFIFO_CMD_CONTINUE_MPIPL 0x02 +#define SBEFIFO_CMD_ENTER_MPIPL 0x01 /* long running */ +#define SBEFIFO_CMD_CONTINUE_MPIPL 0x02 /* long running */ #define SBEFIFO_CMD_STOP_CLOCKS 0x03 -#define SBEFIFO_CMD_GET_TI_INFO 0x04 +#define SBEFIFO_CMD_GET_TI_INFO 0x04 /* long running */ #define SBEFIFO_CMD_CLASS_DUMP 0xAA00 #define SBEFIFO_CMD_GET_DUMP 0x01 diff --git a/libsbefifo/cmd_array.c b/libsbefifo/cmd_array.c index 1ff8c03d7278..9c60b3fe9513 100644 --- a/libsbefifo/cmd_array.c +++ b/libsbefifo/cmd_array.c @@ -69,8 +69,15 @@ int sbefifo_control_fast_array(struct sbefifo_context *sctx, uint16_t target_typ if (rc) return rc; + rc = sbefifo_set_long_timeout(sctx); + if (rc) { + free(msg); + return rc; + } + out_len = 0; rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); + sbefifo_reset_timeout(sctx); free(msg); if (rc) return rc; @@ -136,9 +143,16 @@ int sbefifo_control_trace_array(struct sbefifo_context *sctx, uint16_t target_ty if (rc) return rc; + rc = sbefifo_set_long_timeout(sctx); + if (rc) { + free(msg); + return rc; + } + /* The size of returned data is just a guess */ out_len = 16 * sizeof(uint32_t); rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); + sbefifo_reset_timeout(sctx); free(msg); if (rc) return rc; diff --git a/libsbefifo/cmd_control.c b/libsbefifo/cmd_control.c index e64f555c665d..2ff7ebcac468 100644 --- a/libsbefifo/cmd_control.c +++ b/libsbefifo/cmd_control.c @@ -64,8 +64,15 @@ int sbefifo_istep_execute(struct sbefifo_context *sctx, uint8_t major, uint8_t m if (rc) return rc; + rc = sbefifo_set_long_timeout(sctx); + if (rc) { + free(msg); + return rc; + } + out_len = 0; rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); + sbefifo_reset_timeout(sctx); free(msg); if (rc) return rc; diff --git a/libsbefifo/cmd_generic.c b/libsbefifo/cmd_generic.c index 16c61f4a7863..7035af41b2c8 100644 --- a/libsbefifo/cmd_generic.c +++ b/libsbefifo/cmd_generic.c @@ -199,8 +199,15 @@ int sbefifo_quiesce(struct sbefifo_context *sctx) if (rc) return rc; + rc = sbefifo_set_long_timeout(sctx); + if (rc) { + free(msg); + return rc; + } + out_len = 0; rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); + sbefifo_reset_timeout(sctx); free(msg); if (rc) return rc; diff --git a/libsbefifo/cmd_memory.c b/libsbefifo/cmd_memory.c index 4195a1269963..546037dd84b1 100644 --- a/libsbefifo/cmd_memory.c +++ b/libsbefifo/cmd_memory.c @@ -125,6 +125,12 @@ int sbefifo_mem_get(struct sbefifo_context *sctx, uint64_t addr, uint32_t size, if (rc) return rc; + rc = sbefifo_set_long_timeout(sctx); + if (rc) { + free(msg); + return rc; + } + /* length is 6th word in the request */ len = be32toh(*(uint32_t *)(msg + 20)); extra_bytes = 0; @@ -137,11 +143,11 @@ int sbefifo_mem_get(struct sbefifo_context *sctx, uint64_t addr, uint32_t size, out_len = len + extra_bytes + 4; rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); + sbefifo_reset_timeout(sctx); free(msg); if (rc) return rc; - rc = sbefifo_mem_get_pull(out, out_len, addr, size, flags, data); if (out) free(out); @@ -206,8 +212,15 @@ int sbefifo_mem_put(struct sbefifo_context *sctx, uint64_t addr, uint8_t *data, if (rc) return rc; + rc = sbefifo_set_long_timeout(sctx); + if (rc) { + free(msg); + return rc; + } + out_len = 1 * 4; rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); + sbefifo_reset_timeout(sctx); free(msg); if (rc) return rc; @@ -295,11 +308,18 @@ int sbefifo_sram_get(struct sbefifo_context *sctx, uint16_t chiplet_id, uint64_t if (rc) return rc; + rc = sbefifo_set_long_timeout(sctx); + if (rc) { + free(msg); + return rc; + } + /* length is 6th word in the request */ len = be32toh(*(uint32_t *)(msg + 20)); out_len = len + 4; rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); + sbefifo_reset_timeout(sctx); free(msg); if (rc) return rc; @@ -375,8 +395,15 @@ int sbefifo_sram_put(struct sbefifo_context *sctx, uint16_t chiplet_id, uint64_t if (rc) return rc; + rc = sbefifo_set_long_timeout(sctx); + if (rc) { + free(msg); + return rc; + } + out_len = 4; rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); + sbefifo_reset_timeout(sctx); free(msg); if (rc) return rc; diff --git a/libsbefifo/cmd_mpipl.c b/libsbefifo/cmd_mpipl.c index 1d3249483375..81816fa13012 100644 --- a/libsbefifo/cmd_mpipl.c +++ b/libsbefifo/cmd_mpipl.c @@ -61,8 +61,15 @@ int sbefifo_mpipl_enter(struct sbefifo_context *sctx) if (rc) return rc; + rc = sbefifo_set_long_timeout(sctx); + if (rc) { + free(msg); + return rc; + } + out_len = 0; rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); + sbefifo_reset_timeout(sctx); free(msg); if (rc) return rc; @@ -112,8 +119,15 @@ int sbefifo_mpipl_continue(struct sbefifo_context *sctx) if (rc) return rc; + rc = sbefifo_set_long_timeout(sctx); + if (rc) { + free(msg); + return rc; + } + out_len = 0; rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); + sbefifo_reset_timeout(sctx); free(msg); if (rc) return rc; @@ -224,8 +238,15 @@ int sbefifo_mpipl_get_ti_info(struct sbefifo_context *sctx, uint8_t **data, uint if (rc) return rc; + rc = sbefifo_set_long_timeout(sctx); + if (rc) { + free(msg); + return rc; + } + out_len = 0; rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); + sbefifo_reset_timeout(sctx); free(msg); if (rc) return rc; diff --git a/libsbefifo/cmd_register.c b/libsbefifo/cmd_register.c index 1e74b6ec4eb9..076b774cb905 100644 --- a/libsbefifo/cmd_register.c +++ b/libsbefifo/cmd_register.c @@ -88,12 +88,18 @@ int sbefifo_register_get(struct sbefifo_context *sctx, uint8_t core_id, uint8_t if (rc) return rc; + rc = sbefifo_set_long_timeout(sctx); + if (rc) + return rc; + out_len = reg_count * 8; rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); free(msg); if (rc) return rc; + sbefifo_reset_timeout(sctx); + rc = sbefifo_register_get_pull(out, out_len, reg_count, value); if (out) free(out); @@ -154,12 +160,18 @@ int sbefifo_register_put(struct sbefifo_context *sctx, uint8_t core_id, uint8_t if (rc) return rc; + rc = sbefifo_set_long_timeout(sctx); + if (rc) + return rc; + out_len = 0; rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); free(msg); if (rc) return rc; + sbefifo_reset_timeout(sctx); + rc = sbefifo_register_put_pull(out, out_len); if (out) free(out); diff --git a/libsbefifo/cmd_ring.c b/libsbefifo/cmd_ring.c index 44e8effc4c99..ef6d5b569052 100644 --- a/libsbefifo/cmd_ring.c +++ b/libsbefifo/cmd_ring.c @@ -71,9 +71,16 @@ int sbefifo_ring_get(struct sbefifo_context *sctx, uint32_t ring_addr, uint32_t if (rc) return rc; + rc = sbefifo_set_long_timeout(sctx); + if (rc) { + free(msg); + return rc; + } + /* multiples of 64 bits */ out_len = (ring_len_bits + 63) / 8; rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); + sbefifo_reset_timeout(sctx); free(msg); if (rc) return rc; @@ -125,8 +132,15 @@ int sbefifo_ring_put(struct sbefifo_context *sctx, uint16_t ring_mode, uint8_t * if (rc) return rc; + rc = sbefifo_set_long_timeout(sctx); + if (rc) { + free(msg); + return rc; + } + out_len = 0; rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); + sbefifo_reset_timeout(sctx); free(msg); if (rc) return rc; @@ -185,8 +199,15 @@ int sbefifo_ring_put_from_image(struct sbefifo_context *sctx, uint16_t target, u if (rc) return rc; + rc = sbefifo_set_long_timeout(sctx); + if (rc) { + free(msg); + return rc; + } + out_len = 0; rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len); + sbefifo_reset_timeout(sctx); free(out); if (rc) return rc;