Received: by 10.223.185.116 with SMTP id b49csp2999664wrg; Mon, 5 Mar 2018 12:12:32 -0800 (PST) X-Google-Smtp-Source: AG47ELuG3iSZ++nJfAgRroSlaUHkbBAVjdHsyobiAmGj+42Gl+sWPrG/NaeM2S/2sZax8bNFrv6J X-Received: by 10.98.135.76 with SMTP id i73mr16519862pfe.140.1520280752682; Mon, 05 Mar 2018 12:12:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520280752; cv=none; d=google.com; s=arc-20160816; b=0rAfrHoPlNgYS7CyUUPI+lC+e0uHTthFKsdDNvRixlqK17uDD8PcItTRcTWfAw9QcX OGilaRi0bfdzdRhjcXTP2OiOUNbxmKRgye5RTg+aWk0vmxdO3B3NUrkrOtbI2MODPXPw +ygpSVSwkp0ZSPAz6wGbhIGOhXX3WEPyWcPrU+Q2MMRbEaWKfd1u462xbzyHUYCO8PI4 UB7tzEgEhH2W0h0p+iRFepDlerSI0E+PLE98RA1NhaJRRD7e3hZMNhwRIefXLsTMTXll y0+0lFNBAqSmxRs5hV8QzAOQXTP0W7BmrPg72i9pNLCSqYQTiDZr6DF8dvBcqBLd7kd2 YRqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=OaPf6Fd1WR+kE8wmxscO35NVbYSibdLYFPrKW1im/II=; b=YHcPTEhA1K3c+TmzSJe3qXLuSJdx4RrpEzfJBfpF2+T7i1jMxhwlnMPBLHInNbGC2z 9woCESWndEW9NgLQAXQFEnMtNprOpzgg1fqwdqPlOCgROqU4Xw9I+HT0trcBhtYXL1jO VyW1t7kmvtt2dcS9MAjiIHznWZa9YwVnuMm7AYx0JDcmlDOC2LYJTZmCQg0Ya4jen0Lo +1kGNl3l1Zp6vg85acIk2yYlZcEgUPWUWf/KiD+xvLwsUzrBlMM0lNczpsj98hIIM7Rz jbiEhjSSgFbXPugm64+6qDqLOORTvquMxMRt36/lBSUpDKOXSZThOhCK9upeGHhPb8ZM bDoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@Mellanox.com header.s=selector1 header.b=Z5s6dw7S; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e2si8714573pgr.242.2018.03.05.12.12.17; Mon, 05 Mar 2018 12:12:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@Mellanox.com header.s=selector1 header.b=Z5s6dw7S; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753111AbeCEULN (ORCPT + 99 others); Mon, 5 Mar 2018 15:11:13 -0500 Received: from mail-db5eur01on0063.outbound.protection.outlook.com ([104.47.2.63]:37472 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753079AbeCEULJ (ORCPT ); Mon, 5 Mar 2018 15:11:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=OaPf6Fd1WR+kE8wmxscO35NVbYSibdLYFPrKW1im/II=; b=Z5s6dw7SBSoqyCqET6sjuEV8a1YvyW7wlSwxUcYAS+XKLKDNhWOlRcgHFhT6IgbvIZ2uz7R9czlkBuIPCX0qDG2GUX6CqtLbwE6Vnmszn8NitPbfvw6VkGgQNNElcYUJjZ0FDen1iXpzgnmhmQbK1DG2kf9Q+4ubV6xaUkN+26Q= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jgg@mellanox.com; Received: from mlx.ziepe.ca (70.74.179.152) by DB6PR0501MB2855.eurprd05.prod.outlook.com (2603:10a6:4:83::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.13; Mon, 5 Mar 2018 20:11:03 +0000 Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1eswRh-0006dA-Ql; Mon, 05 Mar 2018 13:10:53 -0700 Date: Mon, 5 Mar 2018 13:10:53 -0700 From: Jason Gunthorpe To: Sagi Grimberg Cc: Keith Busch , Oliver , Jens Axboe , "linux-nvdimm@lists.01.org" , linux-rdma@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Alex Williamson , =?utf-8?B?SsOpcsO0bWU=?= Glisse , Benjamin Herrenschmidt , Bjorn Helgaas , Max Gurtovoy , Christoph Hellwig Subject: Re: [PATCH v2 07/10] nvme-pci: Use PCI p2pmem subsystem to manage the CMB Message-ID: <20180305201053.GK11337@mellanox.com> References: <20180228234006.21093-1-logang@deltatee.com> <20180228234006.21093-8-logang@deltatee.com> <20180305160004.GA30975@localhost.localdomain> <36c78987-006a-a97f-1d18-b0a08cbea9d4@grimberg.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <36c78987-006a-a97f-1d18-b0a08cbea9d4@grimberg.me> User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [70.74.179.152] X-ClientProxiedBy: HE1PR0202CA0019.eurprd02.prod.outlook.com (2603:10a6:3:8c::29) To DB6PR0501MB2855.eurprd05.prod.outlook.com (2603:10a6:4:83::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d832b972-a6ff-4bf2-cf04-08d582d53922 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060)(7193020);SRVR:DB6PR0501MB2855; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0501MB2855;3:X8xOxZhXWKxZNKyG02v2IVWw/gRszYQFTUDTCeLjstWvUSgIrDqNFCF9c/de5pWlRAlgDjP2iIwsYh62cJH/FYVpYeVYE8PGY6HEg3y2XlSqdPvB4PT31fr2rP9doRXeXPLPEdH/HUvw2e7tYBkSXzhcbnzj2CopQO4G+J/3dwrW1I6tERBml1ylKb7/Iq8Wb8zrdxiLs2JxiLLLZxCDzMPf5K/c2YRynGtOKXTCIrpwW+p2PgloC6eqClsBHZbi;25:rBOtnZR3Uiafj1colt0XoFS/jLSGQvKCGiBtC/qed2bpbnjJ0KBEqrzPcs19P5+Ojz9Avn258JmAwaTSqUba/ezaxFD6fxggMK9ge1ZxAN4v4oRZmAjco7l4E/9jbtMji22hvnFrLyQ9wtAECx0x2UWlbtp5voLRIqZ/fC5/bkwp23NxbdqB2GVkeqNfrRw2cXHDDT0H3TzVw5tLHLnhmjbADm4ezyEjwpHIk9A7BA73pbkbyYe/380Vj9j+aFzpSDFc6plz2cMkBFADrwYbYIiQ0CdyxeE/RcU/UHff2YUiASoyTLlNOqNsUMDgJMJA8mXGwj+dr60pPIYDMY9fYg==;31:9tMI13dhjL+ZQml6KbVd8iVs62t30qYUvXRy9mBwL5rIhIfiG/UYU3pZOKhPe53arx95R3TVNJdjYq6awMD11EyZoQL40GPUZls7jE73rd49F+T5D8C7EenyBUygno2kmz9XXqqBR4ZCnpj7JCniPGr3Uy/I5AzcvI42dPYcAKztfI6tcMH2MQbb3l67YFP8En8CDxgak3seOH3SaBbi08WsBgPpOwWTFODFhbdDw3M= X-MS-TrafficTypeDiagnostic: DB6PR0501MB2855: X-Microsoft-Exchange-Diagnostics: 1;DB6PR0501MB2855;20:6eoAB7d5+e9Xu4dGP8lwgTPgwiuVPg3kEy6IN7GcLSjkp3Wid8jyBQwdODvFSTgwu0UiraQDnixiuBofMtaMdDd7jGP32wn/dAwf1aWxTemXk2sPqjAX/x2NVlJgWQfWEnHtOX2W86FiW8TCKc3hCwXkryUYs+dhRktFPudVbNTun6XMkrUKsl20ctxjQPHGp2BqmnjLevGpSGAjIggtZMaJh/BTgESZGDqzvzoVXiONXsWM33j5VgPocuoQTUZ09cPGiaqCnQtESxZ0bmefRyqb+4+pfNyqnMAdwt/qrOUNgxTnrwtJeSLoxAltTMlJ8E3uhdjB7W6IZGRs5jogXvsX4yz0yYksAA6Aiipj7amuZcsMpRsPhOTxyBEZ6lEmRI9EmKzGeU+ISQjsxaj9zyg4fYqlQNCY9oBBWhIlxEJ9kvlIkc14fxeSpu58UvsBqFUY8VnVuVhfzvDFxm3Ki78LC1F6PL62RSQXbNVI5ctGVn1khGN0vS8kBQmhYxyC;4:ITasHg9DwgH3syhtiV/6r7NkC6FmLSTrTLdnOkkaVpsmvR6nz1vEhP8+Ui3N7wTcMQJA/FPjhAU0o+lII5o4EohuqPTK07RXtaJnd1KGCg3Caq7wVBF/9mzVb/Xiea9+N/ogCInzEpLjM14qnqRcA/mT1/36ZuaD54A9Uy9Vja8H6N5hc3+8R1WPtZ9XYmYdP2dFcLUHHTNe9oO4yy2JG40QaWGxlW00Jz1pUAKhc6ubLZBsYsZ9ujGeALYQCSjM1Ewjxh1fpneAh/r2jCkHDg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040501)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231220)(944501244)(52105095)(6055026)(6041288)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123564045)(6072148)(201708071742011);SRVR:DB6PR0501MB2855;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0501MB2855; X-Forefront-PRVS: 06022AA85F X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(396003)(39380400002)(346002)(376002)(39860400002)(366004)(189003)(199004)(47776003)(69596002)(2906002)(8936002)(66066001)(4326008)(81166006)(46656002)(39060400002)(59450400001)(186003)(5660300001)(26005)(23726003)(81156014)(6116002)(122856001)(386003)(1076002)(93886005)(105586002)(68736007)(229853002)(3846002)(7416002)(7736002)(86362001)(52116002)(97736004)(8676002)(16586007)(106356001)(36756003)(9746002)(6246003)(6916009)(50466002)(57986006)(83796002)(33656002)(478600001)(2950100002)(9786002)(54906003)(53936002)(316002)(76176011)(58126008)(305945005)(18370500001)(24400500001)(42262002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR0501MB2855;H:mlx.ziepe.ca;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DB6PR0501MB2855;23:9/bqxGMU/JZTqb8cgRV5YlY5fbogWfvqdHYT3n3?= =?us-ascii?Q?cPWcE/4LWx8V9t8bpb13AO9uJcGyBvYPk5nZEAeIn7IgnLIa9Ktcov+oC/W6?= =?us-ascii?Q?XU8gvOyH0osjx0ompTR2z1acXHZ4NXSBKQ73WTt5ABhcYSjuZC43FIisdUZy?= =?us-ascii?Q?RBIDcsRxYdHU6aasa1r4Xeq7+lIslES+H1Eqo/0WRFj3srz9qMeUhdb64kYg?= =?us-ascii?Q?tLawDTk27G/wE3szv3DadbCjbjZ1DieE0t+++SILArdHvGsXGwQmJGtf9Srb?= =?us-ascii?Q?bOcJ2Wxud0xM48P8d3p19mmzeZBJQXCCr2g4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IkCOup2CgzsqqTbGj2wyFtJLV6q3oVJi1kG0DT6+wXdGR9mbYs4h0Ga9XwdMiwFjE+xg=;7:SL4cj82irfmfTzzm3inpJgGFNH5JfvLh79wTSVa+V+RCLXTD7R8zztgaTmnWrwjUclyZabkH3j0/wecFqYCWuMdFSgQSquddqeHfxWnlirUvkzYD2JbDFzJAjqBbBlhBd51M4z2IHpCE3rhXBaBJF8Uq3oit8hzQOdRy+bfUr/jo6dq+gRjcscQCzM59R0GRVmafV1I/x6h+7qm5uYhZDare+Pd+4xEavVzmRnf7cQYE5o/cYzoubb4jaCvoHoro SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2018 20:11:03.8520 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d832b972-a6ff-4bf2-cf04-08d582d53922 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0501MB2855 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 05, 2018 at 09:57:27PM +0200, Sagi Grimberg wrote: > Keith, while we're on this, regardless of cmb, is SQE memcopy and DB update > ordering always guaranteed? > > If you look at mlx4 (rdma device driver) that works exactly the same as > nvme you will find: > -- > qp->sq.head += nreq; > > /* > * Make sure that descriptors are written before > * doorbell record. > */ > wmb(); > > writel(qp->doorbell_qpn, > to_mdev(ibqp->device)->uar_map + MLX4_SEND_DOORBELL); > > /* > * Make sure doorbells don't leak out of SQ spinlock > * and reach the HCA out of order. > */ > mmiowb(); > -- > > That seems to explicitly make sure to place a barrier before updating > the doorbell. So as I see it, either ordering is guaranteed and the > above code is redundant, or nvme needs to do the same. A wmb() is always required before operations that can trigger DMA. The reason ARM has a barrier in writel() is not to make it ordered with respect to CPU stores to cachable memory, but to make it ordered with respect to *other* writels. Eg Linux defines this: writel(A, mem); writel(B, mem); To always produce two TLPs on PCI-E when mem is UC BAR memory. And ARM cannot guarentee that without the extra barrier. So now we see stuff like this: writel_relaxed(A, mem); writel_relaxed(B, mem+4); Which says the TLPs to A and B can be issued in any order.. So when reading the above mlx code, we see the first wmb() being used to ensure that CPU stores to cachable memory are visible to the DMA triggered by the doorbell ring. The mmiowb() is used to ensure that DB writes are not combined and not issued in any order other than implied by the lock that encloses the whole thing. This is needed because uar_map is WC memory. We don't have ordering with respect to two writel's here, so if ARM performance was a concern the writel could be switched to writel_relaxed(). Presumably nvme has similar requirments, although I guess the DB register is mapped UC not WC? Jason