Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp199236lfu; Wed, 30 Mar 2022 20:37:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT7XUWSHN51Kolp+XhSJ3xG91FSZVI0LW0maU8kIuAtWHUienYd0k0yaz/ywMu+scs2NXr X-Received: by 2002:a17:90a:1548:b0:1c9:8181:9e70 with SMTP id y8-20020a17090a154800b001c981819e70mr3748362pja.78.1648697830893; Wed, 30 Mar 2022 20:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648697830; cv=none; d=google.com; s=arc-20160816; b=vhx6WKZzvPw3CDwtjug7qTQOzbLPcupc24YuNdy429jywPdDsmLf/Y736VC6bLUN3J tT7IMUqVGWRzqQCEBa3YckQjunWNP6LkQE36EaekaY03V5pkOf3fLhnie0rRhwhHsVsC Hbe7G2tkn7FGpwlOyXTHvrrpz5kPkAWM5JGIeWG2UEmjxxEP1YaTIV6bN0ZwiSaP33I6 5qJPNr23Q5ZpNachNTHHgLgFlgWc8Z+HNoF0GNhgzvZuLDnULMEDpoTiUSES8CZRgY2n jjLJZz0lteYJ2NN/zpq56GVSH/PPw27BVBlrzeRd2wGuzXmO8Lg7olVshozUP6hRgjR7 JG8A== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=PYeSRhL4EJ9kSjRef+3ZDgUv5eRzmfmbrcZOn+mT5cQ=; b=hKH/tr8KesxYYwlRMkv1Z5I3+SHUD/UxhZHH1plUEQVyJABNS2UBgb6iiwlVEavE5l HRaT74kdv6Yt8mgfdxR9QnYkivXKyq69HtjwFoJzCtMmwqWT/cTV4dCcfJp/rfApxmyl 8Y5h40Aw41DHlKuLBfvBwdXgM/1zg9ESPwih5W8yqW9T9NSwF+UidHt7tjJ1hWip0lOg eJ7tkfBJfrJl+ym+9vJDqxBHfHqz1oxP1dny4JCr9w88y8sjBzbpMxFay082jfrp0+tj IKbhdt5Qoh+E8zSkMaPFFVY8FFB1B9x1rA5FdZwjdE/2oeIW9SYb/+Y455aXMjU8n41S fSKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ByVj0awv; 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 23-20020a621417000000b004fb83b0732dsi9235278pfu.323.2022.03.30.20.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 20:37:10 -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=ByVj0awv; 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 9AB8912E172; Wed, 30 Mar 2022 19:58:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346905AbiC3Of0 (ORCPT + 99 others); Wed, 30 Mar 2022 10:35:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346893AbiC3OfY (ORCPT ); Wed, 30 Mar 2022 10:35:24 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D71724161D for ; Wed, 30 Mar 2022 07:33:37 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id dr20so41889633ejc.6 for ; Wed, 30 Mar 2022 07:33:37 -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:mime-version :content-transfer-encoding; bh=PYeSRhL4EJ9kSjRef+3ZDgUv5eRzmfmbrcZOn+mT5cQ=; b=ByVj0awv3/ZKRFds4TIlXaEjOC213gnC/dsMTaTQtZw+cwLgR1OMv4LtfQ26nkhV/n L62vIfDajYdNXaNr2oHb9LUPwLg32m7+HnZLmdcRd4o7JLE6+ijC8SPd1UQ3bYJYPh93 KgKm+iijnBLydGJgg9AclIlxR1Ikhoy9GcaGwqup0FwT6At4zii4UapWKJ3VUIVZe73M 8RGmv6XGmszVo0X1oyUWpdCApg5JAmZbRd0O1CgaKPdTG9BvLkDm86irEMrrNIBrl3aP 8o8kBwBz2ByYhnvtzrB3QN5BhEmjzNfCevBW9hcYZb3rXXKpH2fcD9xd5vE+vfZMIfWe DVZg== 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:mime-version :content-transfer-encoding; bh=PYeSRhL4EJ9kSjRef+3ZDgUv5eRzmfmbrcZOn+mT5cQ=; b=mkDsRDrFM8Mj83ui+hKkfqU19FHTstfFFWd7oPvDb1pYQn62wQHV5rwVa2aAII2+cN HaGwWKXHW4nblozW5GIsMTdef3l9PDnHPe9HD1CYHegNkyzAZtWeTyB72A3DN4kfnsLp uvtf7NmkgS2R5FC8EiWKVFHlJnZzIsqg3Viqowx+dP9xZjGDYzilUiH3J62/89qvRH/p y+DiQe/hBD1SW/M5N0nrdScvrInIww6X1iz6Hq0x1a3rA9s81lJrfpiG5WYSD0kgT394 mdDWfqso62XTR00Twl41bgMjNh+hdNnxdK40EE8Zk0QtDF6HIblRv9IUZdMtkBXxpDXa 8SWQ== X-Gm-Message-State: AOAM533+oDeNn3/fizFJ+5BirkMuMzrLSxh8lOytek0BXcukns6hkQyh Qo0cpQ4zrsyEeTV7fz5HBbc= X-Received: by 2002:a17:907:6da6:b0:6e0:bb24:f731 with SMTP id sb38-20020a1709076da600b006e0bb24f731mr29818767ejc.25.1648650816253; Wed, 30 Mar 2022 07:33:36 -0700 (PDT) Received: from localhost.localdomain (host-95-249-145-232.retail.telecomitalia.it. [95.249.145.232]) by smtp.gmail.com with ESMTPSA id z2-20020a17090674c200b006e13403964asm2069249ejl.77.2022.03.30.07.33.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 07:33:35 -0700 (PDT) From: "Fabio M. De Francesco" To: Greg Kroah-Hartman , Benjamin Philip , Bart Van Assche , "Martin K. Petersen" , "Eric W. Biederman" , Colin Ian King , =?UTF-8?q?Samuel=20Sj=C3=B6berg?= , Charlie Sands , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Dan Carpenter , ira.weiny@intel.com, outreachy@lists.linux.dev Cc: "Fabio M. De Francesco" Subject: [PATCH v4] staging: rts5208: Convert kmap() to kmap_local_page() Date: Wed, 30 Mar 2022 16:33:31 +0200 Message-Id: <20220330143331.8306-1-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 The use of kmap() is being deprecated in favor of kmap_local_page() where it is feasible. With kmap_local_page(), the mapping is per thread, CPU local and not globally visible. Therefore rtsx_stor_access_xfer_buf() is a function where the use of kmap_local_page() in place of kmap() is correctly suited. Convert to kmap_local_page() but, instead of open coding it, use the helpers memcpy_to_page() and memcpy_from_page(). Make a minor change to a comment related to scatter-gather. Signed-off-by: Fabio M. De Francesco --- v1 -> v2: Rework the commit message and use the appropriate helpers instead of open coding the use of kmap_local_page()/kunmap_local_page(). (Thanks to Ira Weiny ). v2 -> v3: Use memcpy_{to,from}_page() arguments correctly. (Thanks to Dan Carpenter ). v3 -> v4: According to a suggestion by Ira Weiny, change the test of a comment related to the use of scatter-gather. drivers/staging/rts5208/rtsx_transport.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c index 805dc18fac0a..d5ad49de4c56 100644 --- a/drivers/staging/rts5208/rtsx_transport.c +++ b/drivers/staging/rts5208/rtsx_transport.c @@ -55,9 +55,9 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, *offset += cnt; /* - * Using scatter-gather. We have to go through the list one entry - * at a time. Each s-g entry contains some number of pages, and - * each page has to be kmap()'ed separately. + * Using scatter-gather. We have to go through the list one entry + * at a time. Each s-g entry contains some number of pages which + * have to be copied one at a time. */ } else { struct scatterlist *sg = @@ -92,13 +92,11 @@ 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); if (dir == TO_XFER_BUF) - memcpy(ptr + poff, buffer + cnt, plen); + memcpy_to_page(page, poff, buffer + cnt, plen); else - memcpy(buffer + cnt, ptr + poff, plen); - kunmap(page); + memcpy_from_page(buffer + cnt, page, poff, plen); /* Start at the beginning of the next page */ poff = 0; -- 2.34.1