From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.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 9A76F3019AA for ; Mon, 3 Aug 2026 14:10:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785766241; cv=none; b=nUqiVD1MAcL3aPseaAiu7u1Vvx/P+CIrvJ/doMeJTCdkJj50h6HykkK3Rk9ypiThqW/Ixc4OCT4Vq0/+zFI1stcD8DhkIfl/8UAzsgxLhHEYBi7S/Z8JK4UNLcIX3L3h+S3w+/r3ItJXgDsDh4CBGxw/L98+qbScpd0bKGIRaY4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785766241; c=relaxed/simple; bh=7i97WC0GFc1OjbIZ5PDB9Kp5zZVuZx2ij7tryM/Y8JY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HNMUyZz2n7DwfN5wcqyNsn9ujMPspxjbFIjqsL3H7cmi4c0M1UuEa1szPgXlOMdXwGvVGn/mgwmhdblrYEfpiUN34QdrKIT+KmNUi4JeP3KMo6fr8tdZjkH/R5UbqtVT9OUfabqdCYgnjr6s3q+eTUb2ICGwPDfIu5G6c5qlBiA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=faayjzwC; arc=none smtp.client-ip=209.85.161.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="faayjzwC" Received: by mail-oo1-f49.google.com with SMTP id 006d021491bc7-6acbbcd3798so2071114eaf.3 for ; Mon, 03 Aug 2026 07:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1785766238; x=1786371038; 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:content-type; bh=zn8Ob/lYJrtvb6nSm3sGvGJOnXJvrAS/9UT9vBl2poM=; b=faayjzwCmZtgZe3diLuR9egddinJbQpf5Q+AICYVWyzwFwQTYDTHu9GjV0FbR1zENr rC1DwMjRvheh727R20tEdTUSooJGqP3zNSIMrhmssR19kPPR+jOjjP38MvdAdwt4JIYf oLPnaB1IhGeu6ZnDeETdMRC2E5nbumgRM8iqk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785766238; x=1786371038; 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:content-type; bh=zn8Ob/lYJrtvb6nSm3sGvGJOnXJvrAS/9UT9vBl2poM=; b=UPw8zaMU5Q/inejVS+QEwf9PGhdUNrzQbKuyUk6A3KuWeGkAh+PJzVxehsV5R4h0xc eLe5HWwMb37DrBrZxKK4dLDC4R/SeiCUOvDd5pGFEPkDX0H7Xsjn/ownPM0rIjoDg5ZW OWGgvH3HaJYoqMU+u+1b8HiPnb8lKfrFgKGe0ayxYpfLPLaOVnnweW5cRVPA+1oRlCOr knd/4GEo44mZi65H107ht9hNXJgWO+JkHPG24lLkgbxLdV3Ac+gm9ZMTDyroF8GruMJi Q3ddb+pSaFCWS+A15Rtf8508DBTLm/uKV8ef5yyI6gGrLJB8GYh5bxQNktzOqT1OmDhl nAUQ== X-Forwarded-Encrypted: i=1; AHgh+Rpbs3/zqTqSQVPYWRcW4fCX0SL+Gu5iw9xjrwpFr9AWRQtu/WlTHzcqb9Uc+btGCWW1d/pwE+WKc6Vl6UM=@vger.kernel.org X-Gm-Message-State: AOJu0Ywu6mUIP+0ZxQOZIcoJNd72ROyRe59WNxaUX3f2tXLez5P6hfl8 3QIwVCX4YtGPZWUQCr9y51bpQqvTlslChiOWowtM53WR03K+Aa6BdwYKhCLSn7S7Gg== X-Gm-Gg: AR+sD10Hx92KNjHjgX3eOMaySkFKdG3TYA8qzMDdxLO2XMgn0j8DPYG/4G84pNV/kJr NW4OckAEPSCjNzzOo8pdQClszOCdGqTXwTnfs8DP0h7Di/ouqVgitnCb7SsRBAoekNectVJyk+s pf2UZOQ4XxM8J/wNSXYm2xfkon9rMe4MkzuiDc9OD0zDuMwjmFkmd5UPkxgDp8FDc+96Oxcip4w XUgBbyHkrOJCh9jNTSBCtRKG9JfBRsCgUB4W8XS2gEuAEtYSVpdDUad7ZDEuybJgb1UXiFWLn21 GzXzSlOkBgYWACyhGxjBEm5cHR69WU3oXtEie6aUsjvnKCHaGBZGnU/dGkJAgkvphLwhvSjDdu7 BU4JAoZAVppSIciKsF4WCtHuIdRVdwTTfKeEaFcMWG4UutZw2LYF0aRtCb/bfR8cKpRbZ8Lo1ok drAicn/xJhEf6o6r/SQTrKLJYpZO3pg5PbJkNRn93EiZooEQOXtPGDjYM= X-Received: by 2002:a05:6820:4a08:b0:6a1:5b63:2ae2 with SMTP id 006d021491bc7-6ae4334a975mr12207278eaf.29.1785766238536; Mon, 03 Aug 2026 07:10:38 -0700 (PDT) Received: from chromium.org ([174.51.25.52]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-6ae3a0c9162sm6526695eaf.11.2026.08.03.07.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2026 07:10:37 -0700 (PDT) From: Simon Glass To: Linus Walleij Cc: Heiko Stuebner , linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-gpio@vger.kernel.org, Vladislav Leonov , Jonas Karlman , Simon Glass , Jeffy Chen , huang lin , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] pinctrl: rockchip: Reset the pin count when recalculating SoC data Date: Mon, 3 Aug 2026 08:10:23 -0600 Message-ID: <20260803081024.1.72f72067ea890a9eac79d63bf655738bec374dfd@changeid> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260803141028.710706-1-sjg@chromium.org> References: <20260803141028.710706-1-sjg@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit rockchip_pinctrl_get_soc_data() mutates the static per-SoC data. The iomux and drive offsets are recalculated idempotently, since a rerun anchors at the values calculated before, but the total pin count only accumulates: each run adds every bank's pins again. When the probe is deferred and runs a second time, nr_pins doubles and every bank's pin_base shifts, so later pin lookups resolve to the wrong bank and the wrong registers. Reset the pin count at the start of the calculation, so that a rerun produces the same values. This is verified on a Luckfox Pico Mini B (RV1103, with the pending RV1106 series applied) by forcing the probe to defer once: without this patch the second probe calculates nr_pins=304 instead of 152 and no GPIO bank comes up; with it the recalculation matches the first run and all banks work. Fixes: d3e5116119bd ("pinctrl: add pinctrl driver for Rockchip SoCs") Link: https://sashiko.dev/#/patchset/20260729132736.3807082-1-sjg@chromium.org?part=4 Assisted-by: Claude:claude-opus-5 Signed-off-by: Simon Glass --- drivers/pinctrl/pinctrl-rockchip.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 7e0fcd45fd26..8bfc7ab5de15 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -4296,6 +4296,16 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data( pmu_offs = ctrl->pmu_mux_offset; drv_pmu_offs = ctrl->pmu_drv_offset; drv_grf_offs = ctrl->grf_drv_offset; + + /* + * This function mutates the static per-SoC data. Most of it is + * idempotent: recalculated iomux and drv offsets anchor at the + * values calculated by a previous run. The pin count is not, so + * reset it here; otherwise it accumulates when the probe runs + * again after a probe deferral, shifting every bank's pin_base. + */ + ctrl->nr_pins = 0; + bank = ctrl->pin_banks; for (i = 0; i < ctrl->nr_banks; ++i, ++bank) { int bank_pins = 0; -- 2.43.0