From nobody Fri Jul 10 23:12:16 2026 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="I2CpCi4z" 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-Google-Smtp-Source: AGHT+IGzFcU86ZXbFHnFdO/6QzUc+dgd+s0ZJLfz2MBsc0jnrPY/2M3aQNnsKSWVS72kZvNcFaC8hA== 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: quoted-printable Content-Type: text/plain; charset="utf-8" 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@int= el.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/contr= oller/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); =20 - 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); =20 reset_control_assert(pcie->core_rst); @@ -2245,6 +2254,11 @@ static int tegra_pcie_dw_probe(struct platform_devic= e *pdev) =20 switch (pcie->of_data->mode) { case DW_PCIE_RC_TYPE: + if (!IS_ENABLED(CONFIG_PCIE_TEGRA194_HOST)) { + ret =3D -ENODEV; + goto fail; + } + ret =3D 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_devic= e *pdev) break; =20 case DW_PCIE_EP_TYPE: + if (!IS_ENABLED(CONFIG_PCIE_TEGRA194_EP)) { + ret =3D -ENODEV; + goto fail; + } + ret =3D devm_request_threaded_irq(dev, pp->irq, tegra_pcie_ep_hard_irq, tegra_pcie_ep_irq_thread, --=20 2.25.1