Received: by 10.223.185.116 with SMTP id b49csp923772wrg; Fri, 23 Feb 2018 08:54:25 -0800 (PST) X-Google-Smtp-Source: AH8x226KebgdX/i/wB8Pew2bdmBrxZaeW0SwRUzPJP3gQ9idRgV3VlJ/kcvIs13b9eTbJWvFDNxe X-Received: by 2002:a17:902:ab8c:: with SMTP id f12-v6mr2251733plr.171.1519404865682; Fri, 23 Feb 2018 08:54:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519404865; cv=none; d=google.com; s=arc-20160816; b=NUnETwODiGFZZy6//QdkaRmyMU9CNJji3n8dQGciagSznCOoxCh6ik/1agDLpGMPpX xBpIip2AeQBZ1yXqzIM9PRobPzla8y03Elf0pR5N7TCxDzJ3G2vAxMgMHavxYuzvj2V0 BCfDF0scyl+bWE6VrFTwOhJuCRUbLUtGEG79hF5Bl2ZunxNSecomdQoZD4UXcZcx2nx0 TvDLb1Hoemjh++ZnMcrZE06+rdx3So4Dd6kpkF8U26G4ehrII4GB3Y1SKk4NtIpMY42H lUNZn9ljQvluNv4U0mzhDMVmH04L2e89JqEvIWAmyOteczEqgy/WhmrV7QaYNPkVWTDO I3Ng== 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=KMWSWSKBcm8c11+StbXhzRghOw8qKjFpyO9DkEkrpB0=; b=HgctACSUIr2a8u+WfiXKUT0bXNXts81BR6wqONDU57IlGmkghNjx+rGDSWghosuZ1m 5KcuhUoKUEEme+uqN+uF5z5xnmrBj87AwVzG3IHZgjRL1cZ1zVkPC/Mauzk4aPIaDlUd 59N1ihMeVy52hPwiy8w/aGSQvMA9/CyYMiBdrKxzgmMly+qMGljh39Skk/uoiikVPVHA oCyz6vVu1opupCmiAX0coZ/JCEIw15S+sRDYeYBU2sEs9bTrA+xxt7X4E/waqKwjA9yP nmsk04915EufHR6VM7ZcKRvJSYoF4rhiCVMdESpf9fi1Bu3kcHjX3ya+nabIGU8dKBPO lhmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vK7cM4Au; 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 l62si2085250pfl.160.2018.02.23.08.54.10; Fri, 23 Feb 2018 08:54:25 -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=vK7cM4Au; 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 S1751630AbeBWQxQ (ORCPT + 99 others); Fri, 23 Feb 2018 11:53:16 -0500 Received: from mail-qk0-f194.google.com ([209.85.220.194]:35201 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751460AbeBWQxO (ORCPT ); Fri, 23 Feb 2018 11:53:14 -0500 Received: by mail-qk0-f194.google.com with SMTP id s188so11527532qkb.2; Fri, 23 Feb 2018 08:53:14 -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=KMWSWSKBcm8c11+StbXhzRghOw8qKjFpyO9DkEkrpB0=; b=vK7cM4AuJth9jHsFe/PRwyzlTt79HuYzewl9uKOhzMoD0R7KzSSaQKuEOTcW29woj3 nnNYTE69Z2/ckO7pf/VuBDgQiyDx5qZhUuYT+UsSFBLCxIPdSxYR8fWHaO5eWCbbZbMX L0CbhCqW3OZyxuUbN/2XC8fOHPg8vVe1zzr6NPPhWUcllC9dwcFBYCIzuOiPdhIAND8K xVNBKKFudCrboqwWjkiQyH0CzMlh2CJHqod4FL3smj5p/rwDyO2y72TTdzaBsilqKU6e kVSq07oYH8VX+H397IQqRpwqtrgbyGDt5Axc0CO/LZPi3FTmvn6MQhiC1KcFwIOFseCe 5uRg== 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=KMWSWSKBcm8c11+StbXhzRghOw8qKjFpyO9DkEkrpB0=; b=JF9BFP7p2AfhX3c6g21UUrMqEsQ2aUJSQ1vrkYFg9j9+mv2SdBcclxsPrEeNz74UPy 7DjM4EF5VdjNkK8J8I/7BbBbGNHlQj7mkZB9UTCJYYzyzBJy60jGqnrN4p1tiXg4+Mu6 BjNx+31ZMbEUuuh9qRVsz5xbtLlDz98O4qF19HjwqIKP1eVgl8ElSqC+mbRSLkGYFoL4 FQNozLELaVEWzzojHyecP2hCOmqSk0Ekuk/6zRmyz+i8y+5FRB/cLLNsbiDhmPBlbOzL DNoo/ryrgPtwVz4nILMVE4Q6GLTuPVwczH8hNZMtECiIqEfHv2UM+qaoafVV71sKXfwr tUaQ== X-Gm-Message-State: APf1xPBEtnvQK+JPdQkqiRYj6aOf1yHlm39lwpYT7ZYiDwNYRq+87j00 IuigaDnWoGdVPWqhA26b6gbaBMVnLn7Hn66kaJM= X-Received: by 10.55.15.147 with SMTP id 19mr632767qkp.301.1519404793883; Fri, 23 Feb 2018 08:53:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.195.80 with HTTP; Fri, 23 Feb 2018 08:53:13 -0800 (PST) In-Reply-To: References: <20180223153700.2186058-1-arnd@arndb.de> From: Andy Shevchenko Date: Fri, 23 Feb 2018 18:53:13 +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:51 PM, Andy Shevchenko wrote: > 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. Same for leading bytes as well. arch/x86/lib/memcpy_64.S So, I *hope* that in the code in question there is no unaligned access is used. -- With Best Regards, Andy Shevchenko