From patchwork Fri Oct 12 05:35:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Mason X-Patchwork-Id: 1585331 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 5136DDFF71 for ; Fri, 12 Oct 2012 05:35:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754335Ab2JLFfw (ORCPT ); Fri, 12 Oct 2012 01:35:52 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:60697 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752207Ab2JLFfw (ORCPT ); Fri, 12 Oct 2012 01:35:52 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr4so2593354pbb.19 for ; Thu, 11 Oct 2012 22:35:51 -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:in-reply-to:references :x-gm-message-state; bh=FHFHGu92Lx3hMEDQM5gvYRdC2xBRJUpqhuyINT22dv0=; b=FZZfk8gQ0OCjAAA96MXpbs32QMD7nGsnrbuxKnM2XNYZsOne7mst5RvVpiuDuxxEzy NsazuVNoiadITt6hmJkkR4W5kq8M0uukGLchTHu8nY6tZ31GCOVxloywbObJIdjTKex9 Bb6+jFxao0RJnXIataokib8sI8Geh0nlBzQWDoIhyZ1MKvkOgR5GYcZIzVa7Z1AfwaVk U7EqyD2JsdrGkcmNgLARbcOdH3eL/DWsZJEQmmMATEBLdAU4jsbGZpDTw2xxpxlzGYMq HPhxTwfV7OTym/wb6hrc+0KZZMFC84jbV4Wcwwz2EFyW8hn4ViXfRtmAu8nbaWQAOp+J tnUA== Received: by 10.68.197.9 with SMTP id iq9mr10295321pbc.130.1350020151782; Thu, 11 Oct 2012 22:35:51 -0700 (PDT) Received: from scylla (174-26-23-139.phnx.qwest.net. [174.26.23.139]) by mx.google.com with ESMTPS id gj9sm3895625pbc.16.2012.10.11.22.35.49 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 11 Oct 2012 22:35:50 -0700 (PDT) Received: by scylla (sSMTP sendmail emulation); Thu, 11 Oct 2012 22:36:03 -0700 From: Jon Mason To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Jon Mason Subject: [PATCH 1/3] PCI: correct static code analysis tool issue Date: Thu, 11 Oct 2012 22:35:53 -0700 Message-Id: <1350020155-3782-2-git-send-email-jdmason@kudzu.us> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1350020155-3782-1-git-send-email-jdmason@kudzu.us> References: <1350020155-3782-1-git-send-email-jdmason@kudzu.us> X-Gm-Message-State: ALoCoQlROlJALuvB0T8R0huw8U8IQVWN2J8261r1A9O4lZqaINHkmZ3l89JFXFqJ1Vo2tD7C2GTo 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 | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 9f8a6b7..6b672c1 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1570,21 +1570,36 @@ 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; - + switch (pcie_bus_config) { + /* 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_PERFORMANCE: /* 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) + case PCIE_BUS_PEER2PEER: smpss = 0; + break; - if (pcie_bus_config == PCIE_BUS_SAFE) { + 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);