Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1506742pxk; Fri, 2 Oct 2020 11:11:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQoljryynXz6/YyjMuZHP6OvEl8MP472Ik6+NpxyA+pxQtKleI3aYWtbef1Qy+YYhLr0Dn X-Received: by 2002:a05:6402:84f:: with SMTP id b15mr3798059edz.149.1601662294935; Fri, 02 Oct 2020 11:11:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601662294; cv=none; d=google.com; s=arc-20160816; b=fsQkLVqla7Jwb5RVOQLxvLK8f/8eoRfI8kgp+PLBHBliFtljji6CgMuBwARdnREqoo Gopc/uEYhZZUUanW20CA+iedSzcwPHfI/IRpQyDlhlVjnj5loszI8naSupWAHnlkLFU+ rsKopnf72/jAOKHVhVrbo+RrUtB/HmovbZOBunsxjcbkb3wPQKwd/8jISGs2tWwT0EYH unOvGQBnIym/OE3YU0WwOk6ZtYJbZvx/qaCxP315Ri3o6HvWLwk1x693o+4OfVr6znq8 Dt86cagPnGzW0ASVGuI2wAj3HNmt/ay7psfwCLmECq9a/plrCwK6XNHOfSKACZNp98YT WlFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dmarc-filter:sender:dkim-signature; bh=hbj98IMQqt6iz3FVg6yk7+OVA8RtJa/ki2zf73W1tZo=; b=ywwb0YpjXmlQRqg9q+DVJlIs+ix/uvc5rHRkMZD7TVyGGBav/ffdnINwrTV/JjEB7g X/gFB2MHnxmpulHFghyduK+MocPlbhXAD0VfM2jn/Uk4hPIUT2/16qut0lCnXol+pprg Hp/VjEazEVEGJDFqZ8s53aR8Z2Kh1PDlpvaN08hfbfEsPTTWcVVSpdbVmNacUwuRrK3K gIkmZx2ydfMW0ZE/auGujXODQhkIbNSvfZu6QCa79Npcspxzb8gt4uwJbe/B35tpgLP7 wG5wF2qCuNd7PzkhkzbJJ6af7/8olHbm+c4OBhi/putAW59yFMxjsJR1v2lHUXACpNyx r67w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=YMWedZ8O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g8si1524074ejr.733.2020.10.02.11.11.12; Fri, 02 Oct 2020 11:11:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=YMWedZ8O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388412AbgJBSJj (ORCPT + 99 others); Fri, 2 Oct 2020 14:09:39 -0400 Received: from m42-4.mailgun.net ([69.72.42.4]:27933 "EHLO m42-4.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388034AbgJBSJf (ORCPT ); Fri, 2 Oct 2020 14:09:35 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1601662174; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=hbj98IMQqt6iz3FVg6yk7+OVA8RtJa/ki2zf73W1tZo=; b=YMWedZ8O2BlNxgSxCo2OI6BIFDm94u1nKURMGJkD+oMa37QqUG6ylVc/iEcSyL4zPmv4fRYo onqUuSHgl87oAv2xs+JO8YjAJd8Sifr6R1USm0JCCyB9CpL4MrOwmSqUSIrA+Phusa/XENpH 10rVeTEjChTd+BBqfb9PDaw2wJw= X-Mailgun-Sending-Ip: 69.72.42.4 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n03.prod.us-west-2.postgun.com with SMTP id 5f776cdb319d4e9cb56296bc (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 02 Oct 2020 18:09:31 GMT Sender: rishabhb=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 1D2D5C43382; Fri, 2 Oct 2020 18:09:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from rishabhb-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: rishabhb) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3269EC433C8; Fri, 2 Oct 2020 18:09:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3269EC433C8 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=rishabhb@codeaurora.org From: Rishabh Bhatnagar To: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, bjorn.andersson@linaro.org Cc: tsoni@codeaurora.org, psodagud@codeaurora.org, sidgup@codeaurora.org, Rishabh Bhatnagar Subject: [PATCH v7 3/3] remoteproc: Add recovery configuration to the sysfs interface Date: Fri, 2 Oct 2020 11:09:04 -0700 Message-Id: <1601662144-5964-4-git-send-email-rishabhb@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1601662144-5964-1-git-send-email-rishabhb@codeaurora.org> References: <1601662144-5964-1-git-send-email-rishabhb@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add recovery configuration to the sysfs interface. This will allow usage of this configuration feature in production devices where access to debugfs might be limited. Signed-off-by: Rishabh Bhatnagar --- Documentation/ABI/testing/sysfs-class-remoteproc | 20 +++++++++ drivers/remoteproc/remoteproc_sysfs.c | 56 ++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-remoteproc b/Documentation/ABI/testing/sysfs-class-remoteproc index 050bd25..066b9b6 100644 --- a/Documentation/ABI/testing/sysfs-class-remoteproc +++ b/Documentation/ABI/testing/sysfs-class-remoteproc @@ -82,3 +82,23 @@ Description: Remote processor coredump configuration processor's device memory. Extra buffer will not be used to copy the dump. Also recovery process will not proceed until all data is read by usersapce. + +What: /sys/class/remoteproc/.../recovery +Date: July 2020 +Contact: Bjorn Andersson , Ohad Ben-Cohen +Description: Remote processor recovery mechanism + + Reports the recovery mechanism of the remote processor, + which will be one of: + + "enabled" + "disabled" + + "enabled" means, the remote processor will be automatically + recovered whenever it crashes. Moreover, if the remote + processor crashes while recovery is disabled, it will + be automatically recovered too as soon as recovery is enabled. + + "disabled" means, a remote processor will remain in a crashed + state if it crashes. This is useful for debugging purposes; + without it, debugging a crash is substantially harder. diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 8500271..d1cf7bf 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -10,6 +10,61 @@ #define to_rproc(d) container_of(d, struct rproc, dev) +static ssize_t recovery_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct rproc *rproc = to_rproc(dev); + + return sprintf(buf, "%s", rproc->recovery_disabled ? "disabled\n" : "enabled\n"); +} + +/* + * By writing to the 'recovery' sysfs entry, we control the behavior of the + * recovery mechanism dynamically. The default value of this entry is "enabled". + * + * The 'recovery' sysfs entry supports these commands: + * + * enabled: When enabled, the remote processor will be automatically + * recovered whenever it crashes. Moreover, if the remote + * processor crashes while recovery is disabled, it will + * be automatically recovered too as soon as recovery is enabled. + * + * disabled: When disabled, a remote processor will remain in a crashed + * state if it crashes. This is useful for debugging purposes; + * without it, debugging a crash is substantially harder. + * + * recover: This function will trigger an immediate recovery if the + * remote processor is in a crashed state, without changing + * or checking the recovery state (enabled/disabled). + * This is useful during debugging sessions, when one expects + * additional crashes to happen after enabling recovery. In this + * case, enabling recovery will make it hard to debug subsequent + * crashes, so it's recommended to keep recovery disabled, and + * instead use the "recover" command as needed. + */ +static ssize_t recovery_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct rproc *rproc = to_rproc(dev); + + if (sysfs_streq(buf, "enabled")) { + /* change the flag and begin the recovery process if needed */ + rproc->recovery_disabled = false; + rproc_trigger_recovery(rproc); + } else if (sysfs_streq(buf, "disabled")) { + rproc->recovery_disabled = true; + } else if (sysfs_streq(buf, "recover")) { + /* begin the recovery process without changing the flag */ + rproc_trigger_recovery(rproc); + } else { + return -EINVAL; + } + + return count; +} +static DEVICE_ATTR_RW(recovery); + /* * A coredump-configuration-to-string lookup table, for exposing a * human readable configuration via sysfs. Always keep in sync with @@ -201,6 +256,7 @@ static DEVICE_ATTR_RO(name); static struct attribute *rproc_attrs[] = { &dev_attr_coredump.attr, + &dev_attr_recovery.attr, &dev_attr_firmware.attr, &dev_attr_state.attr, &dev_attr_name.attr, -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project