Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp488719rdb; Thu, 19 Oct 2023 09:52:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGodpVCRVAdIWMLyifAT0SKk0NbzYq1wfilDKjZmX0d7T5WK24Fp7mgZN9gWHJZky/6Zbbk X-Received: by 2002:a05:6871:a087:b0:1ea:206e:cb10 with SMTP id vq7-20020a056871a08700b001ea206ecb10mr2794955oab.22.1697734366027; Thu, 19 Oct 2023 09:52:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697734365; cv=none; d=google.com; s=arc-20160816; b=1Bon1jZRR0gvB08ZdySAbg7ni/Ut7zc/97lbfN5N2n8uN77qem1im78HXZw14Y5Gyn Ebb0ev7prSkh4TkjyAMQePodYclVdWBHqRm9+YJJK/t1JWVF7G8kWeoziN4Pe3IhE6Gp UC6zOpiTRsDmSy2jY4q0yU9BfjHuI3wLt1kJuHD6FGupEZfiKDa6jjfcDHmHGHv9ootm iQAPSxNkG9n4htIyGEtU5haCvvPaq90fH1A9N+zswQYAdKmWyn0DJ5Ib5wNsQIbjt5nL WJVvxF25HR1YKkDjagWdvVN9K9ZtS9Xx5KB6ArVmMU0bzsyAg+1lsed7o7GECvQy9WZM lcQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=459ILY94iQ5HF047dPKIbl/IxLX8OhQFHg5hG/nJcHU=; fh=Ezw3TA502E69C3FHQf3KRVn7RRSWG1inhviPmZu0nQ8=; b=QWfIw0HIkO1YqMS+YmVap3PfDMb7QnKuhe3YG5o3lM4eDtzlZ2iwyXFJBeU4y+p7Zx DMfnMGXSzuFI3chd2xUD5/ffN5g2jcLIu6jY0r1KGYrQ3RzxQpTT1gqToEn3+pspmvjr jRCP6X9nBKNZbfxisQVO64bMOG76KHbKcQaC2esDz3tCxiKJh3UeeFYlaiilAvCX75rj E9Pqj06CZlRr+H6ZHgUeFy6HheLRnK9hruTh5hwcWhD6qtrdCpnUqpRAuhSm4+oPTRRO W58J6F7M70TcjrKM84FPIRC7FKiIkOgEd/1xqF1MB+JhmgND4Ix4+jRaIf6/B56BtodW 1crQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BJxjo80J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id o5-20020a656a45000000b0059c02d055c4si303986pgu.668.2023.10.19.09.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 09:52:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BJxjo80J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 68B8483513AF; Thu, 19 Oct 2023 09:52:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345102AbjJSQwf (ORCPT + 99 others); Thu, 19 Oct 2023 12:52:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229638AbjJSQwe (ORCPT ); Thu, 19 Oct 2023 12:52:34 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64CDA126; Thu, 19 Oct 2023 09:52:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697734351; x=1729270351; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=m7iRacMNsk2e4iWiTshUMyCV5YUTIBNnOvXsf4nbnb8=; b=BJxjo80JyU1nbb/WC8qCaUpauPtQGkfzhTS2pAFi6f7+5KXDfRIz/+5F 6FF80CM4eC6Vte6rxzC3MTapMNvThMRkja8RUMjAlZrY+BlEPCcXHKIIA SwXGberldoMUeLo0sr/Z8Jh5I91zCjECb8cyzBmwG4Nd55hX1fQoJN8P3 7fZZOxJgDx8Jhv5VPmYID9sUAvTV9eZPM2gr/P8wXsCUZt/Mq/95tnfHp OzpCIaRNHDCn57RasI50XG7BS8PzyQwGgrLl5uwSxr2SIqkcp/2e1zeYu bJt9IKDp8gEIyDQs+V5BoUUZOkbS3xAmwsxoTWcIwlA0C3vpNHvyy4NT9 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="366544002" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="366544002" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 09:52:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="900813795" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="900813795" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga001.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 09:50:22 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97-RC2) (envelope-from ) id 1qtWG2-00000006vwy-2qGB; Thu, 19 Oct 2023 19:52:26 +0300 Date: Thu, 19 Oct 2023 19:52:26 +0300 From: Andy Shevchenko To: Dmitry Torokhov Cc: Linus Walleij , Ulf Hansson , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Ferry Toth Subject: Re: [PATCH v1 1/1] Revert "pinctrl: avoid unsafe code pattern in find_pinctrl()" Message-ID: References: <20231017141806.535191-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 19 Oct 2023 09:52:43 -0700 (PDT) On Wed, Oct 18, 2023 at 03:41:24PM -0700, Dmitry Torokhov wrote: > On Wed, Oct 18, 2023 at 08:01:23AM +0300, Andy Shevchenko wrote: > > On Tue, Oct 17, 2023 at 02:43:01PM -0700, Dmitry Torokhov wrote: > > > On Tue, Oct 17, 2023 at 10:45:39PM +0300, Andy Shevchenko wrote: > > > > Thanks for your response. ... > > > I wonder, could you please post entire dmesg for your system? > > > > Working, non-working or both? > > Non working, especially if you also enable debug logs in > drivers/mmc/host/sdhci-pci-core.c. Here we are https://paste.debian.net/hidden/5d778105/ > What I do not quite understand is that I think we should not be hitting > the case where pinctrl is already created for the device, which is the > code path my patch was changing. IIUIC we should be mostly executing the > "pinctrl not found" path and that did not really change. Maybe you could > also put some more annotations to show how/at what exact point the probe > order changed? Maybe log find_pinctrl() calls and compare? I see this order in dmesg [ 48.429681] sdhci-pci 0000:00:01.2: Mapped GSI37 to IRQ79 [ 48.436219] sdhci-pci 0000:00:01.0: Mapped GSI0 to IRQ80 [ 48.450347] sdhci-pci 0000:00:01.3: Mapped GSI38 to IRQ81 which suggests that PCI enabling devices are happening in parallel (pcim_enable_device() in SDHCI PCI driver) and whoever wins first gets the ID via IDA (see mmc_alloc_host() implementation). But PCI itself guarantees that function 0 has to be always present, so the PCI itself enumerates it _always_ in the same order (and we are talking about exactly BDF == x:y.0 in this case). > Linus, BTW, I think there are more problems there with pinctrl lookup, > because, if we assume there are concurrent accesses to pinctrl_get(), > the fact that we did not find an instance while scanning the list does > not mean we will not find it when we go to insert a newly created one. > > Another problem, as far as I can see, that there is not really a defined > owner of pinctrl structure, it is created on demand, and destroyed when > last user is gone. So if we execute last pintctrl_put() and there is > another pinctrl_get() running simultaneously, we may get and bump up the > refcount, and then release (pinctrl_free) will acquire the mutex, and > zap the structure. > > Given that there are more issues in that code, maybe we should revert > the patch for now so Andy has a chance to convert to UUID/LABEL booting? I'm testing a PoC of the script, so looks promising, but needs more time to check other possibilities (see below) and deploy. ... > > > I think the right answer is "fix the userspace" really in this case. We > > > could also try extend of_alias_get_id() to see if we could pass some > > > preferred numbering on x86. But this will again be fragile if the > > > knowledge resides in the driver and is not tied to a particular board > > > (as it is in DT case): there could be multiple controllers, things will > > > be shifting board to board... > > > > Any suggestion how should it be properly done in the minimum shell environment? > > (Busybox uses mdev with static tables IIRC and there is no fancy udev or so) > > I'm not sure, so you have something like blkid running? You just need to > locate the device and chroot there. This assumes you do have initramfs. blkid shows UUID for the partition of interest and it doesn't have any label, OTOH I could parse it for the specific template, while it's less reliable than going via sysfs from PCI device name, that's defined by hardware and may not be changed. -- With Best Regards, Andy Shevchenko