From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id B6B64E5D for ; Mon, 30 Apr 2018 16:54:06 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id j5so14728250wme.5 for ; Mon, 30 Apr 2018 07:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=id7G/Mrc1X8cko0+8yt7dBLBnZ3IETEEGxO4fHWD6bo=; b=n0denFLOFtXmuAI5OCv8q1+wd398Zcwvo221eP0HL4h///9ewasGX8fmcbl8E7gsO/ dGRHE9oilKPtwAoqgSE1jT0QAf6dv2DNdjJu/96sDglvLmxm9fEkGG+cXW1umOMKztcp kIGJfVSwml97M3zLdUOcQJ/Kpp8wp9kbEXhhYlgQczSrbgl9xv0aSyQw7jE3HBkjkVxp r1ClYVUecMjE5IqVa3bpnJ41gDnsnfhnuvSwUTW55rZTV58E6ujyXBqFTVnTH3UdK3HK Z1+6ZnHs8BeH/VVgPvbDAcgAccMKA7/sojgPF+SxDRHChszQWhKhPB7GNXzhkru//AJP 0EHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=id7G/Mrc1X8cko0+8yt7dBLBnZ3IETEEGxO4fHWD6bo=; b=a00IvvLyp8kT4wBiYacypV5UOxqTx14UyOwO3SYil6HNQ2ubmdfppu5A6rhJF6/RB2 fxhomK9Fe5dPGt9Uvi8vxipx21HznX/2Z7aiFczmSBTwPX70dy68CooQMnMTGN77HqDz XWqevBtWpvapyE/CS/DY7jGMmskYJ4LRo7jkDhjyfsXuGGNmxRh9rOM/Ky7YGnUKT7r4 JiPnsbRpUm1l3kno08wokNrEO0sq717iCVnOY2VqbpFSBGAsAUVajYXd7+5BWRpbU4Ic PK9pg2XZe76u6r3mKysWOkOG2U7CyNhvgZRtWop3M37/hEBIatycrHvYeawuXB+BtKJK oiag== X-Gm-Message-State: ALQs6tBJp5fTE5ZwES7zsY6hP/kAtrt3AraRvnNwgrESAZt9pGoPFJHr 3VN0Krh7gVYl1AymbgRiDo8= X-Google-Smtp-Source: AB8JxZrB0lS3owjKP5C+ma99h17GdUWXjPdap070MlsTsCaCfgMPxy4qQTZm062RNKScTpWZ9Rxqfw== X-Received: by 10.28.100.67 with SMTP id y64mr7358350wmb.108.1525100046348; Mon, 30 Apr 2018 07:54:06 -0700 (PDT) Received: from localhost ([2a00:23c5:be9a:5200:ce4c:82c0:d567:ecbb]) by smtp.gmail.com with ESMTPSA id b18-v6sm14006521wrb.55.2018.04.30.07.54.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Apr 2018 07:54:05 -0700 (PDT) From: luca.boccassi@gmail.com To: Gaetan Rivet Cc: dpdk stable Date: Mon, 30 Apr 2018 15:53:20 +0100 Message-Id: <20180430145402.23057-1-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180430144223.18657-85-luca.boccassi@gmail.com> References: <20180430144223.18657-85-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'bus/pci: fix find device implementation' has been queued to stable release 18.02.2 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2018 14:54:06 -0000 Hi, FYI, your patch has been queued to stable release 18.02.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/02/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From 8e800a3bc8f3df06239b4a5edbda790594dd4762 Mon Sep 17 00:00:00 2001 From: Gaetan Rivet Date: Fri, 27 Apr 2018 16:13:05 +0200 Subject: [PATCH] bus/pci: fix find device implementation [ upstream commit 64de7e4069b9b84b0f2d840b44e334233412d55f ] If start is set, and a device before it matches the data passed for comparison, then this first device is returned. This induces potentially infinite loops. Fixes: c7fe1eea8a74 ("bus: simplify finding starting point") Signed-off-by: Gaetan Rivet --- drivers/bus/pci/pci_common.c | 21 ++++++++++++--------- drivers/bus/pci/rte_bus_pci.h | 3 +++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index 2a00f365a..2c45f8151 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -459,17 +459,20 @@ static struct rte_device * pci_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, const void *data) { - struct rte_pci_device *dev; + const struct rte_pci_device *pstart; + struct rte_pci_device *pdev; - FOREACH_DEVICE_ON_PCIBUS(dev) { - if (start && &dev->device == start) { - start = NULL; /* starting point found */ - continue; - } - if (cmp(&dev->device, data) == 0) - return &dev->device; + if (start != NULL) { + pstart = RTE_DEV_TO_PCI_CONST(start); + pdev = TAILQ_NEXT(pstart, next); + } else { + pdev = TAILQ_FIRST(&rte_pci_bus.device_list); + } + while (pdev != NULL) { + if (cmp(&pdev->device, data) == 0) + return &pdev->device; + pdev = TAILQ_NEXT(pdev, next); } - return NULL; } diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h index 357afb912..458e6d076 100644 --- a/drivers/bus/pci/rte_bus_pci.h +++ b/drivers/bus/pci/rte_bus_pci.h @@ -74,6 +74,9 @@ struct rte_pci_device { */ #define RTE_DEV_TO_PCI(ptr) container_of(ptr, struct rte_pci_device, device) +#define RTE_DEV_TO_PCI_CONST(ptr) \ + container_of(ptr, const struct rte_pci_device, device) + #define RTE_ETH_DEV_TO_PCI(eth_dev) RTE_DEV_TO_PCI((eth_dev)->device) /** Any PCI device identifier (vendor, device, ...) */ -- 2.14.2