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 1DB6CA00BE; Wed, 8 Jul 2020 11:39:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 77CBC1D9CF; Wed, 8 Jul 2020 11:39:23 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 766441D9AC for ; Wed, 8 Jul 2020 11:39:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594201160; 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=JAd6BKaA0SzwMqLYb/nnQTzyb2XAbzqmg62uF6UxxIE=; b=jC/wm1Z8BZBsVVRhEF4Tz1ZLv2cfvgmbhSKJ9u5J2FY9E7//Ku4fp+T223U4WWIc4voDhk qRcNF898CNN8wa3wy4E63PS+ieU6xtFbMcEbvJEG9efDw0pBp3pzuq0LDbRINfpZFYa+pi x5lDpoD37V7xU5PznThWhtTiAdmXuPQ= Received: from mail-vk1-f200.google.com (mail-vk1-f200.google.com [209.85.221.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-350-Kqn0UwJoOJO1c7129jKt_w-1; Wed, 08 Jul 2020 05:39:07 -0400 X-MC-Unique: Kqn0UwJoOJO1c7129jKt_w-1 Received: by mail-vk1-f200.google.com with SMTP id e12so7326715vkd.3 for ; Wed, 08 Jul 2020 02:39:07 -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=JAd6BKaA0SzwMqLYb/nnQTzyb2XAbzqmg62uF6UxxIE=; b=p1JKTbAD6o6TTjyVYcrx15L18/l/uR0fVyEm3sjTyQdh5jgbMhO+k6x6QuJWl6MahV 3OirDjNqvKpYjInpNQO3DyDjq75s3ErgaT3wdEP6F2by/a6QYRlgQ/NAAngqVUo+MAEE v7N40KFLbRWIvGAPlFO+HCLpRRowZCNcVJTc/SJLPvNWONfdhWW2U9HHnlVZeTxCaAyA KXdi+APNlk9ZsyE0fU71JVOUlXn2cAoHxjsSfOO/kYnX+Q3N1S/yhDDuPHbYdAzh0kgC 1aWwL879GBLBGhjk3be/98ExTc+fnQjv+PYpM+07oNtxg0z2n1bWoHzNT0ikNL5Bcwba qxzg== X-Gm-Message-State: AOAM532MphvLorIz+KW5oqNzFBrICiH2IX9ppksWSNH2freIFu0ruJhY XvBoXj2B8LJdJ1f2Cgw4UUP4RTdGBSDdIW4SOwdgJ8D1B/BiPGM8R/h5k2XOXszC+52o/VF5H/z GyrHHv3dTgEd2s//Rj7g= X-Received: by 2002:a67:c58c:: with SMTP id h12mr35783298vsk.141.1594201146741; Wed, 08 Jul 2020 02:39:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSssdeYL5k82db0luYyJFD4h1RfF4tLaqopGFo3m/bovWqMUcVnriYyM0vT/G4dmhDhgxofdS1fb7wEPEIw14= X-Received: by 2002:a67:c58c:: with SMTP id h12mr35783287vsk.141.1594201146481; Wed, 08 Jul 2020 02:39:06 -0700 (PDT) MIME-Version: 1.0 References: <20200708092435.9776-1-alvinx.zhang@intel.com> In-Reply-To: <20200708092435.9776-1-alvinx.zhang@intel.com> From: David Marchand Date: Wed, 8 Jul 2020 11:38:55 +0200 Message-ID: To: Tal Shnaiderman , "Burakov, Anatoly" Cc: dev , Beilei Xing , Jeff Guo , "Ma, LihongX" , "Zhang, AlvinX" 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 mmap PCI resource 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 Wed, Jul 8, 2020 at 11:26 AM wrote: > > From: Alvin Zhang > > When mapping a PCI BAR containing an MSI-X table, some devices do not > need to actually map this BAR or only need to map part of them, which > may cause the mapping to fail. Now some checks are added and a non-NULL > initial value is set to the variable to avoid this situation. > > Fixes: 2fd3567e5425 ("pci: use OS generic memory mapping functions") > Cc: talshn@mellanox.com > > Signed-off-by: Alvin Zhang I guess this had to do with: https://bugs.dpdk.org/show_bug.cgi?id=503 Review please. -- David Marchand > --- > drivers/bus/pci/linux/pci_vfio.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c > index fdeb9a8..9143bfc 100644 > --- a/drivers/bus/pci/linux/pci_vfio.c > +++ b/drivers/bus/pci/linux/pci_vfio.c > @@ -547,6 +547,14 @@ > bar_index, > memreg[0].offset, memreg[0].size, > memreg[1].offset, memreg[1].size); > + > + if (memreg[0].size == 0 && memreg[1].size == 0) { > + /* No need to map this BAR */ > + RTE_LOG(DEBUG, EAL, "Skipping BAR%d\n", bar_index); > + bar->size = 0; > + bar->addr = 0; > + return 0; > + } > } else { > memreg[0].offset = bar->offset; > memreg[0].size = bar->size; > @@ -556,7 +564,9 @@ > bar_addr = mmap(bar->addr, bar->size, 0, MAP_PRIVATE | > MAP_ANONYMOUS | additional_flags, -1, 0); > if (bar_addr != MAP_FAILED) { > - void *map_addr = NULL; > + /* Set non NULL initial value for in case of no PCI mapping */ > + void *map_addr = bar_addr; > + > if (memreg[0].size) { > /* actual map of first part */ > map_addr = pci_map_resource(bar_addr, vfio_dev_fd, > -- > 1.8.3.1 >