From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13BE52D8DDD for ; Fri, 14 Nov 2025 18:34:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763145281; cv=none; b=CNJ9J66CveNOfKeYRCg9x8GdYHKdC+hr0i4MJ5DgbLHhs6hYDnVQoupcOv+30uTWPON55a7a6IwXw9xk1jYTSVvr5g6RtwklMbumQ+9CDlbGeEs8kdurBa47LQPXwpDC1u9dFDL7Os98+G8CMc6w4sUTMi5DMP1XZCSlAoncF6o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763145281; c=relaxed/simple; bh=/yPnhTT0De9Q0vqCerBIyCG28nUAMEhj459c3j0cDH0=; h=From:To:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=G8OyuaRe+Sur+tBZaZoqrc5XtfdNHVHRUTZCQKNLSbum8Wsa2c5FnaNEFXCQHM3O1kCWISr9hllateDd/6zFhICwqEfh/ZhtQvRfd+Fi7WKWDGFUmJ5zXEeXB3tgzG5uh5wfYx7axSwjMs1B1KHDdZyaK2zvF8ErdFvmIz68N9k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=c+k44BK2; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=MLeIQZxX; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="c+k44BK2"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="MLeIQZxX" From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1763145278; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AYY3/QPMp2V/LMnXZ8VpToENnCUDc/Jx+oQ1VxLIdus=; b=c+k44BK2rsSwpmmuBpNCHDRakeCrkA2tBZIgs1tl6znYtKW+YY6kcASml2yZJbJnoJNyk9 lhi316GO2DEaqjrChxGWZv6IILTWsR1kELYLzAC3LweQmWhe6kKn3FwYffmUg6XRKScxRT d9APuAIlCdo9m1/MtmzYiriIIOawLRIrqSsld0lwzYLJMpLI0E64QNs4jmPAQrOKC/JFNO nHn3Vttw+GbdEOZUDDwVIz/o1SDpJ4mkBLyLu3IKcDl+SMvPblbm+qKUQ5L/Zvu72N/+Ea z+k/T1Ha9Fjutreid6ZEdXSjDpe19CXFv9L3tSCDYb28Vx1vt5bXEKhqcVTsWA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1763145278; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AYY3/QPMp2V/LMnXZ8VpToENnCUDc/Jx+oQ1VxLIdus=; b=MLeIQZxXmuBoBgusUtjfWASxvm3P3tcxDMYSLPDx4Bb9jKWQFcG6h1Un1wAy6NaIA3EnBJ +HBU7/YrMhkwpNAg== To: Enlin Mu , anna-maria@linutronix.de, frederic@kernel.org, linux-kernel@vger.kernel.org, enlin.mu@unisoc.com, enlin.mu@linux.dev Subject: Re: [PATCH V2] hrtimer: Check running timer state In-Reply-To: <20251114114230.3802-1-enlin.mu@linux.dev> References: <20251114114230.3802-1-enlin.mu@linux.dev> Date: Fri, 14 Nov 2025 19:34:36 +0100 Message-ID: <87o6p4bgzn.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Fri, Nov 14 2025 at 19:42, Enlin Mu wrote: > When the running timer is not NULL, print debugging information. What for? > The test code is roughly as follows: > > static struct hrtimer serial_timer; > enum hrtimer_restart serial_timer_handler(struct hrtimer * timer) > { > local_irq_disable(); What is this for? > ...... > do_someting(); > copy_data_with_dma(); > ...... > hrtimer_forward_now(*serial_timer, ns_to_ktime(1000*2000)); > local_irq_enable(); And this? > return HRTIMER_RESTART; > } > > static int serial_start(struct uart_port *port) > { > ...... > ...... > hrtime_init(&serial_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); That function does not exist. > ktime = no_to_ktime(1000*2000); > serial_timer.function = serial_timer_handler; > hrtimer_start(&serial_timer, ktime, HRTIMER_MODE_REL); > ...... > return 0; > } > > static void serial_shutdown(struct uart_port *port) > { > ...... > hrtimer_cancle(&serial_timer); > ...... > serial_release_dma(port); > ...... > } > The cpu6 canceled serial_timer and released dma,but the > serial_timer still ran many times on CPU7 until a panic occurred. > The reason for the panic is that serial_timer accessed the > released dma,But the serial_timer had been canceled for > some time now on cpu6. You still fail to explain how the timer can still run after being canceled. > The cpu6 can successfully cancel the serial_timer because the > running timer has changed and it is another timer(such as > hrtimer_usb). After that the timer _cannot_ be running anymore unless some other code re-arms it afterwards. > When the serial_timer is enable to interrupt, the next hrtimer > (such as hrtimer_usb) on cpu7 preempts the return of ther serial_timer, > causing a change in the running timer. Then fix your timer callback. The callback is invoked in hard interrupt context and the callback enables interrupts, which is a NONO. You clearly never ran your code with lockdep enabled. It would have told you so. > Signed-off-by: Enlin Mu > Signed-off-by: Enlin Mu > Signed-off-by: Enlin Mu Interesting Signed-off-by chain. Seems you're co-developing this patch with your Alter ego. Thanks, tglx