From patchwork Thu Jul 26 02:34:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Mason X-Patchwork-Id: 1240121 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 5B2BFDFFCD for ; Thu, 26 Jul 2012 02:34:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752249Ab2GZCeQ (ORCPT ); Wed, 25 Jul 2012 22:34:16 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:48556 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752144Ab2GZCeQ (ORCPT ); Wed, 25 Jul 2012 22:34:16 -0400 Received: by yenl2 with SMTP id l2so1464640yen.19 for ; Wed, 25 Jul 2012 19:34:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=nmmpefasGuKjG9rDEBzWS/RBrA0B3nXe7KmTOhBRnxQ=; b=Qxn1kdapp+ETK0hnN8bKuMX6hvI58qplstk7LckAjNi45SsxR8IIvgRVepnFp/7mKg Ib7IpqZKeoWdpf1F0SgB0DauM+fAlM3kKWRO4Ilhrxd1RkhThPsF+iD2bS/eZw9jGteB 8OLXT2/hc0lImPrv5luloSQ4KOvogEunQUjti9RlL2aJfiRRqy5dAHSiYQL6Pv9wDgvh yHKixo4UykWOHOZSQ5eiWHovMj9uOTCcz/nVm12xjUFKIyLSWjTka5qdXcfriG88oCpL XDpHPcLYK27Kk5mmYrQSC38jUrkrb4YY3jZ0bDNRecSuBhAMTH2k5EGgqjNZu3pggGlJ 0AUA== Received: by 10.66.83.200 with SMTP id s8mr17014353pay.10.1343270055014; Wed, 25 Jul 2012 19:34:15 -0700 (PDT) Received: from scylla (184-98-28-109.phnx.qwest.net. [184.98.28.109]) by mx.google.com with ESMTPS id oy8sm15516914pbc.52.2012.07.25.19.34.11 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 Jul 2012 19:34:13 -0700 (PDT) Received: by scylla (sSMTP sendmail emulation); Wed, 25 Jul 2012 19:34:11 -0700 From: Jon Mason To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org Subject: [PATCH] PCI: correct static code analysis tool issue Date: Wed, 25 Jul 2012 19:34:11 -0700 Message-Id: <1343270051-5217-1-git-send-email-jdmason@kudzu.us> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQmykwZzIFTe7La0eZZZ8Ra7RN0dtNt9S8BzD0B+65PHt9VINIGatQc4Df8ys/AA1Fkz2FeL Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Coverity noticed that pcie_bus_configure_settings() can call pcie_bus_configure_set() when "smpss" is uninitialized. The smpss is used to make the bus and all child devices have a uniform value. Setting the smpss is moot for PCIE_BUS_PERFORMANCE, since it will be determined dynamically based on the max size of the parent device and the child device. To avoid the erroneous detection of this issue, set the smpss to 0. Also, add a case statement to make clearer the possible use cases and add a nice comment describing what is being done in the PCIE_BUS_PERFORMANCE case. Signed-off-by: Jon Mason --- drivers/pci/probe.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 6c143b4..e813846 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1567,21 +1567,33 @@ void pcie_bus_configure_settings(struct pci_bus *bus, u8 mpss) if (!pci_is_pcie(bus->self)) return; - if (pcie_bus_config == PCIE_BUS_TUNE_OFF) - return; - - /* FIXME - Peer to peer DMA is possible, though the endpoint would need - * to be aware to the MPS of the destination. To work around this, - * simply force the MPS of the entire system to the smallest possible. - */ - if (pcie_bus_config == PCIE_BUS_PEER2PEER) + switch (pcie_bus_config) { + case PCIE_BUS_PERFORMANCE: + /* The smpss is used to make the bus and all child devices have + * a uniform value. Setting the smpss is moot for + * "Performance", since it will be determined dynamically based + * on the max size of the parent device and the child device. + * However, not setting the smpss can result in static code + * analysis tools erroniously reporting an issue. To avoid + * this, set the smpss to 0. + */ + case PCIE_BUS_PEER2PEER: + /* FIXME - Peer to peer DMA is possible, though the endpoint + * would need to be aware to the MPS of the destination. To + * work around this, simply force the MPS of the entire system + * to the smallest possible. + */ smpss = 0; - - if (pcie_bus_config == PCIE_BUS_SAFE) { + break; + case PCIE_BUS_SAFE: smpss = mpss; pcie_find_smpss(bus->self, &smpss); pci_walk_bus(bus, pcie_find_smpss, &smpss); + break; + case PCIE_BUS_TUNE_OFF: + default: + return; } pcie_bus_configure_set(bus->self, &smpss);