Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp874943lqp; Sun, 14 Apr 2024 03:52:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVGLrgKJW3YjCK5SsAizJ6zSlcIH9Uwx7ueUBGdMPktH3c8DZk6xj40Zaf1ca8cLnSHHAcgyyZuXrUxd2laxB4fviTydp+qasaeQUC8CA== X-Google-Smtp-Source: AGHT+IH61YODgIZ9Mqs5fRJZ5gRW0XxSAoBdscygrFsabPxywiDy7IbVkKOwWRnCXyr3P/6nqS01 X-Received: by 2002:a05:6512:10c7:b0:518:c82a:bdf9 with SMTP id k7-20020a05651210c700b00518c82abdf9mr1833465lfg.44.1713091936452; Sun, 14 Apr 2024 03:52:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713091936; cv=pass; d=google.com; s=arc-20160816; b=HTKiHZ8/jbtV/v8rSYURj+sSp3uhLsxhAYmFgvofbtOHYFihSrY2un4vqVlA3syaRL 3b//WnfD2+RQPiclGR4s+Z4yi1zorsbXHwksIzg3Y6Hrz4vgRZPMqRXRBVJw5s1/Rurt 64EG5QT+st2KiPqnsuswMY9efxPzUGjURV6mc5yesEFzB95kEi1j8FABEnERn1IXi9GJ u2AE0UfpNsIz5GCP53hsVGk2Z/9BeCDMqgFfek7f98oDW5FiG3Iht1Z7644HZkJlvyyf xQGgnnWC1C2eUs9I/GXZOTC0C8m6yjH1WS6FdCsDGEL85984eR6PJCAhL0fSumMuvdvk tQyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=z86tADjA34jPDvp0sH69LSJjWH6CGCLDMrpq88/Jt4c=; fh=xOKuE7jBDgYyI/RG6u5VPOHrcpEQaskO3X1Ppc35Gfk=; b=BDHvDEcB248AjNg4/1eSUYUaamGdRqbGhzhE2BMgRKBsDVXcjVHZyceg9D6TyHZ7TK nwrvfXTRQbeZMO1JA2dQPw44Lrc6uRdPJtdaqkSrRFqOQEwusXI95rzOif36yJZl9c7p xOUyjDrt9+XAk6O2bfx2pj79w3NYOh9EYgZO1PAefI+Aa10WCR4qyAJxx6tAkbuDGCJ0 tNEDnjWBxgQNsNoc7TvA/xSnaWpdvOibFxGKV4n3nedWTg/lq3HK8h54xh4VBoglnt2A yDslFRrp1Z2dLVGy7j53ErdJ0SIwCCCADf7QoP5jiNhQdlpXU6JZAYlEaN7+/DNSmfd+ SJIA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CWaP99Nr; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-144109-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144109-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id lj15-20020a170906f9cf00b00a525b33fa37si668450ejb.130.2024.04.14.03.52.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Apr 2024 03:52:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144109-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CWaP99Nr; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-144109-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144109-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 08D171F21294 for ; Sun, 14 Apr 2024 10:52:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EFB572E647; Sun, 14 Apr 2024 10:52:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="CWaP99Nr" Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) (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 98CEA1CAB0 for ; Sun, 14 Apr 2024 10:52:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713091922; cv=none; b=F9jKV5c1BNo7BVbHTDFcM9eTBRg59Vhm3YJnX/QVlPx/9oA1z+m3Ceyl2ol8qHfyDBcbZszp/awDfO2yrqwfVymJEzb+YC2zEUCnxqSDh9I76HJs/Ctp35Yc5QggoHl1drV/HzRYC0dPCHCay893+V/qxxQeAL3wyWYfZMH9oho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713091922; c=relaxed/simple; bh=Fskwbnc4cdeRPyqLU32Z5qy2jXRijiOAUXtekazEu2U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UpvKcHkIcKo8QfrT5nuaKHPllJhqjWXeQFJcOHO1J04Nv9ydOHM+XQ8rwi7zvAZnVeGhY8rV34tkAC6cxVUXOGjHZpkzzO7ZZvjY4aOLY1dv1L6HahRYjYLuSKY46OhVg2ZatEfVPOORxc0wS7hA1iNWZf7o8KUmSdMLE6vj1mY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=CWaP99Nr; arc=none smtp.client-ip=209.85.161.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-5aa241232faso2079447eaf.0 for ; Sun, 14 Apr 2024 03:52:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713091920; x=1713696720; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=z86tADjA34jPDvp0sH69LSJjWH6CGCLDMrpq88/Jt4c=; b=CWaP99NrQRXk3iFK/wgoPbgyUyGNFKCr4YFHVgLI5kt74TfD3aPIvUhRxQY35Y72gr 8US1fOCunZipK17hTN/LOMXEdlxau01EEf07VFTwJvlw3ts18vKMRyQ8LpQOU19oQYhD lOQcO/ev3XiUEttz4LZOXi8DicZ9/bpTUpAO3tM5HiY3kYzQLnhKkZGlTKPb3+axyWtb L7BbkVoyNfRPHCY+51XaJ4kWSuK5GRTPbpDr2N3drgzT7KO0mJ1PnbDSKJrQx04ySfmL hcuq/+Ncj6C+V+qaDlmdU1nfDW3po9kZiKu3LAl4VWu1iSZY+uiCsB8KPQgDFlMt0MT1 1NZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713091920; x=1713696720; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=z86tADjA34jPDvp0sH69LSJjWH6CGCLDMrpq88/Jt4c=; b=wd1TpUINdEFFzMhtmm9xkgxC9YlBgxgZ0v/TFqpgavCehMPAr5HKEG5PEsFzua/t9p YNva1VXG9moA3sBdsm6hZb7+vY3qUcgY2nFnP9HfZkuoAlulx+45W+xW+ix701ZwWtgC ZstZ+43rpTskkIshJGKnFICqvXY6yJsRU5BJ3ZsDsBgtWcUZ5+WawrYWdgiDTtJYR34b VFHCNuHYOibKOWkQrgdmGfjal25zBAQSv861srfZrKn9VvJevqof1g8CSPO5AeHx+6V3 HFjyGyrXeTPjdIZRr4wiwzMURw+jkBrC1fpkdmNZarhCUIlREz/KpkPnYS0bsqUAF3rG FD7g== X-Forwarded-Encrypted: i=1; AJvYcCUVn490mKzo/mgYAXliGGaEBPd0S771vqDLs4gmNNNtaXt54s8OvIbCivxyf3y9lxsTwK/qTlKVB7pIMbUO3AgDVhQSNrqY/7WQrUWg X-Gm-Message-State: AOJu0YxkomlIb5561OcN44a6kuvT6OQVDL71R+wXhYCjfvZucVK5gehx 6eZhyrxVyHUWM/YuCksJ6Qv8aLmznVQKE8+br7ati0vJKcjxPTTAg7SqwaEbOQ== X-Received: by 2002:a05:6808:218c:b0:3c5:eddb:47c1 with SMTP id be12-20020a056808218c00b003c5eddb47c1mr9182957oib.5.1713091919486; Sun, 14 Apr 2024 03:51:59 -0700 (PDT) Received: from thinkpad ([120.60.136.171]) by smtp.gmail.com with ESMTPSA id im22-20020a170902bb1600b001dcfaf4db22sm5944167plb.2.2024.04.14.03.51.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Apr 2024 03:51:59 -0700 (PDT) Date: Sun, 14 Apr 2024 16:21:48 +0530 From: Manivannan Sadhasivam To: Bjorn Helgaas Cc: Jingoo Han , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Marek Vasut , Yoshihiro Shimoda , Thierry Reding , Jonathan Hunter , Vidya Sagar , Vignesh Raghavendra , Richard Zhu , Lucas Stach , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Minghuan Lian , Mingkai Hu , Roy Zang , Kunihiko Hayashi , Masami Hiramatsu , Kishon Vijay Abraham I , Jesper Nilsson , Srikanth Thokala , Shawn Lin , Heiko Stuebner , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Niklas Cassel , linux-arm-kernel@axis.com, linux-rockchip@lists.infradead.org Subject: Re: [PATCH v12 8/8] PCI: endpoint: Remove "core_init_notifier" flag Message-ID: <20240414105148.GC2294@thinkpad> References: <20240327-pci-dbi-rework-v12-8-082625472414@linaro.org> <20240412202216.GA14590@bhelgaas> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240412202216.GA14590@bhelgaas> On Fri, Apr 12, 2024 at 03:22:16PM -0500, Bjorn Helgaas wrote: > On Wed, Mar 27, 2024 at 02:43:37PM +0530, Manivannan Sadhasivam wrote: > > "core_init_notifier" flag is set by the glue drivers requiring refclk from > > the host to complete the DWC core initialization. Also, those drivers will > > send a notification to the EPF drivers once the initialization is fully > > completed using the pci_epc_init_notify() API. Only then, the EPF drivers > > will start functioning. > > > > For the rest of the drivers generating refclk locally, EPF drivers will > > start functioning post binding with them. EPF drivers rely on the > > 'core_init_notifier' flag to differentiate between the drivers. > > Unfortunately, this creates two different flows for the EPF drivers. > > > > So to avoid that, let's get rid of the "core_init_notifier" flag and follow > > a single initialization flow for the EPF drivers. This is done by calling > > the dw_pcie_ep_init_notify() from all glue drivers after the completion of > > dw_pcie_ep_init_registers() API. This will allow all the glue drivers to > > send the notification to the EPF drivers once the initialization is fully > > completed. > > Thanks for doing this! I think this is a significantly nicer > solution than core_init_notifier was. > > One question: both qcom and tegra194 call dw_pcie_ep_init_registers() > from an interrupt handler, but they register that handler in a > different order with respect to dw_pcie_ep_init(). > > I don't know what actually starts the process that leads to the > interrupt, but if it's dw_pcie_ep_init(), then one of these (qcom, I > think) must be racy: > Your analysis is correct. But there is no race observed as of now since the IRQ will only be enabled by configuring the endpoint using configfs interface and right now I use an init script to do that. By that time, the driver would've already probed completely. But there is a slight chance that if the driver gets loaded as a module and the userspace script starts configuring the endpoint interface using inotify watch or something similar, then race could occur since the IRQ handler may not be registered at that point. > qcom_pcie_ep_probe > dw_pcie_ep_init <- A > qcom_pcie_ep_enable_irq_resources > devm_request_threaded_irq(qcom_pcie_ep_perst_irq_thread) <- B > > qcom_pcie_ep_perst_irq_thread > qcom_pcie_perst_deassert > dw_pcie_ep_init_registers > > tegra_pcie_dw_probe > tegra_pcie_config_ep > devm_request_threaded_irq(tegra_pcie_ep_pex_rst_irq) <- B > dw_pcie_ep_init <- A > > tegra_pcie_ep_pex_rst_irq > pex_ep_event_pex_rst_deassert > dw_pcie_ep_init_registers > > Whatever the right answer is, I think qcom and tegra194 should both > order dw_pcie_ep_init() and the devm_request_threaded_irq() the same > way. > Agree. The right way is to register the IRQ handler first and then do dw_pcie_ep_init(). I will fix it in the qcom driver. Thanks for spotting! - Mani -- மணிவண்ணன் சதாசிவம்