From patchwork Fri Oct 17 17:09:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 38915 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 59C4C202DB for ; Fri, 17 Oct 2014 17:10:53 +0000 (UTC) Received: by mail-la0-f70.google.com with SMTP id ge10sf713696lab.5 for ; Fri, 17 Oct 2014 10:10:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=uqV4kOlMAA+VQopQOqtKvju74SnPO+MiBz7fpn0AU+M=; b=F+dhqbW2FqGCQNAvI5GGqJvb8E6NRtL8TbMqmRMdlD2t/jiKYZk3TYzvnuZHoHHmqQ lPV8JFBf/BHH6v2r00a7FXAg7gO6Gf0sof/mzNlOpCs7F1mE2wJDWfEUUY7XBKC/g3sb VhE+xiOyHmAb5yxNYZmgZWkbF1HV5YBwT1JS2sCXMgSRQgYBy8SGQAvxGPycRqjBrpZ6 okzrf+VtOnnkilSoc6TEvDlh/ezGwDeHqIXBeU9mikfFi1rAenAVt8OWEYhBK9HC1fCi TEUq3mF49d0/jpFFjUrNXs36azIB2Do6nkQgrYMc8LnGvLTXkZ9BDxKLvNOWUij3Sje8 ZqFg== X-Gm-Message-State: ALoCoQl388ByVm1CSvbgagTNcmOOi+qjDRibf15IjEtJTCu6rKgwR5khJjT9TLOHfFq3KgPnSsrN X-Received: by 10.180.75.133 with SMTP id c5mr48515wiw.3.1413565852211; Fri, 17 Oct 2014 10:10:52 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.9.130 with SMTP id z2ls278862laa.61.gmail; Fri, 17 Oct 2014 10:10:52 -0700 (PDT) X-Received: by 10.152.205.103 with SMTP id lf7mr10300044lac.2.1413565852085; Fri, 17 Oct 2014 10:10:52 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id bg6si2989354lbc.42.2014.10.17.10.10.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Oct 2014 10:10:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id gm9so1073989lab.13 for ; Fri, 17 Oct 2014 10:10:52 -0700 (PDT) X-Received: by 10.152.120.200 with SMTP id le8mr9975597lab.67.1413565851980; Fri, 17 Oct 2014 10:10:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp266767lbz; Fri, 17 Oct 2014 10:10:51 -0700 (PDT) X-Received: by 10.68.139.226 with SMTP id rb2mr10071853pbb.78.1413565849962; Fri, 17 Oct 2014 10:10:49 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gl5si1534967pbc.229.2014.10.17.10.10.49 for ; Fri, 17 Oct 2014 10:10:49 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753612AbaJQRKs (ORCPT + 1 other); Fri, 17 Oct 2014 13:10:48 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:44010 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753593AbaJQRKq (ORCPT ); Fri, 17 Oct 2014 13:10:46 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s9HHAYnp007484; Fri, 17 Oct 2014 12:10:34 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9HHAYsM023208; Fri, 17 Oct 2014 12:10:34 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Fri, 17 Oct 2014 12:10:34 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9HHAXMO021788; Fri, 17 Oct 2014 12:10:34 -0500 From: Felipe Balbi To: Linux USB Mailing List CC: Thomas Gleixner , , Sebastian Andrzej Siewior , Felipe Balbi Subject: [PATCH 19/28] usb: musb: cppi41: restart hrtimer only if not yet done Date: Fri, 17 Oct 2014 12:09:55 -0500 Message-ID: <1413565804-13061-20-git-send-email-balbi@ti.com> X-Mailer: git-send-email 2.1.0.GIT In-Reply-To: <1413565804-13061-1-git-send-email-balbi@ti.com> References: <1413565804-13061-1-git-send-email-balbi@ti.com> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: balbi@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Thomas Gleixner commit c58d80f52 ("usb: musb: Ensure that cppi41 timer gets armed on premature DMA TX irq") fixed hrtimer scheduling bug. There is one left which does not trigger that often. The following scenario is still possible: lock(&x->lock); hrtimer_start(&x->t); unlock(&x->lock); expires: t->function(); lock(&x->lock); lock(&x->lock); if (!hrtimer_queued(&x->t)) hrtimer_start(&x->t); unlock(&x->lock); if (!list_empty(x->early_tx_list)) ret = HRTIMER_RESTART; -> hrtimer_forward_now(...) } else ret = HRTIMER_NORESTART; unlock(&x->lock); and the timer callback returns HRTIMER_RESTART for an armed timer. This is wrong and we run into the BUG_ON() in __run_hrtimer(). This can happens on SMP or PREEMPT-RT. The patch fixes the problem by only starting the timer if the timer is not yet queued. Cc: stable@vger.kernel.org Reported-by: Torben Hohn Signed-off-by: Thomas Gleixner [bigeasy: collected information and created a patch + description based on it] Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_cppi41.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c index acdfb3e..5a9b977 100644 --- a/drivers/usb/musb/musb_cppi41.c +++ b/drivers/usb/musb/musb_cppi41.c @@ -209,7 +209,8 @@ static enum hrtimer_restart cppi41_recheck_tx_req(struct hrtimer *timer) } } - if (!list_empty(&controller->early_tx_list)) { + if (!list_empty(&controller->early_tx_list) && + !hrtimer_is_queued(&controller->early_tx)) { ret = HRTIMER_RESTART; hrtimer_forward_now(&controller->early_tx, ktime_set(0, 20 * NSEC_PER_USEC));