mtip32xx: remove trim support
authorChristoph Hellwig <hch@lst.de>
Thu, 25 Apr 2019 06:12:11 +0000 (08:12 +0200)
committerJens Axboe <axboe@kernel.dk>
Thu, 25 Apr 2019 15:11:53 +0000 (09:11 -0600)
The trim support in mtip32xx has been "temporarily" disabled for 6
years, which is 3/4 of the time the driver even exists in the tree.

Remove it as it obviously is dead code now.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/mtip32xx/mtip32xx.c
drivers/block/mtip32xx/mtip32xx.h

index 83302ecdc8db5ea3627ba7e0c2fb9fde83ab5336..f0105d1180568f2f11178b907a875baea5ec5247 100644 (file)
@@ -1192,14 +1192,6 @@ static int mtip_get_identify(struct mtip_port *port, void __user *user_buffer)
        else
                clear_bit(MTIP_DDF_SEC_LOCK_BIT, &port->dd->dd_flag);
 
-#ifdef MTIP_TRIM /* Disabling TRIM support temporarily */
-       /* Demux ID.DRAT & ID.RZAT to determine trim support */
-       if (port->identify[69] & (1 << 14) && port->identify[69] & (1 << 5))
-               port->dd->trim_supp = true;
-       else
-#endif
-               port->dd->trim_supp = false;
-
        /* Set the identify buffer as valid. */
        port->identify_valid = 1;
 
@@ -1386,77 +1378,6 @@ static int mtip_get_smart_attr(struct mtip_port *port, unsigned int id,
        return rv;
 }
 
-/*
- * Trim unused sectors
- *
- * @dd         pointer to driver_data structure
- * @lba                starting lba
- * @len                # of 512b sectors to trim
- */
-static blk_status_t mtip_send_trim(struct driver_data *dd, unsigned int lba,
-               unsigned int len)
-{
-       u64 tlba, tlen, sect_left;
-       struct mtip_trim_entry *buf;
-       dma_addr_t dma_addr;
-       struct host_to_dev_fis fis;
-       blk_status_t ret = BLK_STS_OK;
-       int i;
-
-       if (!len || dd->trim_supp == false)
-               return BLK_STS_IOERR;
-
-       /* Trim request too big */
-       WARN_ON(len > (MTIP_MAX_TRIM_ENTRY_LEN * MTIP_MAX_TRIM_ENTRIES));
-
-       /* Trim request not aligned on 4k boundary */
-       WARN_ON(len % 8 != 0);
-
-       /* Warn if vu_trim structure is too big */
-       WARN_ON(sizeof(struct mtip_trim) > ATA_SECT_SIZE);
-
-       /* Allocate a DMA buffer for the trim structure */
-       buf = dma_alloc_coherent(&dd->pdev->dev, ATA_SECT_SIZE, &dma_addr,
-                                                               GFP_KERNEL);
-       if (!buf)
-               return BLK_STS_RESOURCE;
-       memset(buf, 0, ATA_SECT_SIZE);
-
-       for (i = 0, sect_left = len, tlba = lba;
-                       i < MTIP_MAX_TRIM_ENTRIES && sect_left;
-                       i++) {
-               tlen = (sect_left >= MTIP_MAX_TRIM_ENTRY_LEN ?
-                                       MTIP_MAX_TRIM_ENTRY_LEN :
-                                       sect_left);
-               buf[i].lba = cpu_to_le32(tlba);
-               buf[i].range = cpu_to_le16(tlen);
-               tlba += tlen;
-               sect_left -= tlen;
-       }
-       WARN_ON(sect_left != 0);
-
-       /* Build the fis */
-       memset(&fis, 0, sizeof(struct host_to_dev_fis));
-       fis.type       = 0x27;
-       fis.opts       = 1 << 7;
-       fis.command    = 0xfb;
-       fis.features   = 0x60;
-       fis.sect_count = 1;
-       fis.device     = ATA_DEVICE_OBS;
-
-       if (mtip_exec_internal_command(dd->port,
-                                       &fis,
-                                       5,
-                                       dma_addr,
-                                       ATA_SECT_SIZE,
-                                       0,
-                                       MTIP_TRIM_TIMEOUT_MS) < 0)
-               ret = BLK_STS_IOERR;
-
-       dma_free_coherent(&dd->pdev->dev, ATA_SECT_SIZE, buf, dma_addr);
-       return ret;
-}
-
 /*
  * Get the drive capacity.
  *
@@ -3590,8 +3511,6 @@ static blk_status_t mtip_queue_rq(struct blk_mq_hw_ctx *hctx,
 
        blk_mq_start_request(rq);
 
-       if (req_op(rq) == REQ_OP_DISCARD)
-               return mtip_send_trim(dd, blk_rq_pos(rq), blk_rq_sectors(rq));
        mtip_hw_submit_io(dd, rq, cmd, hctx);
        return BLK_STS_OK;
 }
@@ -3769,14 +3688,6 @@ skip_create_disk:
        blk_queue_max_segment_size(dd->queue, 0x400000);
        blk_queue_io_min(dd->queue, 4096);
 
-       /* Signal trim support */
-       if (dd->trim_supp == true) {
-               blk_queue_flag_set(QUEUE_FLAG_DISCARD, dd->queue);
-               dd->queue->limits.discard_granularity = 4096;
-               blk_queue_max_discard_sectors(dd->queue,
-                       MTIP_MAX_TRIM_ENTRY_LEN * MTIP_MAX_TRIM_ENTRIES);
-       }
-
        /* Set the capacity of the device in 512 byte sectors. */
        if (!(mtip_hw_get_capacity(dd, &capacity))) {
                dev_warn(&dd->pdev->dev,
index abce25f27f5723a7afe9e8af50c6322905c37503..91c1cb5b15329c62c18a5ee31b9a8524f7a7e5a0 100644 (file)
@@ -193,21 +193,6 @@ struct mtip_work {
                mtip_workq_sdbfx(w->port, group, w->completed);     \
        }
 
-#define MTIP_TRIM_TIMEOUT_MS           240000
-#define MTIP_MAX_TRIM_ENTRIES          8
-#define MTIP_MAX_TRIM_ENTRY_LEN                0xfff8
-
-struct mtip_trim_entry {
-       __le32 lba;   /* starting lba of region */
-       __le16 rsvd;  /* unused */
-       __le16 range; /* # of 512b blocks to trim */
-} __packed;
-
-struct mtip_trim {
-       /* Array of regions to trim */
-       struct mtip_trim_entry entry[MTIP_MAX_TRIM_ENTRIES];
-} __packed;
-
 /* Register Frame Information Structure (FIS), host to device. */
 struct host_to_dev_fis {
        /*
@@ -474,8 +459,6 @@ struct driver_data {
 
        struct dentry *dfs_node;
 
-       bool trim_supp; /* flag indicating trim support */
-
        bool sr;
 
        int numa_node; /* NUMA support */