From patchwork Wed Aug 8 23:07:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guzman Lugo, Fernando" X-Patchwork-Id: 1298181 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id A7AA9DF223 for ; Wed, 8 Aug 2012 23:11:00 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SzFMY-0007f3-Vc; Wed, 08 Aug 2012 23:08:27 +0000 Received: from na3sys009aog131.obsmtp.com ([74.125.149.247]) by merlin.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1SzFMF-0007aO-42 for linux-arm-kernel@lists.infradead.org; Wed, 08 Aug 2012 23:08:10 +0000 Received: from mail-ob0-f173.google.com ([209.85.214.173]) (using TLSv1) by na3sys009aob131.postini.com ([74.125.148.12]) with SMTP ID DSNKUCLxVHCMjIpQbncXBDwiYrG5XxfzoizS@postini.com; Wed, 08 Aug 2012 16:08:07 PDT Received: by obbta14 with SMTP id ta14so2338744obb.32 for ; Wed, 08 Aug 2012 16:08:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=ZxW8tSXMXYNiToXMwbyHbWFpEIBxFXVUjBoAJ2VVAS0=; b=RlKMAeK3HXoCErrZ2t8VdwAzs80ZeOZfzyv8tc9dnD+/FnJkQ7h+8GhrIbBY8NGcQq 6rO8ONOvkswlVV1aqRzl8Uy8L/VVGte6p2q92ZD0diCKROWRdU4gtUdOLAe5jducP3wr QZWBtIu1FywQxmXA3z+d6+yeo8ScU3M9Q2lLfxZnuLMNKd4IY/sr8j7f7FIcoHpaRQaE yjagvolRt4P5uBwADGNkVj38fEAviHp3/xn2TD9QNSwWxUqi9bsnHbKQ0KczTcaIO6/d IIBw9S7uos2a+p5iK8tzvK/E4/yLu0ZD9PUM7ysCo590TMy4/D/9R2OpT8xi73FTxKh/ 4Qsg== Received: by 10.60.14.227 with SMTP id s3mr2969155oec.36.1344467283258; Wed, 08 Aug 2012 16:08:03 -0700 (PDT) Received: from localhost.localdomain (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id pj4sm23571216obb.20.2012.08.08.16.08.02 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 08 Aug 2012 16:08:02 -0700 (PDT) From: Fernando Guzman Lugo To: , , , Subject: [PATCH 2/3] remoteproc: recover a remoteproc when it has crashed Date: Wed, 8 Aug 2012 18:07:43 -0500 Message-Id: <1344467264-5128-3-git-send-email-fernando.lugo@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1344467264-5128-1-git-send-email-fernando.lugo@ti.com> References: <1344467264-5128-1-git-send-email-fernando.lugo@ti.com> X-Gm-Message-State: ALoCoQl4Rz8gGi+cci8LpaPdp2X0doZK707omrRx0UlReOdfwfOJXtPoDUnoT13gCP6oRDBa2Pci X-Spam-Note: CRM114 invocation failed X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [74.125.149.247 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Fernando Guzman Lugo X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch is introducing rproc_trigger_recover function which is in charge of recovering the rproc. One way to recover the rproc after a crash is resetting all its virtio devices. Doing that, all rpmsg drivers are restored along with the rpmsg devices and that also causes the reset of the remoteproc making the rpmsg communication with the remoteproc functional again. So far, rproc_trigger_recover function is only resetting all virtio devices, if in the future other rproc features are introduced and need to be reset too, rproc_trigger_recover function should take care of that. Signed-off-by: Fernando Guzman Lugo --- drivers/remoteproc/remoteproc_core.c | 28 +++++++++++++++++++++++++++- drivers/remoteproc/remoteproc_internal.h | 1 + 2 files changed, 28 insertions(+), 1 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 3a6f1a1..c879069 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -882,6 +882,32 @@ out: } /** + * rproc_trigger_recover() - recover a remoteproc + * @rproc: the remote processor + * + * The recovery is done by reseting all the virtio devices, that way all the + * rpmsg drivers will be reseted along with the remote processor making the + * remoteproc functional again. + * + * This function can sleep, so that it cannot be called from atomic context. + */ +int rproc_trigger_recover(struct rproc *rproc) +{ + struct rproc_vdev *rvdev, *rvtmp; + + dev_err(&rproc->dev, "recovering %s\n", rproc->name); + + /* clean up remote vdev entries */ + list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node) + rproc_remove_virtio_dev(rvdev); + + /* run rproc_fw_config_virtio to create vdevs again */ + return request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG, + rproc->firmware, &rproc->dev, GFP_KERNEL, + rproc, rproc_fw_config_virtio); +} + +/** * rproc_crash_handler_work() - handle a crash * * This function needs to handle everything related to a crash, like cpu @@ -906,7 +932,7 @@ static void rproc_crash_handler_work(struct work_struct *work) ++rproc->crash_cnt, rproc->name); mutex_unlock(&rproc->lock); - /* TODO: handle crash */ + rproc_trigger_recover(rproc); } /** diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index a690ebe..d9c0730 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -63,6 +63,7 @@ void rproc_free_vring(struct rproc_vring *rvring); int rproc_alloc_vring(struct rproc_vdev *rvdev, int i); void *rproc_da_to_va(struct rproc *rproc, u64 da, int len); +int rproc_trigger_recover(struct rproc *rproc); static inline int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw)