From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31F187B; Wed, 30 Mar 2022 14:33:38 +0000 (UTC) Received: by mail-ej1-f51.google.com with SMTP id pv16so41973107ejb.0; Wed, 30 Mar 2022 07:33:38 -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=OXeP4q0/0+Ka0RxfDZxoHhvh9K6IvnKutPauaBcfBPT69ZnhaeBozMmhUd5DgO5ndw RdD/uuYl60magpwpqyux1nYNb+g1D29V//SYW7MaDJM99wL7tDPl3we+Rp/qii2At4Nz CzThUmlpRda9q7m/sLXaT525nwJBr6ZwO7P2pcTClZKZKqqmUCV9mkFMV6Ep4nplLo8t 8K6LTHA7T1yHTVkENDioyFI4szUVxgklB+iSx4A9NpCx7yaG5IxUko37hQzH0aguQqV9 +8Z6Hph1MkPAlC2pbf9qYUfWixlFu/HcK+ssTbrHlJZ+C5DY+tgaj7gr5ggbsSSTPjDH LTDA== X-Gm-Message-State: AOAM532NIwdykwkTLqNrbLdFD5666zgOLyolP5dL27+bH2HI2LE/N+LK VLQef2K3trSkayyGF+HA6fk= X-Google-Smtp-Source: ABdhPJwgs/G9LRh561o9F93/Of7ZKFv9d4D65V/c+PfKjEaQdtjtvqaZ2eEvROGfRAYDtVOvsttR1w== 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 Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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