Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp5519215lfu; Mon, 28 Mar 2022 15:52:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5OKr1+FDtyM5FEQBNJZmR9WSHr8wd+GCW4i2k81dkqKd4GFZE60GPpxTRmWZZlE3ZUPK2 X-Received: by 2002:a17:90b:4c8f:b0:1c7:7bc0:954a with SMTP id my15-20020a17090b4c8f00b001c77bc0954amr1377026pjb.214.1648507924755; Mon, 28 Mar 2022 15:52:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648507924; cv=none; d=google.com; s=arc-20160816; b=ZSufHGCpoha73iQ83rmPCbM+fq0GBLh29/T3w/+3pmDtFqB34oQdQoCRehIrZBdj6q JD23IVtuOSVEbZ9Hj03KHlCw1jj/aW5P1t2SDL4KzAjqMCD4lJ6IUXvjaNKn514y12Xk hCo24VMHvRcKuS4Q66jZw2mJ9Efo6L3bmApoC29c/DmYr0UB+O6irxQvycdBW7vZvyj7 AiFCgfm1uRrpKRGXYAn2Slb+sKdzNSmI20WqOIqovLoLHoPZPT08ZbCZ72jvS0j807+/ 1jwAgYaarxlBYFp4pRcyjAU8OPGPKQJ2/RI3yX1Mvas8RQG39eOWQHDO3AtFGrzZJAss 3+LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AA9VriTYf3jKrZYNetwW/7xvUoB3MbpeM0Zb2dqi/hA=; b=J828JomKX4lHs/eKDNfjls+QDWrIJTEknzhdhOjHehFUor9kgrP1spHNFAxJdCZxL5 rl8ooemQNdZSx4++TTN1HnKRKstqUQ+W9mlspxEs9bMOC0Gq72qhC27aq28xVPkeBa+z vwSfIv3MBE4blZQXfWmFIp6YkO3m0Wx8ssId+SYAG6kyX3lID1AKwhSdDXq7W8Cvfpyd Px3jHeABsIgd5PZjgJya0HJV4EzONSD76obgqGSmX50I205SApN2pjerMt8SK98BDqEE SZYxQZG/EnQKNj09/YL6P8MZd19SN4oje1/e8IdFxe8DgwNOvLPWhkh+dJQ8aI6G32Sr 65Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TdMydTYX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d1-20020a170902854100b001562b0bf47bsi1180511plo.58.2022.03.28.15.52.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 15:52:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TdMydTYX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 70B5E1E8CF9; Mon, 28 Mar 2022 14:55:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244570AbiC1RXQ (ORCPT + 99 others); Mon, 28 Mar 2022 13:23:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244563AbiC1RXN (ORCPT ); Mon, 28 Mar 2022 13:23:13 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35A9760CD1 for ; Mon, 28 Mar 2022 10:21:32 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id u16so21382587wru.4 for ; Mon, 28 Mar 2022 10:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AA9VriTYf3jKrZYNetwW/7xvUoB3MbpeM0Zb2dqi/hA=; b=TdMydTYX3pbRo19Mbk4+TDMgMVeGK3c6zUvBYHggkBkGlG9cVCqp6oqanz5J4huQ2m A+8u1alcWk3SdfJIGGMDl7dPZqessWliCcYUWWvQ1XwwA1UggwBElxpDbESlerXUPqYi qo5c1JHbBKMcpAW0scCtmpNLH3ixlX7bEBdu/8M9+YYT8bRp9+MU7pOFS9EyKTa4nYAK PlcV0dpwDREDDhx1+4AYzFTS+LPM0XmstcQoSwT0B6NHgYo78J6Snyro4+0ggK1+ZyrA DzTdvdM9z6X9ZNd890TSPJlGv2HejfGdcwfQzEHRt8HBrUeQAr7NJOTG4BY7AoUqDi50 ztgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AA9VriTYf3jKrZYNetwW/7xvUoB3MbpeM0Zb2dqi/hA=; b=SK1VIYR4S4/9KIr0fYMZIDzawUhbnFdXoX/1+zKp3xTCkt10HeqeR8S6LHmHaBe57w 5Qgz7cutFAG6eXJyZtxgVE+46DU7vGGF0mJ5oKyOrFl4Y5KISrTEUeZrecGQZcSnI/sd xRXW1fMJeUS1ukwfMa4lhkdI6foOj6s5z5OJnETsY1DhPx+2EDKaEFYRKskfDRCPDEhf Rv0APNMnRhXldaiWq9/4o6TSs3HuUXngM+9MPY/kO6YBb4VVqg04P5RWyLRz2Q+QqOq7 Fz42rsFJZt9rbRouSPFk/3tEVGRoiI14Ru/qADGj2xh/UQ+R0/bcDAU3DicQUOW6C2rt TyIg== X-Gm-Message-State: AOAM530kYpUdL+tUZrrDypjZ8213zbP8hQc4Uz1W8s98Ku+OF6289KSL Nu/NSK+3iFkRNehzFWXD8t8= X-Received: by 2002:adf:e483:0:b0:203:f946:396 with SMTP id i3-20020adfe483000000b00203f9460396mr24891290wrm.548.1648488090667; Mon, 28 Mar 2022 10:21:30 -0700 (PDT) Received: from leap.localnet (host-95-249-145-232.retail.telecomitalia.it. [95.249.145.232]) by smtp.gmail.com with ESMTPSA id j16-20020a05600c191000b0038ca3500494sm175034wmq.27.2022.03.28.10.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 10:21:29 -0700 (PDT) From: "Fabio M. De Francesco" To: Ira Weiny Cc: Greg Kroah-Hartman , Benjamin Philip , Bart Van Assche , "Martin K. Petersen" , Charlie Sands , Mitali Borkar , Colin Ian King , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: rts5208: Convert kmap() to kmap_local_page() Date: Mon, 28 Mar 2022 19:21:26 +0200 Message-ID: <1816944.CQOukoFCf9@leap> In-Reply-To: References: <20220328112440.17756-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On luned? 28 marzo 2022 17:41:53 CEST Ira Weiny wrote: > On Mon, Mar 28, 2022 at 01:24:40PM +0200, Fabio M. De Francesco wrote: > > The use of kmap() is being deprecated and kmap_local_page() is faster. > > Use kmap_local_page() in place of kmap(). > > Thanks for the patch! Thanks for your review! > I have just a couple of comments. > > kmap_local_page() is not necessarily faster than kmap() but it is more correct > in this case. You should mention why. Sure, my mistake. Thomas G. was talking about kmap_atomic() when he wrote that it is "faster". It does not apply to kmap_local_page(). What could justify the use of kmap_local_page() is that "The mapping is per thread, CPU local and not globally visible.". Therefore this code is the right context where to use kmap_local_page() in place of kmap(). At this moment I think that I might change my commit message and write something like the above. However, I'll research more information during the next days. In the meantime I'm also going to take a look at the differences in implementation. > Also to help with kmap_local_page() there are a number of helpers implemented > in highmem.h for things like memcpy, memmove, etc. > > Check out memcpy_page() for this use case. Aren't memcpy_to_page() and memcpy_from_page() better suited for the two different branches of the "if" statement? Thank you, Fabio M. De Francesco > > Thank you! > Ira > > > > > Signed-off-by: Fabio M. De Francesco > > --- > > drivers/staging/rts5208/rtsx_transport.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c > > index 805dc18fac0a..de690d7ee5e3 100644 > > --- a/drivers/staging/rts5208/rtsx_transport.c > > +++ b/drivers/staging/rts5208/rtsx_transport.c > > @@ -92,13 +92,13 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, > > while (sglen > 0) { > > unsigned int plen = min(sglen, (unsigned int) > > PAGE_SIZE - poff); > > - unsigned char *ptr = kmap(page); > > + unsigned char *ptr = kmap_local_page(page); > > > > if (dir == TO_XFER_BUF) > > memcpy(ptr + poff, buffer + cnt, plen); > > else > > memcpy(buffer + cnt, ptr + poff, plen); > > - kunmap(page); > > + kunmap_local(ptr); > > > > /* Start at the beginning of the next page */ > > poff = 0; > > -- > > 2.34.1 > > >