Received: by 10.223.185.116 with SMTP id b49csp914381wrg; Fri, 23 Feb 2018 08:45:32 -0800 (PST) X-Google-Smtp-Source: AH8x224klv6M7SwYwj/5TQC6crL1efe9uWT/8pxsqIQEieqMxX8ui/FH3kK10sDxUGzQmMQ7cz56 X-Received: by 2002:a17:902:bb06:: with SMTP id l6-v6mr2260245pls.115.1519404331927; Fri, 23 Feb 2018 08:45:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519404331; cv=none; d=google.com; s=arc-20160816; b=M5zHvGkUqwumeeJrg6uhPDg+xJ1DhTuILpsOijLPJVOXDnxKBm1Ze/F2BGkCBEAynG ZGQp+nYGBub+PP5glXDv1EZ82DlOx6yYHTeTNrb/haGZMRfMLxfK9p1Q7EhTXHRt0xcN 2mE3zLZ0cXcXm5XV5Qlq/YmkOEe6ltfOpUyxq97hb0QqoNzF+oxNTtEXdYSQn5roYVKB 6eYgW1Eb9alKWvlfoA6I3ZKJEPF8ZzGwT1Espnv+zwrE0UBv6cB2AgZtLBkq7UTyWRcl 5EAr3blpP54ZpacZiovi/hBKBY9GPIw9TqTuVqEbjatkyVPnN6H8Z036vZhCr91ywcW/ h7MQ== 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=mm8aag7EWLPOs7C5Bvts6qzqD/xQTtDDvZrDVq57oXY=; b=Sprp4sOvG1ztR5iMHd1NvHAvg6tvPksqNxxwOWImo2D5xhSc/bNBtO+S4Rr4Ak1Wzt GuKNbIk4KFqBCgGkPRxS7ZxchNl6v05CoSbDCEW7pIICA4y8eeKfeiX97mCHG3Tj0n1I IvSlm7NSpwR1vDcZx9Gjxmgxt9LNos/ibvkuiaG6tTzvHoUmQNGRysUEmw4A7YlCOXfk gukC+iChgtYxs82Dp9RRmUOf4xdT8TQeDnjXdedaNxMzFNBic2HUFpNn6d+XbThQJ+6q 2RQeE4/bI5sPRG/SLVM8T56ril4QJZho8YOgY38ICn+9Xlw8dusebPIsTKh4ZeL+Pixf AWIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=lvz+mRkt; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i13si1703677pgp.470.2018.02.23.08.45.16; Fri, 23 Feb 2018 08:45:31 -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=fail header.i=@gmail.com header.s=20161025 header.b=lvz+mRkt; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751910AbeBWQod (ORCPT + 99 others); Fri, 23 Feb 2018 11:44:33 -0500 Received: from mail-qk0-f194.google.com ([209.85.220.194]:37951 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751494AbeBWQoc (ORCPT ); Fri, 23 Feb 2018 11:44:32 -0500 Received: by mail-qk0-f194.google.com with SMTP id s198so11474959qke.5; Fri, 23 Feb 2018 08:44:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=mm8aag7EWLPOs7C5Bvts6qzqD/xQTtDDvZrDVq57oXY=; b=lvz+mRktbyHbjXgBRGHysdj7pGAUhX+QY8OkWQno26ytTFrdkCMPlg/pFTJd+zrTTZ 03sjqG4c8iqGWVKbOxSIuTNSe7Oj0MS2arG+LT5dwlk1TdMiVcKJrbhAOmQ2p3im+oQ5 51Pi6H7s2ELR7QKPTbWzc6KoySMynQFDsUgK6zj7pdnFVUJj5uMYf1mKDEWwbHModbxQ LFJNy6wB14i9N21rc98G9/ZzJGHCbjeIxks7aV2yR0eju4LUB7Afd0YHI1ZxxM9ro5c5 w2dQan9g7qQYpJqG//s5W0cBQkIZj+/XoU8MhizS+j/buSyn9ooiOMwa9Bnf8Ad1KA1i /Ing== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=mm8aag7EWLPOs7C5Bvts6qzqD/xQTtDDvZrDVq57oXY=; b=ER2DjT8yDtySImRcYfDeX4tKgDOkHs+hb1st7ozwVXQ4YA4Rv3o7snA4LK9VwKR+RM hBmBYuAgEJ5oAwjtaDrJ/BYGANX2jcIAreeCGw4BTtkDVuTa4gw79etG2CHJgTaLxhq0 p/OafSW+kpP070uiJCdxRO8ZUZn5tSKi4kWyjHPJ3nMcWnxLUY/nxhrDAW121VCdPboM goE33tNAc5SEOJQfxs1NjftvNtRu2qGBEBMLahEt0ydwsQqwa236tnIOg2GxNyNrxu6h xaaZW8Fwj4CFulqoPzUkeFCHqRxCjJTArct4AGWypGy62nbL76v1ZyedRlA/m5pWqLbt 3zbw== X-Gm-Message-State: APf1xPCrvEsCktAEICr4nClWFK9BBIoeZC/+5b5416G8gmtB019VO3HK F8iUBpLL6SxMbS9j1JJMMQ0vvy/vj0k6ajQfV10= X-Received: by 10.55.158.83 with SMTP id h80mr3309259qke.330.1519404271121; Fri, 23 Feb 2018 08:44:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.198.17 with HTTP; Fri, 23 Feb 2018 08:44:30 -0800 (PST) In-Reply-To: References: <20180223153700.2186058-1-arnd@arndb.de> From: Arnd Bergmann Date: Fri, 23 Feb 2018 17:44:30 +0100 X-Google-Sender-Auth: 8XTqkRFeziahf7OQCz_XPBqSlA4 Message-ID: Subject: Re: [PATCH] scsi: lpfc: use memcpy_toio instead of writeq To: David Laight Cc: 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 5: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. I'm not that familiar with x86, but I would have guessed that on a write-combining I/O mapping, the hardware will combine the 'rep movsb' output data the same was as on a cacheable mapping. Arnd