From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E60BC43331 for ; Tue, 12 Nov 2019 12:29:30 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 029A321783 for ; Tue, 12 Nov 2019 12:29:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 029A321783 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7A6112AB; Tue, 12 Nov 2019 13:29:28 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 51035271 for ; Tue, 12 Nov 2019 13:29:27 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2019 04:29:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,296,1569308400"; d="scan'208";a="229360539" Received: from aburakov-mobl1.ger.corp.intel.com (HELO [10.237.220.92]) ([10.237.220.92]) by fmsmga004.fm.intel.com with ESMTP; 12 Nov 2019 04:29:24 -0800 To: "Wangyu (Eric)" , "dev@dpdk.org" Cc: "ferruh.yigit@intel.com" , Linuxarm , "humin (Q)" , dengxiaofeng , "Liyuan (Larry)" References: <1573521821-21173-1-git-send-email-dengxiaofeng@huawei.com> <78A93308629D474AA53B84C5879E84D24B1086FB@DGGEMM533-MBX.china.huawei.com> From: "Burakov, Anatoly" Message-ID: Date: Tue, 12 Nov 2019 12:29:23 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <78A93308629D474AA53B84C5879E84D24B1086FB@DGGEMM533-MBX.china.huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v3] bus/pci: resolve multiple NICs address conflicts 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 12-Nov-19 2:22 AM, Wangyu (Eric) wrote: > NIC address conflicts on 64K pagesize when using multiple NICs, > > as system will mmap 64K pagesize for NIC, > > but dev->mem_resource[i].len is 16K. Suggested rewording: === bus/pci: align next mapping address on page boundary Currently, the next address picked by PCI mapping infrastructure may be page-unaligned due to BAR length being smaller than page size. This leads to a situation where the requested map address is invalid, resulting in mmap() call returning an arbitrary address, which will later interfere with device BAR mapping in secondary processes. Fix it by always aligning the next requested address on page boundary. === Also, probably missing Fixes: tag and Cc: stable. > > Signed-off-by: beard-627 That's an unconventional name :) > Signed-off-by: Wangyu (Eric) > Acked-by: Wei Hu > Acked-by: Min Hu > --- > drivers/bus/pci/linux/pci_uio.c | 2 ++ drivers/bus/pci/linux/pci_vfio.c | 3 +++ > 2 files changed, 5 insertions(+) > > diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index 6dca05a..097dc19 100644 > --- a/drivers/bus/pci/linux/pci_uio.c > +++ b/drivers/bus/pci/linux/pci_uio.c > @@ -351,6 +351,8 @@ > pci_map_addr = RTE_PTR_ADD(mapaddr, > (size_t)dev->mem_resource[res_idx].len); > > + pci_map_addr = RTE_PTR_ALIGN(pci_map_addr, sysconf(_SC_PAGE_SIZE)); > + > maps[map_idx].phaddr = dev->mem_resource[res_idx].phys_addr; > maps[map_idx].size = dev->mem_resource[res_idx].len; > maps[map_idx].addr = mapaddr; > diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c > index b8faa23..64cd84a 100644 > --- a/drivers/bus/pci/linux/pci_vfio.c > +++ b/drivers/bus/pci/linux/pci_vfio.c > @@ -750,6 +750,9 @@ > bar_addr = pci_map_addr; > pci_map_addr = RTE_PTR_ADD(bar_addr, (size_t) reg->size); > > + pci_map_addr = RTE_PTR_ALIGN(pci_map_addr, > + sysconf(_SC_PAGE_SIZE)); > + > maps[i].addr = bar_addr; > maps[i].offset = reg->offset; > maps[i].size = reg->size; > -- > 1.8.3.1 > > As for contents of this patch (as long as the above is addressed): Acked-by: Anatoly Burakov -- Thanks, Anatoly