Message ID | 20230103173131.21259-1-fmdefrancesco@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4735450wrt; Tue, 3 Jan 2023 09:33:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXtNWMuCBgsImtLXuGWOMjMm7VgBQ+5AawK1WBklNzOaAcGp8EtZYGV2Tb7V9dCfaIqUkHS3 X-Received: by 2002:aa7:dd13:0:b0:47b:a6e:6b69 with SMTP id i19-20020aa7dd13000000b0047b0a6e6b69mr42952423edv.2.1672767206198; Tue, 03 Jan 2023 09:33:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672767206; cv=none; d=google.com; s=arc-20160816; b=AVAxR58dNb3TRfihKMQWaUK9unr901KpfJPzTa0IrGMlM62vEJE4YTzUeW3qubq8fu zSOvP0oHRSzbCaXOF2jbIPav8+rZOnGb/gz/TZmlTTjfqt1Oqy+e7ccerX/1RbNPT425 /3Zhzrp1scHvAcCE8PtpndbddmKqjYw0im41f7ojKbnHoBS8gWp8MNCqWye/b5fw4ToE /kOP9i1C+520Ld+5b7hWFI+MLwTRcKRSZRaEWYS/t9kVHg35rknthecOdei+8N3hnkOl 3l9fFkOiuQF3hSPrLPxqxocstTxlTrnhCzPwwlw3D91AAxtv0HHJnzvq9imaiIbYw0dQ KClQ== 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=lrEcmCtSJ+/1qtNXKPr4kZOp+CyB0SIyAk2dSH3BY8Y=; b=ntXwx+xPLA9obKBDbwkOvtb9TihsuBz6bgrneiI1lFlApmYzMjIdi7IxgKS4qFsQ3r MTmpuesTbk9w8bEPMwhxB0IFwSEOEBP2FyX8kiNJOJoHcckdC9Zojg++N9dYN8HYNAQj cg1M41i76pId4bUB4ZTJqszMeB9KBiH0llbaZ6cAhghFwQaod76pHoRWLyJYE0tUG9wS C2Et2rcx0NjJcKpFeYpcmhoTHVcqjC07A60o+3ptpovMYcByU/SBPaANkjb7HEDu1YOz NEQkeRbXqPPASyxfP3aK8jDQkTbdCNeE10yfFgG+9Pe112yQOnBI+NeB+h47qQ2CJn2Z HSdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Dcvp/yGc"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs27-20020a1709073e9b00b007c167bc7df9si12038989ejc.255.2023.01.03.09.33.02; Tue, 03 Jan 2023 09:33:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Dcvp/yGc"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S238561AbjACRcB (ORCPT <rfc822;tmhikaru@gmail.com> + 99 others); Tue, 3 Jan 2023 12:32:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238534AbjACRbw (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 3 Jan 2023 12:31:52 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90C4611A3C; Tue, 3 Jan 2023 09:31:38 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id c65-20020a1c3544000000b003cfffd00fc0so27083942wma.1; Tue, 03 Jan 2023 09:31:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lrEcmCtSJ+/1qtNXKPr4kZOp+CyB0SIyAk2dSH3BY8Y=; b=Dcvp/yGc7IZz98UBNMbxXxHa148D48TYRMog0iJHDNUQmPvwPC2FOnIN0Ck/tZ9FPT op2ftTnJpnyxXiodELsMofBXY/ax7s6BGe3Hr3mdVKd3qzz05IOhxzAmqk1/hqPnr7Jw 8QcizFVp7GcKkj2CyV3vGY7IAeYZ1xuGvNZbvP0TQHylE83HAeDv0pPLHcOp5ael8P/5 sxFlFSHoH9sD3LQsDwnBdQJ4CpexObo1dMliVrG51Xjztrm7YwjF6PRbu2sOxi4XRqkO irezC/W06LvUMR1l5gVsWbnfrXzmYLk/2NBMaRm5s6yhX9bAvk7AcvnoMHRgGpr1L5V4 uzMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lrEcmCtSJ+/1qtNXKPr4kZOp+CyB0SIyAk2dSH3BY8Y=; b=I9x8+CIru/ga5WwJ72Ogv3QahkFFYC4x00sgy6st9GD8l/JRHt9szx9Q66hrF1eIcR z5l4c4kRw1TpK7HRT+M9PdXFK3ayj6ZDtxjNIpXkQfI4qQUyL/pcdjh8wzRV+8eXOKEe kT8I7dKvKhc8A1x6jls/m/4gXJmte0vWDZl4X25pSOXlSzm8bDTQA6Jk/bG/JZZgoBPm pvZBSGPbN18CDkTWfnH+W2PmT7bD0ibAoyz27qyFNxHY/FzFgEogBWPiG7trW8F2O0Dp wjItl8c4jT2QwzPk7tYsqfw/qAyEH80s683Ny6WobG+kV9bNPvjYVGdP8DgJD2vxTVlu EDuQ== X-Gm-Message-State: AFqh2ko3WqYCuNrGPo+gpyokBmq96BXvEMcosSRq9wwNyC7VPvSqgj1h aCZU+ugn0JqcQp0MS/1NLMs= X-Received: by 2002:a05:600c:6016:b0:3d3:3c93:af5e with SMTP id az22-20020a05600c601600b003d33c93af5emr31825649wmb.35.1672767097053; Tue, 03 Jan 2023 09:31:37 -0800 (PST) Received: from localhost.localdomain (host-79-56-217-20.retail.telecomitalia.it. [79.56.217.20]) by smtp.gmail.com with ESMTPSA id s16-20020a1cf210000000b003c6bd12ac27sm42315707wmc.37.2023.01.03.09.31.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 09:31:36 -0800 (PST) From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com> To: Adaptec OEM Raid Solutions <aacraid@microsemi.com>, "James E.J. Bottomley" <jejb@linux.ibm.com>, "Martin K. Petersen" <martin.petersen@oracle.com>, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>, Ira Weiny <ira.weiny@intel.com> Subject: [PATCH] scsi: ips: Replace kmap_atomic() with kmap_local_page() Date: Tue, 3 Jan 2023 18:31:31 +0100 Message-Id: <20230103173131.21259-1-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754023545941458890?= X-GMAIL-MSGID: =?utf-8?q?1754023545941458890?= |
Series |
scsi: ips: Replace kmap_atomic() with kmap_local_page()
|
|
Commit Message
Fabio M. De Francesco
Jan. 3, 2023, 5:31 p.m. UTC
kmap_atomic() is deprecated in favor of kmap_local_page(). Therefore,
replace kmap_atomic() with kmap_local_page() in ips_is_passthru(). In
the meantime remove an unnecessary comment soon before local mapping,
align code and remove spaces (the function is short, therefore the
reviewers job won't be over-complicated by these logically unrelated
clean-ups).
kmap_atomic() is implemented like a kmap_local_page() which also disables
page-faults and preemption (the latter only for !PREEMPT_RT kernels).
The code within the mapping/unmapping in ips_is_passthru() is already
in atomic context because of a call to local_irq_save() and
kmap_local_page() can be called in atomic context too (including
interrupts).
Therefore, a mere replacement of the old API with the new one is all it
is required (i.e., there is no need to explicitly add any calls to
pagefault_disable() and/or preempt_disable()).
Suggested-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
---
drivers/scsi/ips.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
Comments
On Tue, Jan 03, 2023 at 06:31:31PM +0100, Fabio M. De Francesco wrote: > kmap_atomic() is deprecated in favor of kmap_local_page(). Therefore, > replace kmap_atomic() with kmap_local_page() in ips_is_passthru(). In > the meantime remove an unnecessary comment soon before local mapping, > align code and remove spaces (the function is short, therefore the > reviewers job won't be over-complicated by these logically unrelated > clean-ups). > > kmap_atomic() is implemented like a kmap_local_page() which also disables > page-faults and preemption (the latter only for !PREEMPT_RT kernels). > The code within the mapping/unmapping in ips_is_passthru() is already > in atomic context because of a call to local_irq_save() and > kmap_local_page() can be called in atomic context too (including > interrupts). > > Therefore, a mere replacement of the old API with the new one is all it > is required (i.e., there is no need to explicitly add any calls to > pagefault_disable() and/or preempt_disable()). > > Suggested-by: Ira Weiny <ira.weiny@intel.com> The discussion about preemption is irrelevant AFAICS. But what you say above is not wrong and the code looks right. Reviewed-by: Ira Weiny <ira.weiny@intel.com> > Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> > --- > drivers/scsi/ips.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c > index 16419aeec02d..bb206509265e 100644 > --- a/drivers/scsi/ips.c > +++ b/drivers/scsi/ips.c > @@ -1499,17 +1499,16 @@ static int ips_is_passthru(struct scsi_cmnd *SC) > struct scatterlist *sg = scsi_sglist(SC); > char *buffer; > > - /* kmap_atomic() ensures addressability of the user buffer.*/ > /* local_irq_save() protects the KM_IRQ0 address slot. */ > local_irq_save(flags); > - buffer = kmap_atomic(sg_page(sg)) + sg->offset; > - if (buffer && buffer[0] == 'C' && buffer[1] == 'O' && > - buffer[2] == 'P' && buffer[3] == 'P') { > - kunmap_atomic(buffer - sg->offset); > + buffer = kmap_local_page(sg_page(sg)) + sg->offset; > + if (buffer && buffer[0] == 'C' && buffer[1] == 'O' && > + buffer[2] == 'P' && buffer[3] == 'P') { > + kunmap_local(buffer); > local_irq_restore(flags); > return 1; > } > - kunmap_atomic(buffer - sg->offset); > + kunmap_local(buffer); > local_irq_restore(flags); > } > return 0; > -- > 2.39.0 >
Fabio, > Therefore, a mere replacement of the old API with the new one is all > it is required (i.e., there is no need to explicitly add any calls to > pagefault_disable() and/or preempt_disable()). Applied to 6.3/scsi-staging, thanks!
On Tue, 03 Jan 2023 18:31:31 +0100, Fabio M. De Francesco wrote: > kmap_atomic() is deprecated in favor of kmap_local_page(). Therefore, > replace kmap_atomic() with kmap_local_page() in ips_is_passthru(). In > the meantime remove an unnecessary comment soon before local mapping, > align code and remove spaces (the function is short, therefore the > reviewers job won't be over-complicated by these logically unrelated > clean-ups). > > [...] Applied to 6.3/scsi-queue, thanks! [1/1] scsi: ips: Replace kmap_atomic() with kmap_local_page() https://git.kernel.org/mkp/scsi/c/7edd053b3327
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index 16419aeec02d..bb206509265e 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -1499,17 +1499,16 @@ static int ips_is_passthru(struct scsi_cmnd *SC) struct scatterlist *sg = scsi_sglist(SC); char *buffer; - /* kmap_atomic() ensures addressability of the user buffer.*/ /* local_irq_save() protects the KM_IRQ0 address slot. */ local_irq_save(flags); - buffer = kmap_atomic(sg_page(sg)) + sg->offset; - if (buffer && buffer[0] == 'C' && buffer[1] == 'O' && - buffer[2] == 'P' && buffer[3] == 'P') { - kunmap_atomic(buffer - sg->offset); + buffer = kmap_local_page(sg_page(sg)) + sg->offset; + if (buffer && buffer[0] == 'C' && buffer[1] == 'O' && + buffer[2] == 'P' && buffer[3] == 'P') { + kunmap_local(buffer); local_irq_restore(flags); return 1; } - kunmap_atomic(buffer - sg->offset); + kunmap_local(buffer); local_irq_restore(flags); } return 0;