From patchwork Sat Aug 3 03:34:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Carino X-Patchwork-Id: 264375 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 043812C0084 for ; Sat, 3 Aug 2013 13:36:32 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754591Ab3HCDgb (ORCPT ); Fri, 2 Aug 2013 23:36:31 -0400 Received: from mail-oa0-f48.google.com ([209.85.219.48]:65222 "EHLO mail-oa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753914Ab3HCDga (ORCPT ); Fri, 2 Aug 2013 23:36:30 -0400 Received: by mail-oa0-f48.google.com with SMTP id o17so2787977oag.21 for ; Fri, 02 Aug 2013 20:36:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=RFk9oTCw3RDtls4kmBZpeYCSD7lsJg5hFQn/ZeUC/2E=; b=DW/5EqSoPIQPR/GF9lMDor9L6g5Lt/fs+IPHqCDIOQCy9W0zcGi0nJkN8FCHSsgWDY g3+vmKi9HpSz6X97MogGqAEQz6oNj0YgUXkZYFfgHP65hRiaZ5u+9zB9S9Fj8tAzS3sn LQ5MaSdWfcUk3aRlSTnwV22ZX8y0Xh8LV/rhH4xBCqhKEFriNXS0/ljiw8dbnqJk6QAX 56BpprcTnNTwG6UaBJ3ef5VmWzF12cN1VdA9pazsO2TysknYn2pQBqWlA2CEu3x3+joR 2MPWAuMXti7uBHKVxs4HTO1OoupUU82MbNhyl4ga78cYvurWXk9RQNjeJvdMrRd82nqF QcTw== X-Received: by 10.182.110.164 with SMTP id ib4mr7466722obb.87.1375500990080; Fri, 02 Aug 2013 20:36:30 -0700 (PDT) Received: from localhost.localdomain (ip68-231-212-75.oc.oc.cox.net. [68.231.212.75]) by mx.google.com with ESMTPSA id g1sm12205367oeq.6.2013.08.02.20.36.29 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 Aug 2013 20:36:29 -0700 (PDT) From: Marc C To: tj@kernel.org, linux-ide@vger.kernel.org Cc: Marc C Subject: [PATCH 2/2] libata: Add support for queued DSM TRIM Date: Fri, 2 Aug 2013 20:34:56 -0700 Message-Id: <1375500896-22955-3-git-send-email-marc.ceeeee@gmail.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1375500896-22955-1-git-send-email-marc.ceeeee@gmail.com> References: <1375500896-22955-1-git-send-email-marc.ceeeee@gmail.com> Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org From: Marc C Some new SSDs support the queued version of the DSM TRIM command. Let the driver use the new command if supported. Signed-off-by: Marc C --- drivers/ata/libata-scsi.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index b1e880a..8781e1b 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -3100,12 +3100,26 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc) buf = page_address(sg_page(scsi_sglist(scmd))); size = ata_set_lba_range_entries(buf, 512, block, n_block); - tf->protocol = ATA_PROT_DMA; - tf->hob_feature = 0; - tf->feature = ATA_DSM_TRIM; - tf->hob_nsect = (size / 512) >> 8; - tf->nsect = size / 512; - tf->command = ATA_CMD_DSM; + if (ata_ncq_enabled(dev) && + (dev->ncq_send_recv_cmds[ATA_LOG_NCQ_SEND_RECV_DSM_OFFSET] & + ATA_LOG_NCQ_SEND_RECV_DSM_TRIM)) { + /* Newer devices support queued TRIM commands */ + tf->protocol = ATA_PROT_NCQ; + tf->auxiliary = 1; + tf->command = ATA_CMD_FPDMA_SEND; + tf->hob_nsect = ATA_SUBCMD_FPDMA_SEND_DSM & 0x1f; + tf->nsect = qc->tag << 3; + tf->hob_feature = (size / 512) >> 8; + tf->feature = size / 512; + } else { + tf->protocol = ATA_PROT_DMA; + tf->hob_feature = 0; + tf->feature = ATA_DSM_TRIM; + tf->hob_nsect = (size / 512) >> 8; + tf->nsect = size / 512; + tf->command = ATA_CMD_DSM; + } + tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48 | ATA_TFLAG_WRITE;