Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2137780lqo; Mon, 13 May 2024 08:50:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW3z6dYVxlsq4NtPb4kBE2F9WuglhUi0HvQi3lzk6eAN161jNrSl6+7m9me3H7MG5y7muV3AuG3/Bbu+Nle6hQAheNccnkoBKtI+ztclg== X-Google-Smtp-Source: AGHT+IGa678SChPoLJWvDs+9oEFtEKe4hBcR5NMiWQHaf6pdK1lv1eZXXOU4+R632pxJ/GvkNo/M X-Received: by 2002:a17:903:228d:b0:1e5:a3b2:3dad with SMTP id d9443c01a7336-1ef43f51f2cmr139789255ad.42.1715615417303; Mon, 13 May 2024 08:50:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715615417; cv=pass; d=google.com; s=arc-20160816; b=t/z+xB4Ocy/tJ+v5OCbTgw8VFu2btPxTGrAfXS5r5TmU7/kH5BirNMxIxJ+VdJ9Ck9 RmWwx9/xebFNOu2AQzlynytDQ/Xmz12yMIpjdwVrB5qqEdPnZS2+8DYGQiWjOLwPZQQD jBVpJuN1I/pOVMeu5kydctALIJXBCuzVqRjE5y+vZhWO3lkQU/P74Vn71qXB2Kdl3tiN UVHMrwRLRK/HaZItQdvrr+XK7TU2mJmdCE+A5dPM8DBmPiu5dbwEtT4zR+rWTDN3Wtx8 NNalJjvjPHH3b4g3FKDYf6/ILEUO1kbjYtYIae8XlVUW9exCFI7j2SYYxkrTXMqC3ysE KpEQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=V6WCHEmdC5HDoJfqqfWkmm0fxg3UNJhsL4sisIOTexc=; fh=7M/bxzgXrn2ODR+4Ety/bDk1zPoBhVFr26hUJ6zzwJg=; b=e34yI5m/fLsVsMq6shbMegJ2nRMz6B4Q7uc5Jxuu4JsvvTDZCKKs9HoQ/c5+LXluho d2obIIBpFVllAfiQqe79xvsMi5PQrP7loF1uPr3nG4mEvm6vuJ/Mqik+GYU0YzlEvO1K ocOBbp5w+TfInftvBDJIyE8ZtSdNJbbuRFr7ghI4XgXcPmhLVkRdgCIf654ZrS45u3PP mnEBHylVPIOqWpsFK1x8kqHBpZMm/Bz1PDswgWqZ7pnQwUWun1VhqtgkAexDvKEn/c8D +TNXyyKM8oNzHYJPYKnSP8YeqwCqAn+XkA5BlPUYPmtUewgtGOmfEHTwnO2fjV9QTEAn J0qQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I2CpCi4z; 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-177780-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177780-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c03b0cesi97260865ad.430.2024.05.13.08.50.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 08:50:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177780-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I2CpCi4z; 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-177780-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177780-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 52771B23A35 for ; Mon, 13 May 2024 15:49:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A2539154444; Mon, 13 May 2024 15:49:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="I2CpCi4z" Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 11658154427 for ; Mon, 13 May 2024 15:49:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715615352; cv=none; b=K2jrz2XOOxRtsxYXuJ8z7LI0XPMUeIztfd7pxQAa1ZTrKedxX9MqkYuGU28W/sytVP2P7YJhKUKjvCNVecCULmvdOs3KzhrZJ8v09ua6A9kzgRsfRSGRYDRbpT0npvXUVAjyR5qoOMRarSEjcVK38KSTdp14mLf2YB9xyI24ViU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715615352; c=relaxed/simple; bh=NIN1KoznpuO/QWyceeY5hhLz6j97HZ/lyYNmNLozLJg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=svp7l80v6Jh/gb5lQp5u9faSXZ7cxhhkV/YDWWKPqOZPZAmZI6nDKQC+bNuMqnuF7WXYgwnbIwogtv/Eu44GVpYIIspKkElW4xCR3+dZrtxGkC4pk1fNKR5dA8NTOc64CwuH3xX1ZtRgQmgI0MBPcKRHGTOsGHu8JFx8WmivDmE= 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=I2CpCi4z; arc=none smtp.client-ip=209.85.128.43 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-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4201986d60aso5551555e9.3 for ; Mon, 13 May 2024 08:49:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715615349; x=1716220149; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=V6WCHEmdC5HDoJfqqfWkmm0fxg3UNJhsL4sisIOTexc=; b=I2CpCi4zCt2QFRz5i3oAiVgrfv2EBbhUTruOjfOGiWCRn4k6QKwSZH7nrGiTICU+fr mPPrE+QT7iidcCPx65YJc7GtA31PNxrl2e1FB+N7/ZigXizOQyw5aWDb5RNgVDbiqjqp CC47TuZRlnLQu07p8qbvM3ndLcGBuqJJfXDN2MTEZ54T+5V1YAQc7LNQZr3WdDB5qE2K V05xA5V1Eqf2TpcNQK3cjfrCzEUTGZsUhHs/qSHNiuc9SMobFsX61kr7nr+vNW+/3FGz 0u6NWb23sWHodain4+ZUCNosxr3zsuMWrmSjdf98orCDnRACTtQf+vFOuY5y4R+9PdKO INhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715615349; x=1716220149; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=V6WCHEmdC5HDoJfqqfWkmm0fxg3UNJhsL4sisIOTexc=; b=fHcavK7c1KSmykfQ6ZUzlhlzaTUlDiREJk64hNSSyN2aTMpfY/UCUu9aZ5KhiVhGg8 h2mGw3LpJJOHApi2iwt0JiZZslmMtQHHDk3htJ+aQFC669Q08P0CWhBvSqSyowzVvDQe vKFnycR9k6YlRYXGggyKsIDuTcuOJjj/k6JWdWsPW+f8cRtUEzG9a4NhSi9fL+ZRdN4Z zdJlre2MqYIJrvM4umvT743tICkRc/WlKwNp70qAMHeDuJ3MRbklE0qJjO4SviEJ9/Q8 1OzlFMys2z3z2XT9rOHYybDStA4PFtgRYaG+KcinU459StBmD0vGeGUfEheIU/8EdNu6 rWag== X-Forwarded-Encrypted: i=1; AJvYcCXplL139Q2QmoSjNzRDPzCQe2NyPupKsFntchx3UcKwXJ3dWVb3KHuxfCzo15yio3VsrAS+u1/g4CVscP2jfN4WDLy8PNfkkhYu0uBn X-Gm-Message-State: AOJu0YwUycsx0cpZx/NA8/DV5MVy+el6WuwlZBFCfebpeYTe+qQdJmKY gqDJrruGmvQNbbtIF4sCOZ0amioUGb2GQwgJUkhWArq+n+woygHkjHndVoeDmA== X-Received: by 2002:a05:600c:1d0a:b0:41a:ff7d:2473 with SMTP id 5b1f17b1804b1-41feaa2f414mr86453735e9.4.1715615349104; Mon, 13 May 2024 08:49:09 -0700 (PDT) Received: from localhost.localdomain ([149.14.240.163]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502b79bcf9sm11503628f8f.6.2024.05.13.08.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 08:49:08 -0700 (PDT) From: Manivannan Sadhasivam To: lpieralisi@kernel.org, kw@linux.com, bhelgaas@google.com Cc: robh@kernel.org, thierry.reding@gmail.com, jonathanh@nvidia.com, vidyas@nvidia.com, linux-pci@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , kernel test robot Subject: [PATCH] PCI: tegra194: Add check for host and endpoint modes Date: Mon, 13 May 2024 17:49:00 +0200 Message-Id: <20240513154900.127612-1-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Tegra194 driver supports both the host and endpoint mode, but there are no checks to validate whether the corresponding mode is enabled in kernel config or not. So if the driver tries to function without enabling the required mode (CONFIG_PCIE_TEGRA194_HOST/CONFIG_PCIE_TEGRA194_EP), then it will result in driver malfunction. So let's add the checks in probe() before doing the mode specific config and fail probe() if the corresponding mode is not enabled. But this also requires adding one redundant check in pex_ep_event_pex_rst_assert() for pci_epc_deinit_notify(). Because the function is called outside of probe() and the compiler fails to spot the dependency in probe() and still complains about the undefined reference to pci_epc_deinit_notify(). Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202405130815.BwBrIepL-lkp@intel.com Signed-off-by: Manivannan Sadhasivam --- drivers/pci/controller/dwc/pcie-tegra194.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c index d2223821e122..e02a9bca70ef 100644 --- a/drivers/pci/controller/dwc/pcie-tegra194.c +++ b/drivers/pci/controller/dwc/pcie-tegra194.c @@ -1715,7 +1715,16 @@ static void pex_ep_event_pex_rst_assert(struct tegra_pcie_dw *pcie) if (ret) dev_err(pcie->dev, "Failed to go Detect state: %d\n", ret); - pci_epc_deinit_notify(pcie->pci.ep.epc); + /* + * We do not really need the below guard as the driver won't probe + * successfully if it tries to probe in EP mode and + * CONFIG_PCIE_TEGRA194_EP is not enabled. But since this function is + * being called outside of probe(), compiler fails to spot the + * dependency in probe() and hence this redundant check. + */ + if (IS_ENABLED(CONFIG_PCIE_TEGRA194_EP)) + pci_epc_deinit_notify(pcie->pci.ep.epc); + dw_pcie_ep_cleanup(&pcie->pci.ep); reset_control_assert(pcie->core_rst); @@ -2245,6 +2254,11 @@ static int tegra_pcie_dw_probe(struct platform_device *pdev) switch (pcie->of_data->mode) { case DW_PCIE_RC_TYPE: + if (!IS_ENABLED(CONFIG_PCIE_TEGRA194_HOST)) { + ret = -ENODEV; + goto fail; + } + ret = devm_request_irq(dev, pp->irq, tegra_pcie_rp_irq_handler, IRQF_SHARED, "tegra-pcie-intr", pcie); if (ret) { @@ -2261,6 +2275,11 @@ static int tegra_pcie_dw_probe(struct platform_device *pdev) break; case DW_PCIE_EP_TYPE: + if (!IS_ENABLED(CONFIG_PCIE_TEGRA194_EP)) { + ret = -ENODEV; + goto fail; + } + ret = devm_request_threaded_irq(dev, pp->irq, tegra_pcie_ep_hard_irq, tegra_pcie_ep_irq_thread, -- 2.25.1