From nobody Mon Apr 6 21:31:14 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9FA5ECAAD3 for ; Thu, 1 Sep 2022 15:44:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233806AbiIAPoh (ORCPT ); Thu, 1 Sep 2022 11:44:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233606AbiIAPoS (ORCPT ); Thu, 1 Sep 2022 11:44:18 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DB3F72FFC for ; Thu, 1 Sep 2022 08:44:17 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id og21so35572048ejc.2 for ; Thu, 01 Sep 2022 08:44:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=jbUUbn6xBzZd7j5ZqfqvA6Ey7A3ETCPriOiqhA/qkHA=; b=e3b00MlFma6liGQaarM70G3/5zFPDlvJyUrB2qnIjGXHN17p8oEmGBAHa8AoIN7JDX HOvlPAmTLZLkn3GdmRMI0n1kx2I1ngYT2jKNv43pTtqPdy2rMkUDll8BUpAWr3G/LnKv 6qoJfPhsTQX3wfWmgjAciZN8XewNltgYYxwi5oIPzslT8KOn7HYSnPN13kvCoNoMaEMB 2b/bpPSm6x/yw3K1jgkM/o4fOesp6fgbKOZvmtVeSy5VP2pAwC5KLQWgG1oWp+8fIWdu vSKRycQ7y1UCoH6+8jDO13EMSexx/EshsNN3ukOUWzRpUnSlKE2OZImxtRqQV+MXa2o8 GjHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=jbUUbn6xBzZd7j5ZqfqvA6Ey7A3ETCPriOiqhA/qkHA=; b=AgqrKOMXnuXl8SEdDwXsihRfwUW2RU7JMIrexqmEMCmQ73lPePGVjLdP+u+b7K5jyb IsHckz0or+zrEg/O2uDJ7iWeTNcSIGds9jIuSdmNPB5kPBZnFdSF1wgXhSyhJ2IbCnun 66XJxkOInTj6FkGvLEvUjdtwCP6hO5GTgrCVCkkqsKnjRJsnrpiSYwGRE2Vk+wwWFs7i G7/Ejby9/XLJpfRuTTQzBf/uzEFmkYx9cNy8thPyMCvN/OKFVqjdgs+Hbwvqlcok7Msb 7JHSMj0in3I/YSx1IG/CmcT2mmkw21HTZgQRV8RlieH2Q78L7XaGeCPWBEbb6sBF4xss ukjQ== X-Gm-Message-State: ACgBeo324CBc2/LdS7w4Ay6EE4dWRL7GNPviHr/kOLw4eGxusTWnGKxS c9YNyHTBlzbrAEuTWaqqEu4= X-Google-Smtp-Source: AA6agR6lAq4C798R8uHf3uTQfD3A7XLABoTzBW9PEWsOSi140q8G5AWvZ5RyZ6XknTxk0jOZxcz2rw== X-Received: by 2002:a17:907:7e8c:b0:73d:85ec:46c with SMTP id qb12-20020a1709077e8c00b0073d85ec046cmr22845510ejc.257.1662047055743; Thu, 01 Sep 2022 08:44:15 -0700 (PDT) Received: from localhost.localdomain (host-87-1-103-238.retail.telecomitalia.it. [87.1.103.238]) by smtp.gmail.com with ESMTPSA id g6-20020a170906198600b0073dc6def190sm8576682ejd.158.2022.09.01.08.44.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 08:44:14 -0700 (PDT) From: "Fabio M. De Francesco" To: Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Michal Simek , Ira Weiny , "Venkataramanan, Anirudh" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: "Fabio M. De Francesco" Subject: [PATCH 1/2] misc/xilinx_sdfec: Call kunmap() on pages mapped with kmap() Date: Thu, 1 Sep 2022 17:44:07 +0200 Message-Id: <20220901154408.23984-2-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220901154408.23984-1-fmdefrancesco@gmail.com> References: <20220901154408.23984-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Pages in an array are mapped in a loop but, after the code is done with the virtual addresses, these pages are never unmapped. Therefore, call kunmap() to unmap pages[i]. Cc: "Venkataramanan, Anirudh" Cc: Ira Weiny Signed-off-by: Fabio M. De Francesco Suggested-by: Ira Weiny --- drivers/misc/xilinx_sdfec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/misc/xilinx_sdfec.c b/drivers/misc/xilinx_sdfec.c index d6e3c650bd11..4b1d82ae7312 100644 --- a/drivers/misc/xilinx_sdfec.c +++ b/drivers/misc/xilinx_sdfec.c @@ -645,6 +645,7 @@ static int xsdfec_table_write(struct xsdfec_dev *xsdfec= , u32 offset, reg++; } while ((reg < len) && ((reg * XSDFEC_REG_WIDTH_JUMP) % PAGE_SIZE)); + kunmap(pages[i]); unpin_user_page(pages[i]); } return 0; --=20 2.37.2 From nobody Mon Apr 6 21:31:14 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20435ECAAD1 for ; Thu, 1 Sep 2022 15:44:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234660AbiIAPok (ORCPT ); Thu, 1 Sep 2022 11:44:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234406AbiIAPo1 (ORCPT ); Thu, 1 Sep 2022 11:44:27 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 924D78B2C1 for ; Thu, 1 Sep 2022 08:44:19 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id qh18so15290948ejb.7 for ; Thu, 01 Sep 2022 08:44:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=sm81rFnMC95UT/sLYUuNGPmK2vB2Ge/WfYCIgeR1caI=; b=ZYilaImcLXiDpt5s0mImwJWlARkse5J910Tiofph6MltZYXKQN+QY5OWEAsC9WnOQx IOoU5OHcy8IC2Lk+jlGxguZCXy3mfuc61+dekre9oc0ZN+IBf1WTqLcoH3ceNiQB9VWA WqTqjz7HdtHkOIDrtlmnmcmEToZh+aMxB/3iT5wuzhPn+jiq238dTs797RjbgHmz2aJN BQndNJsOK+FEQMQQSxAK8x6AiJR6lG2wHyZzJedKE+vTh8nlQzU8UUbcvJoGJPvQguiD m7FQpPE7Ua+WtHbr8Y+sVX1bob9c2JBnOc4Mr4AkVuC3k7pq5bR4/abFDmZh97uWgxZm bL+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=sm81rFnMC95UT/sLYUuNGPmK2vB2Ge/WfYCIgeR1caI=; b=DdXIhdvd9qC3M/+WNlaM8JdI9xiGh4nistk7TavYnkWdwUnLgIyfQnU7cdDPJ2yqeA rY9f6+MPPq9Tq8yiLXDc2xT8zWOMOZ8/avRMinq7RP4ENwlZ5cxq17EBIornR/dQ+75w t7eCELIOl9p4Sq+bXBsPecrv8xvgMeZe/CLh65oRHMwFGpj5kAwkX3DU55tMMUfEJ57N 7yMRMY29w/bsgUjZ0ewas5GDjfp9bsJS2vPRb2vWDDDY/p/i/odoLSMmKSVYoHZLS9Hi oNi+LN03hveJnhvj7dKnNtHdcgvuI5ky3C7/vR12d/PvQSctoEmM6N9gnqsflDmR0sv/ mpYw== X-Gm-Message-State: ACgBeo0aPRQfVvLbeKt4pnMiFClxq6lQJRyxv1mDbCgw5XpouGLb9Q5C I651PC5/QTFpXq76G6Gy1jE= X-Google-Smtp-Source: AA6agR5HRM91GDph9126hEGDoQoFaqeifP7y1mhv3MDQkVYYSuLpvCyiqZdmsxzGln87BGqXoj289A== X-Received: by 2002:a17:907:7283:b0:731:60a5:5fc9 with SMTP id dt3-20020a170907728300b0073160a55fc9mr23798439ejc.51.1662047058085; Thu, 01 Sep 2022 08:44:18 -0700 (PDT) Received: from localhost.localdomain (host-87-1-103-238.retail.telecomitalia.it. [87.1.103.238]) by smtp.gmail.com with ESMTPSA id g6-20020a170906198600b0073dc6def190sm8576682ejd.158.2022.09.01.08.44.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 08:44:16 -0700 (PDT) From: "Fabio M. De Francesco" To: Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Michal Simek , Ira Weiny , "Venkataramanan, Anirudh" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: "Fabio M. De Francesco" Subject: [PATCH 2/2] misc/xilinx_sdfec: Replace kmap() with kmap_local_page() Date: Thu, 1 Sep 2022 17:44:08 +0200 Message-Id: <20220901154408.23984-3-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220901154408.23984-1-fmdefrancesco@gmail.com> References: <20220901154408.23984-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kmap() is being deprecated in favor of kmap_local_page(). There are two main problems with kmap(): (1) It comes with an overhead as the mapping space is restricted and protected by a global lock for synchronization and (2) it also requires global TLB invalidation when the kmap=E2=80=99s pool wraps and it might block when the mapping space is fully utilized until a slot becomes available. With kmap_local_page() the mappings are per thread, CPU local, can take page faults, and can be called from any context (including interrupts). It is faster than kmap() in kernels with HIGHMEM enabled. Furthermore, the tasks can be preempted and, when they are scheduled to run again, the kernel virtual addresses are restored and still valid. Since its use in xilinx_sdfec.c is safe, replace kmap()i / kunmap() with kmap_local_page() / kunmap_local(). Cc: "Venkataramanan, Anirudh" Suggested-by: Ira Weiny Signed-off-by: Fabio M. De Francesco --- drivers/misc/xilinx_sdfec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/xilinx_sdfec.c b/drivers/misc/xilinx_sdfec.c index 4b1d82ae7312..cb9506f9cbd0 100644 --- a/drivers/misc/xilinx_sdfec.c +++ b/drivers/misc/xilinx_sdfec.c @@ -636,7 +636,7 @@ static int xsdfec_table_write(struct xsdfec_dev *xsdfec= , u32 offset, } =20 for (i =3D 0; i < nr_pages; i++) { - addr =3D kmap(pages[i]); + addr =3D kmap_local_page(pages[i]); do { xsdfec_regwrite(xsdfec, base_addr + ((offset + reg) * @@ -645,7 +645,7 @@ static int xsdfec_table_write(struct xsdfec_dev *xsdfec= , u32 offset, reg++; } while ((reg < len) && ((reg * XSDFEC_REG_WIDTH_JUMP) % PAGE_SIZE)); - kunmap(pages[i]); + kunmap_local(addr); unpin_user_page(pages[i]); } return 0; --=20 2.37.2