From patchwork Mon Jan 24 14:39:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1583513 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=YNRYuhHJ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjCLh01BMz9t5m for ; Tue, 25 Jan 2022 01:39:55 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4JjCLg2VHFz3bYw for ; Tue, 25 Jan 2022 01:39:55 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=YNRYuhHJ; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::1031; helo=mail-pj1-x1031.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=YNRYuhHJ; dkim-atps=neutral Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4JjCLN5hTtz30N0 for ; Tue, 25 Jan 2022 01:39:38 +1100 (AEDT) Received: by mail-pj1-x1031.google.com with SMTP id pf13so16706685pjb.0 for ; Mon, 24 Jan 2022 06:39:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LEmuMQlrY9DfxLeNF4WP/5Py7qqcPlKWwDwFkAmbfpY=; b=YNRYuhHJKHbPIhv24T7B0PISB+NJGt0IHCDMqiOzXPodq3nZhy2w4+29/mnkm9UBMH tiEVHmzjpfIVt1C+2qk1B53M8k6vl5UJqEDzEw2FjcG04ejYeepJ5TtnKS2LNBNpwNjO JMiDX3uvYd6xd/isybjEfuWdjPBOEXWWIxnttywQ9HfaxrC/GIdcFiC8216fXaazsF2v wF/oyMYrCr/lBI6kzz5HxYbu7gJbt8Nrhk4vnXjCykDNHkYvcKyAQt/7/X+FyZ0x436j Xi8qTyV3IgLYLSQ0lZof1eZYEuXzlnCRjqT5JlkfIQyuCtLk0HYZrLAnyPvgVwy62icX KvBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LEmuMQlrY9DfxLeNF4WP/5Py7qqcPlKWwDwFkAmbfpY=; b=r9RoH+rEeGKZyZHviU+SVjpXD8POK5W1ppheBq9gtGleRL+/Ifn6nT6LmTXL/VCWrf FvuWfJ1vc3EmlLPGvhSqLFnWOJn+Xi0+7yIYIEDmFbokhzAWYAs8PfQgo5KumMVk0N4f DEuuKtX31YmbPrSvzJheQ0eREBNZHpBQZQDJQlC1lelvrAy/aDXKMEbXlh84y9qnj6aL J4AWvkaKyqvtRvjFZtLh2fTfFALlUI1yD7A08YforHCx/DnV+GP1LWctG94xBmSnLjJs AIcCA0RpFPo7Ve90KU9pkOdv3Jb6VcFKnK7K6HIhibq6UUO2AdvDXIRS9+vtLvmB1Jit tHTA== X-Gm-Message-State: AOAM5338d8vdqi+E9ljlPaTWeBinMm9EaUkB1FlPFpy5ja8qLRyynRRM TqpYSD10u0tXzDNW/SQ9M3G4knAT2is= X-Google-Smtp-Source: ABdhPJwOHirAdFZ/Jnw0LxMeNalucCRnXx1yMP1Z7Dgy/wcFwhP18/mW4klks3f+ToT+1Udsc6g4mA== X-Received: by 2002:a17:902:ab12:b0:149:c5a5:5323 with SMTP id ik18-20020a170902ab1200b00149c5a55323mr14741801plb.97.1643035176542; Mon, 24 Jan 2022 06:39:36 -0800 (PST) Received: from bobo.ozlabs.ibm.com (193-116-82-75.tpgi.com.au. [193.116.82.75]) by smtp.gmail.com with ESMTPSA id k16sm12748001pgm.26.2022.01.24.06.39.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 06:39:36 -0800 (PST) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 1/3] powerpc/64s/interrupt: Fix decrementer storm Date: Tue, 25 Jan 2022 00:39:28 +1000 Message-Id: <20220124143930.3923442-1-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Nicholas Piggin Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The decrementer exception can fail to be cleared when the interrupt returns in the case where the decrementer wraps with the next timer still beyond decrementer_max. This results in a decrementer interrupt storm. This is triggerable with small decrementer system with hard and soft watchdogs disabled. Fix this by always programming the decrementer if there was no timer. Fixes: 0faf20a1ad16 ("powerpc/64s/interrupt: Don't enable MSR[EE] in irq handlers unless perf is in use") Reported-by: Alexey Kardashevskiy Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/time.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 62361cc7281c..cd0b8b71ecdd 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -649,8 +649,9 @@ DEFINE_INTERRUPT_HANDLER_ASYNC(timer_interrupt) __this_cpu_inc(irq_stat.timer_irqs_event); } else { now = *next_tb - now; - if (now <= decrementer_max) - set_dec_or_work(now); + if (now > decrementer_max) + now = decrementer_max; + set_dec_or_work(now); __this_cpu_inc(irq_stat.timer_irqs_others); } From patchwork Mon Jan 24 14:39:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1583514 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=D61N7jn+; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjCML4ncKz9t5m for ; Tue, 25 Jan 2022 01:40:30 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4JjCML49jNz3cPg for ; Tue, 25 Jan 2022 01:40:30 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=D61N7jn+; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::530; helo=mail-pg1-x530.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=D61N7jn+; dkim-atps=neutral Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4JjCLQ6j77z30N0 for ; Tue, 25 Jan 2022 01:39:42 +1100 (AEDT) Received: by mail-pg1-x530.google.com with SMTP id q75so15573909pgq.5 for ; Mon, 24 Jan 2022 06:39:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G0a5OoRfjvn4retKMpcQQcdxSBRwvpndVWNz0dW1Gm0=; b=D61N7jn+7Bas8QmT1jBsiCkE8qHjHJN8aIF2NNfu9EsS95+0x6cHaZzhL1/RzXrkKE eFEef029/jSlo7958bhdbAt+iqhhxJQVFEbTQzZ+JZRqjs7k9uQ9YzL8HVvxAs1BGpL1 MBq00QhNANI2rgAqPfMwaUCApKIr+vXn95rXoWMQ0QnkLYdcugqyBHIUetD4UiEH03p+ qtvFp4QzPeYbnr1h1dEQhVgLGoqUx1UP1CSAd5096ZRXIo1XoclphvuWFVu7vstD9T39 E00b3Y3N4uKA0LANso6IadZPT+P+KJHQEFbR/t03W3btaGhSe9eNpZrve6OB4o4fk/ZR /t+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G0a5OoRfjvn4retKMpcQQcdxSBRwvpndVWNz0dW1Gm0=; b=ApQZZdWk4E9FacEmyYfW/YKsAw5QEvrhlvuLX3FtzTwj9Odn7ShqvkSvqNYxntgaaC 0XOt5lbIpP3scZo3mT+F0QL7uKSKFxOFfLTq3n6xWf4jiFaKGg/Cz0LC33aI1R6BAHYX pC00GnQ5XZt6fOV6aXHqRX0n5FzK6p+Ax5lzm9fvHG50wL5pGGqQJlNIQSzGh/2dsQ27 AcAi0daf5A9indv5BuRGb39r9e2jrMbydcDjJ7l1yjAqc1vKrURHf9ZR2jMIkraGPpUZ h9XGXduggYRNsPf5cMnBB1YoZQ0IbZRU503FGHqIlXNBKzSBF2vhitwwPr6GefJjE6mv /rSw== X-Gm-Message-State: AOAM530yQ91DUtSyYrZsU+q44XFL3hgZ8FddTDAq9UHEOiz4WiNvDUbt p7aoohEz3vCNLnoj/vx3wO3vzBwW4c4= X-Google-Smtp-Source: ABdhPJyJPVfBMka/FstsQv1SnYgHq50X19RMRVRL6bMCy8WkNW+jJzkmqWhba3EweIvJvfqNTIaLcw== X-Received: by 2002:a63:6a41:: with SMTP id f62mr11813242pgc.364.1643035178830; Mon, 24 Jan 2022 06:39:38 -0800 (PST) Received: from bobo.ozlabs.ibm.com (193-116-82-75.tpgi.com.au. [193.116.82.75]) by smtp.gmail.com with ESMTPSA id k16sm12748001pgm.26.2022.01.24.06.39.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 06:39:38 -0800 (PST) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 2/3] powerpc/time: Fix KVM host re-arming a timer beyond decrementer range Date: Tue, 25 Jan 2022 00:39:29 +1000 Message-Id: <20220124143930.3923442-2-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220124143930.3923442-1-npiggin@gmail.com> References: <20220124143930.3923442-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Nicholas Piggin Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" If the next host timer is beyond decrementer range, timer_rearm_host_dec will leave decrementer not programmed. This will not cause a problem for the host it will just set the decrementer correctly when the decrementer interrupt hits, it seems safer not to leave the next host decrementer interrupt timing able to be influenced by a guest. This code is only used in the P9 KVM paths so it's unlikely to be hit practically unless large decrementer is force disabled in the host. Fixes: 25aa145856cd ("powerpc/time: add API for KVM to re-arm the host timer/decrementer") Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/time.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index cd0b8b71ecdd..384f58a3f373 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -582,8 +582,9 @@ void timer_rearm_host_dec(u64 now) local_paca->irq_happened |= PACA_IRQ_DEC; } else { now = *next_tb - now; - if (now <= decrementer_max) - set_dec_or_work(now); + if (now > decrementer_max) + now = decrementer_max; + set_dec_or_work(now); } } EXPORT_SYMBOL_GPL(timer_rearm_host_dec); From patchwork Mon Jan 24 14:39:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1583515 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=PqjGu2aP; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjCN43TDTz9t5m for ; Tue, 25 Jan 2022 01:41:08 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4JjCN35BjZz3cCK for ; Tue, 25 Jan 2022 01:41:07 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=PqjGu2aP; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::533; helo=mail-pg1-x533.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=PqjGu2aP; dkim-atps=neutral Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4JjCLR5qJFz30N0 for ; Tue, 25 Jan 2022 01:39:43 +1100 (AEDT) Received: by mail-pg1-x533.google.com with SMTP id i8so15523031pgt.13 for ; Mon, 24 Jan 2022 06:39:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JXg8E5Lndpzi6IklKyVrPNfHKkjhFg0trjH6MKcvRkU=; b=PqjGu2aPxjEU96qr16Z8EZt12kZq5PzGj/1JeJmVH2FJik59bzBUumkvKN5ZXiX8jR GKXDvMC1LVYMhTbS4eMKLlh33cCAWwMNr1Rc/fbFmDXqRxIiXrspT5SFJYTf5LcXaXrE /RHFAskNCLEuUTdf6r7d4j9S3EfV55w781Se3bKqcSlieuUjUIIRvxqRltFJplCuYSdh Mnsk+lnneOPizC0DsVcb0oeJRi+pRlvsB1gWHJyKUUj8NOt1YewMygwZ1ih4G6X2vRZg zL/bzcqMTIkZuxbBC0rQjDg/znUZDXBLnKhMcn1gudroGtIzCruvN3Iw2EZekidrFp3J mYig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JXg8E5Lndpzi6IklKyVrPNfHKkjhFg0trjH6MKcvRkU=; b=nTfAqFQyaJaEtCjsySyVdWKWJNUHm0eELKNvzB74nfOQ96iOpI99VtIr58HAj+PPMN qhFNmsKZljGOpi6mAvmLYwS5/zxHh6kF/LV8zePUbOeRCEK6wKK7BGanLPsv2rUQ5zWp 4ERDq2+HmHwGbgwdPP29iY8z09Dc/6xIwiF2ytV7+tXPyEYLmv5DneBIhJbRnlzaiYjt I7C4gWKIFRZSx3d5xGlrWiHgAG1BtsqhdrMlDn+G4a1DgkyU1qoFwK2cqOeta5B+j1/n geeFxiqyqvtscCnIBj1HEsBFLz0dOi7xuP9x3n1wHt1VsfCnv9qN4kxaspR+KN14O40d XwDw== X-Gm-Message-State: AOAM532HWOYLT+csqfFrkMt06Vp//cgZStdd0OqcPXPMm6C9+35irM5U TVPay71Fwzogg569Y+8or/t0vpvrElE= X-Google-Smtp-Source: ABdhPJw3Duklt5v/SfTcwYyMT+0noVnlmRJHy2E3gOOV7UaqKunYKmYURul7hJV0C4rvLXpwcmP6bw== X-Received: by 2002:a63:7f12:: with SMTP id a18mr3157715pgd.453.1643035181032; Mon, 24 Jan 2022 06:39:41 -0800 (PST) Received: from bobo.ozlabs.ibm.com (193-116-82-75.tpgi.com.au. [193.116.82.75]) by smtp.gmail.com with ESMTPSA id k16sm12748001pgm.26.2022.01.24.06.39.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 06:39:40 -0800 (PST) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 3/3] powerpc/time: improve decrementer clockevent processing Date: Tue, 25 Jan 2022 00:39:30 +1000 Message-Id: <20220124143930.3923442-3-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220124143930.3923442-1-npiggin@gmail.com> References: <20220124143930.3923442-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Nicholas Piggin Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The stop/shutdown op should not use decrementer_set_next_event because that sets decrementers_next_tb to now + decrementer_max, which means a decrementer interrupt that occurs after that time will call the clockevent event handler unexpectedly. Set next_tb to ~0 here to prevent any clock event call. Init all clockevents to stopped. Then the decrementer clockevent device always has event_handler set and applicable because we know the clock event device was not stopped. So make this call unconditional to show that it is always called. next_tb need not be set to ~0 before the event handler is called because it will stop the clockevent device if there is no other timer. Finally, the timer broadcast interrupt should not modify next_tb because it is not involved with the local decrementer clockevent on this CPU. This doesn't fix a known bug, just tidies the code. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/time.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 384f58a3f373..f3845601ab6a 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -107,7 +107,12 @@ struct clock_event_device decrementer_clockevent = { }; EXPORT_SYMBOL(decrementer_clockevent); -DEFINE_PER_CPU(u64, decrementers_next_tb); +/* + * This always puts next_tb beyond now, so the clock event will never fire + * with the usual comparison, no need for a separate test for stopped. + */ +#define DEC_CLOCKEVENT_STOPPED ~0ULL +DEFINE_PER_CPU(u64, decrementers_next_tb) = DEC_CLOCKEVENT_STOPPED; EXPORT_SYMBOL_GPL(decrementers_next_tb); static DEFINE_PER_CPU(struct clock_event_device, decrementers); @@ -644,9 +649,7 @@ DEFINE_INTERRUPT_HANDLER_ASYNC(timer_interrupt) now = get_tb(); if (now >= *next_tb) { - *next_tb = ~(u64)0; - if (evt->event_handler) - evt->event_handler(evt); + evt->event_handler(evt); __this_cpu_inc(irq_stat.timer_irqs_event); } else { now = *next_tb - now; @@ -665,9 +668,6 @@ EXPORT_SYMBOL(timer_interrupt); #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST void timer_broadcast_interrupt(void) { - u64 *next_tb = this_cpu_ptr(&decrementers_next_tb); - - *next_tb = ~(u64)0; tick_receive_broadcast(); __this_cpu_inc(irq_stat.broadcast_irqs_event); } @@ -893,7 +893,9 @@ static int decrementer_set_next_event(unsigned long evt, static int decrementer_shutdown(struct clock_event_device *dev) { - decrementer_set_next_event(decrementer_max, dev); + __this_cpu_write(decrementers_next_tb, DEC_CLOCKEVENT_STOPPED); + set_dec_or_work(decrementer_max); + return 0; }