From patchwork Mon Nov 7 15:31:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Song X-Patchwork-Id: 13034569 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3B23C4332F for ; Mon, 7 Nov 2022 15:32:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231809AbiKGPb7 (ORCPT ); Mon, 7 Nov 2022 10:31:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231698AbiKGPb7 (ORCPT ); Mon, 7 Nov 2022 10:31:59 -0500 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDFFE1F2FB; Mon, 7 Nov 2022 07:31:57 -0800 (PST) Received: by mail-pj1-x1042.google.com with SMTP id e7-20020a17090a77c700b00216928a3917so10114410pjs.4; Mon, 07 Nov 2022 07:31:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Xe7Vf2fqmhjfKJbAENjC282hA0fF9hfDgyTK1BSujFM=; b=Fr1d+LDHwevMeyCpAaZMAQA0nOzCctwpC44IJanDyPOeP/1jasRetxNDorlo9j7TgZ 6hfhveZRk7O0o3+65DTj5BLCPE/O6tG97G/vt4BFWOJwECH7VbJBD5beIJiorbXiBIP1 8CYSFIq6K8/q1aQsLaHYJwhRLcheHbHRFOG9z3RM1VWYKDuf3mBLoegyg9rQjcankFTL 0ZDK7GtY9XOgzp3ZDMiaIwl5ViUXhW5K4zn1vP/cJVe0UilbBOKRd8MWIuKyNFX55oqR LV6IuUFxp/mQyfwmppSTbybh+fQmoCTZQG6K9sOF1arOLVNCp7OJcEUKSCubVIImDNwM 1zLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Xe7Vf2fqmhjfKJbAENjC282hA0fF9hfDgyTK1BSujFM=; b=ViL0/27HP/evwfDxsuTx550W272K3ynDwGBze2VOkZZeLo8eE/cJ2zp+V/bJNOdUr3 PmBWmfx6TBgL599wjPtuUK/j32VKUKIMlVHbavW8+S61AuixydzMxUsLV36ROM2d2Ybb GMcAZ8X77qLDskYBaftFKpgDIXru31sjqiJ9SirZjrvlgu3PdHhZWIvALMm0PwtFH9bd vN+3bwu0h7CO7N1fYgYJrjNM2NgsHn4oLmqTSXirPNRSq74nlrWUPDJKUDg+ftU0q/2G i93au46InPFQX0zOdrEJ1DyduP+KB75YLHigi1i7MCetQVDbg6nUR0xY3rEFXvRrCXHu 0TWQ== X-Gm-Message-State: ACrzQf2xWAo1E9BGCywBKJoHNj3LSNMgB8lh5RJr8jlVyiQ+tiDv2jbT 9YgUzZOvyxe6A71QLobkekOme6n5OIntdQ== X-Google-Smtp-Source: AMsMyM76YngygHaPtJLkp0nl39HicmW2EAkqC2cac5M+80l1HPl93v9HBRoJvkwmFywH0B2I/w47gA== X-Received: by 2002:a17:90b:3c0c:b0:216:ab4c:5bfc with SMTP id pb12-20020a17090b3c0c00b00216ab4c5bfcmr20368718pjb.135.1667835117396; Mon, 07 Nov 2022 07:31:57 -0800 (PST) Received: from junjun.localdomain ([113.140.248.157]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b00180a7ff78ccsm5139343plg.126.2022.11.07.07.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 07:31:56 -0800 (PST) From: JunDong Song To: jingoohan1@gmail.com, gustavo.pimentel@synopsys.com, lpieralisi@kernel.org Cc: robh@kernel.org, kw@linux.com, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, JunDong Song Subject: [PATCH 1/2] PCI: dwc-host: Add a warning to prevent invalid values Date: Mon, 7 Nov 2022 23:31:07 +0800 Message-Id: <20221107153108.5770-1-jundongsong1@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org of_pci_get_max_link_speed() may return a negative value, causing the controller to not set the speed correctly. Add a warning in case the driver engineer misses it. Signed-off-by: JunDong Song --- When I use the pcie dwc driver, the controller speed is abnormal, but it has not been detected because of the @max-link-speed error, so I think I need to return an error or warning here. Thanks. drivers/pci/controller/dwc/pcie-designware-ep.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 83ddb1902..573342601 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -739,8 +739,11 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) return -ENOMEM; ep->outbound_addr = addr; - if (pci->link_gen < 1) + if (pci->link_gen < 1) { pci->link_gen = of_pci_get_max_link_speed(np); + if (unlikely(pci->link_gen < 0)) + dev_warn(dev, "Failed to get max link speed\n"); + } epc = devm_pci_epc_create(dev, &epc_ops); if (IS_ERR(epc)) { From patchwork Mon Nov 7 15:31:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Song X-Patchwork-Id: 13034570 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F74FC433FE for ; Mon, 7 Nov 2022 15:32:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232538AbiKGPcG (ORCPT ); Mon, 7 Nov 2022 10:32:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232507AbiKGPcE (ORCPT ); Mon, 7 Nov 2022 10:32:04 -0500 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D17E1F9D6; Mon, 7 Nov 2022 07:32:04 -0800 (PST) Received: by mail-pj1-x1043.google.com with SMTP id b11so10920472pjp.2; Mon, 07 Nov 2022 07:32:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OZs6+8Cv8xWSPLX0Qi/Fzkt7aGwFHCvaqnCns2dt4ww=; b=kq1tirL/q/Rt3zlWfS2mBj0DhFo6mQZihF3KKzgY8JayWJDl/BRHOgMxk0eMXeV/IG p1ykC0yxcCQwC0qADvGNLmg+YNmw6b7JwdNR2DH232OQejpRYxPnTAPusk1qPoKA9PT8 JjiwFDfAho0y2PN3VvybhhBVLF6Raf//lkIWBvlBAUTu45pOjsX+EuN4ZqjhcAjB30xp +s8TYOFSxcbi2ZYkCTqJpEk03BNvXhgf1d3+htmJnZ582m+E9cdxeIbp6FHcHM8suYNc 70M8K8wqfFQbfrGJDnvonNgRfqE8yBlPiqjYSUlWggTf98oeZ6tx5BI080i+iWiMETOB fBFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OZs6+8Cv8xWSPLX0Qi/Fzkt7aGwFHCvaqnCns2dt4ww=; b=xk3OaACBWaljM7q5f2OhQzx8zPcNJsN2lezNNizVy0UxH3RfymcBy29w2npIvan2s0 CaWCYeM6LhL/vChDDHrrjzaAmDCUeBPWpLT5Zp74cGt16MxDrmnvtzvBIda/jrRzWEtJ LgzfUnoBN8Ar+x6+KLRPiJN8q7RDRdf3G2lFV60YjRm9R1Bxi1cf+EuCula8IvoLfqI1 8P1J8YVxbdlgDmWbn3J7VKpxXdsBMBR5X3/3Bbhmqtqh0jyE7Vq0ln6BwP3N0vPbpM5z a7NEvGj1rl0Eg+bg3qKO4yFvlvxY5HWjWLlIjqV5KdSml4sIaxzeOBoNALpLnNe05987 5MKA== X-Gm-Message-State: ACrzQf3x0XWgZRyYg6wBBkuzX+SL5iVirhegyRxUucv6DRij0cv2fkqo 492hGcvRSEVwvXW+6iSrW8w= X-Google-Smtp-Source: AMsMyM7+bEs1K6hPHyWAboG/pBYceVbCj2JlGjW/S4S9NkMToyenmq/pX00pHk8BjJQX5YriWrdqWQ== X-Received: by 2002:a17:902:a383:b0:187:34f6:439d with SMTP id x3-20020a170902a38300b0018734f6439dmr35090489pla.35.1667835123572; Mon, 07 Nov 2022 07:32:03 -0800 (PST) Received: from junjun.localdomain ([113.140.248.157]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b00180a7ff78ccsm5139343plg.126.2022.11.07.07.32.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 07:32:03 -0800 (PST) From: JunDong Song To: jingoohan1@gmail.com, gustavo.pimentel@synopsys.com, lpieralisi@kernel.org Cc: robh@kernel.org, kw@linux.com, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, JunDong Song Subject: [PATCH 2/2] PCI: dwc-host: Add a warning to prevent invalid values Date: Mon, 7 Nov 2022 23:31:08 +0800 Message-Id: <20221107153108.5770-2-jundongsong1@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221107153108.5770-1-jundongsong1@gmail.com> References: <20221107153108.5770-1-jundongsong1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org of_pci_get_max_link_speed() may return a negative value, causing the controller to not set the speed correctly. Add a warning in case the driver engineer misses it. Signed-off-by: JunDong Song --- When I use the pcie dwc driver, the controller speed is abnormal, but it has not been detected because of the @max-link-speed error, so I think I need to return an error or warning here. Thanks. drivers/pci/controller/dwc/pcie-designware-host.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 39f3b37d4..0103b9a63 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -429,8 +429,11 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp) pp->io_base = pci_pio_to_address(win->res->start); } - if (pci->link_gen < 1) + if (pci->link_gen < 1) { pci->link_gen = of_pci_get_max_link_speed(np); + if (unlikely(pci->link_gen < 0)) + dev_warn(dev, "Failed to get max link speed\n"); + } /* Set default bus ops */ bridge->ops = &dw_pcie_ops;