From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32323C433E0 for ; Fri, 26 Jun 2020 19:21:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0295E2070A for ; Fri, 26 Jun 2020 19:21:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="d0D/qi0z"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=beagleboard-org.20150623.gappssmtp.com header.i=@beagleboard-org.20150623.gappssmtp.com header.b="NQTltRUU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0295E2070A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=beagleboard.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=crPWJKKaJalpUndH+F+jfbapEXowrvD2XmlL+NF1rD8=; b=d0D/qi0zMOqJc7qEPd5y8S5YN Ls/g/4T/3Q542Y6UJZOAlNhg6qKCSdNpWqWjsVto2smUB9RDs2CdxW30zS/9BXYLW+OWIqpJfGFwc b3zN0iQO0D7lrhMw7s2uWHA4NCpCCk0cXyI1rwqJpEyjpokOvxt+tePle2sHMTEij4yXc2T6QzrG1 cKJ5v4vS4jdDl2o36EoQnRDNs/P2aFYDDRTddzfF1nFb6txjWUJ5rZNKrx/QxsHzHf+DrPqYflCAn 1cI1EGmhUal85mCxgaNdChfxdPeaWyPdI1/jCnTIVCk7vbLVTz/ne2GN4lc3euy8uYCiaNGZcONE5 6OU6tslDg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jottC-0001BF-Oq; Fri, 26 Jun 2020 19:19:54 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jott9-0001Ae-Tm for linux-arm-kernel@lists.infradead.org; Fri, 26 Jun 2020 19:19:53 +0000 Received: by mail-wr1-x444.google.com with SMTP id f7so7516061wrw.1 for ; Fri, 26 Jun 2020 12:19:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beagleboard-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=v3oOHqdeiilgAo1krqYM7ZW2FYPIuBxdWkBI8kNf8w4=; b=NQTltRUUQEyW33Cu2UEltV6GamFzrhZ94/moDjBBeDIWK+eLNpNbN3QnKUQZ633i2K SAsyOsZB2dkM/QqQzckArvwRNsGVVPcFsTY3EBvlYaR1TH2zFC+ToIUhC3weBqAwMNqY 46WgvtmTea15ADPMKPKljDfRBsW1N6yeG9DPkIqCntAcs+IIAJ7Q3uhTiN9qATp6+4Gb uVNjVPK5U6YHPGAtTdvXUTqdLbqBuznHnSm7leob0E5rMqNAoLutVOjPOmoP1dyYLzT6 CAjpfEhlqeTrl0rjehSk66/5E9syf5SYN3q29L41ioUbUusekaKJf+TwW8farRSItzlT /Jqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=v3oOHqdeiilgAo1krqYM7ZW2FYPIuBxdWkBI8kNf8w4=; b=QDvMUGlB8W5S4Yq8X0AK+5DHuS/yj724Cz7NcxO8kkLBREhwnfvelXrsasOs/jxNEu K2AGeCyxR1Yi/ji4mBPaPth98AzBpJTb4oR8oqlCk9D3J2ZHcDfMjpYGo9KEcQ5GkIQ6 ZAXJ2wqNn5Cjd+DlbyVkhMkHHr+COaOIeYGavkqJNrl7efjCnZcyTwjfOGarxxNPH3yK uV9qeaXm5M7Tl9mA/2Pd9WrAZMmP3qmdbVWPY8Fa1NERT6qexXEDwsz+X3jNmISoqKlr UFB9CY0jT2pej/HX+M5pZIRvPXQf4xsf2Vf9sLLJiIG5INAqOyAEH/tP8+KFYYnWQtWY dyWw== X-Gm-Message-State: AOAM5328orPYQlVDUJJ2a44FHrzM+fw53xptDETfFILmeJ3AuYiXwAH4 L2IFj9J2uFcw5KWg6zEdZGow8g== X-Google-Smtp-Source: ABdhPJyxppcg9yXdgcCtGmzUVM0Qhgol51JAPy/Ev0oDVmvT+dzG+dcduwYmDgiNPxITN/BSFtuOaA== X-Received: by 2002:a5d:664a:: with SMTP id f10mr5249137wrw.300.1593199189262; Fri, 26 Jun 2020 12:19:49 -0700 (PDT) Received: from x1 ([2001:16b8:5c03:b001:3446:ed90:fece:8da5]) by smtp.gmail.com with ESMTPSA id w12sm29179536wrm.79.2020.06.26.12.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 12:19:48 -0700 (PDT) Date: Fri, 26 Jun 2020 21:19:46 +0200 From: Drew Fustini To: Linus Walleij Subject: Re: [PATCH v2] pinctrl-single: fix pcs_parse_pinconf() return value Message-ID: <20200626191946.GA97666@x1> References: <20200608125143.GA2789203@x1> <20200616115951.GA3976568@x1> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200616115951.GA3976568@x1> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Grygorii Strashko , Tony Lindgren , "linux-kernel@vger.kernel.org" , Robert Nelson , "open list:GPIO SUBSYSTEM" , Jason Kridner , Haojian Zhuang , Daniel Mack , Linux-OMAP , Robert Jarzmik , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jun 16, 2020 at 01:59:51PM +0200, Drew Fustini wrote: > On Tue, Jun 16, 2020 at 10:31:54AM +0200, Linus Walleij wrote: > > On Mon, Jun 8, 2020 at 2:51 PM Drew Fustini wrote: > > > > > This patch causes pcs_parse_pinconf() to return -ENOTSUPP when no > > > pinctrl_map is added. The current behavior is to return 0 when > > > !PCS_HAS_PINCONF or !nconfs. Thus pcs_parse_one_pinctrl_entry() > > > incorrectly assumes that a map was added and sets num_maps = 2. > > > > > > Analysis: > > > ========= > > > The function pcs_parse_one_pinctrl_entry() calls pcs_parse_pinconf() > > > if PCS_HAS_PINCONF is enabled. The function pcs_parse_pinconf() > > > returns 0 to indicate there was no error and num_maps is then set to 2: > > > > > > 980 static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs, > > > 981 struct device_node *np, > > > 982 struct pinctrl_map **map, > > > 983 unsigned *num_maps, > > > 984 const char **pgnames) > > > 985 { > > > > > > 1053 (*map)->type = PIN_MAP_TYPE_MUX_GROUP; > > > 1054 (*map)->data.mux.group = np->name; > > > 1055 (*map)->data.mux.function = np->name; > > > 1056 > > > 1057 if (PCS_HAS_PINCONF && function) { > > > 1058 res = pcs_parse_pinconf(pcs, np, function, map); > > > 1059 if (res) > > > 1060 goto free_pingroups; > > > 1061 *num_maps = 2; > > > 1062 } else { > > > 1063 *num_maps = 1; > > > 1064 } > > > > > > However, pcs_parse_pinconf() will also return 0 if !PCS_HAS_PINCONF or > > > !nconfs. I believe these conditions should indicate that no map was > > > added by returning -ENOTSUPP. Otherwise pcs_parse_one_pinctrl_entry() > > > will set num_maps = 2 even though no maps were successfully added, as > > > it does not reach "m++" on line 940: > > > > > > 895 static int pcs_parse_pinconf(struct pcs_device *pcs, struct device_node *np, > > > 896 struct pcs_function *func, > > > 897 struct pinctrl_map **map) > > > 898 > > > 899 { > > > 900 struct pinctrl_map *m = *map; > > > > > > 917 /* If pinconf isn't supported, don't parse properties in below. */ > > > 918 if (!PCS_HAS_PINCONF) > > > 919 return 0; > > > 920 > > > 921 /* cacluate how much properties are supported in current node */ > > > 922 for (i = 0; i < ARRAY_SIZE(prop2); i++) { > > > 923 if (of_find_property(np, prop2[i].name, NULL)) > > > 924 nconfs++; > > > 925 } > > > 926 for (i = 0; i < ARRAY_SIZE(prop4); i++) { > > > 927 if (of_find_property(np, prop4[i].name, NULL)) > > > 928 nconfs++; > > > 929 } > > > 930 if (!nconfs) > > > 919 return 0; > > > 932 > > > 933 func->conf = devm_kcalloc(pcs->dev, > > > 934 nconfs, sizeof(struct pcs_conf_vals), > > > 935 GFP_KERNEL); > > > 936 if (!func->conf) > > > 937 return -ENOMEM; > > > 938 func->nconfs = nconfs; > > > 939 conf = &(func->conf[0]); > > > 940 m++; > > > > > > This situtation will cause a boot failure [0] on the BeagleBone Black > > > (AM3358) when am33xx_pinmux node in arch/arm/boot/dts/am33xx-l4.dtsi > > > has compatible = "pinconf-single" instead of "pinctrl-single". > > > > > > The patch fixes this issue by returning -ENOSUPP when !PCS_HAS_PINCONF > > > or !nconfs, so that pcs_parse_one_pinctrl_entry() will know that no > > > map was added. > > > > > > Logic is also added to pcs_parse_one_pinctrl_entry() to distinguish > > > between -ENOSUPP and other errors. In the case of -ENOSUPP, num_maps > > > is set to 1 as it is valid for pinconf to be enabled and a given pin > > > group to not any pinconf properties. > > > > > > [0] https://lore.kernel.org/linux-omap/20200529175544.GA3766151@x1/ > > > > > > Fixes: 9dddb4df90d1 ("pinctrl: single: support generic pinconf") > > > Signed-off-by: Drew Fustini > > > > Patch applied as non-critical (for-next) fix. > > > > If there is no hurry let's merge it this way with lots of testing > > along the way. > > > > Yours, > > Linus Walleij > > Thanks, I agree more testing is a good idea. > > In particular, do you have a way to followup with Haojian Zhuang within > Linaro? > Linus - do you have a way to contact Haojian Zhuan? I found them on Freenode but they have been idle since beginning of June. Last email I can find on the mailing list is from March. Tony and I would both like someone familiar with Hisilicon to comment on this patch as it is using pinctrl-single. Thanks, Drew _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel