From patchwork Tue Oct 21 11:07:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Kumar K X-Patchwork-Id: 26497 X-Patchwork-Delegate: kamil@wypas.org Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1XgXIQ-0002Xd-3r; Tue, 21 Oct 2014 13:08:10 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.72/mailfrontend-6) with esmtp id 1XgXIO-0004W4-3j; Tue, 21 Oct 2014 13:08:10 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932330AbaJULHy (ORCPT + 1 other); Tue, 21 Oct 2014 07:07:54 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:54058 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932321AbaJULHw (ORCPT ); Tue, 21 Oct 2014 07:07:52 -0400 Received: by mail-pa0-f53.google.com with SMTP id kq14so1167080pab.26 for ; Tue, 21 Oct 2014 04:07:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=8PJ1UnfYjhWnlnbZvoR0wIIfwhj7nI27N02SMX7iECs=; b=Cpmd0MpBHpbNV6gJCEbnsvCRBID28lm6z5/6w03AgmY5U8IRHNQeIoKOBlcx+AnP9x 8hKSqJBYjZp1jkZcFwrDIvFvB5aiey0lnMKCFG5fdT5tB5FrmOfW4RjCXZUw6pihil+A zB0320WgdRTrougvJE8iJFPsM5NuNOpu4fiJxKECJy2yQzKdve7w4OemN19zIqtB1UyT 6EExdUwTYej13y1FXhrEkgqqnPTqLFsu7OMLUYb5T/9caAjvHUK5ekcES+bvJMwi7xNN OBs/O3URYKXyFPYJ6C0SbkLfgyjj2fZbLkC81DIJXQARf0//xVfrJDdMWdq1uGeejVIo BhSQ== X-Received: by 10.70.102.205 with SMTP id fq13mr9888436pdb.136.1413889671991; Tue, 21 Oct 2014 04:07:51 -0700 (PDT) Received: from localhost.localdomain ([14.140.216.146]) by mx.google.com with ESMTPSA id s9sm11680849pdp.1.2014.10.21.04.07.47 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 Oct 2014 04:07:51 -0700 (PDT) From: Arun Kumar K To: linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: k.debski@samsung.com, wuchengli@chromium.org, posciak@chromium.org, arun.m@samsung.com, ihf@chromium.org, prathyush.k@samsung.com, kiran@chromium.org, arunkk.samsung@gmail.com Subject: [PATCH v3 07/13] [media] s5p-mfc: Don't crash the kernel if the watchdog kicks in. Date: Tue, 21 Oct 2014 16:37:01 +0530 Message-Id: <1413889627-8431-8-git-send-email-arun.kk@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1413889627-8431-1-git-send-email-arun.kk@samsung.com> References: <1413889627-8431-1-git-send-email-arun.kk@samsung.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2014.10.21.110025 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DKIM_SIGNATURE 0, FROM_NAME_PHRASE 0, SUBJ_PHRASE_WATCHES 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS , __YOUTUBE_RCVD 0' From: Pawel Osciak If the software watchdog kicks in, the watchdog worker is not synchronized with hardware interrupts and does not block other instances. It's possible for it to clear the hw_lock, making other instances trigger a BUG() on hw_lock checks. Since it's not fatal to clear the hw_lock to zero twice, just WARN in those cases for now. We should not explode, as firmware will return errors as needed for other instances after it's reloaded, or they will time out. A clean fix should involve killing other instances when watchdog kicks in, but requires a major redesign of locking in the driver. Signed-off-by: Pawel Osciak Signed-off-by: Kiran AVND Signed-off-by: Arun Kumar K --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index eb71055..8620236 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -342,8 +342,7 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx, ctx->state = MFCINST_RES_CHANGE_INIT; s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); wake_up_ctx(ctx, reason, err); - if (test_and_clear_bit(0, &dev->hw_lock) == 0) - BUG(); + WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); s5p_mfc_clock_off(); s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); return; @@ -415,8 +414,7 @@ leave_handle_frame: clear_work_bit(ctx); s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); wake_up_ctx(ctx, reason, err); - if (test_and_clear_bit(0, &dev->hw_lock) == 0) - BUG(); + WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); s5p_mfc_clock_off(); /* if suspending, wake up device and do not try_run again*/ if (test_bit(0, &dev->enter_suspend)) @@ -463,8 +461,7 @@ static void s5p_mfc_handle_error(struct s5p_mfc_dev *dev, break; } } - if (test_and_clear_bit(0, &dev->hw_lock) == 0) - BUG(); + WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); s5p_mfc_clock_off(); wake_up_dev(dev, reason, err); @@ -518,8 +515,7 @@ static void s5p_mfc_handle_seq_done(struct s5p_mfc_ctx *ctx, } s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); clear_work_bit(ctx); - if (test_and_clear_bit(0, &dev->hw_lock) == 0) - BUG(); + WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); s5p_mfc_clock_off(); s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); wake_up_ctx(ctx, reason, err); @@ -557,16 +553,14 @@ static void s5p_mfc_handle_init_buffers(struct s5p_mfc_ctx *ctx, } else { ctx->dpb_flush_flag = 0; } - if (test_and_clear_bit(0, &dev->hw_lock) == 0) - BUG(); + WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); s5p_mfc_clock_off(); wake_up(&ctx->queue); s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); } else { - if (test_and_clear_bit(0, &dev->hw_lock) == 0) - BUG(); + WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); s5p_mfc_clock_off(); @@ -643,8 +637,7 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv) mfc_err("post_frame_start() failed\n"); s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); wake_up_ctx(ctx, reason, err); - if (test_and_clear_bit(0, &dev->hw_lock) == 0) - BUG(); + WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); s5p_mfc_clock_off(); s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); } else {