From: Linus Torvalds Date: Wed, 22 Feb 2017 01:21:32 +0000 (-0800) Subject: Merge branch 'for-4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata X-Git-Tag: v4.11-rc1~130 X-Git-Url: http://git.samba.org/samba.git/?p=sfrench%2Fcifs-2.6.git;a=commitdiff_plain;h=79f4d1d5c0d7d115b5a693a5bb369e69efb7e7a5;hp=-c Merge branch 'for-4.11' of git://git./linux/kernel/git/tj/libata Pull libata updates from Tejun Heo: - Bartlomiej added pata_falcon - Christoph is trying to remove use of static 4k buf. It's still WIP - config cleanup around HAS_DMA - other fixes and driver-specific changes * 'for-4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: (29 commits) ata: pata_of_platform: using of_property_read_u32() helper pata_atiixp: Don't use unconnected secondary port on SB600/SB700 libata-sff: Don't scan disabled ports when checking for legacy mode. pata_octeon_cf: remove unused local variables from octeon_cf_set_piomode() ahci: qoriq: added ls2088a platforms support ahci: qoriq: report error when ecc register address is missing in dts ahci: qoriq: added a condition to enable dma coherence Revert "libata: switch to dynamic allocation instead of ata_scsi_rbuf" ahci: imx: fix building without hwmon or thermal ata: add Atari Falcon PATA controller driver ata: pass queued command to ->sff_data_xfer method ata: allow subsystem to be used on m68k arch libata: switch to dynamic allocation instead of ata_scsi_rbuf libata: don't call ata_scsi_rbuf_fill for command without a response buffer libata: call ->scsi_done from ata_scsi_simulate libata: remove the done callback from ata_scsi_args libata: move struct ata_scsi_args to libata-scsi.c libata: avoid global response buffer in atapi_qc_complete libata-eh: Use switch() instead of sparse array for protocol strings ata: sata_mv: Convert to devm_ioremap_resource() ... --- 79f4d1d5c0d7d115b5a693a5bb369e69efb7e7a5 diff --combined drivers/ata/libata-eh.c index 50ee10db160f,e7196fc29ff0..4e5bf36c5f46 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@@ -549,7 -549,6 +549,7 @@@ enum blk_eh_timer_return ata_scsi_timed DPRINTK("EXIT, ret=%d\n", ret); return ret; } +EXPORT_SYMBOL(ata_scsi_timed_out); static void ata_eh_unload(struct ata_port *ap) { @@@ -2607,21 -2606,39 +2607,39 @@@ static void ata_eh_link_report(struct a [DMA_TO_DEVICE] = "out", [DMA_FROM_DEVICE] = "in", }; - static const char *prot_str[] = { - [ATA_PROT_UNKNOWN] = "unknown", - [ATA_PROT_NODATA] = "nodata", - [ATA_PROT_PIO] = "pio", - [ATA_PROT_DMA] = "dma", - [ATA_PROT_NCQ] = "ncq dma", - [ATA_PROT_NCQ_NODATA] = "ncq nodata", - [ATAPI_PROT_NODATA] = "nodata", - [ATAPI_PROT_PIO] = "pio", - [ATAPI_PROT_DMA] = "dma", - }; - + const char *prot_str = NULL; + + switch (qc->tf.protocol) { + case ATA_PROT_UNKNOWN: + prot_str = "unknown"; + break; + case ATA_PROT_NODATA: + prot_str = "nodata"; + break; + case ATA_PROT_PIO: + prot_str = "pio"; + break; + case ATA_PROT_DMA: + prot_str = "dma"; + break; + case ATA_PROT_NCQ: + prot_str = "ncq dma"; + break; + case ATA_PROT_NCQ_NODATA: + prot_str = "ncq nodata"; + break; + case ATAPI_PROT_NODATA: + prot_str = "nodata"; + break; + case ATAPI_PROT_PIO: + prot_str = "pio"; + break; + case ATAPI_PROT_DMA: + prot_str = "dma"; + break; + } snprintf(data_buf, sizeof(data_buf), " %s %u %s", - prot_str[qc->tf.protocol], qc->nbytes, - dma_str[qc->dma_dir]); + prot_str, qc->nbytes, dma_str[qc->dma_dir]); } if (ata_is_atapi(qc->tf.protocol)) { diff --combined drivers/ata/libata-scsi.c index c771d4c341ea,395c8591980f..12d3a66600a3 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@@ -484,13 -484,6 +484,6 @@@ struct device_attribute *ata_common_sde }; EXPORT_SYMBOL_GPL(ata_common_sdev_attrs); - static void ata_scsi_invalid_field(struct ata_device *dev, - struct scsi_cmnd *cmd, u16 field) - { - ata_scsi_set_invalid_field(dev, cmd, field, 0xff); - cmd->scsi_done(cmd); - } - /** * ata_std_bios_param - generic bios head/sector/cylinder calculator used by sd. * @sdev: SCSI device for which BIOS geometry is to be determined @@@ -1265,13 -1258,13 +1258,13 @@@ static void ata_scsi_sdev_config(struc */ static int atapi_drain_needed(struct request *rq) { - if (likely(rq->cmd_type != REQ_TYPE_BLOCK_PC)) + if (likely(!blk_rq_is_passthrough(rq))) return 0; if (!blk_rq_bytes(rq) || op_is_write(req_op(rq))) return 0; - return atapi_cmd_type(rq->cmd[0]) == ATAPI_MISC; + return atapi_cmd_type(scsi_req(rq)->cmd[0]) == ATAPI_MISC; } static int ata_scsi_dev_config(struct scsi_device *sdev, @@@ -2057,6 -2050,12 +2050,12 @@@ defer return SCSI_MLQUEUE_HOST_BUSY; } + struct ata_scsi_args { + struct ata_device *dev; + u16 *id; + struct scsi_cmnd *cmd; + }; + /** * ata_scsi_rbuf_get - Map response buffer. * @cmd: SCSI command containing buffer to be mapped. @@@ -2133,7 -2132,6 +2132,6 @@@ static void ata_scsi_rbuf_fill(struct a if (rc == 0) cmd->result = SAM_STAT_GOOD; - args->done(cmd); } /** @@@ -2454,23 -2452,6 +2452,6 @@@ static unsigned int ata_scsiop_inq_b6(s return 0; } - /** - * ata_scsiop_noop - Command handler that simply returns success. - * @args: device IDENTIFY data / SCSI command of interest. - * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. - * - * No operation. Simply returns success to caller, to indicate - * that the caller should successfully complete this SCSI command. - * - * LOCKING: - * spin_lock_irqsave(host lock) - */ - static unsigned int ata_scsiop_noop(struct ata_scsi_args *args, u8 *rbuf) - { - VPRINTK("ENTER\n"); - return 0; - } - /** * modecpy - Prepare response for MODE SENSE * @dest: output buffer @@@ -2873,6 -2854,26 +2854,26 @@@ static void atapi_request_sense(struct DPRINTK("EXIT\n"); } + /* + * ATAPI devices typically report zero for their SCSI version, and sometimes + * deviate from the spec WRT response data format. If SCSI version is + * reported as zero like normal, then we make the following fixups: + * 1) Fake MMC-5 version, to indicate to the Linux scsi midlayer this is a + * modern device. + * 2) Ensure response data format / ATAPI information are always correct. + */ + static void atapi_fixup_inquiry(struct scsi_cmnd *cmd) + { + u8 buf[4]; + + sg_copy_to_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buf, 4); + if (buf[2] == 0) { + buf[2] = 0x5; + buf[3] = 0x32; + } + sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buf, 4); + } + static void atapi_qc_complete(struct ata_queued_cmd *qc) { struct scsi_cmnd *cmd = qc->scsicmd; @@@ -2927,30 -2928,8 +2928,8 @@@ */ ata_gen_passthru_sense(qc); } else { - u8 *scsicmd = cmd->cmnd; - - if ((scsicmd[0] == INQUIRY) && ((scsicmd[1] & 0x03) == 0)) { - unsigned long flags; - u8 *buf; - - buf = ata_scsi_rbuf_get(cmd, true, &flags); - - /* ATAPI devices typically report zero for their SCSI version, - * and sometimes deviate from the spec WRT response data - * format. If SCSI version is reported as zero like normal, - * then we make the following fixups: 1) Fake MMC-5 version, - * to indicate to the Linux scsi midlayer this is a modern - * device. 2) Ensure response data format / ATAPI information - * are always correct. - */ - if (buf[2] == 0) { - buf[2] = 0x5; - buf[3] = 0x32; - } - - ata_scsi_rbuf_put(cmd, true, &flags); - } - + if (cmd->cmnd[0] == INQUIRY && (cmd->cmnd[1] & 0x03) == 0) + atapi_fixup_inquiry(cmd); cmd->result = SAM_STAT_GOOD; } @@@ -4352,12 -4331,11 +4331,11 @@@ void ata_scsi_simulate(struct ata_devic args.dev = dev; args.id = dev->id; args.cmd = cmd; - args.done = cmd->scsi_done; switch(scsicmd[0]) { case INQUIRY: if (scsicmd[1] & 2) /* is CmdDt set? */ - ata_scsi_invalid_field(dev, cmd, 1); + ata_scsi_set_invalid_field(dev, cmd, 1, 0xff); else if ((scsicmd[1] & 1) == 0) /* is EVPD clear? */ ata_scsi_rbuf_fill(&args, ata_scsiop_inq_std); else switch (scsicmd[2]) { @@@ -4389,7 -4367,7 +4367,7 @@@ } /* Fallthrough */ default: - ata_scsi_invalid_field(dev, cmd, 2); + ata_scsi_set_invalid_field(dev, cmd, 2, 0xff); break; } break; @@@ -4407,7 -4385,7 +4385,7 @@@ if ((scsicmd[1] & 0x1f) == SAI_READ_CAPACITY_16) ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap); else - ata_scsi_invalid_field(dev, cmd, 1); + ata_scsi_set_invalid_field(dev, cmd, 1, 0xff); break; case REPORT_LUNS: @@@ -4417,7 -4395,6 +4395,6 @@@ case REQUEST_SENSE: ata_scsi_set_sense(dev, cmd, 0, 0, 0); cmd->result = (DRIVER_SENSE << 24); - cmd->scsi_done(cmd); break; /* if we reach this, then writeback caching is disabled, @@@ -4431,31 -4408,29 +4408,29 @@@ case SEEK_6: case SEEK_10: case TEST_UNIT_READY: - ata_scsi_rbuf_fill(&args, ata_scsiop_noop); break; case SEND_DIAGNOSTIC: tmp8 = scsicmd[1] & ~(1 << 3); - if ((tmp8 == 0x4) && (!scsicmd[3]) && (!scsicmd[4])) - ata_scsi_rbuf_fill(&args, ata_scsiop_noop); - else - ata_scsi_invalid_field(dev, cmd, 1); + if (tmp8 != 0x4 || scsicmd[3] || scsicmd[4]) + ata_scsi_set_invalid_field(dev, cmd, 1, 0xff); break; case MAINTENANCE_IN: if (scsicmd[1] == MI_REPORT_SUPPORTED_OPERATION_CODES) ata_scsi_rbuf_fill(&args, ata_scsiop_maint_in); else - ata_scsi_invalid_field(dev, cmd, 1); + ata_scsi_set_invalid_field(dev, cmd, 1, 0xff); break; /* all other commands */ default: ata_scsi_set_sense(dev, cmd, ILLEGAL_REQUEST, 0x20, 0x0); /* "Invalid command operation code" */ - cmd->scsi_done(cmd); break; } + + cmd->scsi_done(cmd); } int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht) diff --combined drivers/ata/libata.h index 06d479d1f302,bba39a62552b..120fce0befd3 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h @@@ -31,13 -31,6 +31,6 @@@ #define DRV_NAME "libata" #define DRV_VERSION "3.00" /* must be exactly four chars */ - struct ata_scsi_args { - struct ata_device *dev; - u16 *id; - struct scsi_cmnd *cmd; - void (*done)(struct scsi_cmnd *); - }; - /* libata-core.c */ enum { /* flags for ata_dev_read_id() */ @@@ -89,7 -82,6 +82,6 @@@ extern int sata_down_spd_limit(struct a extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel); extern unsigned int ata_dev_set_feature(struct ata_device *dev, u8 enable, u8 feature); - extern void ata_sg_clean(struct ata_queued_cmd *qc); extern void ata_qc_free(struct ata_queued_cmd *qc); extern void ata_qc_issue(struct ata_queued_cmd *qc); extern void __ata_qc_complete(struct ata_queued_cmd *qc); @@@ -159,6 -151,7 +151,6 @@@ extern unsigned long ata_internal_cmd_t extern void ata_internal_cmd_timed_out(struct ata_device *dev, u8 cmd); extern void ata_eh_acquire(struct ata_port *ap); extern void ata_eh_release(struct ata_port *ap); -extern enum blk_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd); extern void ata_scsi_error(struct Scsi_Host *host); extern void ata_eh_fastdrain_timerfn(unsigned long arg); extern void ata_qc_schedule_eh(struct ata_queued_cmd *qc); diff --combined drivers/ata/pata_falcon.c index 000000000000,78264082a4cf..5b0c57d1c59f mode 000000,100644..100644 --- a/drivers/ata/pata_falcon.c +++ b/drivers/ata/pata_falcon.c @@@ -1,0 -1,184 +1,184 @@@ + /* + * Atari Falcon PATA controller driver + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * http://www.samsung.com + * + * Based on falconide.c: + * + * Created 12 Jul 1997 by Geert Uytterhoeven + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + */ + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + #include + #include + #include + #include + #include + + #define DRV_NAME "pata_falcon" + #define DRV_VERSION "0.1.0" + + #define ATA_HD_BASE 0xfff00000 + #define ATA_HD_CONTROL 0x39 + + static struct scsi_host_template pata_falcon_sht = { + ATA_PIO_SHT(DRV_NAME), + }; + + static unsigned int pata_falcon_data_xfer(struct ata_queued_cmd *qc, + unsigned char *buf, + unsigned int buflen, int rw) + { + struct ata_device *dev = qc->dev; + struct ata_port *ap = dev->link->ap; + void __iomem *data_addr = ap->ioaddr.data_addr; + unsigned int words = buflen >> 1; + struct scsi_cmnd *cmd = qc->scsicmd; + bool swap = 1; + + if (dev->class == ATA_DEV_ATA && cmd && cmd->request && - cmd->request->cmd_type == REQ_TYPE_FS) ++ !blk_rq_is_passthrough(cmd->request)) + swap = 0; + + /* Transfer multiple of 2 bytes */ + if (rw == READ) { + if (swap) + raw_insw_swapw((u16 *)data_addr, (u16 *)buf, words); + else + raw_insw((u16 *)data_addr, (u16 *)buf, words); + } else { + if (swap) + raw_outsw_swapw((u16 *)data_addr, (u16 *)buf, words); + else + raw_outsw((u16 *)data_addr, (u16 *)buf, words); + } + + /* Transfer trailing byte, if any. */ + if (unlikely(buflen & 0x01)) { + unsigned char pad[2] = { }; + + /* Point buf to the tail of buffer */ + buf += buflen - 1; + + if (rw == READ) { + if (swap) + raw_insw_swapw((u16 *)data_addr, (u16 *)pad, 1); + else + raw_insw((u16 *)data_addr, (u16 *)pad, 1); + *buf = pad[0]; + } else { + pad[0] = *buf; + if (swap) + raw_outsw_swapw((u16 *)data_addr, (u16 *)pad, 1); + else + raw_outsw((u16 *)data_addr, (u16 *)pad, 1); + } + words++; + } + + return words << 1; + } + + /* + * Provide our own set_mode() as we don't want to change anything that has + * already been configured.. + */ + static int pata_falcon_set_mode(struct ata_link *link, + struct ata_device **unused) + { + struct ata_device *dev; + + ata_for_each_dev(dev, link, ENABLED) { + /* We don't really care */ + dev->pio_mode = dev->xfer_mode = XFER_PIO_0; + dev->xfer_shift = ATA_SHIFT_PIO; + dev->flags |= ATA_DFLAG_PIO; + ata_dev_info(dev, "configured for PIO\n"); + } + return 0; + } + + static struct ata_port_operations pata_falcon_ops = { + .inherits = &ata_sff_port_ops, + .sff_data_xfer = pata_falcon_data_xfer, + .cable_detect = ata_cable_unknown, + .set_mode = pata_falcon_set_mode, + }; + + static int pata_falcon_init_one(void) + { + struct ata_host *host; + struct ata_port *ap; + struct platform_device *pdev; + void __iomem *base; + + if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE)) + return -ENODEV; + + pr_info(DRV_NAME ": Atari Falcon PATA controller\n"); + + pdev = platform_device_register_simple(DRV_NAME, 0, NULL, 0); + if (IS_ERR(pdev)) + return PTR_ERR(pdev); + + if (!devm_request_mem_region(&pdev->dev, ATA_HD_BASE, 0x40, DRV_NAME)) { + pr_err(DRV_NAME ": resources busy\n"); + return -EBUSY; + } + + /* allocate host */ + host = ata_host_alloc(&pdev->dev, 1); + if (!host) + return -ENOMEM; + ap = host->ports[0]; + + ap->ops = &pata_falcon_ops; + ap->pio_mask = ATA_PIO4; + ap->flags |= ATA_FLAG_SLAVE_POSS | ATA_FLAG_NO_IORDY; + ap->flags |= ATA_FLAG_PIO_POLLING; + + base = (void __iomem *)ATA_HD_BASE; + ap->ioaddr.data_addr = base; + ap->ioaddr.error_addr = base + 1 + 1 * 4; + ap->ioaddr.feature_addr = base + 1 + 1 * 4; + ap->ioaddr.nsect_addr = base + 1 + 2 * 4; + ap->ioaddr.lbal_addr = base + 1 + 3 * 4; + ap->ioaddr.lbam_addr = base + 1 + 4 * 4; + ap->ioaddr.lbah_addr = base + 1 + 5 * 4; + ap->ioaddr.device_addr = base + 1 + 6 * 4; + ap->ioaddr.status_addr = base + 1 + 7 * 4; + ap->ioaddr.command_addr = base + 1 + 7 * 4; + + ap->ioaddr.altstatus_addr = base + ATA_HD_CONTROL; + ap->ioaddr.ctl_addr = base + ATA_HD_CONTROL; + + ata_port_desc(ap, "cmd 0x%lx ctl 0x%lx", (unsigned long)base, + (unsigned long)base + ATA_HD_CONTROL); + + /* activate */ + return ata_host_activate(host, 0, NULL, 0, &pata_falcon_sht); + } + + module_init(pata_falcon_init_one); + + MODULE_AUTHOR("Bartlomiej Zolnierkiewicz"); + MODULE_DESCRIPTION("low-level driver for Atari Falcon PATA"); + MODULE_LICENSE("GPL"); + MODULE_VERSION(DRV_VERSION); diff --combined include/linux/libata.h index 46e18c0619c6,0e8a8000b45f..c9a69fc8821e --- a/include/linux/libata.h +++ b/include/linux/libata.h @@@ -968,7 -968,7 +968,7 @@@ struct ata_port_operations void (*sff_tf_read)(struct ata_port *ap, struct ata_taskfile *tf); void (*sff_exec_command)(struct ata_port *ap, const struct ata_taskfile *tf); - unsigned int (*sff_data_xfer)(struct ata_device *dev, + unsigned int (*sff_data_xfer)(struct ata_queued_cmd *qc, unsigned char *buf, unsigned int buflen, int rw); void (*sff_irq_on)(struct ata_port *); bool (*sff_irq_check)(struct ata_port *); @@@ -1130,7 -1130,6 +1130,7 @@@ extern int ata_sas_port_start(struct at extern void ata_sas_port_stop(struct ata_port *ap); extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *); extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap); +extern enum blk_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd); extern int sata_scr_valid(struct ata_link *link); extern int sata_scr_read(struct ata_link *link, int reg, u32 *val); extern int sata_scr_write(struct ata_link *link, int reg, u32 val); @@@ -1356,7 -1355,6 +1356,7 @@@ extern struct device_attribute *ata_com .proc_name = drv_name, \ .slave_configure = ata_scsi_slave_config, \ .slave_destroy = ata_scsi_slave_destroy, \ + .eh_timed_out = ata_scsi_timed_out, \ .bios_param = ata_std_bios_param, \ .unlock_native_capacity = ata_scsi_unlock_native_capacity, \ .sdev_attrs = ata_common_sdev_attrs @@@ -1825,11 -1823,11 +1825,11 @@@ extern void ata_sff_tf_load(struct ata_ extern void ata_sff_tf_read(struct ata_port *ap, struct ata_taskfile *tf); extern void ata_sff_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); - extern unsigned int ata_sff_data_xfer(struct ata_device *dev, + extern unsigned int ata_sff_data_xfer(struct ata_queued_cmd *qc, unsigned char *buf, unsigned int buflen, int rw); - extern unsigned int ata_sff_data_xfer32(struct ata_device *dev, + extern unsigned int ata_sff_data_xfer32(struct ata_queued_cmd *qc, unsigned char *buf, unsigned int buflen, int rw); - extern unsigned int ata_sff_data_xfer_noirq(struct ata_device *dev, + extern unsigned int ata_sff_data_xfer_noirq(struct ata_queued_cmd *qc, unsigned char *buf, unsigned int buflen, int rw); extern void ata_sff_irq_on(struct ata_port *ap); extern void ata_sff_irq_clear(struct ata_port *ap);