Received: by 10.223.185.116 with SMTP id b49csp921381wrg; Fri, 23 Feb 2018 08:52:05 -0800 (PST) X-Google-Smtp-Source: AH8x227uXdkSlR7BBnLuvgW8an7hc3J7QF72a1391f6cb4GWGLfFSTanuRkW5oBQs1eoRmBrSrEC X-Received: by 2002:a17:902:63:: with SMTP id 90-v6mr2245083pla.125.1519404725216; Fri, 23 Feb 2018 08:52:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519404725; cv=none; d=google.com; s=arc-20160816; b=u8INNi/0lrY4fKaad/JDbVkb8YjHEJTBCbwc+DEiVtZQae3hREOkgzKpF/g+nnbN1s mBpxAKFVi1iNE1GYznLtO55ulusZc9J4nIs7GUrHFAhmm1PrcugoNGKnIamwF/PgioPY eqcxFNnJVch75cncR6xmXLpD2OnBPf90kQOd7YEtstCOzs7h5IKIbj9UoCtb+YuYHUYi 26MmYNBajs3AjnX7F2adI1DTwfvwoDJwTMOJlMeGEAPbrrGWgrMG2kjb1xzx6xuhChOD xlhvwzI49okzgQyHjwYXJSSkdCbHLvRAgOqhdvsK339/AXEPAVeWAvlQ5meDTUwWI2vL N7Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=L/QSXrwRVWREPjcwPrBbfKOjH861PD+ojUZG+/nt6bw=; b=tB1XRriWKAptNzMUQrt01nMUybkhF0TQ5ynN9hkfpHQnzQDa4r4qBf3pnTKc+lhwJo SAs7TLRGgtLGzDP5piMa12R7IOIIjNC258cmO8e/y+DIa/SVX61QYTbXod5vT101ZMFl shRpX8hvTsHWiF/1hDyxhxB5uq9eQ6ENkSpqIQ3KwSpxclM5bI1ppyK2WezYpKr7C4YD SS7SoTci8e9dPnlooHK6z0Hrijjf7PCgllte7LNWbltOOdHdtHNFh4ZNb9+vgL51g0Xl n7FyMkc1ntFVTk3CpwwJBJKURl4gtAsnq0xJVg867a4+GIUfpd+IhEoJVQGd/BZkmZU8 4sXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=D0PjO/di; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c18si1692466pgv.519.2018.02.23.08.51.50; Fri, 23 Feb 2018 08:52:05 -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=@gmail.com header.s=20161025 header.b=D0PjO/di; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751836AbeBWQvO (ORCPT + 99 others); Fri, 23 Feb 2018 11:51:14 -0500 Received: from mail-qt0-f195.google.com ([209.85.216.195]:40044 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751402AbeBWQvM (ORCPT ); Fri, 23 Feb 2018 11:51:12 -0500 Received: by mail-qt0-f195.google.com with SMTP id c19so11267945qtm.7; Fri, 23 Feb 2018 08:51:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=L/QSXrwRVWREPjcwPrBbfKOjH861PD+ojUZG+/nt6bw=; b=D0PjO/dixBwVM3BV6RddO1YfQPt1BMUZrOuy1C9b4nI0d2YUsNGUu2NomMC1ul4v48 0WLrnI+NM74b08EszjeV473mhBnHT6+bqVtHqw3MFTVf4emAR6bQ6s+h7eiTkCgKUWRj ocPJTOjd99R1zWNZE7bedD/+WZFyFSvWuIbjqR0qB382ocxc6K8xeaafYob6MbHRVVCS rbm8ZQAw4zp9hirUyuj1ERmMREHplfkjFzShEZuHAophj+mRBvcl5Jqt91gxLP2NjDB5 fjraT10//wfiATqQGChyXK6ywz4yI9d7Q10IW6p9VcyTbZJiTcRWcFvVIwaqQIlU0xHn gX9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=L/QSXrwRVWREPjcwPrBbfKOjH861PD+ojUZG+/nt6bw=; b=UDHNRj+4DT6Gd2hjhDn023qGCqTW261WMj1gqz60hcCAfBgf9nsbXbXutb/fxI99+h K6uudTtBFqg6FN/+sglj+J6S/SuLz79Cx+GrN8vf5lb+3+hYf8lmSNaXUW7MOATmVLKH kHg4m/lWWDhPSVw4R5uHHP9SP/UFuvD8L9lTKEorDXg9vIXz3f+zVnmtIFjAvG5OW1OQ XHvXn3To5vC2KeIzlzYZ5PBPmaF1p1R2NsL5yVXJjZp+HXm85lhHiQsQRtBIMwGGIBe9 wroMcl3L60RXzjF1Nm26RjSgT23WQZl5jvOcRBRXGkPvAuhD75uLCshLq7mVURTy4hQd bzWw== X-Gm-Message-State: APf1xPCWPUfGAYUDXfd/TfXlU6s80hPS3HhVt0bk0gXPWvWTyaz5CEJ7 wucvWWziy6/+3PcFeN6OqJUrrz0XWzd8AIg2KZA= X-Received: by 10.237.59.232 with SMTP id s37mr3457959qte.83.1519404671957; Fri, 23 Feb 2018 08:51:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.195.80 with HTTP; Fri, 23 Feb 2018 08:51:11 -0800 (PST) In-Reply-To: References: <20180223153700.2186058-1-arnd@arndb.de> From: Andy Shevchenko Date: Fri, 23 Feb 2018 18:51:11 +0200 Message-ID: Subject: Re: [PATCH] scsi: lpfc: use memcpy_toio instead of writeq To: David Laight Cc: Arnd Bergmann , James Smart , Dick Kennedy , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke , Johannes Thumshirn , "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 23, 2018 at 6:41 PM, David Laight wrote: > From: Arnd Bergmann >> Sent: 23 February 2018 15:37 >> >> 32-bit architectures generally cannot use writeq(), so we now get a build >> failure for the lpfc driver: >> >> drivers/scsi/lpfc/lpfc_sli.c: In function 'lpfc_sli4_wq_put': >> drivers/scsi/lpfc/lpfc_sli.c:145:4: error: implicit declaration of function 'writeq'; did you mean >> 'writeb'? [-Werror=implicit-function-declaration] >> >> Another problem here is that writing out actual data (unlike accessing >> mmio registers) means we must write the data with the same endianess >> that we have read from memory, but writeq() will perform byte swaps >> and add barriers inbetween accesses as we do for registers. >> >> Using memcpy_toio() should do the right thing here, using register >> sized stores with correct endianess conversion and barriers (i.e. none), >> but on some architectures might fall back to byte-size access. > ... > > Have you looked at the performance impact of this on x86? > Last time I looked memcpy_toio() aliased directly to memcpy(). > memcpy() is run-time patched between several different algorithms. > On recent Intel cpus memcpy() is implemented as 'rep movsb' relying > on the hardware to DTRT. > For uncached accesses (typical for io) the 'RT' has to be byte transfers. > So instead of the 8 byte transfers (on 64 bit) you get single bytes. > This won't be what is intended! > memcpy_toio() should probably use 'rep movsd' for the bulk of the transfer. Maybe I'm wrong but it uses movsq on 64-bit and movsl on 32-bit. The side-effect I referred previously is about tails, i.e. unaligned bytes are transferred in portions like 7 on 64-bit will be 4 + 2 + 1, 5 = 4 + 1 etc Similar way on 32-bit. -- With Best Regards, Andy Shevchenko