From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FEF5280035 for ; Sun, 5 Jul 2026 07:48:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783237686; cv=none; b=PWmrhXLzm9NqvMTTHsz4LgPjUg5id7SNgBLYpr99e1EUwm6m6qzOLN3fDq2s/Su7/X5EES29yqliuvlZWzZniDINMfHaj42JJgKzn/6Kuu0WfxsYx1q0ik+rwwOfDLjBNJZ+VdNv6I3Xe4kiLYSFQHKFe6j1WxbMOvQsT9ygbl4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783237686; c=relaxed/simple; bh=Dbilg9/n2unXm7B+wlncUdwupZtYPq3wzAaKZ1VRYoI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Itm52rDYjq3DYOAEK6vY1BblHdHpKaUeRJtoTz5fRuI0GXoh+45D+w+UzkXc0ZXZtqMzNEG/2EsSusbSEpF8bFWC06NbaA48GYRYejBhP6AjI6WuSpj9tQpq2OFGObJ58dSbHtGhuQnmMgjyJXnitLm+EAs3OHeeHSdfxDtl5b4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MUyxLTsF; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MUyxLTsF" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2cc84e77e78so2323915ad.2 for ; Sun, 05 Jul 2026 00:48:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783237685; x=1783842485; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=B7rYvqmtxh7QVbsMGEyyEdKfUiA/iq7LRZnhoQl1CVw=; b=MUyxLTsFPC5js0suuJXRHaatqV3Y2YNTQTlNXiCc+unIP7DqQeIT4xPs2NS2E856Ih S/29s2FM8/XyPZruYAmhKICUpkG1Aiv2UDXMYyH/W7PszjWYnBgP14+AoVQNMnMtsbnX +ZX7GbCsqSGGL/WZTtYqHGcU1DsuDNgdtdPq5Jl4LyeFgJ60L4qfHku7aYMC0x5Sm4JP hOL3HkmQBMBZfcugfbwCOk/b/ngP90RTs3+RkElVrOoi7SHEzB7gM0FAcdlV722valOY il5SqR+hT3yPaq65qgsBKwB/5+hTWNo+nOGUxbhDzhKXWemnm33fqMwO1h9x7R1ydR0A yihg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783237685; x=1783842485; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=B7rYvqmtxh7QVbsMGEyyEdKfUiA/iq7LRZnhoQl1CVw=; b=jCpsYCdNbee+ICtLts1RzNIqDGhdH+DPTZtOJJ0TaqPkiC4Lr6gZDADKwHn5gJu+yg 5riI36gr+LKr/hfs2O9AEiSelq1bq6/SVddn4c8WzyueR1HwACmRVExdgSDct6RacEUC DT6/nm6Cb1IU4EOOt75QgvW68BFg7yK/dJUC9BAHTNjE4wyVktOCfUUeHt8PNf0af12z hFIv5kjU3eZ1xYFWt26phi5WxnkPn3KYgWbCJIDl9IK/BXdG7RBQtao4jZIkgGzTSmKZ iw1zqV/4akHm9C3eGlvGQwGLcqXiJNYNjXuNyYwuBgGdDAuuEzRfhQyOK8N0NER+JEIA EJgQ== X-Forwarded-Encrypted: i=1; AHgh+RrMQk5pdxn51pbJeJ2inPm2IM5XMmOBdAnnSjRyETKUX84HIGnohEQeT6kf470YuLzTs+MzscuSj3/n7rg=@vger.kernel.org X-Gm-Message-State: AOJu0YyF+a60MPMzbgJSv9mgPG+EUpqj+rvjYlmyrRca/jCdfL1RuydT fZd659viyQ1gEZ8Rd/5a1KJQno/0MJEFNXJmbXc1w0zxjI9zaAzTQlz7 X-Gm-Gg: AfdE7cnD4d1SCH1InWIPmGg/7iNNAn3+ygXLc9Z1qJrwZXIbAQWmsnFf43+G8rc3TTX M1roo+3Cw3TjiP9DPUhtDdi+KBWq5iKDE0Y6ddIRRPlv+aZRs/CP89pXXuXwNoFOVZgZrWHeywD MXEPML2faxxg1najyQ7UJ4PhUYhjYxp6p/dPq7pmklAl4TtVO7QvMRJ8+vCf0uQ+GPKJn+b9kiM PJnCC+QcAy3sD53g2s1cASMnQlRHjbrJLrLjQuqHa+GO4PDt+yGVsKMsBk1PqXmvo6tL1XwSO53 sOgzWfEqegBgtsMhu0DGro5Cw5fIH+VkWHsR6ZRZvgc5/AzpWduav8+tmZnA1wnSkF6QLrkTu2K yBBM2DR+KxVLJ487ChrFolt1aE1XCX8c8tFeHhvOhLZLxdpBD1kg9X/kp++pR+108wNW5KfWDoE 9fzkNJ9UVQ7Vubrv8tJ+L9/ZG/ X-Received: by 2002:a17:903:ac6:b0:2c9:e86e:aa0a with SMTP id d9443c01a7336-2cb97d1228dmr51504625ad.0.1783237684522; Sun, 05 Jul 2026 00:48:04 -0700 (PDT) Received: from localhost ([112.65.12.207]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2cad7893a8dsm30766295ad.73.2026.07.05.00.48.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2026 00:48:04 -0700 (PDT) From: Liang Hao To: tglx@kernel.org Cc: brgl@kernel.org, haohlliang@gmail.com, hoan@os.amperecomputing.com, linusw@kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4] gpio: dwapb: Mask interrupts at hardware initialization Date: Sun, 5 Jul 2026 15:47:59 +0800 Message-ID: <20260705074759.47863-1-haohlliang@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <875x2vlpjx.ffs@fw13> References: <875x2vlpjx.ffs@fw13> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit GPIO interrupts may retain stale state across warm reboots when peripherals remain powered. If a GPIO line is not explicitly configured for interrupts, this can result in interrupt storms due to missing handlers. Fix this by ensuring all interrupts are masked and disabled at hardware initialization time via the init_hw() callback. Pending interrupts are also cleared to start from a known-safe state. Interrupts will be unmasked only when explicitly configured by userspace or kernel drivers. Signed-off-by: Liang Hao --- v3 -> v4: - Instead of handling errors in the interrupt handler, properly initialize hardware interrupt state at probe time via init_hw() - This addresses the root cause identified by tglx rather than papering over the symptom v2 -> v3: - Remove duplicate comment v1 -> v2: - Add spinlock protection for register access in error path - Protect against race with irq_chip callbacks accessing shared registers --- drivers/gpio/gpio-dwapb.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index 7b92b233fafe..3189a0269efc 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c @@ -199,6 +199,22 @@ static void dwapb_toggle_trigger(struct dwapb_gpio *gpio, unsigned int offs) dwapb_write(gpio, GPIO_INT_POLARITY, pol); } +static int dwapb_irq_init_hw(struct gpio_chip *gc) +{ + struct dwapb_gpio *gpio = to_dwapb_gpio(gc); + + /* + * GPIO interrupts may retain stale state across warm reboots when + * peripherals stay powered. Force a known-safe state before the GPIO + * irqchip and irq domain are set up. + */ + dwapb_write(gpio, GPIO_INTEN, 0); + dwapb_write(gpio, GPIO_INTMASK, 0xffffffff); + dwapb_write(gpio, GPIO_PORTA_EOI, 0xffffffff); + + return 0; +} + static u32 dwapb_do_irq(struct dwapb_gpio *gpio) { struct gpio_generic_chip *gen_gc = &gpio->ports[0].chip; @@ -457,6 +473,7 @@ static void dwapb_configure_irqs(struct dwapb_gpio *gpio, girq = &gc->irq; girq->handler = handle_bad_irq; girq->default_type = IRQ_TYPE_NONE; + girq->init_hw = dwapb_irq_init_hw; port->pirq = pirq; -- 2.50.1 (Apple Git-155)