diff options
| author | Jeff Garzik <jgarzik@pobox.com> | 2005-11-05 15:37:24 -0500 |
|---|---|---|
| committer | Jeff Garzik <jgarzik@pobox.com> | 2005-11-05 15:37:24 -0500 |
| commit | d40d9d29c020f8466c96f8e3ad4b7c014ff1085d (patch) | |
| tree | cb30b4e80f37e0d734a826aa6b29394f46123f9f /include/linux/libata.h | |
| parent | 96a71d52bb91d9b386a60f904956420f98946dd3 (diff) | |
| parent | 70d9d825e0a5a78ec1dacaaaf5c72ff5b0206fab (diff) | |
Merge branch 'master'
Diffstat (limited to 'include/linux/libata.h')
| -rw-r--r-- | include/linux/libata.h | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h index 0ba3af7a1236..dcd17e7458ab 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
| @@ -155,6 +155,10 @@ enum { | |||
| 155 | ATA_SHIFT_UDMA = 0, | 155 | ATA_SHIFT_UDMA = 0, |
| 156 | ATA_SHIFT_MWDMA = 8, | 156 | ATA_SHIFT_MWDMA = 8, |
| 157 | ATA_SHIFT_PIO = 11, | 157 | ATA_SHIFT_PIO = 11, |
| 158 | |||
| 159 | /* size of buffer to pad xfers ending on unaligned boundaries */ | ||
| 160 | ATA_DMA_PAD_SZ = 4, | ||
| 161 | ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE, | ||
| 158 | 162 | ||
| 159 | /* Masks for port functions */ | 163 | /* Masks for port functions */ |
| 160 | ATA_PORT_PRIMARY = (1 << 0), | 164 | ATA_PORT_PRIMARY = (1 << 0), |
| @@ -249,9 +253,12 @@ struct ata_queued_cmd { | |||
| 249 | unsigned long flags; /* ATA_QCFLAG_xxx */ | 253 | unsigned long flags; /* ATA_QCFLAG_xxx */ |
| 250 | unsigned int tag; | 254 | unsigned int tag; |
| 251 | unsigned int n_elem; | 255 | unsigned int n_elem; |
| 256 | unsigned int orig_n_elem; | ||
| 252 | 257 | ||
| 253 | int dma_dir; | 258 | int dma_dir; |
| 254 | 259 | ||
| 260 | unsigned int pad_len; | ||
| 261 | |||
| 255 | unsigned int nsect; | 262 | unsigned int nsect; |
| 256 | unsigned int cursect; | 263 | unsigned int cursect; |
| 257 | 264 | ||
| @@ -262,9 +269,11 @@ struct ata_queued_cmd { | |||
| 262 | unsigned int cursg_ofs; | 269 | unsigned int cursg_ofs; |
| 263 | 270 | ||
| 264 | struct scatterlist sgent; | 271 | struct scatterlist sgent; |
| 272 | struct scatterlist pad_sgent; | ||
| 265 | void *buf_virt; | 273 | void *buf_virt; |
| 266 | 274 | ||
| 267 | struct scatterlist *sg; | 275 | /* DO NOT iterate over __sg manually, use ata_for_each_sg() */ |
| 276 | struct scatterlist *__sg; | ||
| 268 | 277 | ||
| 269 | ata_qc_cb_t complete_fn; | 278 | ata_qc_cb_t complete_fn; |
| 270 | 279 | ||
| @@ -310,6 +319,9 @@ struct ata_port { | |||
| 310 | struct ata_prd *prd; /* our SG list */ | 319 | struct ata_prd *prd; /* our SG list */ |
| 311 | dma_addr_t prd_dma; /* and its DMA mapping */ | 320 | dma_addr_t prd_dma; /* and its DMA mapping */ |
| 312 | 321 | ||
| 322 | void *pad; /* array of DMA pad buffers */ | ||
| 323 | dma_addr_t pad_dma; | ||
| 324 | |||
| 313 | struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */ | 325 | struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */ |
| 314 | 326 | ||
| 315 | u8 ctl; /* cache of ATA control register */ | 327 | u8 ctl; /* cache of ATA control register */ |
| @@ -512,6 +524,31 @@ extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bit | |||
| 512 | #endif /* CONFIG_PCI */ | 524 | #endif /* CONFIG_PCI */ |
| 513 | 525 | ||
| 514 | 526 | ||
| 527 | static inline int | ||
| 528 | ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) | ||
| 529 | { | ||
| 530 | if (sg == &qc->pad_sgent) | ||
| 531 | return 1; | ||
| 532 | if (qc->pad_len) | ||
| 533 | return 0; | ||
| 534 | if (((sg - qc->__sg) + 1) == qc->n_elem) | ||
| 535 | return 1; | ||
| 536 | return 0; | ||
| 537 | } | ||
| 538 | |||
| 539 | static inline struct scatterlist * | ||
| 540 | ata_qc_next_sg(struct scatterlist *sg, struct ata_queued_cmd *qc) | ||
| 541 | { | ||
| 542 | if (sg == &qc->pad_sgent) | ||
| 543 | return NULL; | ||
| 544 | if (++sg - qc->__sg < qc->n_elem) | ||
| 545 | return sg; | ||
| 546 | return qc->pad_len ? &qc->pad_sgent : NULL; | ||
| 547 | } | ||
| 548 | |||
| 549 | #define ata_for_each_sg(sg, qc) \ | ||
| 550 | for (sg = qc->__sg; sg; sg = ata_qc_next_sg(sg, qc)) | ||
| 551 | |||
| 515 | static inline unsigned int ata_tag_valid(unsigned int tag) | 552 | static inline unsigned int ata_tag_valid(unsigned int tag) |
| 516 | { | 553 | { |
| 517 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; | 554 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; |
| @@ -740,4 +777,17 @@ static inline unsigned int __ac_err_mask(u8 status) | |||
| 740 | return mask; | 777 | return mask; |
| 741 | } | 778 | } |
| 742 | 779 | ||
| 780 | static inline int ata_pad_alloc(struct ata_port *ap, struct device *dev) | ||
| 781 | { | ||
| 782 | ap->pad_dma = 0; | ||
| 783 | ap->pad = dma_alloc_coherent(dev, ATA_DMA_PAD_BUF_SZ, | ||
| 784 | &ap->pad_dma, GFP_KERNEL); | ||
| 785 | return (ap->pad == NULL) ? -ENOMEM : 0; | ||
| 786 | } | ||
| 787 | |||
| 788 | static inline void ata_pad_free(struct ata_port *ap, struct device *dev) | ||
| 789 | { | ||
| 790 | dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); | ||
| 791 | } | ||
| 792 | |||
| 743 | #endif /* __LINUX_LIBATA_H__ */ | 793 | #endif /* __LINUX_LIBATA_H__ */ |
