From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796397780; b=liS3PnnHM0tgR7yML7aDgTdeZArSaY3GhTlN1GdKTbqeAzzbQHjil1ZQ7r3I4desTeaT DdYHl7zcXisXLul4EjvkOvf5ERAUub4+XVCyhJgcUShNRghwdKVBlMe0YC8TouXb9ve4k ssdHv/PEU533p2pD72Sczw87Z+b7btekD9FAnWg/jYXy5WhuAEAR7mCaZiWomZEL+hfOg 5yPn2j+yN3Mlm/yBIQwn6xDG2B6GIiG67auVIJSapsqRkL8/x8LTQuzYHV89ZWoq6IU+z IaX8gvm7+cK1Y0ug7gYS/yDAD9w49gq8jxewIc3jkD9m/j4aXsdrR9TL5IRhgjTR9zg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796397780; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Z4VjPvKYn4ul7KTDhMb5YosDDnwS3PRMtLxS6bGJQ40=; b=m/rF5GtzVFnVoLaSCh3Sib25HLZAjcidKDLtaVr0tMZeno9RdZp/2Bz3z402aaB51O4t bGLXXH9C5OwjT6VSaUcahHfinQM2XiAUu8hZGEIkEEeJLWxby/1C6pXigPG8Kf1sk3e4t bxayteOYbv4u96DDr6hemFheF4B//6LEasli+7vRxtqm/707Mbgk+uugbn4L/vCp2yg/X ONttvBbAPaSTwPmCH/3s6fYS5z9klt5j1hUr8ruxPpXnXgVQJ1w8VOlqmdGJBNXsGYGeS u2mhBY9tr5+mnaSpeVhpdtBNQyt+IgcwGJD5tEu0vf9VRw2B6yphgvvJsZNyJcmekOA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=indNqz9+; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD185606A322; Fri, 4 Dec 2026 15:23:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=indNqz9+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63E7F1F00897; Fri, 4 Dec 2026 15:23:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796397780; bh=Z4VjPvKYn4ul7KTDhMb5YosDDnwS3PRMtLxS6bGJQ40=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=indNqz9+d9fkldyMbv+zA2RkPRe7z7GJ58LsTqV1Fwp9bC4KPR8q2nsp8wddT7Vw0 ODYrnp0W+R7V8Bm8r9uxfMhmOFEJcUSx7CljIi0AFYtdWmNYyhqOl3r4fVR42e5qHK NSHVkDfC9G7nGH1eeDA1D4BVhawo4S8doMc74dzBqIbfIzTXnWa2vmel96UWwOKkmd mzkF/mjX4uQfsevRhS12Q+r7SlxA+oudMj3+4GZpyZfIaj7DXWpT6UCZOgMYFIGz3R Mlb63q3t69u3M8nutDBIrgii41MRCtAnm0/ccoGBuqFwVe0k7AUmiahpOpn8UK/wEV DQEqargRPBFIg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 04/13] pinctrl: berlin: add optional pinconf support Reply-To: sashiko-reviews@lists.linux.dev To: "Jisheng Zhang" Cc: devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-gpio@vger.kernel.org, mfd@lists.linux.dev, robh@kernel.org, conor+dt@kernel.org, lee@kernel.org In-Reply-To: <20261204140732.31223-5-jszhang@kernel.org> References: <20261204140732.31223-1-jszhang@kernel.org> <20261204140732.31223-5-jszhang@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 15:22:59 +0000 X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 6 potential issues to consider: - [Medium] pinctrl: berlin: wrong errno -EOPNOTSUPP in berlin_pinconf_group_get() - [Medium] pinctrl: berlin: map memory leak on error in berlin_pinctrl_dt_node_to_map() - [Medium] pinctrl: berlin: raw DS register values used for PIN_CONFIG_DRIVE_STRENGTH - [Low] pinctrl: berlin: map over-allocation in berlin_pinctrl_dt_node_to_map() - [Low] pinctrl: berlin: berlin_pinctrl_dt_node_to_map() duplicates core helper - [Low] pinctrl: berlin: berlin_pinconf_group_get() ignores PINCFG_SPU_10BIT -- commit feaf1efaaaf2673c7dd44e0c2079579524261efa Author: Jisheng Zhang pinctrl: berlin: add optional pinconf support This commit adds optional generic pinconf support to the Berlin pinctrl driver, extending DT node-to-map parsing and adding group get/set callbacks for 8-bit and 10-bit pad configuration registers. > diff --git a/drivers/pinctrl/berlin/berlin.c b/drivers/pinctrl/berlin/ber= lin.c > index 9337de1973af9..82215c36b856a 100644 > --- a/drivers/pinctrl/berlin/berlin.c > +++ b/drivers/pinctrl/berlin/berlin.c [ ... ] > @@ -75,11 +95,19 @@ static int berlin_pinctrl_dt_node_to_map(struct pinct= rl_dev *pctrl_dev, > return -EINVAL; > } > =20 > + ret =3D pinconf_generic_parse_dt_config(node, pctrl_dev, &configs, > + &num_configs); > + if (ret < 0) { > + dev_err(pctrl->dev, "%s: could not parse node property\n", > + node->name); > + return ret; > + } > + > ret =3D pinctrl_utils_reserve_map(pctrl_dev, map, &reserved_maps, > - num_maps, ngroups); > + num_maps, ngroups * (num_configs + 1)); [Severity: Low] Does this over-allocate the pinctrl_map array when a node has more than one pinconf property? pinctrl_utils_add_map_configs() stores all num_configs items in a single struct pinctrl_map entry per group, so each group needs at most two slots (ngroups * (num_configs ? 2 : 1)). Because dt_remember_or_free_map() keeps the allocated array without shrinking it, the excess slots remain allocated for the lifetime of the mapping. [ ... ] > @@ -88,11 +116,22 @@ static int berlin_pinctrl_dt_node_to_map(struct pinc= trl_dev *pctrl_dev, > function_name); > if (ret) { > dev_err(pctrl->dev, "can't add map: %d\n", ret); > - return ret; > + goto exit; > + } > + > + if (num_configs) { > + ret =3D pinctrl_utils_add_map_configs(pctrl_dev, map, > + &reserved_maps, num_maps, group_name, > + configs, num_configs, > + PIN_MAP_TYPE_CONFIGS_GROUP); > + if (ret < 0) > + goto exit; > } > } > =20 > - return 0; > +exit: > + kfree(configs); > + return ret; > } [Severity: Medium] Does the error path leak *map and any previously duplicated per-group configs? If pinctrl_utils_add_map_configs() fails with -ENOMEM in kmemdup_array() (or pinctrl_utils_add_map_mux() fails), jumping to exit frees only the temporary configs buffer. dt_to_map_one_config() does not call dt_free_map() when dt_node_to_map() returns a negative error, so pinctrl_utils_free_map() is needed on the error path. > static const struct pinctrl_ops berlin_pinctrl_ops =3D { [Severity: Low] Now that PINCTRL_BERLIN selects GENERIC_PINCONF, can berlin_pinctrl_ops.dt_node_to_map use pinconf_generic_dt_node_to_map_group() directly instead of maintaining berlin_pinctrl_dt_node_to_map()? The core helper already handles group-based mux and generic pinconf mapping with exact map reservation and pinctrl_utils_free_map() cleanup on failure. [ ... ] > @@ -177,6 +216,186 @@ static const struct pinmux_ops berlin_pinmux_ops = =3D { > .set_mux =3D &berlin_pinmux_set, > }; > =20 > +static int berlin_pinconf_group_get(struct pinctrl_dev *pctrl_dev, > + unsigned int group, unsigned long *configs) > +{ > + enum pin_config_param param =3D pinconf_to_config_param(*configs); > + struct berlin_pinctrl *pctrl =3D pinctrl_dev_get_drvdata(pctrl_dev); > + const struct berlin_desc_group *group_desc =3D pctrl->desc->groups + gr= oup; > + bool enabled; > + u32 val; > + int ret; > + u8 conf_bits =3D group_desc->conf_bits; > + > + if (!conf_bits) > + return -EOPNOTSUPP; [Severity: Medium] Should berlin_pinconf_group_get() and berlin_pinconf_group_set() return -ENOTSUPP instead of -EOPNOTSUPP here and in their default branches? struct pinconf_ops requires -ENOTSUPP for unsupported configurations, and pinconf_generic_dump_one() only treats -EINVAL and -ENOTSUPP as legal errors. Because berlin_confops is registered unconditionally with is_generic =3D true, reading debugfs pinconf-groups prints "ERROR READING CONFIG SETTING" for unsupported parameters and for every group on older Berlin/AS370 SoCs where conf_bits is 0. [ ... ] > + case PIN_CONFIG_BIAS_DISABLE: > + if (conf_bits =3D=3D 10) > + enabled =3D !(val & PINCFG_PE_10BIT); > + else > + enabled =3D !(val & (PINCFG_PD_8BIT | PINCFG_PU_8BIT)); > + val =3D 0; > + break; > + case PIN_CONFIG_BIAS_PULL_DOWN: > + if (conf_bits =3D=3D 10) > + enabled =3D (val & (PINCFG_PE_10BIT | PINCFG_PS_10BIT)) =3D=3D PINCFG= _PE_10BIT; > + else > + enabled =3D val & PINCFG_PD_8BIT; > + val =3D enabled ? 1 : 0; > + break; > + case PIN_CONFIG_BIAS_PULL_UP: > + if (conf_bits =3D=3D 10) > + enabled =3D (val & (PINCFG_PE_10BIT | PINCFG_PS_10BIT)) =3D=3D > + (PINCFG_PE_10BIT | PINCFG_PS_10BIT); > + else > + enabled =3D val & PINCFG_PU_8BIT; > + val =3D enabled ? 1 : 0; > + break; [Severity: Low] Should these 10-bit bias cases also check PINCFG_SPU_10BIT? berlin_pinconf_group_set() includes and clears PINCFG_SPU_10BIT alongside PINCFG_PE_10BIT and PINCFG_PS_10BIT on bias writes, but berlin_pinconf_group_get() ignores it. If reset defaults or firmware leave PINCFG_SPU_10BIT set before a kernel write, reading pinconf-groups can misreport the pad as bias-disabled or pull-down instead of pull-up. > + case PIN_CONFIG_DRIVE_STRENGTH: > + enabled =3D true; > + if (conf_bits =3D=3D 10) > + val =3D FIELD_GET(PINCFG_DS_10BIT, val); > + else > + val =3D FIELD_GET(PINCFG_DS_8BIT, val); > + break; [Severity: Medium] Does PIN_CONFIG_DRIVE_STRENGTH need conversion between milliamps and the raw 3-bit/4-bit DS register field in berlin_pinconf_group_get() and berlin_pinconf_group_set()? Both PIN_CONFIG_DRIVE_STRENGTH and pincfg-node.yaml define drive-strength in mA, and pinconf_generic_dump_one() prints the returned value with an mA unit. Passing the raw selector through directly reports values like 0 mA in debugfs, rejects valid mA values above 15 (or 7 for 8-bit pads) with -EINVAL, and risks locking raw register selectors into the SL2610 DT ABI. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204140732.3122= 3-1-jszhang@kernel.org?part=3D4