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: 1298131 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id B3005DF223 for ; Wed, 8 Aug 2012 23:08:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759350Ab2HHXIS (ORCPT ); Wed, 8 Aug 2012 19:08:18 -0400 Received: from na3sys009aog111.obsmtp.com ([74.125.149.205]:34304 "EHLO na3sys009aog111.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758803Ab2HHXIF (ORCPT ); Wed, 8 Aug 2012 19:08:05 -0400 Received: from mail-yx0-f182.google.com ([209.85.213.182]) (using TLSv1) by na3sys009aob111.postini.com ([74.125.148.12]) with SMTP ID DSNKUCLxU2+rCsheL/C086jYYQA0bYu4coXu@postini.com; Wed, 08 Aug 2012 16:08:04 PDT Received: by yenl7 with SMTP id l7so2116072yen.27 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=dctBv5IlpMI6I5QLPbTKXbb9J24Eoq6V4OFnNfyZoe+vr/Q7CNCW3PbXnsfVpyLIKy e/esssP1qcNCJwGQzJKVSROTKYSCHMtY1sEG7ROrkX7FL7a7QEiKca8LtIpqKlmEbj12 Brt+LWdcIHy+OnvqS8grs1NeKU27AINtwJT8BvYyPuOF9xjM6JH9iiTC2BXrdpQ9fFv5 vUnfMSc7FrDv1jnPugfF8ctbNFGh1WZu1P6GL4mJ8RflXQOw4NFX54SEMRGY0AwPy4Ea +I+c/7dZsQ8KYl2pJM2+sJQvapdRh5WvNssLmfArRPD74oR0NW8Lii9GUfGTZsP4JiQV 5gWw== 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: , , , Cc: Fernando Guzman Lugo 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: ALoCoQkv7iCiKX1RHsJRH8SuxZsxDdR4Pn43Z5fNwZ2hpa1T5u8q2kc5tfMExaUNquk6jyvbwifl Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.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)