From patchwork Thu Dec 7 17:20:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Salisbury X-Patchwork-Id: 845706 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3yt2M34XbTz9t3B; Fri, 8 Dec 2017 04:21:03 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1eMzr1-0005Uj-5E; Thu, 07 Dec 2017 17:20:59 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1eMzqy-0005Tc-Rb for kernel-team@lists.ubuntu.com; Thu, 07 Dec 2017 17:20:56 +0000 Received: from 1.general.jsalisbury.us.vpn ([10.172.67.212] helo=salisbury) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1eMzqy-0008JG-G0 for kernel-team@lists.ubuntu.com; Thu, 07 Dec 2017 17:20:56 +0000 Received: by salisbury (Postfix, from userid 1000) id 72BFC7E26C8; Thu, 7 Dec 2017 12:20:55 -0500 (EST) From: Joseph Salisbury To: kernel-team@lists.ubuntu.com Subject: [SRU][Zesty][Artful][Bionic][PATCH 1/3] scsi: cxlflash: Use derived maximum write same length Date: Thu, 7 Dec 2017 12:20:53 -0500 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: "Matthew R. Ochs" BugLink: http://bugs.launchpad.net/bugs/1730515 The existing write same routine within the cxlflash driver uses a statically defined value for the maximum write same transfer length. While this is close to the value reflected by the original device that was supported by cxlflash, newer devices are capable of much larger lengths. Supporting what the device is capable of offers substantial performance improvement as the scrub routine within cxlflash operates on 'chunk size' units (256MB with a 4K sector size). Instead of a #define, use the write same maximum length that is stored in the block layer in units of 512 byte sectors. This value is initially determined from the block limits VPD page during device discovery and can also be manipulated from sysfs. As a general cleanup, designate the timeout used when executing the write same command as constant. Signed-off-by: Matthew R. Ochs Signed-off-by: Uma Krishnan Signed-off-by: Martin K. Petersen (cherry picked from commit 285e6670d0229b0157a9167eb8b2626b445a5a0e) Signed-off-by: Joseph Salisbury --- drivers/scsi/cxlflash/sislite.h | 3 --- drivers/scsi/cxlflash/vlun.c | 6 ++++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/cxlflash/sislite.h b/drivers/scsi/cxlflash/sislite.h index 09daa86..bedf1ce 100644 --- a/drivers/scsi/cxlflash/sislite.h +++ b/drivers/scsi/cxlflash/sislite.h @@ -548,7 +548,4 @@ struct sisl_rht_entry_f1 { #define TMF_LUN_RESET 0x1U #define TMF_CLEAR_ACA 0x2U - -#define SISLITE_MAX_WS_BLOCKS 512 - #endif /* _SISLITE_H */ diff --git a/drivers/scsi/cxlflash/vlun.c b/drivers/scsi/cxlflash/vlun.c index 8de6a80..77e3689 100644 --- a/drivers/scsi/cxlflash/vlun.c +++ b/drivers/scsi/cxlflash/vlun.c @@ -428,12 +428,14 @@ static int write_same16(struct scsi_device *sdev, u8 *sense_buf = NULL; int rc = 0; int result = 0; - int ws_limit = SISLITE_MAX_WS_BLOCKS; u64 offset = lba; int left = nblks; - u32 to = sdev->request_queue->rq_timeout; struct cxlflash_cfg *cfg = shost_priv(sdev->host); struct device *dev = &cfg->dev->dev; + const u32 s = ilog2(sdev->sector_size) - 9; + const u32 to = sdev->request_queue->rq_timeout; + const u32 ws_limit = blk_queue_get_max_sectors(sdev->request_queue, + REQ_OP_WRITE_SAME) >> s; cmd_buf = kzalloc(CMD_BUFSIZE, GFP_KERNEL); scsi_cmd = kzalloc(MAX_COMMAND_SIZE, GFP_KERNEL);