From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 51762A04AF; Mon, 28 Sep 2020 11:43:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5AEE61D65E; Mon, 28 Sep 2020 11:43:00 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by dpdk.org (Postfix) with ESMTP id 108C01D657 for ; Mon, 28 Sep 2020 11:42:57 +0200 (CEST) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601286176; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8wTBwJY1nBCqy+ooYbDgxW8uLxPg5hTssrazskuMXEA=; b=OWedxHcWMkTpSAIVrVKUYS6Uds+6yXQ8dS3qIwemxEnAgdy2S0FqXsAO7FIUA+iUW9k0LQ PY4qD5nzyBYnsGk/5uijXDVeMI4cSZeLsCgnmjUktCTChU2IGTI4MJFHzz2JtEjfxnr5N4 ak/OILi1GsYiwkts3XhlEK953IS9d5U= Received: from mail-vs1-f72.google.com (mail-vs1-f72.google.com [209.85.217.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-429-JmRcsvH3OP6ww10UZgf_ZQ-1; Mon, 28 Sep 2020 05:42:54 -0400 X-MC-Unique: JmRcsvH3OP6ww10UZgf_ZQ-1 Received: by mail-vs1-f72.google.com with SMTP id 125so119185vst.23 for ; Mon, 28 Sep 2020 02:42:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8wTBwJY1nBCqy+ooYbDgxW8uLxPg5hTssrazskuMXEA=; b=KmZ7tBUb/VrKEr9bZF6fAqtMY/KfGoeDUjL9Wvb2EmW/PWalbAisCtQ2xmvnlmIWCb GhIoXAL3SouFknZj8CIXfKqN4QdG52sUIowMn5tEfUxuKueM26kn4u4GBjLXUnA9q3Ao ChqSPw3rg0OR+ITfTvLQ7tJ2NnQkid/0YsMboijGH2HmiEAmiYI68cLIl46fFW/rfZTP k/qML4GF30jh1Kg7o1s41RB2ITYbYuue32rS8KkABkoLondvo51x2YbzoEQZ4IqpLxpo FOsuEDcUkz5Ct1t5tI0JiNgi+Xsr4lleEccZIadi035zwLpj3mEB639U3LtmoLVHOZS5 F+pQ== X-Gm-Message-State: AOAM531xSzMydWWVkd2jBLYyCtGz+pQV/Fh6PO+rjsDhE62a13BFww9M kPbVTwVQ3xDTKJZHLOliDA0Ohv5X+0w0P4tAX6YFWiZxIrgFL1TPjvlQrl0mhb3XLzkh0+hMKCb +rN5Q48YmTONieLK+z6Y= X-Received: by 2002:a05:6102:20e:: with SMTP id z14mr317752vsp.17.1601286174121; Mon, 28 Sep 2020 02:42:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTd2NMtha8Z1IbUxExLM6bxvdjz8vbINenzB5p+r5zHrUrONiSbbyskOdfFGqVeTCnOfCx08Vb1Q8n68y7FcA= X-Received: by 2002:a05:6102:20e:: with SMTP id z14mr317746vsp.17.1601286173908; Mon, 28 Sep 2020 02:42:53 -0700 (PDT) MIME-Version: 1.0 References: <20200925021435.16114-1-hyonkim@cisco.com> In-Reply-To: <20200925021435.16114-1-hyonkim@cisco.com> From: David Marchand Date: Mon, 28 Sep 2020 11:42:42 +0200 Message-ID: To: Hyong Youb Kim Cc: Ferruh Yigit , Thomas Monjalon , dev , John Daley , Anatoly Burakov Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH] bus/pci: fix mapping BAR containing MSI-X table X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Fri, Sep 25, 2020 at 4:15 AM Hyong Youb Kim wrote: > > When the BAR contains MSI-X table, pci_vfio_mmap_bar() tries to skip > the table and map the rest. "map around it" is the phrase used in the > source. The function splits the BAR into two regions: the region > before the table (first part or memreg[0]) and the region after the > table (second part or memreg[1]). > > For hardware that has MSI-X vector table offset 0, the first part does > not exist (memreg[0].size == 0). > > Capabilities: [60] MSI-X: Enable- Count=48 Masked- > Vector table: BAR=2 offset=00000000 > PBA: BAR=2 offset=00001000 > > The mapping part of the function maps the first part, if it > exists. Then, it maps the second part, if it exists and "if mapping the > first part succeeded". > > The recent change that replaces MAP_FAILED with NULL breaks the "if > mapping the first part succeeded" condition (1) in the snippet below. > > void *map_addr = NULL; > if (memreg[0].size) { > /* actual map of first part */ > map_addr = pci_map_resource(...); > } > > /* if there's a second part, try to map it */ > if (map_addr != NULL // -- (1) > && memreg[1].offset && memreg[1].size) { > [...] > } > > if (map_addr == NULL) { > RTE_LOG(ERR, EAL, "Failed to map pci BAR%d\n", > bar_index); > return -1; > } > > When the first part does not exist, (1) sees map_addr is still NULL, > and the function fails. This behavior is a regression and fails > probing hardware with vector table offset 0. > > Previously, (1) was "map_addr != MAP_FAILED", which meant > pci_map_resource() was actually attempted and failed. So, expand (1) > to check if the first part exists as well, to match the semantics of > MAP_FAILED. > > Bugzilla ID: 539 > Fixes: e200535c1ca3 ("mem: drop mapping API workaround") > > Signed-off-by: Hyong Youb Kim Acked-by: Anatoly Burakov Applied, thanks. -- David Marchand