From nobody Sat Feb 7 15:11:10 2026 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 2A9D32D0625 for ; Thu, 9 Oct 2025 13:29:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760016586; cv=none; b=XufjkzUm4fQPq2TzPJpyL99GPp/qmUf0g4PVLOu3GkA41ulhCawBQSTENeE1xeWdJuNzBwW2/54Zsuad5ruexIWYFCxh0Nvi4CzeFnm31QtbrXda6IIXrMhwlJsVN4z0R93GDUazqeZo9XR5xk1q233vxS8IPWQDonFIJ7dqpQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760016586; c=relaxed/simple; bh=E1h2IymeZxzN8DEA2ATr3BDwi+1E2Uj1VWWEwU62eVI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=NL1+10soSQq8eanb7XTN1iXVu+GhMsaEYXL8N8GsIUcfYc2xVHkR6hGjiEA1B5rI/XC17AMdZ9wWnpxb1pyyi41VcL3Tr0L5I2yC9Xy53fRhKixA8REeM8q+/cnjKI8YcB+6komaJ57Goa5cAI9qVMn4v0IdIkggzzyx2tIhpm8= 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=hbrsIOey; arc=none smtp.client-ip=209.85.167.49 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="hbrsIOey" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-57bf912cbf6so1025329e87.3 for ; Thu, 09 Oct 2025 06:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760016582; x=1760621382; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QoD3OyvkVVLE8lgWVUBgOO0PRXTO7rnUz/rDybwGWOw=; b=hbrsIOeyE7lstuSc4qq2WI8N3OXwfrDdCDfz660iAd69eGF4Yw/NTBl2RmFXXt3JUA K5NI9xZhIxaOgh4sc/jkC4a3xElxpSCa5/jLHWO6DfOtQ+saYhzjSXakH50R/yRh7kZm /iFqPt6BfDKc3FflhS/yPzAL3oZ5TC3xQ+3bx59jP40jiwwHrXYns1lbDyBentOhkLyw incDVtmXw8dOQ4gaZYLC6kNuRb0p5LAjEpz1j/xOxvd+VnNKBd6aLAKbroYvfwCnvCR4 P0UptJ5G8fmvvsZIN+n51DYlVQuboTnZq1D/EKjbG9vqT0eCGW7pA43+reXSx1H2j375 vknw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760016582; x=1760621382; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QoD3OyvkVVLE8lgWVUBgOO0PRXTO7rnUz/rDybwGWOw=; b=jv/HZGdMaBZE/9Q95r4fvBaLAbtSMJJ0sVlrr+GSqVHmjvd+Aodjuu519z07sUjr2E 1I+H6iQUcS3btYDuKM8y4FiX981Tucn3G94f2Moa20uGn9xp1KWrT0xEcDfZnyhf42mu NlggO3UxjErjrQNDq8vW/WXwVDaX1QVChOL67y99CnLbS+pHKwGpqZyn/3ZDAveP7For x2y4IHGSzz1tSbY/bw2V85b/Rc4Z+p4NwO+XfZwWvRbBG3bap3ZgvNObc475tTv7lvsL WWGZDryHlR9JW4kyMpZ2zAiW+qzYVpjjDsml4OtoJ8VueA4E6V5eDlmx6vMGMkuMOXX2 vygw== X-Forwarded-Encrypted: i=1; AJvYcCV216ZgHwrJqvtTpch61N1qJ524zwULkvbKiBERVoTi4QNb88BcZqzqY7I/ef+ftXJgxMXua0JLgV2McDI=@vger.kernel.org X-Gm-Message-State: AOJu0YwDalipa7Lx+lrlQwM9aO5iYqvhlFShkg49T/kSJd6EEXFIK9bn DsCZad/2hZSIF+snXtO4nxWLW7G9sBdnnDgcNPFELeFPVVMtA1uFb54pm4kxJ8W/ X-Gm-Gg: ASbGnctBPmSc/xJQ7lh8NgdGxeighZ0NEedLUUNgD5npIN/LcE5mVv3R6aALY3mVPeW RhDqNELLY0xki3PxSrt+XQIpSbHPUNjE2gRTdbuvSieMJNxgIof6D1D1trA4dUmP0e09V9LaPSC +72Qp8hFiVQ7JF9MVfg5XuWowkXNRJV+rI5TH89pavaP1lkO1Z1SYBe0Lj+apvfxpEkREggWBPq vwdLdHNDB0QSRETmzFsmt6jqqlyIKCN4oy8hhRcF/ummg5ZGAELti4lHUZyyO1S/PHp3kNTCCEF zLgfg15LL8tNZ/HA+ghRme+9H/wJiUysMCoejoOHQrQwkflM4di/afU7NHD+T1u62WC+0HV2mnB V1uf6i/u2Ka2wR7eNkKpdD7jHxsEdZkdY9kWZ/VcGFYUPI2jFztWco1btjVRZIXq1KbgkTH6rpg == X-Google-Smtp-Source: AGHT+IH1VIKsG88C3aAeaqwYTWYVqCA6XHMJZDpaPDWK1Emc97Vc5AG1FPkm5MMZ+Hs0OjrfL5bbFw== X-Received: by 2002:a05:6512:12d1:b0:58b:2b8:f8d0 with SMTP id 2adb3069b0e04-5906de90442mr1868002e87.55.1760016581986; Thu, 09 Oct 2025 06:29:41 -0700 (PDT) Received: from wpc.lan (host-95-152-52-178.dsl.sura.ru. [95.152.52.178]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5907adb28a9sm1042587e87.98.2025.10.09.06.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 06:29:41 -0700 (PDT) From: bigunclemax@gmail.com To: Cc: bigunclemax@gmail.com, Mike Looijmans , Linus Walleij , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] pinctrl: mcp23s08: delete regmap reg_defaults to avoid cache sync issues Date: Thu, 9 Oct 2025 16:26:47 +0300 Message-ID: <20251009132651.649099-2-bigunclemax@gmail.com> X-Mailer: git-send-email 2.48.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Maksim Kiselev The probe function does not guarantee that chip registers are in their default state. Thus using reg_defaults for regmap is incorrect. For example, the chip may have already been configured by the bootloader before the Linux driver loads, or the mcp might not have a reset at all and not reset a state between reboots. In such cases, using reg_defaults leads to the cache values diverging from the actual registers values in the chip. Previous attempts to fix consequences of this issue were made in 'commit 3ede3f8b4b4b ("pinctrl: mcp23s08: Reset all pins to input at probe")', but this is insufficient. The OLAT register reset is also required. And there's still potential for new issues arising due to cache desynchronization of other registers. Therefore, remove reg_defaults entirely to eliminate the root cause of these problems. Also remove the force reset all pins to input at probe as it is no longer required. Link: https://lore.kernel.org/all/20251006074934.27180-1-bigunclemax@gmail.= com/ Suggested-by: Mike Looijmans Signed-off-by: Maksim Kiselev --- drivers/pinctrl/pinctrl-mcp23s08.c | 34 ------------------------------ 1 file changed, 34 deletions(-) diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-m= cp23s08.c index 78ff7930649d2..0b329661b5978 100644 --- a/drivers/pinctrl/pinctrl-mcp23s08.c +++ b/drivers/pinctrl/pinctrl-mcp23s08.c @@ -44,17 +44,6 @@ #define MCP_GPIO 0x09 #define MCP_OLAT 0x0a =20 -static const struct reg_default mcp23x08_defaults[] =3D { - {.reg =3D MCP_IODIR, .def =3D 0xff}, - {.reg =3D MCP_IPOL, .def =3D 0x00}, - {.reg =3D MCP_GPINTEN, .def =3D 0x00}, - {.reg =3D MCP_DEFVAL, .def =3D 0x00}, - {.reg =3D MCP_INTCON, .def =3D 0x00}, - {.reg =3D MCP_IOCON, .def =3D 0x00}, - {.reg =3D MCP_GPPU, .def =3D 0x00}, - {.reg =3D MCP_OLAT, .def =3D 0x00}, -}; - static const struct regmap_range mcp23x08_volatile_range =3D { .range_min =3D MCP_INTF, .range_max =3D MCP_GPIO, @@ -82,25 +71,12 @@ const struct regmap_config mcp23x08_regmap =3D { .reg_stride =3D 1, .volatile_table =3D &mcp23x08_volatile_table, .precious_table =3D &mcp23x08_precious_table, - .reg_defaults =3D mcp23x08_defaults, - .num_reg_defaults =3D ARRAY_SIZE(mcp23x08_defaults), .cache_type =3D REGCACHE_FLAT, .max_register =3D MCP_OLAT, .disable_locking =3D true, /* mcp->lock protects the regmap */ }; EXPORT_SYMBOL_GPL(mcp23x08_regmap); =20 -static const struct reg_default mcp23x17_defaults[] =3D { - {.reg =3D MCP_IODIR << 1, .def =3D 0xffff}, - {.reg =3D MCP_IPOL << 1, .def =3D 0x0000}, - {.reg =3D MCP_GPINTEN << 1, .def =3D 0x0000}, - {.reg =3D MCP_DEFVAL << 1, .def =3D 0x0000}, - {.reg =3D MCP_INTCON << 1, .def =3D 0x0000}, - {.reg =3D MCP_IOCON << 1, .def =3D 0x0000}, - {.reg =3D MCP_GPPU << 1, .def =3D 0x0000}, - {.reg =3D MCP_OLAT << 1, .def =3D 0x0000}, -}; - static const struct regmap_range mcp23x17_volatile_range =3D { .range_min =3D MCP_INTF << 1, .range_max =3D MCP_GPIO << 1, @@ -129,8 +105,6 @@ const struct regmap_config mcp23x17_regmap =3D { .max_register =3D MCP_OLAT << 1, .volatile_table =3D &mcp23x17_volatile_table, .precious_table =3D &mcp23x17_precious_table, - .reg_defaults =3D mcp23x17_defaults, - .num_reg_defaults =3D ARRAY_SIZE(mcp23x17_defaults), .cache_type =3D REGCACHE_FLAT, .val_format_endian =3D REGMAP_ENDIAN_LITTLE, .disable_locking =3D true, /* mcp->lock protects the regmap */ @@ -614,14 +588,6 @@ int mcp23s08_probe_one(struct mcp23s08 *mcp, struct de= vice *dev, =20 mcp->reset_gpio =3D devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); =20 - /* - * Reset the chip - we don't really know what state it's in, so reset - * all pins to input first to prevent surprises. - */ - ret =3D mcp_write(mcp, MCP_IODIR, mcp->chip.ngpio =3D=3D 16 ? 0xFFFF : 0x= FF); - if (ret < 0) - return ret; - /* verify MCP_IOCON.SEQOP =3D 0, so sequential reads work, * and MCP_IOCON.HAEN =3D 1, so we work with all chips. */ --=20 2.48.1