Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp314329imm; Thu, 7 Jun 2018 19:26:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKGkE2ymgK4HEuN4uDUJpsOp1sA0bK9VEZkY4fs5bBCu8PiXRVSap1Nv2Jv3pIH3i2IGERc X-Received: by 2002:a65:6517:: with SMTP id x23-v6mr3592800pgv.268.1528424818078; Thu, 07 Jun 2018 19:26:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528424818; cv=none; d=google.com; s=arc-20160816; b=vfOcUCCXx5GS5Sga1Pnij/Rf0ZEqPGn1taX3NCNZbUYNwFHTpjoS3usXUbpDu8GVrk sBXcVZhmP6X4qNf0X/3b3g4r2b5RXu/LgakJcZGpDmdBr6kwQgCgxfJKQRqdwK7nvjJ4 3Y3jPtVYgHfIII/sA/CuB/YrBV7/YPDYVK7hOSEAjMsdGN2LDpKe9i/KmWSueA4hU2XT xyWA5+OvbJCe6SdYrQR7P5RIUzCWc8eouOfTwUAgJdYoHs5G+cZScvMTP7JezN+XwB7a Z7BtzjGpwnG30FJQgScLpodcdYUpry8Hx4jHH4jhW0rpWpXJtAxVZHeihe5LpXyFhT54 vumg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:from:references:in-reply-to :message-id:cc:to:arc-authentication-results; bh=EMDdwwGDlNNi4BtlQK9/tZI6CV2PoMnOoPxBV2/Z7ck=; b=pnfWc9l7J2MEmOz5xw0EcoXBtpwoNP9sstoTyeUyvyfhHg13FNbtMACalLkopxv8Re otgNMPLvivsUpiIb7JEXs0TxUextjxnBmj7a9VWdnSniSk83NQEM6Q9KCMO+kREDPKcf p96kRHzTM1ucyR6fxpv56iehsF70svcTu9pVy7wIE1qZbY0l6VVnb5iwkqpstPdK9nYD v5/4n8WGLBJRWd5WO5j2f70gP17m3nmRITSIHq4OguNDOtnshgW7wmw4mAPkFJQ6rqWB fHOhQBK7vCHA0ktL3TAawf+QhJhHf0S7ImCtVMlHwSJ0kimMahdNvI9pyZ1ZAYsaRhjC r8LA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k79-v6si3837197pfb.34.2018.06.07.19.26.43; Thu, 07 Jun 2018 19:26:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752845AbeFHCY7 (ORCPT + 99 others); Thu, 7 Jun 2018 22:24:59 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:58598 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752673AbeFHCYb (ORCPT ); Thu, 7 Jun 2018 22:24:31 -0400 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 9C4742A33B; Thu, 7 Jun 2018 22:24:29 -0400 (EDT) To: Benjamin Herrenschmidt Cc: Michael Schmitz , , , Message-Id: <2b0138faa6313416576fcf760226ef70e8655cd3.1528423341.git.fthain@telegraphics.com.au> In-Reply-To: References: From: Finn Thain Subject: [PATCH v2 12/12] macintosh/via-pmu: Disambiguate interrupt statistics Date: Thu, 7 Jun 2018 22:24:29 -0400 (EDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some of the event counters are overloaded which makes it very difficult to interpret their values. Counter 0 is supposed to report CB1 interrupts but it can also count PMU_INT_WAITING_CHARGER events. Counter 1 is supposed to report GPIO interrupts but it can also count other events (depending upon the value of the PMU_INT_ADB bit). Disambiguate these statistics with dedicated counters for GPIO and CB1 interrupts. Comments in the MkLinux source code say that the type 0 and type 1 interrupts are model-specific. Label them as "unknown". This change to the contents of /proc/pmu/interrupts is by necessity visible in userland. However, packages which interact with the PMU (that is, pbbuttonsd, pmac-utils and pmud) don't open this file. AFAIK, user software has no need to poll these counters. Tested-by: Stan Johnson Signed-off-by: Finn Thain --- The file now looks like this, 0: 0 (Unknown interrupt (type 0)) 1: 0 (Unknown interrupt (type 1)) 2: 0 (PC-Card eject button) 3: 23 (Sound/Brightness button) 4: 74 (ADB message) 5: 0 (Battery state change) 6: 0 (Environment interrupt) 7: 121 (Tick timer) 8: 0 (Ghost interrupt (zero len)) 9: 1 (Empty interrupt (empty mask)) 10: 2 (Max irqs in a row) 11: 194 (Total CB1 triggered events) 12: 0 (Total GPIO1 triggered events) rather than this, 0: 194 (Total CB1 triggered events) 1: 0 (Total GPIO1 triggered events) 2: 0 (PC-Card eject button) 3: 23 (Sound/Brightness button) 4: 74 (ADB message) 5: 0 (Battery state change) 6: 0 (Environment interrupt) 7: 121 (Tick timer) 8: 0 (Ghost interrupt (zero len)) 9: 1 (Empty interrupt (empty mask)) 10: 2 (Max irqs in a row) If some parser exists for this file, and if this change is problematic, we could increment the driver version number in /proc/pmu/info, to correspond with the format change. --- drivers/macintosh/via-pmu.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index 730c10f7fbb7..44919b3b56e0 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c @@ -172,7 +172,9 @@ static int drop_interrupts; static int option_lid_wakeup = 1; #endif /* CONFIG_SUSPEND && CONFIG_PPC32 */ static unsigned long async_req_locks; -static unsigned int pmu_irq_stats[11]; + +#define NUM_IRQ_STATS 13 +static unsigned int pmu_irq_stats[NUM_IRQ_STATS]; static struct proc_dir_entry *proc_pmu_root; static struct proc_dir_entry *proc_pmu_info; @@ -884,9 +886,9 @@ static const struct file_operations pmu_info_proc_fops = { static int pmu_irqstats_proc_show(struct seq_file *m, void *v) { int i; - static const char *irq_names[] = { - "Total CB1 triggered events", - "Total GPIO1 triggered events", + static const char *irq_names[NUM_IRQ_STATS] = { + "Unknown interrupt (type 0)", + "Unknown interrupt (type 1)", "PC-Card eject button", "Sound/Brightness button", "ADB message", @@ -895,10 +897,12 @@ static int pmu_irqstats_proc_show(struct seq_file *m, void *v) "Tick timer", "Ghost interrupt (zero len)", "Empty interrupt (empty mask)", - "Max irqs in a row" + "Max irqs in a row", + "Total CB1 triggered events", + "Total GPIO1 triggered events", }; - for (i=0; i<11; i++) { + for (i = 0; i < NUM_IRQ_STATS; i++) { seq_printf(m, " %2u: %10u (%s)\n", i, pmu_irq_stats[i], irq_names[i]); } @@ -1659,7 +1663,7 @@ via_pmu_interrupt(int irq, void *arg) } if (intr & CB1_INT) { adb_int_pending = 1; - pmu_irq_stats[0]++; + pmu_irq_stats[11]++; } if (intr & SR_INT) { req = pmu_sr_intr(); @@ -1746,7 +1750,7 @@ gpio1_interrupt(int irq, void *arg) disable_irq_nosync(gpio_irq); gpio_irq_enabled = 0; } - pmu_irq_stats[1]++; + pmu_irq_stats[12]++; adb_int_pending = 1; spin_unlock_irqrestore(&pmu_lock, flags); via_pmu_interrupt(0, NULL); -- 2.16.4