From patchwork Fri Aug 3 08:14:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 953104 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IULm79j5"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41hfz10X4sz9ryt for ; Fri, 3 Aug 2018 18:17:00 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id A67D6C21E34; Fri, 3 Aug 2018 08:13:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E435AC21F91; Fri, 3 Aug 2018 08:10:51 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7434AC21FA5; Fri, 3 Aug 2018 08:10:26 +0000 (UTC) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by lists.denx.de (Postfix) with ESMTPS id 4A0E4C21F31 for ; Fri, 3 Aug 2018 08:10:20 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id r5-v6so2505996pgv.0 for ; Fri, 03 Aug 2018 01:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=iljfwTLluQLukW/j9Nz/smiOQsNCLPMtxZvhtmd2vXw=; b=IULm79j5FqnZ0cK4qwSeJpIofnlKOnm87m0L2buDt6Fec2v5cnP7iKUcxeSwanP4NU mflhvSUZR8lyvEPeoGiJsTDNFDkViIPTYrXsbP51sAEFFH66Gp8Q260o1zMzKb8IMm8l pE7WA9b6GHH5mcbSWDQOdNYxV5qI+rZFbVZzCrkucP7YeafMG8j/FP6L89zEp/Wlvamj octH5LlUqYHqtO4DP68Y6/y4KuR9TYqaMAXFRd289TMNQKDSuLNCxVWVC+Sb9ZEKlMpx jpNW6cCThf8VeG8IlHYjbt9SJ4LtvzVDhJ3hBnc6bh73r/A6skr4R+S1CX6bLEOupbHS KauA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=iljfwTLluQLukW/j9Nz/smiOQsNCLPMtxZvhtmd2vXw=; b=V5wqhqD6Vliwg9rtELR18VY1eQkrEikXMN0dBZfhAY6X+ERumkBkIDPD31O0u112IA eDLU8AIjdGTSVhJ7E/StrLA+ENOjOnycihbH5uAYptV1WHqjDQZvT9seBjnVkikOw/qC dTdkiVBI1+Vhqq1kzJACxqXFttWn23juL4dtul6JLVBoIkFi3aOqxRRKFcArLukppFVR 8dy///ZHKFIUx5ukR7Afhcr/z4GdEayVQinOZ/273g3v27AcScaBA3NblcstR9nM+4ow VXVqeUJrx43bQrn7wKpwTmkZyC4h0I3JgAL7wSn4eWZdGYrw+3tqI96i1mcBAcYOEmVd t/yQ== X-Gm-Message-State: AOUpUlEcAKLW4/yn2xe5iQBhSTKEiM3CQyoP8C+4MXefr+zQRyZlPiwV wj9rQybaiWvEw+fm8Lj5NPc= X-Google-Smtp-Source: AAOMgpdxF8ZpKaVx8x+n0k/hT0W8InIgCxlALQZwgdx13jyt2LYDY14dvCQ7jy0u/2PraIykIrwiug== X-Received: by 2002:a62:9dcc:: with SMTP id a73-v6mr3139084pfk.249.1533283818999; Fri, 03 Aug 2018 01:10:18 -0700 (PDT) Received: from ala-d2121-lx1.wrs.com (unknown-156-139.windriver.com. [147.11.156.139]) by smtp.gmail.com with ESMTPSA id 1-v6sm9190070pfk.134.2018.08.03.01.10.17 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Aug 2018 01:10:18 -0700 (PDT) From: Bin Meng To: Simon Glass , U-Boot Mailing List Date: Fri, 3 Aug 2018 01:14:43 -0700 Message-Id: <1533284093-3084-12-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1533284093-3084-1-git-send-email-bmeng.cn@gmail.com> References: <1533284093-3084-1-git-send-email-bmeng.cn@gmail.com> Subject: [U-Boot] [PATCH v3 11/21] pci: sandbox: emul: Fix the call to pci_bus_find_devfn() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" With the newly added test cases for PCI configuration access, we get: => ut dm pci_busdev Test: dm_test_pci_busdev: pci.c test/dm/pci.c:49, dm_test_pci_busdev(): SANDBOX_PCI_VENDOR_ID == vendor: Expected 4660, got 65535 Test: dm_test_pci_busdev: pci.c (flat tree) test/dm/pci.c:49, dm_test_pci_busdev(): SANDBOX_PCI_VENDOR_ID == vendor: Expected 4660, got 65535 Failures: 2 The bug only shows up when bus number is not equal to zero. This is caused by the plain find_devfn parameter is passed to function call pci_bus_find_devfn(), inside which find_devfn is compared to devfn in the device's pplat structure. However pplat->devfn does not carry the bus number. Fix this by passing find_devfn with bus number masked. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/pci/pci-emul-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pci-emul-uclass.c b/drivers/pci/pci-emul-uclass.c index 79e2c14..8570a5d 100644 --- a/drivers/pci/pci-emul-uclass.c +++ b/drivers/pci/pci-emul-uclass.c @@ -21,7 +21,7 @@ int sandbox_pci_get_emul(struct udevice *bus, pci_dev_t find_devfn, struct udevice *dev; int ret; - ret = pci_bus_find_devfn(bus, find_devfn, &dev); + ret = pci_bus_find_devfn(bus, PCI_MASK_BUS(find_devfn), &dev); if (ret) { debug("%s: Could not find emulator for dev %x\n", __func__, find_devfn);