]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - include/linux/ide.h
ide: add ->dma_timer_expiry method and remove ->dma_exec_cmd one (v2)
[mirror_ubuntu-bionic-kernel.git] / include / linux / ide.h
index 901d323c7bbe4056af3361ffc1fc3563174b4b95..9476939101be7c3a2e48c4e2506a942b5213b37e 100644 (file)
 #define ERROR_RESET    3       /* Reset controller every 4th retry */
 #define ERROR_RECAL    1       /* Recalibrate every 2nd retry */
 
+/* Error codes returned in rq->errors to the higher part of the driver. */
+enum {
+       IDE_DRV_ERROR_GENERAL   = 101,
+       IDE_DRV_ERROR_FILEMARK  = 102,
+       IDE_DRV_ERROR_EOD       = 103,
+};
+
 /*
  * Definitions for accessing IDE controller registers
  */
@@ -234,56 +241,52 @@ typedef enum {
 
 enum {
        IDE_TFLAG_LBA48                 = (1 << 0),
-       IDE_TFLAG_FLAGGED               = (1 << 2),
-       IDE_TFLAG_OUT_DATA              = (1 << 3),
-       IDE_TFLAG_OUT_HOB_FEATURE       = (1 << 4),
-       IDE_TFLAG_OUT_HOB_NSECT         = (1 << 5),
-       IDE_TFLAG_OUT_HOB_LBAL          = (1 << 6),
-       IDE_TFLAG_OUT_HOB_LBAM          = (1 << 7),
-       IDE_TFLAG_OUT_HOB_LBAH          = (1 << 8),
+       IDE_TFLAG_OUT_HOB_FEATURE       = (1 << 1),
+       IDE_TFLAG_OUT_HOB_NSECT         = (1 << 2),
+       IDE_TFLAG_OUT_HOB_LBAL          = (1 << 3),
+       IDE_TFLAG_OUT_HOB_LBAM          = (1 << 4),
+       IDE_TFLAG_OUT_HOB_LBAH          = (1 << 5),
        IDE_TFLAG_OUT_HOB               = IDE_TFLAG_OUT_HOB_FEATURE |
                                          IDE_TFLAG_OUT_HOB_NSECT |
                                          IDE_TFLAG_OUT_HOB_LBAL |
                                          IDE_TFLAG_OUT_HOB_LBAM |
                                          IDE_TFLAG_OUT_HOB_LBAH,
-       IDE_TFLAG_OUT_FEATURE           = (1 << 9),
-       IDE_TFLAG_OUT_NSECT             = (1 << 10),
-       IDE_TFLAG_OUT_LBAL              = (1 << 11),
-       IDE_TFLAG_OUT_LBAM              = (1 << 12),
-       IDE_TFLAG_OUT_LBAH              = (1 << 13),
+       IDE_TFLAG_OUT_FEATURE           = (1 << 6),
+       IDE_TFLAG_OUT_NSECT             = (1 << 7),
+       IDE_TFLAG_OUT_LBAL              = (1 << 8),
+       IDE_TFLAG_OUT_LBAM              = (1 << 9),
+       IDE_TFLAG_OUT_LBAH              = (1 << 10),
        IDE_TFLAG_OUT_TF                = IDE_TFLAG_OUT_FEATURE |
                                          IDE_TFLAG_OUT_NSECT |
                                          IDE_TFLAG_OUT_LBAL |
                                          IDE_TFLAG_OUT_LBAM |
                                          IDE_TFLAG_OUT_LBAH,
-       IDE_TFLAG_OUT_DEVICE            = (1 << 14),
-       IDE_TFLAG_WRITE                 = (1 << 15),
-       IDE_TFLAG_FLAGGED_SET_IN_FLAGS  = (1 << 16),
-       IDE_TFLAG_IN_DATA               = (1 << 17),
-       IDE_TFLAG_CUSTOM_HANDLER        = (1 << 18),
-       IDE_TFLAG_DMA_PIO_FALLBACK      = (1 << 19),
-       IDE_TFLAG_IN_HOB_FEATURE        = (1 << 20),
-       IDE_TFLAG_IN_HOB_NSECT          = (1 << 21),
-       IDE_TFLAG_IN_HOB_LBAL           = (1 << 22),
-       IDE_TFLAG_IN_HOB_LBAM           = (1 << 23),
-       IDE_TFLAG_IN_HOB_LBAH           = (1 << 24),
+       IDE_TFLAG_OUT_DEVICE            = (1 << 11),
+       IDE_TFLAG_WRITE                 = (1 << 12),
+       IDE_TFLAG_CUSTOM_HANDLER        = (1 << 13),
+       IDE_TFLAG_DMA_PIO_FALLBACK      = (1 << 14),
+       IDE_TFLAG_IN_HOB_FEATURE        = (1 << 15),
+       IDE_TFLAG_IN_HOB_NSECT          = (1 << 16),
+       IDE_TFLAG_IN_HOB_LBAL           = (1 << 17),
+       IDE_TFLAG_IN_HOB_LBAM           = (1 << 18),
+       IDE_TFLAG_IN_HOB_LBAH           = (1 << 19),
        IDE_TFLAG_IN_HOB_LBA            = IDE_TFLAG_IN_HOB_LBAL |
                                          IDE_TFLAG_IN_HOB_LBAM |
                                          IDE_TFLAG_IN_HOB_LBAH,
        IDE_TFLAG_IN_HOB                = IDE_TFLAG_IN_HOB_FEATURE |
                                          IDE_TFLAG_IN_HOB_NSECT |
                                          IDE_TFLAG_IN_HOB_LBA,
-       IDE_TFLAG_IN_FEATURE            = (1 << 1),
-       IDE_TFLAG_IN_NSECT              = (1 << 25),
-       IDE_TFLAG_IN_LBAL               = (1 << 26),
-       IDE_TFLAG_IN_LBAM               = (1 << 27),
-       IDE_TFLAG_IN_LBAH               = (1 << 28),
+       IDE_TFLAG_IN_FEATURE            = (1 << 20),
+       IDE_TFLAG_IN_NSECT              = (1 << 21),
+       IDE_TFLAG_IN_LBAL               = (1 << 22),
+       IDE_TFLAG_IN_LBAM               = (1 << 23),
+       IDE_TFLAG_IN_LBAH               = (1 << 24),
        IDE_TFLAG_IN_LBA                = IDE_TFLAG_IN_LBAL |
                                          IDE_TFLAG_IN_LBAM |
                                          IDE_TFLAG_IN_LBAH,
        IDE_TFLAG_IN_TF                 = IDE_TFLAG_IN_NSECT |
                                          IDE_TFLAG_IN_LBA,
-       IDE_TFLAG_IN_DEVICE             = (1 << 29),
+       IDE_TFLAG_IN_DEVICE             = (1 << 25),
        IDE_TFLAG_HOB                   = IDE_TFLAG_OUT_HOB |
                                          IDE_TFLAG_IN_HOB,
        IDE_TFLAG_TF                    = IDE_TFLAG_OUT_TF |
@@ -291,9 +294,18 @@ enum {
        IDE_TFLAG_DEVICE                = IDE_TFLAG_OUT_DEVICE |
                                          IDE_TFLAG_IN_DEVICE,
        /* force 16-bit I/O operations */
-       IDE_TFLAG_IO_16BIT              = (1 << 30),
-       /* ide_task_t was allocated using kmalloc() */
-       IDE_TFLAG_DYN                   = (1 << 31),
+       IDE_TFLAG_IO_16BIT              = (1 << 26),
+       /* struct ide_cmd was allocated using kmalloc() */
+       IDE_TFLAG_DYN                   = (1 << 27),
+       IDE_TFLAG_FS                    = (1 << 28),
+       IDE_TFLAG_MULTI_PIO             = (1 << 29),
+};
+
+enum {
+       IDE_FTFLAG_FLAGGED              = (1 << 0),
+       IDE_FTFLAG_SET_IN_FLAGS         = (1 << 1),
+       IDE_FTFLAG_OUT_DATA             = (1 << 2),
+       IDE_FTFLAG_IN_DATA              = (1 << 3),
 };
 
 struct ide_taskfile {
@@ -325,16 +337,27 @@ struct ide_taskfile {
        };
 };
 
-typedef struct ide_task_s {
+struct ide_cmd {
        union {
                struct ide_taskfile     tf;
                u8                      tf_array[14];
        };
+       u8                      ftf_flags;      /* for TASKFILE ioctl */
        u32                     tf_flags;
-       int                     data_phase;
+       int                     protocol;
+
+       int                     sg_nents;         /* number of sg entries */
+       int                     orig_sg_nents;
+       int                     sg_dma_direction; /* DMA transfer direction */
+
+       unsigned int            nsect;
+       unsigned int            nleft;
+       struct scatterlist      *cursg;
+       unsigned int            cursg_ofs;
+
        struct request          *rq;            /* copy of request */
        void                    *special;       /* valid_t generally */
-} ide_task_t;
+};
 
 /* ATAPI packet command flags */
 enum {
@@ -346,8 +369,6 @@ enum {
        PC_FLAG_DMA_IN_PROGRESS         = (1 << 4),
        PC_FLAG_DMA_ERROR               = (1 << 5),
        PC_FLAG_WRITING                 = (1 << 6),
-       /* command timed out */
-       PC_FLAG_TIMEDOUT                = (1 << 7),
 };
 
 /*
@@ -418,7 +439,6 @@ struct ide_disk_ops {
                                        int);
        ide_startstop_t (*do_request)(struct ide_drive_s *, struct request *,
                                      sector_t);
-       int             (*end_request)(struct ide_drive_s *, int, int);
        int             (*ioctl)(struct ide_drive_s *, struct block_device *,
                                 fmode_t, unsigned int, unsigned long);
 };
@@ -607,8 +627,11 @@ struct ide_drive_s {
        /* current packet command */
        struct ide_atapi_pc *pc;
 
+       /* last failed packet command */
+       struct ide_atapi_pc *failed_pc;
+
        /* callback for packet commands */
-       void (*pc_callback)(struct ide_drive_s *, int);
+       int  (*pc_callback)(struct ide_drive_s *, int);
 
        void (*pc_update_buffers)(struct ide_drive_s *, struct ide_atapi_pc *);
        int  (*pc_io_buffers)(struct ide_drive_s *, struct ide_atapi_pc *,
@@ -641,13 +664,13 @@ struct ide_tp_ops {
 
        void    (*set_irq)(struct hwif_s *, int);
 
-       void    (*tf_load)(ide_drive_t *, struct ide_task_s *);
-       void    (*tf_read)(ide_drive_t *, struct ide_task_s *);
+       void    (*tf_load)(ide_drive_t *, struct ide_cmd *);
+       void    (*tf_read)(ide_drive_t *, struct ide_cmd *);
 
-       void    (*input_data)(ide_drive_t *, struct request *, void *,
-                             unsigned int);
-       void    (*output_data)(ide_drive_t *, struct request *, void *,
-                              unsigned int);
+       void    (*input_data)(ide_drive_t *, struct ide_cmd *,
+                             void *, unsigned int);
+       void    (*output_data)(ide_drive_t *, struct ide_cmd *,
+                              void *, unsigned int);
 };
 
 extern const struct ide_tp_ops default_tp_ops;
@@ -691,12 +714,12 @@ struct ide_port_ops {
 
 struct ide_dma_ops {
        void    (*dma_host_set)(struct ide_drive_s *, int);
-       int     (*dma_setup)(struct ide_drive_s *);
-       void    (*dma_exec_cmd)(struct ide_drive_s *, u8);
+       int     (*dma_setup)(struct ide_drive_s *, struct ide_cmd *);
        void    (*dma_start)(struct ide_drive_s *);
        int     (*dma_end)(struct ide_drive_s *);
        int     (*dma_test_irq)(struct ide_drive_s *);
        void    (*dma_lost_irq)(struct ide_drive_s *);
+       int     (*dma_timer_expiry)(struct ide_drive_s *);
        void    (*dma_timeout)(struct ide_drive_s *);
        /*
         * The following method is optional and only required to be
@@ -760,19 +783,8 @@ typedef struct hwif_s {
        /* Scatter-gather list used to build the above */
        struct scatterlist *sg_table;
        int sg_max_nents;               /* Maximum number of entries in it */
-       int sg_nents;                   /* Current number of entries in it */
-       int orig_sg_nents;
-       int sg_dma_direction;           /* dma transfer direction */
-
-       /* data phase of the active command (currently only valid for PIO/DMA) */
-       int             data_phase;
-
-       struct ide_task_s task;         /* current command */
 
-       unsigned int nsect;
-       unsigned int nleft;
-       struct scatterlist *cursg;
-       unsigned int cursg_ofs;
+       struct ide_cmd cmd;             /* current command */
 
        int             rqsize;         /* max sectors per request */
        int             irq;            /* our irq number */
@@ -858,7 +870,7 @@ typedef ide_startstop_t (ide_handler_t)(ide_drive_t *);
 typedef int (ide_expiry_t)(ide_drive_t *);
 
 /* used by ide-cd, ide-floppy, etc. */
-typedef void (xfer_func_t)(ide_drive_t *, struct request *rq, void *, unsigned);
+typedef void (xfer_func_t)(ide_drive_t *, struct ide_cmd *, void *, unsigned);
 
 extern struct mutex ide_setting_mtx;
 
@@ -1077,7 +1089,7 @@ int generic_ide_resume(struct device *);
 
 void ide_complete_power_step(ide_drive_t *, struct request *);
 ide_startstop_t ide_start_power_step(ide_drive_t *, struct request *);
-void ide_complete_pm_request(ide_drive_t *, struct request *);
+void ide_complete_pm_rq(ide_drive_t *, struct request *);
 void ide_check_pm_state(ide_drive_t *, struct request *);
 
 /*
@@ -1089,7 +1101,6 @@ void ide_check_pm_state(ide_drive_t *, struct request *);
 struct ide_driver {
        const char                      *version;
        ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t);
-       int             (*end_request)(ide_drive_t *, int, int);
        struct device_driver    gen_driver;
        int             (*probe)(ide_drive_t *);
        void            (*remove)(ide_drive_t *);
@@ -1120,17 +1131,14 @@ int generic_ide_ioctl(ide_drive_t *, struct block_device *, unsigned, unsigned l
 extern int ide_vlb_clk;
 extern int ide_pci_clk;
 
-int ide_end_request(ide_drive_t *, int, int);
-int ide_end_dequeued_request(ide_drive_t *, struct request *, int, int);
+unsigned int ide_rq_bytes(struct request *);
+int ide_end_rq(ide_drive_t *, struct request *, int, unsigned int);
 void ide_kill_rq(ide_drive_t *, struct request *);
 
-void __ide_set_handler(ide_drive_t *, ide_handler_t *, unsigned int,
-                      ide_expiry_t *);
-void ide_set_handler(ide_drive_t *, ide_handler_t *, unsigned int,
-                    ide_expiry_t *);
+void __ide_set_handler(ide_drive_t *, ide_handler_t *, unsigned int);
+void ide_set_handler(ide_drive_t *, ide_handler_t *, unsigned int);
 
-void ide_execute_command(ide_drive_t *, u8, ide_handler_t *, unsigned int,
-                        ide_expiry_t *);
+void ide_execute_command(ide_drive_t *, u8, ide_handler_t *, unsigned int);
 
 void ide_execute_pkt_cmd(ide_drive_t *);
 
@@ -1154,7 +1162,8 @@ extern ide_startstop_t ide_do_reset (ide_drive_t *);
 extern int ide_devset_execute(ide_drive_t *drive,
                              const struct ide_devset *setting, int arg);
 
-extern void ide_end_drive_cmd(ide_drive_t *, u8, u8);
+void ide_complete_cmd(ide_drive_t *, struct ide_cmd *, u8, u8);
+int ide_complete_rq(ide_drive_t *, int, unsigned int);
 
 void ide_tf_dump(const char *, struct ide_taskfile *);
 
@@ -1164,11 +1173,11 @@ u8 ide_read_altstatus(ide_hwif_t *);
 
 void ide_set_irq(ide_hwif_t *, int);
 
-void ide_tf_load(ide_drive_t *, ide_task_t *);
-void ide_tf_read(ide_drive_t *, ide_task_t *);
+void ide_tf_load(ide_drive_t *, struct ide_cmd *);
+void ide_tf_read(ide_drive_t *, struct ide_cmd *);
 
-void ide_input_data(ide_drive_t *, struct request *, void *, unsigned int);
-void ide_output_data(ide_drive_t *, struct request *, void *, unsigned int);
+void ide_input_data(ide_drive_t *, struct ide_cmd *, void *, unsigned int);
+void ide_output_data(ide_drive_t *, struct ide_cmd *, void *, unsigned int);
 
 int ide_io_buffers(ide_drive_t *, struct ide_atapi_pc *, unsigned int, int);
 
@@ -1214,16 +1223,16 @@ int ide_cd_expiry(ide_drive_t *);
 
 int ide_cd_get_xferlen(struct request *);
 
-ide_startstop_t ide_issue_pc(ide_drive_t *);
+ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_cmd *);
 
-ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);
+ide_startstop_t do_rw_taskfile(ide_drive_t *, struct ide_cmd *);
 
-void task_end_request(ide_drive_t *, struct request *, u8);
+void ide_finish_cmd(ide_drive_t *, struct ide_cmd *, u8);
 
-int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *, u16);
-int ide_no_data_taskfile(ide_drive_t *, ide_task_t *);
+int ide_raw_taskfile(ide_drive_t *, struct ide_cmd *, u8 *, u16);
+int ide_no_data_taskfile(ide_drive_t *, struct ide_cmd *);
 
-int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long);
+int ide_taskfile_ioctl(ide_drive_t *, unsigned long);
 
 int ide_dev_read_id(ide_drive_t *, u8, u16 *);
 
@@ -1325,6 +1334,10 @@ enum {
        IDE_HFLAG_ERROR_STOPS_FIFO      = (1 << 19),
        /* serialize ports */
        IDE_HFLAG_SERIALIZE             = (1 << 20),
+       /* host is DTC2278 */
+       IDE_HFLAG_DTC2278               = (1 << 21),
+       /* 4 devices on a single set of I/O ports */
+       IDE_HFLAG_4DRIVES               = (1 << 22),
        /* host is TRM290 */
        IDE_HFLAG_TRM290                = (1 << 23),
        /* use 32-bit I/O ops */
@@ -1396,8 +1409,8 @@ int ide_pci_resume(struct pci_dev *);
 #define ide_pci_resume NULL
 #endif
 
-void ide_map_sg(ide_drive_t *, struct request *);
-void ide_init_sg_cmd(ide_drive_t *, struct request *);
+void ide_map_sg(ide_drive_t *, struct ide_cmd *);
+void ide_init_sg_cmd(struct ide_cmd *, int);
 
 #define BAD_DMA_DRIVE          0
 #define GOOD_DMA_DRIVE         1
@@ -1431,18 +1444,18 @@ ide_startstop_t ide_dma_intr(ide_drive_t *);
 int ide_allocate_dma_engine(ide_hwif_t *);
 void ide_release_dma_engine(ide_hwif_t *);
 
-int ide_build_sglist(ide_drive_t *, struct request *);
+int ide_build_sglist(ide_drive_t *, struct ide_cmd *);
 void ide_destroy_dmatable(ide_drive_t *);
 
 #ifdef CONFIG_BLK_DEV_IDEDMA_SFF
 int config_drive_for_dma(ide_drive_t *);
-extern int ide_build_dmatable(ide_drive_t *, struct request *);
+int ide_build_dmatable(ide_drive_t *, struct ide_cmd *);
 void ide_dma_host_set(ide_drive_t *, int);
-extern int ide_dma_setup(ide_drive_t *);
-void ide_dma_exec_cmd(ide_drive_t *, u8);
+int ide_dma_setup(ide_drive_t *, struct ide_cmd *);
 extern void ide_dma_start(ide_drive_t *);
 int ide_dma_end(ide_drive_t *);
 int ide_dma_test_irq(ide_drive_t *);
+int ide_dma_sff_timer_expiry(ide_drive_t *);
 u8 ide_dma_sff_read_status(ide_hwif_t *);
 extern const struct ide_dma_ops sff_dma_ops;
 #else
@@ -1463,8 +1476,11 @@ static inline void ide_dma_on(ide_drive_t *drive) { ; }
 static inline void ide_dma_verbose(ide_drive_t *drive) { ; }
 static inline int ide_set_dma(ide_drive_t *drive) { return 1; }
 static inline void ide_check_dma_crc(ide_drive_t *drive) { ; }
+static inline ide_startstop_t ide_dma_intr(ide_drive_t *drive) { return ide_stopped; }
 static inline ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) { return ide_stopped; }
 static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; }
+static inline int ide_build_sglist(ide_drive_t *drive,
+                                  struct ide_cmd *cmd) { return 0; }
 #endif /* CONFIG_BLK_DEV_IDEDMA */
 
 #ifdef CONFIG_BLK_DEV_IDEACPI