scsi: libata: Switch to using ->device_configure
authorChristoph Hellwig <hch@lst.de>
Tue, 9 Apr 2024 14:37:45 +0000 (16:37 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 12 Apr 2024 01:37:50 +0000 (21:37 -0400)
Switch to the ->device_configure method instead of ->slave_configure and
update the block limits on the passed in queue_limits instead of using the
per-limit accessors.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-21-hch@lst.de
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Acked-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
16 files changed:
drivers/ata/ahci.h
drivers/ata/libata-sata.c
drivers/ata/libata-scsi.c
drivers/ata/libata.h
drivers/ata/pata_macio.c
drivers/ata/sata_mv.c
drivers/ata/sata_nv.c
drivers/ata/sata_sil24.c
drivers/scsi/hisi_sas/hisi_sas.h
drivers/scsi/hisi_sas/hisi_sas_main.c
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
drivers/scsi/libsas/sas_scsi_host.c
include/linux/libata.h
include/scsi/libsas.h

index 344c87210d8fe4f43bc51912c44d5750f6d52502..8f40f75ba08cff4deca261b1162ee9a0fb91fed6 100644 (file)
@@ -397,7 +397,7 @@ extern const struct attribute_group *ahci_sdev_groups[];
        .sdev_groups            = ahci_sdev_groups,                     \
        .change_queue_depth     = ata_scsi_change_queue_depth,          \
        .tag_alloc_policy       = BLK_TAG_ALLOC_RR,                     \
-       .slave_configure        = ata_scsi_slave_config
+       .device_configure       = ata_scsi_device_configure
 
 extern struct ata_port_operations ahci_ops;
 extern struct ata_port_operations ahci_platform_ops;
index a8d773003d74bf44763f1219ef2408038f46b23d..9e047bf912b12bdf0d29bc68890755e6a96dd762 100644 (file)
@@ -1254,21 +1254,24 @@ void ata_sas_tport_delete(struct ata_port *ap)
 EXPORT_SYMBOL_GPL(ata_sas_tport_delete);
 
 /**
- *     ata_sas_slave_configure - Default slave_config routine for libata devices
+ *     ata_sas_device_configure - Default device_configure routine for libata
+ *                                devices
  *     @sdev: SCSI device to configure
+ *     @lim: queue limits
  *     @ap: ATA port to which SCSI device is attached
  *
  *     RETURNS:
  *     Zero.
  */
 
-int ata_sas_slave_configure(struct scsi_device *sdev, struct ata_port *ap)
+int ata_sas_device_configure(struct scsi_device *sdev, struct queue_limits *lim,
+               struct ata_port *ap)
 {
        ata_scsi_sdev_config(sdev);
 
-       return ata_scsi_dev_config(sdev, ap->link.device);
+       return ata_scsi_dev_config(sdev, lim, ap->link.device);
 }
-EXPORT_SYMBOL_GPL(ata_sas_slave_configure);
+EXPORT_SYMBOL_GPL(ata_sas_device_configure);
 
 /**
  *     ata_sas_queuecmd - Issue SCSI cdb to libata-managed device
index 0a0f483124c3a56af47abb498e67193236416b18..db441815d63306ba96543931628baec64ec82b8d 100644 (file)
@@ -1021,7 +1021,8 @@ bool ata_scsi_dma_need_drain(struct request *rq)
 }
 EXPORT_SYMBOL_GPL(ata_scsi_dma_need_drain);
 
-int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev)
+int ata_scsi_dev_config(struct scsi_device *sdev, struct queue_limits *lim,
+               struct ata_device *dev)
 {
        struct request_queue *q = sdev->request_queue;
        int depth = 1;
@@ -1031,7 +1032,7 @@ int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev)
 
        /* configure max sectors */
        dev->max_sectors = min(dev->max_sectors, sdev->host->max_sectors);
-       blk_queue_max_hw_sectors(q, dev->max_sectors);
+       lim->max_hw_sectors = dev->max_sectors;
 
        if (dev->class == ATA_DEV_ATAPI) {
                sdev->sector_size = ATA_SECT_SIZE;
@@ -1040,7 +1041,7 @@ int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev)
                blk_queue_update_dma_pad(q, ATA_DMA_PAD_SZ - 1);
 
                /* make room for appending the drain */
-               blk_queue_max_segments(q, queue_max_segments(q) - 1);
+               lim->max_segments--;
 
                sdev->dma_drain_len = ATAPI_MAX_DRAIN;
                sdev->dma_drain_buf = kmalloc(sdev->dma_drain_len, GFP_NOIO);
@@ -1077,7 +1078,7 @@ int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev)
                        "sector_size=%u > PAGE_SIZE, PIO may malfunction\n",
                        sdev->sector_size);
 
-       blk_queue_update_dma_alignment(q, sdev->sector_size - 1);
+       lim->dma_alignment = sdev->sector_size - 1;
 
        if (dev->flags & ATA_DFLAG_AN)
                set_bit(SDEV_EVT_MEDIA_CHANGE, sdev->supported_events);
@@ -1131,8 +1132,9 @@ int ata_scsi_slave_alloc(struct scsi_device *sdev)
 EXPORT_SYMBOL_GPL(ata_scsi_slave_alloc);
 
 /**
- *     ata_scsi_slave_config - Set SCSI device attributes
+ *     ata_scsi_device_configure - Set SCSI device attributes
  *     @sdev: SCSI device to examine
+ *     @lim: queue limits
  *
  *     This is called before we actually start reading
  *     and writing to the device, to configure certain
@@ -1142,17 +1144,18 @@ EXPORT_SYMBOL_GPL(ata_scsi_slave_alloc);
  *     Defined by SCSI layer.  We don't really care.
  */
 
-int ata_scsi_slave_config(struct scsi_device *sdev)
+int ata_scsi_device_configure(struct scsi_device *sdev,
+               struct queue_limits *lim)
 {
        struct ata_port *ap = ata_shost_to_port(sdev->host);
        struct ata_device *dev = __ata_scsi_find_dev(ap, sdev);
 
        if (dev)
-               return ata_scsi_dev_config(sdev, dev);
+               return ata_scsi_dev_config(sdev, lim, dev);
 
        return 0;
 }
-EXPORT_SYMBOL_GPL(ata_scsi_slave_config);
+EXPORT_SYMBOL_GPL(ata_scsi_device_configure);
 
 /**
  *     ata_scsi_slave_destroy - SCSI device is about to be destroyed
index 5c685bb1939e68c32d3768de508249b812af033b..8aab0df549eacd3419e3649b128fba70cdfb94cf 100644 (file)
@@ -131,7 +131,8 @@ extern void ata_scsi_dev_rescan(struct work_struct *work);
 extern int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
                              unsigned int id, u64 lun);
 void ata_scsi_sdev_config(struct scsi_device *sdev);
-int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev);
+int ata_scsi_dev_config(struct scsi_device *sdev, struct queue_limits *lim,
+               struct ata_device *dev);
 int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, struct ata_device *dev);
 
 /* libata-eh.c */
index f046bfa5c6e7f670bee844c71e02226aacbe182f..3dbcd737ebb7926c2ba59974ab18f8b05ac6e232 100644 (file)
@@ -806,7 +806,7 @@ static int pata_macio_device_configure(struct scsi_device *sdev,
        int rc;
 
        /* First call original */
-       rc = ata_scsi_slave_config(sdev);
+       rc = ata_scsi_device_configure(sdev, lim);
        if (rc)
                return rc;
 
index e82786c63fbd73decc4af68d1a3aff1113411a27..0bb900869ee08c86aa588e7419f27737ac22290d 100644 (file)
@@ -673,7 +673,7 @@ static const struct scsi_host_template mv6_sht = {
        .sdev_groups            = ata_ncq_sdev_groups,
        .change_queue_depth     = ata_scsi_change_queue_depth,
        .tag_alloc_policy       = BLK_TAG_ALLOC_RR,
-       .slave_configure        = ata_scsi_slave_config
+       .device_configure       = ata_scsi_device_configure
 };
 
 static struct ata_port_operations mv5_ops = {
index d0a8eb0e8011d0a5428220c7789c8ed6268224b6..36d99043ef50ff15eaaee78ba6efc0da36c4e61a 100644 (file)
@@ -676,7 +676,7 @@ static int nv_adma_device_configure(struct scsi_device *sdev,
        int adma_enable;
        u32 current_reg, new_reg, config_mask;
 
-       rc = ata_scsi_slave_config(sdev);
+       rc = ata_scsi_device_configure(sdev, lim);
 
        if (sdev->id >= ATA_MAX_DEVICES || sdev->channel || sdev->lun)
                /* Not a proper libata device, ignore */
@@ -1882,7 +1882,7 @@ static int nv_swncq_device_configure(struct scsi_device *sdev,
        u8 check_maxtor = 0;
        unsigned char model_num[ATA_ID_PROD_LEN + 1];
 
-       rc = ata_scsi_slave_config(sdev);
+       rc = ata_scsi_device_configure(sdev, lim);
        if (sdev->id >= ATA_MAX_DEVICES || sdev->channel || sdev->lun)
                /* Not a proper libata device, ignore */
                return rc;
index 142e70bfc4982c13af4752e60b34f759449a6511..72c03cbdaff43b02f1b21b7bdb4f3cf458bc0887 100644 (file)
@@ -381,7 +381,7 @@ static const struct scsi_host_template sil24_sht = {
        .tag_alloc_policy       = BLK_TAG_ALLOC_FIFO,
        .sdev_groups            = ata_ncq_sdev_groups,
        .change_queue_depth     = ata_scsi_change_queue_depth,
-       .slave_configure        = ata_scsi_slave_config
+       .device_configure       = ata_scsi_device_configure
 };
 
 static struct ata_port_operations sil24_ops = {
index 1e4550156b735d82599a273b125999c0b19353df..d223f482488fc6cebc2838e92ae7ec70fb4e1437 100644 (file)
@@ -643,7 +643,8 @@ extern int hisi_sas_probe(struct platform_device *pdev,
                          const struct hisi_sas_hw *ops);
 extern void hisi_sas_remove(struct platform_device *pdev);
 
-extern int hisi_sas_slave_configure(struct scsi_device *sdev);
+int hisi_sas_device_configure(struct scsi_device *sdev,
+               struct queue_limits *lim);
 extern int hisi_sas_slave_alloc(struct scsi_device *sdev);
 extern int hisi_sas_scan_finished(struct Scsi_Host *shost, unsigned long time);
 extern void hisi_sas_scan_start(struct Scsi_Host *shost);
index 097dfe4b620dce85736b8a0d5cf7f4b3c4842e9b..11228ba51ded74cdcb6426aba293e5adddce016f 100644 (file)
@@ -868,10 +868,11 @@ err_out:
        return rc;
 }
 
-int hisi_sas_slave_configure(struct scsi_device *sdev)
+int hisi_sas_device_configure(struct scsi_device *sdev,
+               struct queue_limits *lim)
 {
        struct domain_device *dev = sdev_to_domain_dev(sdev);
-       int ret = sas_slave_configure(sdev);
+       int ret = sas_device_configure(sdev, lim);
 
        if (ret)
                return ret;
@@ -880,7 +881,7 @@ int hisi_sas_slave_configure(struct scsi_device *sdev)
 
        return 0;
 }
-EXPORT_SYMBOL_GPL(hisi_sas_slave_configure);
+EXPORT_SYMBOL_GPL(hisi_sas_device_configure);
 
 void hisi_sas_scan_start(struct Scsi_Host *shost)
 {
index 161feae3acaba272253e7ce8dd38660b3d52b368..71b5008c3552cb4ed1ee5aaae43a40f0061fdb59 100644 (file)
@@ -1736,7 +1736,7 @@ ATTRIBUTE_GROUPS(host_v1_hw);
 
 static const struct scsi_host_template sht_v1_hw = {
        LIBSAS_SHT_BASE_NO_SLAVE_INIT
-       .slave_configure        = hisi_sas_slave_configure,
+       .device_configure       = hisi_sas_device_configure,
        .scan_finished          = hisi_sas_scan_finished,
        .scan_start             = hisi_sas_scan_start,
        .sg_tablesize           = HISI_SAS_SGE_PAGE_CNT,
index d89e97e8f5c2c260752271020d11707ad8db119f..342d75f12051d28fb1a0692b45ff568dd5b6f814 100644 (file)
@@ -3568,7 +3568,7 @@ static void map_queues_v2_hw(struct Scsi_Host *shost)
 
 static const struct scsi_host_template sht_v2_hw = {
        LIBSAS_SHT_BASE_NO_SLAVE_INIT
-       .slave_configure        = hisi_sas_slave_configure,
+       .device_configure       = hisi_sas_device_configure,
        .scan_finished          = hisi_sas_scan_finished,
        .scan_start             = hisi_sas_scan_start,
        .sg_tablesize           = HISI_SAS_SGE_PAGE_CNT,
index 756660588a1e88cd637192e15470b908cc4de5d9..a38165995e86c2a8e33afadc9ccf6a76958480db 100644 (file)
@@ -2894,11 +2894,12 @@ static ssize_t iopoll_q_cnt_v3_hw_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(iopoll_q_cnt_v3_hw);
 
-static int slave_configure_v3_hw(struct scsi_device *sdev)
+static int device_configure_v3_hw(struct scsi_device *sdev,
+               struct queue_limits *lim)
 {
        struct Scsi_Host *shost = dev_to_shost(&sdev->sdev_gendev);
        struct hisi_hba *hisi_hba = shost_priv(shost);
-       int ret = hisi_sas_slave_configure(sdev);
+       int ret = hisi_sas_device_configure(sdev, lim);
        struct device *dev = hisi_hba->dev;
 
        if (ret)
@@ -3321,7 +3322,7 @@ static void hisi_sas_map_queues(struct Scsi_Host *shost)
 
 static const struct scsi_host_template sht_v3_hw = {
        LIBSAS_SHT_BASE_NO_SLAVE_INIT
-       .slave_configure        = slave_configure_v3_hw,
+       .device_configure       = device_configure_v3_hw,
        .scan_finished          = hisi_sas_scan_finished,
        .scan_start             = hisi_sas_scan_start,
        .map_queues             = hisi_sas_map_queues,
index 9047cfcd1072ecc7b272bf925254c7d43413b169..da11d32840e2723e3a53df54203c938ce801b0ce 100644 (file)
@@ -804,14 +804,15 @@ EXPORT_SYMBOL_GPL(sas_target_alloc);
 
 #define SAS_DEF_QD 256
 
-int sas_slave_configure(struct scsi_device *scsi_dev)
+int sas_device_configure(struct scsi_device *scsi_dev,
+               struct queue_limits *lim)
 {
        struct domain_device *dev = sdev_to_domain_dev(scsi_dev);
 
        BUG_ON(dev->rphy->identify.device_type != SAS_END_DEVICE);
 
        if (dev_is_sata(dev)) {
-               ata_sas_slave_configure(scsi_dev, dev->sata_dev.ap);
+               ata_sas_device_configure(scsi_dev, lim, dev->sata_dev.ap);
                return 0;
        }
 
@@ -829,7 +830,7 @@ int sas_slave_configure(struct scsi_device *scsi_dev)
 
        return 0;
 }
-EXPORT_SYMBOL_GPL(sas_slave_configure);
+EXPORT_SYMBOL_GPL(sas_device_configure);
 
 int sas_change_queue_depth(struct scsi_device *sdev, int depth)
 {
index 6dd9a4f9ca7cb5a5d313d18b66807b8a90931180..f9c892f8940d5b22f5e7bc0f7d55e3f491e05505 100644 (file)
@@ -1151,7 +1151,8 @@ extern int ata_std_bios_param(struct scsi_device *sdev,
                              sector_t capacity, int geom[]);
 extern void ata_scsi_unlock_native_capacity(struct scsi_device *sdev);
 extern int ata_scsi_slave_alloc(struct scsi_device *sdev);
-extern int ata_scsi_slave_config(struct scsi_device *sdev);
+int ata_scsi_device_configure(struct scsi_device *sdev,
+               struct queue_limits *lim);
 extern void ata_scsi_slave_destroy(struct scsi_device *sdev);
 extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
                                       int queue_depth);
@@ -1249,7 +1250,8 @@ extern struct ata_port *ata_sas_port_alloc(struct ata_host *,
 extern void ata_port_probe(struct ata_port *ap);
 extern int ata_sas_tport_add(struct device *parent, struct ata_port *ap);
 extern void ata_sas_tport_delete(struct ata_port *ap);
-extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *);
+int ata_sas_device_configure(struct scsi_device *sdev, struct queue_limits *lim,
+               struct ata_port *ap);
 extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap);
 extern void ata_tf_to_fis(const struct ata_taskfile *tf,
                          u8 pmp, int is_cmd, u8 *fis);
@@ -1415,13 +1417,13 @@ extern const struct attribute_group *ata_common_sdev_groups[];
        __ATA_BASE_SHT(drv_name),                               \
        .can_queue              = ATA_DEF_QUEUE,                \
        .tag_alloc_policy       = BLK_TAG_ALLOC_RR,             \
-       .slave_configure        = ata_scsi_slave_config
+       .device_configure       = ata_scsi_device_configure
 
 #define ATA_SUBBASE_SHT_QD(drv_name, drv_qd)                   \
        __ATA_BASE_SHT(drv_name),                               \
        .can_queue              = drv_qd,                       \
        .tag_alloc_policy       = BLK_TAG_ALLOC_RR,             \
-       .slave_configure        = ata_scsi_slave_config
+       .device_configure       = ata_scsi_device_configure
 
 #define ATA_BASE_SHT(drv_name)                                 \
        ATA_SUBBASE_SHT(drv_name),                              \
index d06a0570f4c530a45ffafe04a57566e01538863b..1324068dd950f3dfb69400b90f5cbcdd82f7f835 100644 (file)
@@ -683,7 +683,8 @@ int sas_phy_reset(struct sas_phy *phy, int hard_reset);
 int sas_phy_enable(struct sas_phy *phy, int enable);
 extern int sas_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
 extern int sas_target_alloc(struct scsi_target *);
-extern int sas_slave_configure(struct scsi_device *);
+int sas_device_configure(struct scsi_device *dev,
+               struct queue_limits *lim);
 extern int sas_change_queue_depth(struct scsi_device *, int new_depth);
 extern int sas_bios_param(struct scsi_device *, struct block_device *,
                          sector_t capacity, int *hsc);
@@ -749,7 +750,7 @@ void sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event,
 #endif
 
 #define LIBSAS_SHT_BASE                        _LIBSAS_SHT_BASE                \
-       .slave_configure                = sas_slave_configure,          \
+       .device_configure               = sas_device_configure,         \
        .slave_alloc                    = sas_slave_alloc,              \
 
 #define LIBSAS_SHT_BASE_NO_SLAVE_INIT  _LIBSAS_SHT_BASE