diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-14 19:43:47 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-14 19:43:47 -0500 |
commit | 6ae840e7cc4be0be3aa40d9f67c35c75cfc67d83 (patch) | |
tree | 9c83c87a8670ef678d95f8d6f76a07f24a09a49f /drivers/misc | |
parent | e6b5be2be4e30037eb551e0ed09dd97bd00d85d3 (diff) | |
parent | 91905b6f4afe51e23a3f58df93e4cdc5e49cf40c (diff) |
Merge tag 'char-misc-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver updates from Greg KH:
"Here's the big char/misc driver update for 3.19-rc1
Lots of little things all over the place in different drivers, and a
new subsystem, "coresight" has been added. Full details are in the
shortlog"
* tag 'char-misc-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (73 commits)
parport: parport_pc, do not remove parent devices early
spmi: Remove shutdown/suspend/resume kernel-doc
carma-fpga-program: drop videobuf dependency
carma-fpga: drop videobuf dependency
carma-fpga-program.c: fix compile errors
i8k: Fix temperature bug handling in i8k_get_temp()
cxl: Name interrupts in /proc/interrupt
CXL: Return error to PSL if IRQ demultiplexing fails & print clearer warning
coresight-replicator: remove .owner field for driver
coresight: fixed comments in coresight.h
coresight: fix typo in comment in coresight-priv.h
coresight: bindings for coresight drivers
coresight: Adding ABI documentation
w1: support auto-load of w1_bq27000 module.
w1: avoid potential u16 overflow
cn: verify msg->len before making callback
mei: export fw status registers through sysfs
mei: read and print all six FW status registers
mei: txe: add cherrytrail device id
mei: kill cached host and me csr values
...
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/atmel-ssc.c | 4 | ||||
-rw-r--r-- | drivers/misc/carma/Kconfig | 6 | ||||
-rw-r--r-- | drivers/misc/carma/carma-fpga-program.c | 104 | ||||
-rw-r--r-- | drivers/misc/carma/carma-fpga.c | 98 | ||||
-rw-r--r-- | drivers/misc/fuse/Makefile | 1 | ||||
-rw-r--r-- | drivers/misc/genwqe/card_utils.c | 2 | ||||
-rw-r--r-- | drivers/misc/mei/amthif.c | 34 | ||||
-rw-r--r-- | drivers/misc/mei/bus.c | 4 | ||||
-rw-r--r-- | drivers/misc/mei/client.c | 2 | ||||
-rw-r--r-- | drivers/misc/mei/debugfs.c | 8 | ||||
-rw-r--r-- | drivers/misc/mei/hbm.c | 23 | ||||
-rw-r--r-- | drivers/misc/mei/hbm.h | 4 | ||||
-rw-r--r-- | drivers/misc/mei/hw-me-regs.h | 12 | ||||
-rw-r--r-- | drivers/misc/mei/hw-me.c | 49 | ||||
-rw-r--r-- | drivers/misc/mei/hw-me.h | 10 | ||||
-rw-r--r-- | drivers/misc/mei/hw-txe.c | 7 | ||||
-rw-r--r-- | drivers/misc/mei/init.c | 38 | ||||
-rw-r--r-- | drivers/misc/mei/interrupt.c | 12 | ||||
-rw-r--r-- | drivers/misc/mei/main.c | 43 | ||||
-rw-r--r-- | drivers/misc/mei/mei_dev.h | 39 | ||||
-rw-r--r-- | drivers/misc/mei/nfc.c | 52 | ||||
-rw-r--r-- | drivers/misc/mei/pci-me.c | 12 | ||||
-rw-r--r-- | drivers/misc/mei/pci-txe.c | 1 | ||||
-rw-r--r-- | drivers/misc/mei/wd.c | 9 | ||||
-rw-r--r-- | drivers/misc/pch_phub.c | 2 |
25 files changed, 411 insertions, 165 deletions
diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c index 5305ac8dfb3e..e11a0bd6c66e 100644 --- a/drivers/misc/atmel-ssc.c +++ b/drivers/misc/atmel-ssc.c | |||
@@ -57,7 +57,7 @@ struct ssc_device *ssc_request(unsigned int ssc_num) | |||
57 | ssc->user++; | 57 | ssc->user++; |
58 | spin_unlock(&user_lock); | 58 | spin_unlock(&user_lock); |
59 | 59 | ||
60 | clk_prepare_enable(ssc->clk); | 60 | clk_prepare(ssc->clk); |
61 | 61 | ||
62 | return ssc; | 62 | return ssc; |
63 | } | 63 | } |
@@ -77,7 +77,7 @@ void ssc_free(struct ssc_device *ssc) | |||
77 | spin_unlock(&user_lock); | 77 | spin_unlock(&user_lock); |
78 | 78 | ||
79 | if (disable_clk) | 79 | if (disable_clk) |
80 | clk_disable_unprepare(ssc->clk); | 80 | clk_unprepare(ssc->clk); |
81 | } | 81 | } |
82 | EXPORT_SYMBOL(ssc_free); | 82 | EXPORT_SYMBOL(ssc_free); |
83 | 83 | ||
diff --git a/drivers/misc/carma/Kconfig b/drivers/misc/carma/Kconfig index c90370ed712b..295882bfb14e 100644 --- a/drivers/misc/carma/Kconfig +++ b/drivers/misc/carma/Kconfig | |||
@@ -1,7 +1,6 @@ | |||
1 | config CARMA_FPGA | 1 | config CARMA_FPGA |
2 | tristate "CARMA DATA-FPGA Access Driver" | 2 | tristate "CARMA DATA-FPGA Access Driver" |
3 | depends on FSL_SOC && PPC_83xx && MEDIA_SUPPORT && HAS_DMA && FSL_DMA | 3 | depends on FSL_SOC && PPC_83xx && HAS_DMA && FSL_DMA |
4 | select VIDEOBUF_DMA_SG | ||
5 | default n | 4 | default n |
6 | help | 5 | help |
7 | Say Y here to include support for communicating with the data | 6 | Say Y here to include support for communicating with the data |
@@ -9,8 +8,7 @@ config CARMA_FPGA | |||
9 | 8 | ||
10 | config CARMA_FPGA_PROGRAM | 9 | config CARMA_FPGA_PROGRAM |
11 | tristate "CARMA DATA-FPGA Programmer" | 10 | tristate "CARMA DATA-FPGA Programmer" |
12 | depends on FSL_SOC && PPC_83xx && MEDIA_SUPPORT && HAS_DMA && FSL_DMA | 11 | depends on FSL_SOC && PPC_83xx && HAS_DMA && FSL_DMA |
13 | select VIDEOBUF_DMA_SG | ||
14 | default n | 12 | default n |
15 | help | 13 | help |
16 | Say Y here to include support for programming the data processing | 14 | Say Y here to include support for programming the data processing |
diff --git a/drivers/misc/carma/carma-fpga-program.c b/drivers/misc/carma/carma-fpga-program.c index 6fa52f71f51c..06166ac000e0 100644 --- a/drivers/misc/carma/carma-fpga-program.c +++ b/drivers/misc/carma/carma-fpga-program.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/fsldma.h> | 19 | #include <linux/fsldma.h> |
20 | #include <linux/interrupt.h> | 20 | #include <linux/interrupt.h> |
21 | #include <linux/highmem.h> | 21 | #include <linux/highmem.h> |
22 | #include <linux/vmalloc.h> | ||
22 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
23 | #include <linux/module.h> | 24 | #include <linux/module.h> |
24 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
@@ -30,8 +31,6 @@ | |||
30 | #include <linux/fs.h> | 31 | #include <linux/fs.h> |
31 | #include <linux/io.h> | 32 | #include <linux/io.h> |
32 | 33 | ||
33 | #include <media/videobuf-dma-sg.h> | ||
34 | |||
35 | /* MPC8349EMDS specific get_immrbase() */ | 34 | /* MPC8349EMDS specific get_immrbase() */ |
36 | #include <sysdev/fsl_soc.h> | 35 | #include <sysdev/fsl_soc.h> |
37 | 36 | ||
@@ -67,14 +66,79 @@ struct fpga_dev { | |||
67 | /* FPGA Bitfile */ | 66 | /* FPGA Bitfile */ |
68 | struct mutex lock; | 67 | struct mutex lock; |
69 | 68 | ||
70 | struct videobuf_dmabuf vb; | 69 | void *vaddr; |
71 | bool vb_allocated; | 70 | struct scatterlist *sglist; |
71 | int sglen; | ||
72 | int nr_pages; | ||
73 | bool buf_allocated; | ||
72 | 74 | ||
73 | /* max size and written bytes */ | 75 | /* max size and written bytes */ |
74 | size_t fw_size; | 76 | size_t fw_size; |
75 | size_t bytes; | 77 | size_t bytes; |
76 | }; | 78 | }; |
77 | 79 | ||
80 | static int fpga_dma_init(struct fpga_dev *priv, int nr_pages) | ||
81 | { | ||
82 | struct page *pg; | ||
83 | int i; | ||
84 | |||
85 | priv->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT); | ||
86 | if (NULL == priv->vaddr) { | ||
87 | pr_debug("vmalloc_32(%d pages) failed\n", nr_pages); | ||
88 | return -ENOMEM; | ||
89 | } | ||
90 | |||
91 | pr_debug("vmalloc is at addr 0x%08lx, size=%d\n", | ||
92 | (unsigned long)priv->vaddr, | ||
93 | nr_pages << PAGE_SHIFT); | ||
94 | |||
95 | memset(priv->vaddr, 0, nr_pages << PAGE_SHIFT); | ||
96 | priv->nr_pages = nr_pages; | ||
97 | |||
98 | priv->sglist = vzalloc(priv->nr_pages * sizeof(*priv->sglist)); | ||
99 | if (NULL == priv->sglist) | ||
100 | goto vzalloc_err; | ||
101 | |||
102 | sg_init_table(priv->sglist, priv->nr_pages); | ||
103 | for (i = 0; i < priv->nr_pages; i++) { | ||
104 | pg = vmalloc_to_page(priv->vaddr + i * PAGE_SIZE); | ||
105 | if (NULL == pg) | ||
106 | goto vmalloc_to_page_err; | ||
107 | sg_set_page(&priv->sglist[i], pg, PAGE_SIZE, 0); | ||
108 | } | ||
109 | return 0; | ||
110 | |||
111 | vmalloc_to_page_err: | ||
112 | vfree(priv->sglist); | ||
113 | priv->sglist = NULL; | ||
114 | vzalloc_err: | ||
115 | vfree(priv->vaddr); | ||
116 | priv->vaddr = NULL; | ||
117 | return -ENOMEM; | ||
118 | } | ||
119 | |||
120 | static int fpga_dma_map(struct fpga_dev *priv) | ||
121 | { | ||
122 | priv->sglen = dma_map_sg(priv->dev, priv->sglist, | ||
123 | priv->nr_pages, DMA_TO_DEVICE); | ||
124 | |||
125 | if (0 == priv->sglen) { | ||
126 | pr_warn("%s: dma_map_sg failed\n", __func__); | ||
127 | return -ENOMEM; | ||
128 | } | ||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | static int fpga_dma_unmap(struct fpga_dev *priv) | ||
133 | { | ||
134 | if (!priv->sglen) | ||
135 | return 0; | ||
136 | |||
137 | dma_unmap_sg(priv->dev, priv->sglist, priv->sglen, DMA_TO_DEVICE); | ||
138 | priv->sglen = 0; | ||
139 | return 0; | ||
140 | } | ||
141 | |||
78 | /* | 142 | /* |
79 | * FPGA Bitfile Helpers | 143 | * FPGA Bitfile Helpers |
80 | */ | 144 | */ |
@@ -87,8 +151,9 @@ struct fpga_dev { | |||
87 | */ | 151 | */ |
88 | static void fpga_drop_firmware_data(struct fpga_dev *priv) | 152 | static void fpga_drop_firmware_data(struct fpga_dev *priv) |
89 | { | 153 | { |
90 | videobuf_dma_free(&priv->vb); | 154 | vfree(priv->sglist); |
91 | priv->vb_allocated = false; | 155 | vfree(priv->vaddr); |
156 | priv->buf_allocated = false; | ||
92 | priv->bytes = 0; | 157 | priv->bytes = 0; |
93 | } | 158 | } |
94 | 159 | ||
@@ -427,7 +492,7 @@ static noinline int fpga_program_cpu(struct fpga_dev *priv) | |||
427 | dev_dbg(priv->dev, "enabled the controller\n"); | 492 | dev_dbg(priv->dev, "enabled the controller\n"); |
428 | 493 | ||
429 | /* Write each chunk of the FPGA bitfile to FPGA programmer */ | 494 | /* Write each chunk of the FPGA bitfile to FPGA programmer */ |
430 | ret = fpga_program_block(priv, priv->vb.vaddr, priv->bytes); | 495 | ret = fpga_program_block(priv, priv->vaddr, priv->bytes); |
431 | if (ret) | 496 | if (ret) |
432 | goto out_disable_controller; | 497 | goto out_disable_controller; |
433 | 498 | ||
@@ -463,7 +528,6 @@ out_disable_controller: | |||
463 | */ | 528 | */ |
464 | static noinline int fpga_program_dma(struct fpga_dev *priv) | 529 | static noinline int fpga_program_dma(struct fpga_dev *priv) |
465 | { | 530 | { |
466 | struct videobuf_dmabuf *vb = &priv->vb; | ||
467 | struct dma_chan *chan = priv->chan; | 531 | struct dma_chan *chan = priv->chan; |
468 | struct dma_async_tx_descriptor *tx; | 532 | struct dma_async_tx_descriptor *tx; |
469 | size_t num_pages, len, avail = 0; | 533 | size_t num_pages, len, avail = 0; |
@@ -505,7 +569,7 @@ static noinline int fpga_program_dma(struct fpga_dev *priv) | |||
505 | } | 569 | } |
506 | 570 | ||
507 | /* Map the buffer for DMA */ | 571 | /* Map the buffer for DMA */ |
508 | ret = videobuf_dma_map(priv->dev, &priv->vb); | 572 | ret = fpga_dma_map(priv); |
509 | if (ret) { | 573 | if (ret) { |
510 | dev_err(priv->dev, "Unable to map buffer for DMA\n"); | 574 | dev_err(priv->dev, "Unable to map buffer for DMA\n"); |
511 | goto out_free_table; | 575 | goto out_free_table; |
@@ -525,7 +589,7 @@ static noinline int fpga_program_dma(struct fpga_dev *priv) | |||
525 | goto out_dma_unmap; | 589 | goto out_dma_unmap; |
526 | } | 590 | } |
527 | 591 | ||
528 | ret = fsl_dma_external_start(chan, 1) | 592 | ret = fsl_dma_external_start(chan, 1); |
529 | if (ret) { | 593 | if (ret) { |
530 | dev_err(priv->dev, "DMA external control setup failed\n"); | 594 | dev_err(priv->dev, "DMA external control setup failed\n"); |
531 | goto out_dma_unmap; | 595 | goto out_dma_unmap; |
@@ -534,7 +598,7 @@ static noinline int fpga_program_dma(struct fpga_dev *priv) | |||
534 | /* setup and submit the DMA transaction */ | 598 | /* setup and submit the DMA transaction */ |
535 | 599 | ||
536 | tx = dmaengine_prep_dma_sg(chan, table.sgl, num_pages, | 600 | tx = dmaengine_prep_dma_sg(chan, table.sgl, num_pages, |
537 | vb->sglist, vb->sglen, 0); | 601 | priv->sglist, priv->sglen, 0); |
538 | if (!tx) { | 602 | if (!tx) { |
539 | dev_err(priv->dev, "Unable to prep DMA transaction\n"); | 603 | dev_err(priv->dev, "Unable to prep DMA transaction\n"); |
540 | ret = -ENOMEM; | 604 | ret = -ENOMEM; |
@@ -572,7 +636,7 @@ static noinline int fpga_program_dma(struct fpga_dev *priv) | |||
572 | out_disable_controller: | 636 | out_disable_controller: |
573 | fpga_programmer_disable(priv); | 637 | fpga_programmer_disable(priv); |
574 | out_dma_unmap: | 638 | out_dma_unmap: |
575 | videobuf_dma_unmap(priv->dev, vb); | 639 | fpga_dma_unmap(priv); |
576 | out_free_table: | 640 | out_free_table: |
577 | sg_free_table(&table); | 641 | sg_free_table(&table); |
578 | out_return: | 642 | out_return: |
@@ -702,12 +766,12 @@ static int fpga_open(struct inode *inode, struct file *filp) | |||
702 | priv->bytes = 0; | 766 | priv->bytes = 0; |
703 | 767 | ||
704 | /* Check if we have already allocated a buffer */ | 768 | /* Check if we have already allocated a buffer */ |
705 | if (priv->vb_allocated) | 769 | if (priv->buf_allocated) |
706 | return 0; | 770 | return 0; |
707 | 771 | ||
708 | /* Allocate a buffer to hold enough data for the bitfile */ | 772 | /* Allocate a buffer to hold enough data for the bitfile */ |
709 | nr_pages = DIV_ROUND_UP(priv->fw_size, PAGE_SIZE); | 773 | nr_pages = DIV_ROUND_UP(priv->fw_size, PAGE_SIZE); |
710 | ret = videobuf_dma_init_kernel(&priv->vb, DMA_TO_DEVICE, nr_pages); | 774 | ret = fpga_dma_init(priv, nr_pages); |
711 | if (ret) { | 775 | if (ret) { |
712 | dev_err(priv->dev, "unable to allocate data buffer\n"); | 776 | dev_err(priv->dev, "unable to allocate data buffer\n"); |
713 | mutex_unlock(&priv->lock); | 777 | mutex_unlock(&priv->lock); |
@@ -715,7 +779,7 @@ static int fpga_open(struct inode *inode, struct file *filp) | |||
715 | return ret; | 779 | return ret; |
716 | } | 780 | } |
717 | 781 | ||
718 | priv->vb_allocated = true; | 782 | priv->buf_allocated = true; |
719 | return 0; | 783 | return 0; |
720 | } | 784 | } |
721 | 785 | ||
@@ -738,7 +802,7 @@ static ssize_t fpga_write(struct file *filp, const char __user *buf, | |||
738 | return -ENOSPC; | 802 | return -ENOSPC; |
739 | 803 | ||
740 | count = min_t(size_t, priv->fw_size - priv->bytes, count); | 804 | count = min_t(size_t, priv->fw_size - priv->bytes, count); |
741 | if (copy_from_user(priv->vb.vaddr + priv->bytes, buf, count)) | 805 | if (copy_from_user(priv->vaddr + priv->bytes, buf, count)) |
742 | return -EFAULT; | 806 | return -EFAULT; |
743 | 807 | ||
744 | priv->bytes += count; | 808 | priv->bytes += count; |
@@ -749,20 +813,19 @@ static ssize_t fpga_read(struct file *filp, char __user *buf, size_t count, | |||
749 | loff_t *f_pos) | 813 | loff_t *f_pos) |
750 | { | 814 | { |
751 | struct fpga_dev *priv = filp->private_data; | 815 | struct fpga_dev *priv = filp->private_data; |
752 | return simple_read_from_buffer(buf, count, ppos, | 816 | return simple_read_from_buffer(buf, count, f_pos, |
753 | priv->vb.vaddr, priv->bytes); | 817 | priv->vaddr, priv->bytes); |
754 | } | 818 | } |
755 | 819 | ||
756 | static loff_t fpga_llseek(struct file *filp, loff_t offset, int origin) | 820 | static loff_t fpga_llseek(struct file *filp, loff_t offset, int origin) |
757 | { | 821 | { |
758 | struct fpga_dev *priv = filp->private_data; | 822 | struct fpga_dev *priv = filp->private_data; |
759 | loff_t newpos; | ||
760 | 823 | ||
761 | /* only read-only opens are allowed to seek */ | 824 | /* only read-only opens are allowed to seek */ |
762 | if ((filp->f_flags & O_ACCMODE) != O_RDONLY) | 825 | if ((filp->f_flags & O_ACCMODE) != O_RDONLY) |
763 | return -EINVAL; | 826 | return -EINVAL; |
764 | 827 | ||
765 | return fixed_size_llseek(file, offset, origin, priv->fw_size); | 828 | return fixed_size_llseek(filp, offset, origin, priv->fw_size); |
766 | } | 829 | } |
767 | 830 | ||
768 | static const struct file_operations fpga_fops = { | 831 | static const struct file_operations fpga_fops = { |
@@ -953,7 +1016,6 @@ static int fpga_of_probe(struct platform_device *op) | |||
953 | priv->dev = &op->dev; | 1016 | priv->dev = &op->dev; |
954 | mutex_init(&priv->lock); | 1017 | mutex_init(&priv->lock); |
955 | init_completion(&priv->completion); | 1018 | init_completion(&priv->completion); |
956 | videobuf_dma_init(&priv->vb); | ||
957 | 1019 | ||
958 | dev_set_drvdata(priv->dev, priv); | 1020 | dev_set_drvdata(priv->dev, priv); |
959 | dma_cap_zero(mask); | 1021 | dma_cap_zero(mask); |
diff --git a/drivers/misc/carma/carma-fpga.c b/drivers/misc/carma/carma-fpga.c index cdf2d7b902bb..68cdfe151bdb 100644 --- a/drivers/misc/carma/carma-fpga.c +++ b/drivers/misc/carma/carma-fpga.c | |||
@@ -98,6 +98,7 @@ | |||
98 | #include <linux/seq_file.h> | 98 | #include <linux/seq_file.h> |
99 | #include <linux/highmem.h> | 99 | #include <linux/highmem.h> |
100 | #include <linux/debugfs.h> | 100 | #include <linux/debugfs.h> |
101 | #include <linux/vmalloc.h> | ||
101 | #include <linux/kernel.h> | 102 | #include <linux/kernel.h> |
102 | #include <linux/module.h> | 103 | #include <linux/module.h> |
103 | #include <linux/poll.h> | 104 | #include <linux/poll.h> |
@@ -105,8 +106,6 @@ | |||
105 | #include <linux/kref.h> | 106 | #include <linux/kref.h> |
106 | #include <linux/io.h> | 107 | #include <linux/io.h> |
107 | 108 | ||
108 | #include <media/videobuf-dma-sg.h> | ||
109 | |||
110 | /* system controller registers */ | 109 | /* system controller registers */ |
111 | #define SYS_IRQ_SOURCE_CTL 0x24 | 110 | #define SYS_IRQ_SOURCE_CTL 0x24 |
112 | #define SYS_IRQ_OUTPUT_EN 0x28 | 111 | #define SYS_IRQ_OUTPUT_EN 0x28 |
@@ -142,7 +141,10 @@ struct fpga_info { | |||
142 | 141 | ||
143 | struct data_buf { | 142 | struct data_buf { |
144 | struct list_head entry; | 143 | struct list_head entry; |
145 | struct videobuf_dmabuf vb; | 144 | void *vaddr; |
145 | struct scatterlist *sglist; | ||
146 | int sglen; | ||
147 | int nr_pages; | ||
146 | size_t size; | 148 | size_t size; |
147 | }; | 149 | }; |
148 | 150 | ||
@@ -207,6 +209,68 @@ static void fpga_device_release(struct kref *ref) | |||
207 | * Data Buffer Allocation Helpers | 209 | * Data Buffer Allocation Helpers |
208 | */ | 210 | */ |
209 | 211 | ||
212 | static int carma_dma_init(struct data_buf *buf, int nr_pages) | ||
213 | { | ||
214 | struct page *pg; | ||
215 | int i; | ||
216 | |||
217 | buf->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT); | ||
218 | if (NULL == buf->vaddr) { | ||
219 | pr_debug("vmalloc_32(%d pages) failed\n", nr_pages); | ||
220 | return -ENOMEM; | ||
221 | } | ||
222 | |||
223 | pr_debug("vmalloc is at addr 0x%08lx, size=%d\n", | ||
224 | (unsigned long)buf->vaddr, | ||
225 | nr_pages << PAGE_SHIFT); | ||
226 | |||
227 | memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT); | ||
228 | buf->nr_pages = nr_pages; | ||
229 | |||
230 | buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist)); | ||
231 | if (NULL == buf->sglist) | ||
232 | goto vzalloc_err; | ||
233 | |||
234 | sg_init_table(buf->sglist, buf->nr_pages); | ||
235 | for (i = 0; i < buf->nr_pages; i++) { | ||
236 | pg = vmalloc_to_page(buf->vaddr + i * PAGE_SIZE); | ||
237 | if (NULL == pg) | ||
238 | goto vmalloc_to_page_err; | ||
239 | sg_set_page(&buf->sglist[i], pg, PAGE_SIZE, 0); | ||
240 | } | ||
241 | return 0; | ||
242 | |||
243 | vmalloc_to_page_err: | ||
244 | vfree(buf->sglist); | ||
245 | buf->sglist = NULL; | ||
246 | vzalloc_err: | ||
247 | vfree(buf->vaddr); | ||
248 | buf->vaddr = NULL; | ||
249 | return -ENOMEM; | ||
250 | } | ||
251 | |||
252 | static int carma_dma_map(struct device *dev, struct data_buf *buf) | ||
253 | { | ||
254 | buf->sglen = dma_map_sg(dev, buf->sglist, | ||
255 | buf->nr_pages, DMA_FROM_DEVICE); | ||
256 | |||
257 | if (0 == buf->sglen) { | ||
258 | pr_warn("%s: dma_map_sg failed\n", __func__); | ||
259 | return -ENOMEM; | ||
260 | } | ||
261 | return 0; | ||
262 | } | ||
263 | |||
264 | static int carma_dma_unmap(struct device *dev, struct data_buf *buf) | ||
265 | { | ||
266 | if (!buf->sglen) | ||
267 | return 0; | ||
268 | |||
269 | dma_unmap_sg(dev, buf->sglist, buf->sglen, DMA_FROM_DEVICE); | ||
270 | buf->sglen = 0; | ||
271 | return 0; | ||
272 | } | ||
273 | |||
210 | /** | 274 | /** |
211 | * data_free_buffer() - free a single data buffer and all allocated memory | 275 | * data_free_buffer() - free a single data buffer and all allocated memory |
212 | * @buf: the buffer to free | 276 | * @buf: the buffer to free |
@@ -221,7 +285,8 @@ static void data_free_buffer(struct data_buf *buf) | |||
221 | return; | 285 | return; |
222 | 286 | ||
223 | /* free all memory */ | 287 | /* free all memory */ |
224 | videobuf_dma_free(&buf->vb); | 288 | vfree(buf->sglist); |
289 | vfree(buf->vaddr); | ||
225 | kfree(buf); | 290 | kfree(buf); |
226 | } | 291 | } |
227 | 292 | ||
@@ -230,7 +295,7 @@ static void data_free_buffer(struct data_buf *buf) | |||
230 | * @bytes: the number of bytes required | 295 | * @bytes: the number of bytes required |
231 | * | 296 | * |
232 | * This allocates all space needed for a data buffer. It must be mapped before | 297 | * This allocates all space needed for a data buffer. It must be mapped before |
233 | * use in a DMA transaction using videobuf_dma_map(). | 298 | * use in a DMA transaction using carma_dma_map(). |
234 | * | 299 | * |
235 | * Returns NULL on failure | 300 | * Returns NULL on failure |
236 | */ | 301 | */ |
@@ -252,9 +317,8 @@ static struct data_buf *data_alloc_buffer(const size_t bytes) | |||
252 | INIT_LIST_HEAD(&buf->entry); | 317 | INIT_LIST_HEAD(&buf->entry); |
253 | buf->size = bytes; | 318 | buf->size = bytes; |
254 | 319 | ||
255 | /* allocate the videobuf */ | 320 | /* allocate the buffer */ |
256 | videobuf_dma_init(&buf->vb); | 321 | ret = carma_dma_init(buf, nr_pages); |
257 | ret = videobuf_dma_init_kernel(&buf->vb, DMA_FROM_DEVICE, nr_pages); | ||
258 | if (ret) | 322 | if (ret) |
259 | goto out_free_buf; | 323 | goto out_free_buf; |
260 | 324 | ||
@@ -285,13 +349,13 @@ static void data_free_buffers(struct fpga_device *priv) | |||
285 | 349 | ||
286 | list_for_each_entry_safe(buf, tmp, &priv->free, entry) { | 350 | list_for_each_entry_safe(buf, tmp, &priv->free, entry) { |
287 | list_del_init(&buf->entry); | 351 | list_del_init(&buf->entry); |
288 | videobuf_dma_unmap(priv->dev, &buf->vb); | 352 | carma_dma_unmap(priv->dev, buf); |
289 | data_free_buffer(buf); | 353 | data_free_buffer(buf); |
290 | } | 354 | } |
291 | 355 | ||
292 | list_for_each_entry_safe(buf, tmp, &priv->used, entry) { | 356 | list_for_each_entry_safe(buf, tmp, &priv->used, entry) { |
293 | list_del_init(&buf->entry); | 357 | list_del_init(&buf->entry); |
294 | videobuf_dma_unmap(priv->dev, &buf->vb); | 358 | carma_dma_unmap(priv->dev, buf); |
295 | data_free_buffer(buf); | 359 | data_free_buffer(buf); |
296 | } | 360 | } |
297 | 361 | ||
@@ -330,7 +394,7 @@ static int data_alloc_buffers(struct fpga_device *priv) | |||
330 | break; | 394 | break; |
331 | 395 | ||
332 | /* map it for DMA */ | 396 | /* map it for DMA */ |
333 | ret = videobuf_dma_map(priv->dev, &buf->vb); | 397 | ret = carma_dma_map(priv->dev, buf); |
334 | if (ret) { | 398 | if (ret) { |
335 | data_free_buffer(buf); | 399 | data_free_buffer(buf); |
336 | break; | 400 | break; |
@@ -634,8 +698,8 @@ static int data_submit_dma(struct fpga_device *priv, struct data_buf *buf) | |||
634 | dma_addr_t dst, src; | 698 | dma_addr_t dst, src; |
635 | unsigned long dma_flags = 0; | 699 | unsigned long dma_flags = 0; |
636 | 700 | ||
637 | dst_sg = buf->vb.sglist; | 701 | dst_sg = buf->sglist; |
638 | dst_nents = buf->vb.sglen; | 702 | dst_nents = buf->sglen; |
639 | 703 | ||
640 | src_sg = priv->corl_table.sgl; | 704 | src_sg = priv->corl_table.sgl; |
641 | src_nents = priv->corl_nents; | 705 | src_nents = priv->corl_nents; |
@@ -1134,7 +1198,7 @@ static ssize_t data_read(struct file *filp, char __user *ubuf, size_t count, | |||
1134 | spin_unlock_irq(&priv->lock); | 1198 | spin_unlock_irq(&priv->lock); |
1135 | 1199 | ||
1136 | /* Buffers are always mapped: unmap it */ | 1200 | /* Buffers are always mapped: unmap it */ |
1137 | videobuf_dma_unmap(priv->dev, &dbuf->vb); | 1201 | carma_dma_unmap(priv->dev, dbuf); |
1138 | 1202 | ||
1139 | /* save the buffer for later */ | 1203 | /* save the buffer for later */ |
1140 | reader->buf = dbuf; | 1204 | reader->buf = dbuf; |
@@ -1143,7 +1207,7 @@ static ssize_t data_read(struct file *filp, char __user *ubuf, size_t count, | |||
1143 | have_buffer: | 1207 | have_buffer: |
1144 | /* Get the number of bytes available */ | 1208 | /* Get the number of bytes available */ |
1145 | avail = dbuf->size - reader->buf_start; | 1209 | avail = dbuf->size - reader->buf_start; |
1146 | data = dbuf->vb.vaddr + reader->buf_start; | 1210 | data = dbuf->vaddr + reader->buf_start; |
1147 | 1211 | ||
1148 | /* Get the number of bytes we can transfer */ | 1212 | /* Get the number of bytes we can transfer */ |
1149 | count = min(count, avail); | 1213 | count = min(count, avail); |
@@ -1171,7 +1235,7 @@ have_buffer: | |||
1171 | * If it fails, we pretend that the read never happed and return | 1235 | * If it fails, we pretend that the read never happed and return |
1172 | * -EFAULT to userspace. The read will be retried. | 1236 | * -EFAULT to userspace. The read will be retried. |
1173 | */ | 1237 | */ |
1174 | ret = videobuf_dma_map(priv->dev, &dbuf->vb); | 1238 | ret = carma_dma_map(priv->dev, dbuf); |
1175 | if (ret) { | 1239 | if (ret) { |
1176 | dev_err(priv->dev, "unable to remap buffer for DMA\n"); | 1240 | dev_err(priv->dev, "unable to remap buffer for DMA\n"); |
1177 | return -EFAULT; | 1241 | return -EFAULT; |
@@ -1203,7 +1267,7 @@ out_unlock: | |||
1203 | spin_unlock_irq(&priv->lock); | 1267 | spin_unlock_irq(&priv->lock); |
1204 | 1268 | ||
1205 | if (drop_buffer) { | 1269 | if (drop_buffer) { |
1206 | videobuf_dma_unmap(priv->dev, &dbuf->vb); | 1270 | carma_dma_unmap(priv->dev, dbuf); |
1207 | data_free_buffer(dbuf); | 1271 | data_free_buffer(dbuf); |
1208 | } | 1272 | } |
1209 | 1273 | ||
diff --git a/drivers/misc/fuse/Makefile b/drivers/misc/fuse/Makefile deleted file mode 100644 index 0679c4febc89..000000000000 --- a/drivers/misc/fuse/Makefile +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | obj-$(CONFIG_ARCH_TEGRA) += tegra/ | ||
diff --git a/drivers/misc/genwqe/card_utils.c b/drivers/misc/genwqe/card_utils.c index 7cb3b7e41739..1ca94e6fa8fb 100644 --- a/drivers/misc/genwqe/card_utils.c +++ b/drivers/misc/genwqe/card_utils.c | |||
@@ -590,6 +590,8 @@ int genwqe_user_vmap(struct genwqe_dev *cd, struct dma_mapping *m, void *uaddr, | |||
590 | m->nr_pages, | 590 | m->nr_pages, |
591 | 1, /* write by caller */ | 591 | 1, /* write by caller */ |
592 | m->page_list); /* ptrs to pages */ | 592 | m->page_list); /* ptrs to pages */ |
593 | if (rc < 0) | ||
594 | goto fail_get_user_pages; | ||
593 | 595 | ||
594 | /* assumption: get_user_pages can be killed by signals. */ | 596 | /* assumption: get_user_pages can be killed by signals. */ |
595 | if (rc < m->nr_pages) { | 597 | if (rc < m->nr_pages) { |
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c index 6cdce8477f57..79f53941779d 100644 --- a/drivers/misc/mei/amthif.c +++ b/drivers/misc/mei/amthif.c | |||
@@ -262,6 +262,7 @@ out: | |||
262 | static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb) | 262 | static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb) |
263 | { | 263 | { |
264 | struct mei_msg_hdr mei_hdr; | 264 | struct mei_msg_hdr mei_hdr; |
265 | struct mei_cl *cl; | ||
265 | int ret; | 266 | int ret; |
266 | 267 | ||
267 | if (!dev || !cb) | 268 | if (!dev || !cb) |
@@ -277,8 +278,9 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb) | |||
277 | dev->iamthif_msg_buf_size = cb->request_buffer.size; | 278 | dev->iamthif_msg_buf_size = cb->request_buffer.size; |
278 | memcpy(dev->iamthif_msg_buf, cb->request_buffer.data, | 279 | memcpy(dev->iamthif_msg_buf, cb->request_buffer.data, |
279 | cb->request_buffer.size); | 280 | cb->request_buffer.size); |
281 | cl = &dev->iamthif_cl; | ||
280 | 282 | ||
281 | ret = mei_cl_flow_ctrl_creds(&dev->iamthif_cl); | 283 | ret = mei_cl_flow_ctrl_creds(cl); |
282 | if (ret < 0) | 284 | if (ret < 0) |
283 | return ret; | 285 | return ret; |
284 | 286 | ||
@@ -292,8 +294,8 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb) | |||
292 | mei_hdr.msg_complete = 1; | 294 | mei_hdr.msg_complete = 1; |
293 | } | 295 | } |
294 | 296 | ||
295 | mei_hdr.host_addr = dev->iamthif_cl.host_client_id; | 297 | mei_hdr.host_addr = cl->host_client_id; |
296 | mei_hdr.me_addr = dev->iamthif_cl.me_client_id; | 298 | mei_hdr.me_addr = cl->me_client_id; |
297 | mei_hdr.reserved = 0; | 299 | mei_hdr.reserved = 0; |
298 | mei_hdr.internal = 0; | 300 | mei_hdr.internal = 0; |
299 | dev->iamthif_msg_buf_index += mei_hdr.length; | 301 | dev->iamthif_msg_buf_index += mei_hdr.length; |
@@ -302,7 +304,7 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb) | |||
302 | return ret; | 304 | return ret; |
303 | 305 | ||
304 | if (mei_hdr.msg_complete) { | 306 | if (mei_hdr.msg_complete) { |
305 | if (mei_cl_flow_ctrl_reduce(&dev->iamthif_cl)) | 307 | if (mei_cl_flow_ctrl_reduce(cl)) |
306 | return -EIO; | 308 | return -EIO; |
307 | dev->iamthif_flow_control_pending = true; | 309 | dev->iamthif_flow_control_pending = true; |
308 | dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL; | 310 | dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL; |
@@ -360,8 +362,7 @@ int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *cb) | |||
360 | void mei_amthif_run_next_cmd(struct mei_device *dev) | 362 | void mei_amthif_run_next_cmd(struct mei_device *dev) |
361 | { | 363 | { |
362 | struct mei_cl_cb *cb; | 364 | struct mei_cl_cb *cb; |
363 | struct mei_cl_cb *next; | 365 | int ret; |
364 | int status; | ||
365 | 366 | ||
366 | if (!dev) | 367 | if (!dev) |
367 | return; | 368 | return; |
@@ -376,16 +377,14 @@ void mei_amthif_run_next_cmd(struct mei_device *dev) | |||
376 | 377 | ||
377 | dev_dbg(dev->dev, "complete amthif cmd_list cb.\n"); | 378 | dev_dbg(dev->dev, "complete amthif cmd_list cb.\n"); |
378 | 379 | ||
379 | list_for_each_entry_safe(cb, next, &dev->amthif_cmd_list.list, list) { | 380 | cb = list_first_entry_or_null(&dev->amthif_cmd_list.list, |
380 | list_del(&cb->list); | 381 | typeof(*cb), list); |
381 | if (!cb->cl) | 382 | if (!cb) |
382 | continue; | 383 | return; |
383 | status = mei_amthif_send_cmd(dev, cb); | 384 | list_del(&cb->list); |
384 | if (status) | 385 | ret = mei_amthif_send_cmd(dev, cb); |
385 | dev_warn(dev->dev, "amthif write failed status = %d\n", | 386 | if (ret) |
386 | status); | 387 | dev_warn(dev->dev, "amthif write failed status = %d\n", ret); |
387 | break; | ||
388 | } | ||
389 | } | 388 | } |
390 | 389 | ||
391 | 390 | ||
@@ -536,9 +535,6 @@ int mei_amthif_irq_read_msg(struct mei_device *dev, | |||
536 | cb = dev->iamthif_current_cb; | 535 | cb = dev->iamthif_current_cb; |
537 | dev->iamthif_current_cb = NULL; | 536 | dev->iamthif_current_cb = NULL; |
538 | 537 | ||
539 | if (!cb->cl) | ||
540 | return -ENODEV; | ||
541 | |||
542 | dev->iamthif_stall_timer = 0; | 538 | dev->iamthif_stall_timer = 0; |
543 | cb->buf_idx = dev->iamthif_msg_buf_index; | 539 | cb->buf_idx = dev->iamthif_msg_buf_index; |
544 | cb->read_time = jiffies; | 540 | cb->read_time = jiffies; |
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index 4d20d60ca38d..b3a72bca5242 100644 --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c | |||
@@ -140,7 +140,7 @@ static struct device_type mei_cl_device_type = { | |||
140 | .release = mei_cl_dev_release, | 140 | .release = mei_cl_dev_release, |
141 | }; | 141 | }; |
142 | 142 | ||
143 | static struct mei_cl *mei_bus_find_mei_cl_by_uuid(struct mei_device *dev, | 143 | struct mei_cl *mei_cl_bus_find_cl_by_uuid(struct mei_device *dev, |
144 | uuid_le uuid) | 144 | uuid_le uuid) |
145 | { | 145 | { |
146 | struct mei_cl *cl; | 146 | struct mei_cl *cl; |
@@ -160,7 +160,7 @@ struct mei_cl_device *mei_cl_add_device(struct mei_device *dev, | |||
160 | struct mei_cl *cl; | 160 | struct mei_cl *cl; |
161 | int status; | 161 | int status; |
162 | 162 | ||
163 | cl = mei_bus_find_mei_cl_by_uuid(dev, uuid); | 163 | cl = mei_cl_bus_find_cl_by_uuid(dev, uuid); |
164 | if (cl == NULL) | 164 | if (cl == NULL) |
165 | return NULL; | 165 | return NULL; |
166 | 166 | ||
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c index bc9ba5359bc6..1382d551d7ed 100644 --- a/drivers/misc/mei/client.c +++ b/drivers/misc/mei/client.c | |||
@@ -146,7 +146,7 @@ static void __mei_io_list_flush(struct mei_cl_cb *list, | |||
146 | 146 | ||
147 | /* enable removing everything if no cl is specified */ | 147 | /* enable removing everything if no cl is specified */ |
148 | list_for_each_entry_safe(cb, next, &list->list, list) { | 148 | list_for_each_entry_safe(cb, next, &list->list, list) { |
149 | if (!cl || (cb->cl && mei_cl_cmp_id(cl, cb->cl))) { | 149 | if (!cl || mei_cl_cmp_id(cl, cb->cl)) { |
150 | list_del(&cb->list); | 150 | list_del(&cb->list); |
151 | if (free) | 151 | if (free) |
152 | mei_io_cb_free(cb); | 152 | mei_io_cb_free(cb); |
diff --git a/drivers/misc/mei/debugfs.c b/drivers/misc/mei/debugfs.c index ce1566715f80..b60b4263cf0f 100644 --- a/drivers/misc/mei/debugfs.c +++ b/drivers/misc/mei/debugfs.c | |||
@@ -34,7 +34,7 @@ static ssize_t mei_dbgfs_read_meclients(struct file *fp, char __user *ubuf, | |||
34 | int pos = 0; | 34 | int pos = 0; |
35 | int ret; | 35 | int ret; |
36 | 36 | ||
37 | #define HDR " |id|addr| UUID |con|msg len|sb|\n" | 37 | #define HDR " |id|fix| UUID |con|msg len|sb|\n" |
38 | 38 | ||
39 | mutex_lock(&dev->device_lock); | 39 | mutex_lock(&dev->device_lock); |
40 | 40 | ||
@@ -56,12 +56,8 @@ static ssize_t mei_dbgfs_read_meclients(struct file *fp, char __user *ubuf, | |||
56 | 56 | ||
57 | list_for_each_entry(me_cl, &dev->me_clients, list) { | 57 | list_for_each_entry(me_cl, &dev->me_clients, list) { |
58 | 58 | ||
59 | /* skip me clients that cannot be connected */ | ||
60 | if (me_cl->props.max_number_of_connections == 0) | ||
61 | continue; | ||
62 | |||
63 | pos += scnprintf(buf + pos, bufsz - pos, | 59 | pos += scnprintf(buf + pos, bufsz - pos, |
64 | "%2d|%2d|%4d|%pUl|%3d|%7d|%2d|\n", | 60 | "%2d|%2d|%3d|%pUl|%3d|%7d|%2d|\n", |
65 | i++, me_cl->client_id, | 61 | i++, me_cl->client_id, |
66 | me_cl->props.fixed_address, | 62 | me_cl->props.fixed_address, |
67 | &me_cl->props.protocol_name, | 63 | &me_cl->props.protocol_name, |
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c index 49a2653d91a5..239d7f5d6a92 100644 --- a/drivers/misc/mei/hbm.c +++ b/drivers/misc/mei/hbm.c | |||
@@ -562,17 +562,17 @@ int mei_hbm_cl_disconnect_rsp(struct mei_device *dev, struct mei_cl *cl) | |||
562 | * mei_hbm_cl_disconnect_res - update the client state according | 562 | * mei_hbm_cl_disconnect_res - update the client state according |
563 | * disconnect response | 563 | * disconnect response |
564 | * | 564 | * |
565 | * @dev: the device structure | ||
565 | * @cl: mei host client | 566 | * @cl: mei host client |
566 | * @cmd: disconnect client response host bus message | 567 | * @cmd: disconnect client response host bus message |
567 | */ | 568 | */ |
568 | static void mei_hbm_cl_disconnect_res(struct mei_cl *cl, | 569 | static void mei_hbm_cl_disconnect_res(struct mei_device *dev, struct mei_cl *cl, |
569 | struct mei_hbm_cl_cmd *cmd) | 570 | struct mei_hbm_cl_cmd *cmd) |
570 | { | 571 | { |
571 | struct hbm_client_connect_response *rs = | 572 | struct hbm_client_connect_response *rs = |
572 | (struct hbm_client_connect_response *)cmd; | 573 | (struct hbm_client_connect_response *)cmd; |
573 | 574 | ||
574 | dev_dbg(cl->dev->dev, "hbm: disconnect response cl:host=%02d me=%02d status=%d\n", | 575 | cl_dbg(dev, cl, "hbm: disconnect response status=%d\n", rs->status); |
575 | rs->me_addr, rs->host_addr, rs->status); | ||
576 | 576 | ||
577 | if (rs->status == MEI_CL_DISCONN_SUCCESS) | 577 | if (rs->status == MEI_CL_DISCONN_SUCCESS) |
578 | cl->state = MEI_FILE_DISCONNECTED; | 578 | cl->state = MEI_FILE_DISCONNECTED; |
@@ -598,17 +598,17 @@ int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl) | |||
598 | * mei_hbm_cl_connect_res - update the client state according | 598 | * mei_hbm_cl_connect_res - update the client state according |
599 | * connection response | 599 | * connection response |
600 | * | 600 | * |
601 | * @dev: the device structure | ||
601 | * @cl: mei host client | 602 | * @cl: mei host client |
602 | * @cmd: connect client response host bus message | 603 | * @cmd: connect client response host bus message |
603 | */ | 604 | */ |
604 | static void mei_hbm_cl_connect_res(struct mei_cl *cl, | 605 | static void mei_hbm_cl_connect_res(struct mei_device *dev, struct mei_cl *cl, |
605 | struct mei_hbm_cl_cmd *cmd) | 606 | struct mei_hbm_cl_cmd *cmd) |
606 | { | 607 | { |
607 | struct hbm_client_connect_response *rs = | 608 | struct hbm_client_connect_response *rs = |
608 | (struct hbm_client_connect_response *)cmd; | 609 | (struct hbm_client_connect_response *)cmd; |
609 | 610 | ||
610 | dev_dbg(cl->dev->dev, "hbm: connect response cl:host=%02d me=%02d status=%s\n", | 611 | cl_dbg(dev, cl, "hbm: connect response status=%s\n", |
611 | rs->me_addr, rs->host_addr, | ||
612 | mei_cl_conn_status_str(rs->status)); | 612 | mei_cl_conn_status_str(rs->status)); |
613 | 613 | ||
614 | if (rs->status == MEI_CL_CONN_SUCCESS) | 614 | if (rs->status == MEI_CL_CONN_SUCCESS) |
@@ -637,11 +637,6 @@ static void mei_hbm_cl_res(struct mei_device *dev, | |||
637 | list_for_each_entry_safe(cb, next, &dev->ctrl_rd_list.list, list) { | 637 | list_for_each_entry_safe(cb, next, &dev->ctrl_rd_list.list, list) { |
638 | 638 | ||
639 | cl = cb->cl; | 639 | cl = cb->cl; |
640 | /* this should not happen */ | ||
641 | if (WARN_ON(!cl)) { | ||
642 | list_del_init(&cb->list); | ||
643 | continue; | ||
644 | } | ||
645 | 640 | ||
646 | if (cb->fop_type != fop_type) | 641 | if (cb->fop_type != fop_type) |
647 | continue; | 642 | continue; |
@@ -657,10 +652,10 @@ static void mei_hbm_cl_res(struct mei_device *dev, | |||
657 | 652 | ||
658 | switch (fop_type) { | 653 | switch (fop_type) { |
659 | case MEI_FOP_CONNECT: | 654 | case MEI_FOP_CONNECT: |
660 | mei_hbm_cl_connect_res(cl, rs); | 655 | mei_hbm_cl_connect_res(dev, cl, rs); |
661 | break; | 656 | break; |
662 | case MEI_FOP_DISCONNECT: | 657 | case MEI_FOP_DISCONNECT: |
663 | mei_hbm_cl_disconnect_res(cl, rs); | 658 | mei_hbm_cl_disconnect_res(dev, cl, rs); |
664 | break; | 659 | break; |
665 | default: | 660 | default: |
666 | return; | 661 | return; |
@@ -811,8 +806,6 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr) | |||
811 | return -EPROTO; | 806 | return -EPROTO; |
812 | } | 807 | } |
813 | 808 | ||
814 | dev->hbm_state = MEI_HBM_STARTED; | ||
815 | |||
816 | if (mei_hbm_enum_clients_req(dev)) { | 809 | if (mei_hbm_enum_clients_req(dev)) { |
817 | dev_err(dev->dev, "hbm: start: failed to send enumeration request\n"); | 810 | dev_err(dev->dev, "hbm: start: failed to send enumeration request\n"); |
818 | return -EIO; | 811 | return -EIO; |
diff --git a/drivers/misc/mei/hbm.h b/drivers/misc/mei/hbm.h index b7cd3d857fd5..2544db7d1649 100644 --- a/drivers/misc/mei/hbm.h +++ b/drivers/misc/mei/hbm.h | |||
@@ -26,17 +26,17 @@ struct mei_cl; | |||
26 | * | 26 | * |
27 | * @MEI_HBM_IDLE : protocol not started | 27 | * @MEI_HBM_IDLE : protocol not started |
28 | * @MEI_HBM_STARTING : start request message was sent | 28 | * @MEI_HBM_STARTING : start request message was sent |
29 | * @MEI_HBM_STARTED : start reply message was received | ||
30 | * @MEI_HBM_ENUM_CLIENTS : enumeration request was sent | 29 | * @MEI_HBM_ENUM_CLIENTS : enumeration request was sent |
31 | * @MEI_HBM_CLIENT_PROPERTIES : acquiring clients properties | 30 | * @MEI_HBM_CLIENT_PROPERTIES : acquiring clients properties |
31 | * @MEI_HBM_STARTED : enumeration was completed | ||
32 | * @MEI_HBM_STOPPED : stopping exchange | 32 | * @MEI_HBM_STOPPED : stopping exchange |
33 | */ | 33 | */ |
34 | enum mei_hbm_state { | 34 | enum mei_hbm_state { |
35 | MEI_HBM_IDLE = 0, | 35 | MEI_HBM_IDLE = 0, |
36 | MEI_HBM_STARTING, | 36 | MEI_HBM_STARTING, |
37 | MEI_HBM_STARTED, | ||
38 | MEI_HBM_ENUM_CLIENTS, | 37 | MEI_HBM_ENUM_CLIENTS, |
39 | MEI_HBM_CLIENT_PROPERTIES, | 38 | MEI_HBM_CLIENT_PROPERTIES, |
39 | MEI_HBM_STARTED, | ||
40 | MEI_HBM_STOPPED, | 40 | MEI_HBM_STOPPED, |
41 | }; | 41 | }; |
42 | 42 | ||
diff --git a/drivers/misc/mei/hw-me-regs.h b/drivers/misc/mei/hw-me-regs.h index c5feafdd58a8..9eb7ed70ace2 100644 --- a/drivers/misc/mei/hw-me-regs.h +++ b/drivers/misc/mei/hw-me-regs.h | |||
@@ -117,14 +117,18 @@ | |||
117 | #define MEI_DEV_ID_WPT_LP 0x9CBA /* Wildcat Point LP */ | 117 | #define MEI_DEV_ID_WPT_LP 0x9CBA /* Wildcat Point LP */ |
118 | #define MEI_DEV_ID_WPT_LP_2 0x9CBB /* Wildcat Point LP 2 */ | 118 | #define MEI_DEV_ID_WPT_LP_2 0x9CBB /* Wildcat Point LP 2 */ |
119 | 119 | ||
120 | /* Host Firmware Status Registers in PCI Config Space */ | ||
121 | #define PCI_CFG_HFS_1 0x40 | ||
122 | #define PCI_CFG_HFS_2 0x48 | ||
123 | |||
124 | /* | 120 | /* |
125 | * MEI HW Section | 121 | * MEI HW Section |
126 | */ | 122 | */ |
127 | 123 | ||
124 | /* Host Firmware Status Registers in PCI Config Space */ | ||
125 | #define PCI_CFG_HFS_1 0x40 | ||
126 | #define PCI_CFG_HFS_2 0x48 | ||
127 | #define PCI_CFG_HFS_3 0x60 | ||
128 | #define PCI_CFG_HFS_4 0x64 | ||
129 | #define PCI_CFG_HFS_5 0x68 | ||
130 | #define PCI_CFG_HFS_6 0x6C | ||
131 | |||
128 | /* MEI registers */ | 132 | /* MEI registers */ |
129 | /* H_CB_WW - Host Circular Buffer (CB) Write Window register */ | 133 | /* H_CB_WW - Host Circular Buffer (CB) Write Window register */ |
130 | #define H_CB_WW 0 | 134 | #define H_CB_WW 0 |
diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c index 4f2fd6fc1e23..ff2755062b44 100644 --- a/drivers/misc/mei/hw-me.c +++ b/drivers/misc/mei/hw-me.c | |||
@@ -270,10 +270,10 @@ static int mei_me_hw_reset(struct mei_device *dev, bool intr_enable) | |||
270 | static void mei_me_host_set_ready(struct mei_device *dev) | 270 | static void mei_me_host_set_ready(struct mei_device *dev) |
271 | { | 271 | { |
272 | struct mei_me_hw *hw = to_me_hw(dev); | 272 | struct mei_me_hw *hw = to_me_hw(dev); |
273 | u32 hcsr = mei_hcsr_read(hw); | ||
273 | 274 | ||
274 | hw->host_hw_state = mei_hcsr_read(hw); | 275 | hcsr |= H_IE | H_IG | H_RDY; |
275 | hw->host_hw_state |= H_IE | H_IG | H_RDY; | 276 | mei_hcsr_set(hw, hcsr); |
276 | mei_hcsr_set(hw, hw->host_hw_state); | ||
277 | } | 277 | } |
278 | 278 | ||
279 | /** | 279 | /** |
@@ -285,9 +285,9 @@ static void mei_me_host_set_ready(struct mei_device *dev) | |||
285 | static bool mei_me_host_is_ready(struct mei_device *dev) | 285 | static bool mei_me_host_is_ready(struct mei_device *dev) |
286 | { | 286 | { |
287 | struct mei_me_hw *hw = to_me_hw(dev); | 287 | struct mei_me_hw *hw = to_me_hw(dev); |
288 | u32 hcsr = mei_hcsr_read(hw); | ||
288 | 289 | ||
289 | hw->host_hw_state = mei_hcsr_read(hw); | 290 | return (hcsr & H_RDY) == H_RDY; |
290 | return (hw->host_hw_state & H_RDY) == H_RDY; | ||
291 | } | 291 | } |
292 | 292 | ||
293 | /** | 293 | /** |
@@ -299,9 +299,9 @@ static bool mei_me_host_is_ready(struct mei_device *dev) | |||
299 | static bool mei_me_hw_is_ready(struct mei_device *dev) | 299 | static bool mei_me_hw_is_ready(struct mei_device *dev) |
300 | { | 300 | { |
301 | struct mei_me_hw *hw = to_me_hw(dev); | 301 | struct mei_me_hw *hw = to_me_hw(dev); |
302 | u32 mecsr = mei_me_mecsr_read(hw); | ||
302 | 303 | ||
303 | hw->me_hw_state = mei_me_mecsr_read(hw); | 304 | return (mecsr & ME_RDY_HRA) == ME_RDY_HRA; |
304 | return (hw->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA; | ||
305 | } | 305 | } |
306 | 306 | ||
307 | /** | 307 | /** |
@@ -356,12 +356,13 @@ static int mei_me_hw_start(struct mei_device *dev) | |||
356 | static unsigned char mei_hbuf_filled_slots(struct mei_device *dev) | 356 | static unsigned char mei_hbuf_filled_slots(struct mei_device *dev) |
357 | { | 357 | { |
358 | struct mei_me_hw *hw = to_me_hw(dev); | 358 | struct mei_me_hw *hw = to_me_hw(dev); |
359 | u32 hcsr; | ||
359 | char read_ptr, write_ptr; | 360 | char read_ptr, write_ptr; |
360 | 361 | ||
361 | hw->host_hw_state = mei_hcsr_read(hw); | 362 | hcsr = mei_hcsr_read(hw); |
362 | 363 | ||
363 | read_ptr = (char) ((hw->host_hw_state & H_CBRP) >> 8); | 364 | read_ptr = (char) ((hcsr & H_CBRP) >> 8); |
364 | write_ptr = (char) ((hw->host_hw_state & H_CBWP) >> 16); | 365 | write_ptr = (char) ((hcsr & H_CBWP) >> 16); |
365 | 366 | ||
366 | return (unsigned char) (write_ptr - read_ptr); | 367 | return (unsigned char) (write_ptr - read_ptr); |
367 | } | 368 | } |
@@ -474,13 +475,14 @@ static int mei_me_write_message(struct mei_device *dev, | |||
474 | static int mei_me_count_full_read_slots(struct mei_device *dev) | 475 | static int mei_me_count_full_read_slots(struct mei_device *dev) |
475 | { | 476 | { |
476 | struct mei_me_hw *hw = to_me_hw(dev); | 477 | struct mei_me_hw *hw = to_me_hw(dev); |
478 | u32 me_csr; | ||
477 | char read_ptr, write_ptr; | 479 | char read_ptr, write_ptr; |
478 | unsigned char buffer_depth, filled_slots; | 480 | unsigned char buffer_depth, filled_slots; |
479 | 481 | ||
480 | hw->me_hw_state = mei_me_mecsr_read(hw); | 482 | me_csr = mei_me_mecsr_read(hw); |
481 | buffer_depth = (unsigned char)((hw->me_hw_state & ME_CBD_HRA) >> 24); | 483 | buffer_depth = (unsigned char)((me_csr & ME_CBD_HRA) >> 24); |
482 | read_ptr = (char) ((hw->me_hw_state & ME_CBRP_HRA) >> 8); | 484 | read_ptr = (char) ((me_csr & ME_CBRP_HRA) >> 8); |
483 | write_ptr = (char) ((hw->me_hw_state & ME_CBWP_HRA) >> 16); | 485 | write_ptr = (char) ((me_csr & ME_CBWP_HRA) >> 16); |
484 | filled_slots = (unsigned char) (write_ptr - read_ptr); | 486 | filled_slots = (unsigned char) (write_ptr - read_ptr); |
485 | 487 | ||
486 | /* check for overflow */ | 488 | /* check for overflow */ |
@@ -833,6 +835,14 @@ static bool mei_me_fw_type_sps(struct pci_dev *pdev) | |||
833 | .fw_status.status[0] = PCI_CFG_HFS_1, \ | 835 | .fw_status.status[0] = PCI_CFG_HFS_1, \ |
834 | .fw_status.status[1] = PCI_CFG_HFS_2 | 836 | .fw_status.status[1] = PCI_CFG_HFS_2 |
835 | 837 | ||
838 | #define MEI_CFG_PCH8_HFS \ | ||
839 | .fw_status.count = 6, \ | ||
840 | .fw_status.status[0] = PCI_CFG_HFS_1, \ | ||
841 | .fw_status.status[1] = PCI_CFG_HFS_2, \ | ||
842 | .fw_status.status[2] = PCI_CFG_HFS_3, \ | ||
843 | .fw_status.status[3] = PCI_CFG_HFS_4, \ | ||
844 | .fw_status.status[4] = PCI_CFG_HFS_5, \ | ||
845 | .fw_status.status[5] = PCI_CFG_HFS_6 | ||
836 | 846 | ||
837 | /* ICH Legacy devices */ | 847 | /* ICH Legacy devices */ |
838 | const struct mei_cfg mei_me_legacy_cfg = { | 848 | const struct mei_cfg mei_me_legacy_cfg = { |
@@ -856,9 +866,14 @@ const struct mei_cfg mei_me_pch_cpt_pbg_cfg = { | |||
856 | MEI_CFG_FW_NM, | 866 | MEI_CFG_FW_NM, |
857 | }; | 867 | }; |
858 | 868 | ||
859 | /* PCH Lynx Point with quirk for SPS Firmware exclusion */ | 869 | /* PCH8 Lynx Point and newer devices */ |
860 | const struct mei_cfg mei_me_lpt_cfg = { | 870 | const struct mei_cfg mei_me_pch8_cfg = { |
861 | MEI_CFG_PCH_HFS, | 871 | MEI_CFG_PCH8_HFS, |
872 | }; | ||
873 | |||
874 | /* PCH8 Lynx Point with quirk for SPS Firmware exclusion */ | ||
875 | const struct mei_cfg mei_me_pch8_sps_cfg = { | ||
876 | MEI_CFG_PCH8_HFS, | ||
862 | MEI_CFG_FW_SPS, | 877 | MEI_CFG_FW_SPS, |
863 | }; | 878 | }; |
864 | 879 | ||
diff --git a/drivers/misc/mei/hw-me.h b/drivers/misc/mei/hw-me.h index e6a59a62573a..d6567af44377 100644 --- a/drivers/misc/mei/hw-me.h +++ b/drivers/misc/mei/hw-me.h | |||
@@ -51,18 +51,11 @@ struct mei_cfg { | |||
51 | * | 51 | * |
52 | * @cfg: per device generation config and ops | 52 | * @cfg: per device generation config and ops |
53 | * @mem_addr: io memory address | 53 | * @mem_addr: io memory address |
54 | * @host_hw_state: cached host state | ||
55 | * @me_hw_state: cached me (fw) state | ||
56 | * @pg_state: power gating state | 54 | * @pg_state: power gating state |
57 | */ | 55 | */ |
58 | struct mei_me_hw { | 56 | struct mei_me_hw { |
59 | const struct mei_cfg *cfg; | 57 | const struct mei_cfg *cfg; |
60 | void __iomem *mem_addr; | 58 | void __iomem *mem_addr; |
61 | /* | ||
62 | * hw states of host and fw(ME) | ||
63 | */ | ||
64 | u32 host_hw_state; | ||
65 | u32 me_hw_state; | ||
66 | enum mei_pg_state pg_state; | 59 | enum mei_pg_state pg_state; |
67 | }; | 60 | }; |
68 | 61 | ||
@@ -72,7 +65,8 @@ extern const struct mei_cfg mei_me_legacy_cfg; | |||
72 | extern const struct mei_cfg mei_me_ich_cfg; | 65 | extern const struct mei_cfg mei_me_ich_cfg; |
73 | extern const struct mei_cfg mei_me_pch_cfg; | 66 | extern const struct mei_cfg mei_me_pch_cfg; |
74 | extern const struct mei_cfg mei_me_pch_cpt_pbg_cfg; | 67 | extern const struct mei_cfg mei_me_pch_cpt_pbg_cfg; |
75 | extern const struct mei_cfg mei_me_lpt_cfg; | 68 | extern const struct mei_cfg mei_me_pch8_cfg; |
69 | extern const struct mei_cfg mei_me_pch8_sps_cfg; | ||
76 | 70 | ||
77 | struct mei_device *mei_me_dev_init(struct pci_dev *pdev, | 71 | struct mei_device *mei_me_dev_init(struct pci_dev *pdev, |
78 | const struct mei_cfg *cfg); | 72 | const struct mei_cfg *cfg); |
diff --git a/drivers/misc/mei/hw-txe.c b/drivers/misc/mei/hw-txe.c index c5e1902e493f..618ea721aca8 100644 --- a/drivers/misc/mei/hw-txe.c +++ b/drivers/misc/mei/hw-txe.c | |||
@@ -700,11 +700,10 @@ static int mei_txe_write(struct mei_device *dev, | |||
700 | mei_txe_input_ready_interrupt_enable(dev); | 700 | mei_txe_input_ready_interrupt_enable(dev); |
701 | 701 | ||
702 | if (!mei_txe_is_input_ready(dev)) { | 702 | if (!mei_txe_is_input_ready(dev)) { |
703 | struct mei_fw_status fw_status; | 703 | char fw_sts_str[MEI_FW_STATUS_STR_SZ]; |
704 | 704 | ||
705 | mei_fw_status(dev, &fw_status); | 705 | mei_fw_status_str(dev, fw_sts_str, MEI_FW_STATUS_STR_SZ); |
706 | dev_err(dev->dev, "Input is not ready " FW_STS_FMT "\n", | 706 | dev_err(dev->dev, "Input is not ready %s\n", fw_sts_str); |
707 | FW_STS_PRM(fw_status)); | ||
708 | return -EAGAIN; | 707 | return -EAGAIN; |
709 | } | 708 | } |
710 | 709 | ||
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c index 7901d076c127..9306219d5675 100644 --- a/drivers/misc/mei/init.c +++ b/drivers/misc/mei/init.c | |||
@@ -54,6 +54,35 @@ const char *mei_pg_state_str(enum mei_pg_state state) | |||
54 | #undef MEI_PG_STATE | 54 | #undef MEI_PG_STATE |
55 | } | 55 | } |
56 | 56 | ||
57 | /** | ||
58 | * mei_fw_status2str - convert fw status registers to printable string | ||
59 | * | ||
60 | * @fw_status: firmware status | ||
61 | * @buf: string buffer at minimal size MEI_FW_STATUS_STR_SZ | ||
62 | * @len: buffer len must be >= MEI_FW_STATUS_STR_SZ | ||
63 | * | ||
64 | * Return: number of bytes written or -EINVAL if buffer is to small | ||
65 | */ | ||
66 | ssize_t mei_fw_status2str(struct mei_fw_status *fw_status, | ||
67 | char *buf, size_t len) | ||
68 | { | ||
69 | ssize_t cnt = 0; | ||
70 | int i; | ||
71 | |||
72 | buf[0] = '\0'; | ||
73 | |||
74 | if (len < MEI_FW_STATUS_STR_SZ) | ||
75 | return -EINVAL; | ||
76 | |||
77 | for (i = 0; i < fw_status->count; i++) | ||
78 | cnt += scnprintf(buf + cnt, len - cnt, "%08X ", | ||
79 | fw_status->status[i]); | ||
80 | |||
81 | /* drop last space */ | ||
82 | buf[cnt] = '\0'; | ||
83 | return cnt; | ||
84 | } | ||
85 | EXPORT_SYMBOL_GPL(mei_fw_status2str); | ||
57 | 86 | ||
58 | /** | 87 | /** |
59 | * mei_cancel_work - Cancel mei background jobs | 88 | * mei_cancel_work - Cancel mei background jobs |
@@ -86,12 +115,11 @@ int mei_reset(struct mei_device *dev) | |||
86 | state != MEI_DEV_DISABLED && | 115 | state != MEI_DEV_DISABLED && |
87 | state != MEI_DEV_POWER_DOWN && | 116 | state != MEI_DEV_POWER_DOWN && |
88 | state != MEI_DEV_POWER_UP) { | 117 | state != MEI_DEV_POWER_UP) { |
89 | struct mei_fw_status fw_status; | 118 | char fw_sts_str[MEI_FW_STATUS_STR_SZ]; |
90 | 119 | ||
91 | mei_fw_status(dev, &fw_status); | 120 | mei_fw_status_str(dev, fw_sts_str, MEI_FW_STATUS_STR_SZ); |
92 | dev_warn(dev->dev, | 121 | dev_warn(dev->dev, "unexpected reset: dev_state = %s fw status = %s\n", |
93 | "unexpected reset: dev_state = %s " FW_STS_FMT "\n", | 122 | mei_dev_state_str(state), fw_sts_str); |
94 | mei_dev_state_str(state), FW_STS_PRM(fw_status)); | ||
95 | } | 123 | } |
96 | 124 | ||
97 | /* we're already in reset, cancel the init timer | 125 | /* we're already in reset, cancel the init timer |
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c index 20c6c511f438..711cddfa9c99 100644 --- a/drivers/misc/mei/interrupt.c +++ b/drivers/misc/mei/interrupt.c | |||
@@ -44,8 +44,6 @@ void mei_irq_compl_handler(struct mei_device *dev, struct mei_cl_cb *compl_list) | |||
44 | list_for_each_entry_safe(cb, next, &compl_list->list, list) { | 44 | list_for_each_entry_safe(cb, next, &compl_list->list, list) { |
45 | cl = cb->cl; | 45 | cl = cb->cl; |
46 | list_del(&cb->list); | 46 | list_del(&cb->list); |
47 | if (!cl) | ||
48 | continue; | ||
49 | 47 | ||
50 | dev_dbg(dev->dev, "completing call back.\n"); | 48 | dev_dbg(dev->dev, "completing call back.\n"); |
51 | if (cl == &dev->iamthif_cl) | 49 | if (cl == &dev->iamthif_cl) |
@@ -105,7 +103,7 @@ static int mei_cl_irq_read_msg(struct mei_device *dev, | |||
105 | 103 | ||
106 | list_for_each_entry_safe(cb, next, &dev->read_list.list, list) { | 104 | list_for_each_entry_safe(cb, next, &dev->read_list.list, list) { |
107 | cl = cb->cl; | 105 | cl = cb->cl; |
108 | if (!cl || !mei_cl_is_reading(cl, mei_hdr)) | 106 | if (!mei_cl_is_reading(cl, mei_hdr)) |
109 | continue; | 107 | continue; |
110 | 108 | ||
111 | cl->reading_state = MEI_READING; | 109 | cl->reading_state = MEI_READING; |
@@ -449,8 +447,6 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list) | |||
449 | list = &dev->write_waiting_list; | 447 | list = &dev->write_waiting_list; |
450 | list_for_each_entry_safe(cb, next, &list->list, list) { | 448 | list_for_each_entry_safe(cb, next, &list->list, list) { |
451 | cl = cb->cl; | 449 | cl = cb->cl; |
452 | if (cl == NULL) | ||
453 | continue; | ||
454 | 450 | ||
455 | cl->status = 0; | 451 | cl->status = 0; |
456 | list_del(&cb->list); | 452 | list_del(&cb->list); |
@@ -489,10 +485,6 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list) | |||
489 | dev_dbg(dev->dev, "complete control write list cb.\n"); | 485 | dev_dbg(dev->dev, "complete control write list cb.\n"); |
490 | list_for_each_entry_safe(cb, next, &dev->ctrl_wr_list.list, list) { | 486 | list_for_each_entry_safe(cb, next, &dev->ctrl_wr_list.list, list) { |
491 | cl = cb->cl; | 487 | cl = cb->cl; |
492 | if (!cl) { | ||
493 | list_del(&cb->list); | ||
494 | return -ENODEV; | ||
495 | } | ||
496 | switch (cb->fop_type) { | 488 | switch (cb->fop_type) { |
497 | case MEI_FOP_DISCONNECT: | 489 | case MEI_FOP_DISCONNECT: |
498 | /* send disconnect message */ | 490 | /* send disconnect message */ |
@@ -530,8 +522,6 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list) | |||
530 | dev_dbg(dev->dev, "complete write list cb.\n"); | 522 | dev_dbg(dev->dev, "complete write list cb.\n"); |
531 | list_for_each_entry_safe(cb, next, &dev->write_list.list, list) { | 523 | list_for_each_entry_safe(cb, next, &dev->write_list.list, list) { |
532 | cl = cb->cl; | 524 | cl = cb->cl; |
533 | if (cl == NULL) | ||
534 | continue; | ||
535 | if (cl == &dev->iamthif_cl) | 525 | if (cl == &dev->iamthif_cl) |
536 | ret = mei_amthif_irq_write(cl, cb, cmpl_list); | 526 | ret = mei_amthif_irq_write(cl, cb, cmpl_list); |
537 | else | 527 | else |
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index beedc91f03a6..ae56ba6ca0e3 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c | |||
@@ -631,6 +631,44 @@ out: | |||
631 | return mask; | 631 | return mask; |
632 | } | 632 | } |
633 | 633 | ||
634 | /** | ||
635 | * fw_status_show - mei device attribute show method | ||
636 | * | ||
637 | * @device: device pointer | ||
638 | * @attr: attribute pointer | ||
639 | * @buf: char out buffer | ||
640 | * | ||
641 | * Return: number of the bytes printed into buf or error | ||
642 | */ | ||
643 | static ssize_t fw_status_show(struct device *device, | ||
644 | struct device_attribute *attr, char *buf) | ||
645 | { | ||
646 | struct mei_device *dev = dev_get_drvdata(device); | ||
647 | struct mei_fw_status fw_status; | ||
648 | int err, i; | ||
649 | ssize_t cnt = 0; | ||
650 | |||
651 | mutex_lock(&dev->device_lock); | ||
652 | err = mei_fw_status(dev, &fw_status); | ||
653 | mutex_unlock(&dev->device_lock); | ||
654 | if (err) { | ||
655 | dev_err(device, "read fw_status error = %d\n", err); | ||
656 | return err; | ||
657 | } | ||
658 | |||
659 | for (i = 0; i < fw_status.count; i++) | ||
660 | cnt += scnprintf(buf + cnt, PAGE_SIZE - cnt, "%08X\n", | ||
661 | fw_status.status[i]); | ||
662 | return cnt; | ||
663 | } | ||
664 | static DEVICE_ATTR_RO(fw_status); | ||
665 | |||
666 | static struct attribute *mei_attrs[] = { | ||
667 | &dev_attr_fw_status.attr, | ||
668 | NULL | ||
669 | }; | ||
670 | ATTRIBUTE_GROUPS(mei); | ||
671 | |||
634 | /* | 672 | /* |
635 | * file operations structure will be used for mei char device. | 673 | * file operations structure will be used for mei char device. |
636 | */ | 674 | */ |
@@ -710,8 +748,9 @@ int mei_register(struct mei_device *dev, struct device *parent) | |||
710 | goto err_dev_add; | 748 | goto err_dev_add; |
711 | } | 749 | } |
712 | 750 | ||
713 | clsdev = device_create(mei_class, parent, devno, | 751 | clsdev = device_create_with_groups(mei_class, parent, devno, |
714 | NULL, "mei%d", dev->minor); | 752 | dev, mei_groups, |
753 | "mei%d", dev->minor); | ||
715 | 754 | ||
716 | if (IS_ERR(clsdev)) { | 755 | if (IS_ERR(clsdev)) { |
717 | dev_err(parent, "unable to create device %d:%d\n", | 756 | dev_err(parent, "unable to create device %d:%d\n", |
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h index 61b04d7646f1..3dad74a8d496 100644 --- a/drivers/misc/mei/mei_dev.h +++ b/drivers/misc/mei/mei_dev.h | |||
@@ -152,7 +152,10 @@ struct mei_msg_data { | |||
152 | }; | 152 | }; |
153 | 153 | ||
154 | /* Maximum number of processed FW status registers */ | 154 | /* Maximum number of processed FW status registers */ |
155 | #define MEI_FW_STATUS_MAX 2 | 155 | #define MEI_FW_STATUS_MAX 6 |
156 | /* Minimal buffer for FW status string (8 bytes in dw + space or '\0') */ | ||
157 | #define MEI_FW_STATUS_STR_SZ (MEI_FW_STATUS_MAX * (8 + 1)) | ||
158 | |||
156 | 159 | ||
157 | /* | 160 | /* |
158 | * struct mei_fw_status - storage of FW status data | 161 | * struct mei_fw_status - storage of FW status data |
@@ -349,6 +352,7 @@ void mei_cl_bus_rx_event(struct mei_cl *cl); | |||
349 | void mei_cl_bus_remove_devices(struct mei_device *dev); | 352 | void mei_cl_bus_remove_devices(struct mei_device *dev); |
350 | int mei_cl_bus_init(void); | 353 | int mei_cl_bus_init(void); |
351 | void mei_cl_bus_exit(void); | 354 | void mei_cl_bus_exit(void); |
355 | struct mei_cl *mei_cl_bus_find_cl_by_uuid(struct mei_device *dev, uuid_le uuid); | ||
352 | 356 | ||
353 | 357 | ||
354 | /** | 358 | /** |
@@ -804,11 +808,6 @@ static inline int mei_fw_status(struct mei_device *dev, | |||
804 | return dev->ops->fw_status(dev, fw_status); | 808 | return dev->ops->fw_status(dev, fw_status); |
805 | } | 809 | } |
806 | 810 | ||
807 | #define FW_STS_FMT "%08X %08X" | ||
808 | #define FW_STS_PRM(fw_status) \ | ||
809 | (fw_status).count > 0 ? (fw_status).status[0] : 0xDEADBEEF, \ | ||
810 | (fw_status).count > 1 ? (fw_status).status[1] : 0xDEADBEEF | ||
811 | |||
812 | bool mei_hbuf_acquire(struct mei_device *dev); | 811 | bool mei_hbuf_acquire(struct mei_device *dev); |
813 | 812 | ||
814 | bool mei_write_is_idle(struct mei_device *dev); | 813 | bool mei_write_is_idle(struct mei_device *dev); |
@@ -832,4 +831,32 @@ void mei_deregister(struct mei_device *dev); | |||
832 | (hdr)->host_addr, (hdr)->me_addr, \ | 831 | (hdr)->host_addr, (hdr)->me_addr, \ |
833 | (hdr)->length, (hdr)->internal, (hdr)->msg_complete | 832 | (hdr)->length, (hdr)->internal, (hdr)->msg_complete |
834 | 833 | ||
834 | ssize_t mei_fw_status2str(struct mei_fw_status *fw_sts, char *buf, size_t len); | ||
835 | /** | ||
836 | * mei_fw_status_str - fetch and convert fw status registers to printable string | ||
837 | * | ||
838 | * @dev: the device structure | ||
839 | * @buf: string buffer at minimal size MEI_FW_STATUS_STR_SZ | ||
840 | * @len: buffer len must be >= MEI_FW_STATUS_STR_SZ | ||
841 | * | ||
842 | * Return: number of bytes written or < 0 on failure | ||
843 | */ | ||
844 | static inline ssize_t mei_fw_status_str(struct mei_device *dev, | ||
845 | char *buf, size_t len) | ||
846 | { | ||
847 | struct mei_fw_status fw_status; | ||
848 | int ret; | ||
849 | |||
850 | buf[0] = '\0'; | ||
851 | |||
852 | ret = mei_fw_status(dev, &fw_status); | ||
853 | if (ret) | ||
854 | return ret; | ||
855 | |||
856 | ret = mei_fw_status2str(&fw_status, buf, MEI_FW_STATUS_STR_SZ); | ||
857 | |||
858 | return ret; | ||
859 | } | ||
860 | |||
861 | |||
835 | #endif | 862 | #endif |
diff --git a/drivers/misc/mei/nfc.c b/drivers/misc/mei/nfc.c index 622654323177..60ca9240368e 100644 --- a/drivers/misc/mei/nfc.c +++ b/drivers/misc/mei/nfc.c | |||
@@ -117,8 +117,6 @@ struct mei_nfc_dev { | |||
117 | u16 recv_req_id; | 117 | u16 recv_req_id; |
118 | }; | 118 | }; |
119 | 119 | ||
120 | static struct mei_nfc_dev nfc_dev; | ||
121 | |||
122 | /* UUIDs for NFC F/W clients */ | 120 | /* UUIDs for NFC F/W clients */ |
123 | const uuid_le mei_nfc_guid = UUID_LE(0x0bb17a78, 0x2a8e, 0x4c50, | 121 | const uuid_le mei_nfc_guid = UUID_LE(0x0bb17a78, 0x2a8e, 0x4c50, |
124 | 0x94, 0xd4, 0x50, 0x26, | 122 | 0x94, 0xd4, 0x50, 0x26, |
@@ -138,6 +136,9 @@ static const uuid_le mei_nfc_info_guid = UUID_LE(0xd2de1625, 0x382d, 0x417d, | |||
138 | 136 | ||
139 | static void mei_nfc_free(struct mei_nfc_dev *ndev) | 137 | static void mei_nfc_free(struct mei_nfc_dev *ndev) |
140 | { | 138 | { |
139 | if (!ndev) | ||
140 | return; | ||
141 | |||
141 | if (ndev->cl) { | 142 | if (ndev->cl) { |
142 | list_del(&ndev->cl->device_link); | 143 | list_del(&ndev->cl->device_link); |
143 | mei_cl_unlink(ndev->cl); | 144 | mei_cl_unlink(ndev->cl); |
@@ -150,7 +151,7 @@ static void mei_nfc_free(struct mei_nfc_dev *ndev) | |||
150 | kfree(ndev->cl_info); | 151 | kfree(ndev->cl_info); |
151 | } | 152 | } |
152 | 153 | ||
153 | memset(ndev, 0, sizeof(struct mei_nfc_dev)); | 154 | kfree(ndev); |
154 | } | 155 | } |
155 | 156 | ||
156 | static int mei_nfc_build_bus_name(struct mei_nfc_dev *ndev) | 157 | static int mei_nfc_build_bus_name(struct mei_nfc_dev *ndev) |
@@ -319,9 +320,10 @@ err: | |||
319 | static int mei_nfc_enable(struct mei_cl_device *cldev) | 320 | static int mei_nfc_enable(struct mei_cl_device *cldev) |
320 | { | 321 | { |
321 | struct mei_device *dev; | 322 | struct mei_device *dev; |
322 | struct mei_nfc_dev *ndev = &nfc_dev; | 323 | struct mei_nfc_dev *ndev; |
323 | int ret; | 324 | int ret; |
324 | 325 | ||
326 | ndev = (struct mei_nfc_dev *)cldev->priv_data; | ||
325 | dev = ndev->cl->dev; | 327 | dev = ndev->cl->dev; |
326 | 328 | ||
327 | ret = mei_nfc_connect(ndev); | 329 | ret = mei_nfc_connect(ndev); |
@@ -479,15 +481,25 @@ err: | |||
479 | 481 | ||
480 | int mei_nfc_host_init(struct mei_device *dev) | 482 | int mei_nfc_host_init(struct mei_device *dev) |
481 | { | 483 | { |
482 | struct mei_nfc_dev *ndev = &nfc_dev; | 484 | struct mei_nfc_dev *ndev; |
483 | struct mei_cl *cl_info, *cl = NULL; | 485 | struct mei_cl *cl_info, *cl = NULL; |
484 | struct mei_me_client *me_cl; | 486 | struct mei_me_client *me_cl; |
485 | int ret; | 487 | int ret; |
486 | 488 | ||
487 | /* already initialized */ | 489 | |
488 | if (ndev->cl_info) | 490 | /* in case of internal reset bail out |
491 | * as the device is already setup | ||
492 | */ | ||
493 | cl = mei_cl_bus_find_cl_by_uuid(dev, mei_nfc_guid); | ||
494 | if (cl) | ||
489 | return 0; | 495 | return 0; |
490 | 496 | ||
497 | ndev = kzalloc(sizeof(struct mei_nfc_dev), GFP_KERNEL); | ||
498 | if (!ndev) { | ||
499 | ret = -ENOMEM; | ||
500 | goto err; | ||
501 | } | ||
502 | |||
491 | ndev->cl_info = mei_cl_allocate(dev); | 503 | ndev->cl_info = mei_cl_allocate(dev); |
492 | ndev->cl = mei_cl_allocate(dev); | 504 | ndev->cl = mei_cl_allocate(dev); |
493 | 505 | ||
@@ -550,9 +562,31 @@ err: | |||
550 | 562 | ||
551 | void mei_nfc_host_exit(struct mei_device *dev) | 563 | void mei_nfc_host_exit(struct mei_device *dev) |
552 | { | 564 | { |
553 | struct mei_nfc_dev *ndev = &nfc_dev; | 565 | struct mei_nfc_dev *ndev; |
566 | struct mei_cl *cl; | ||
567 | struct mei_cl_device *cldev; | ||
568 | |||
569 | cl = mei_cl_bus_find_cl_by_uuid(dev, mei_nfc_guid); | ||
570 | if (!cl) | ||
571 | return; | ||
572 | |||
573 | cldev = cl->device; | ||
574 | if (!cldev) | ||
575 | return; | ||
554 | 576 | ||
555 | cancel_work_sync(&ndev->init_work); | 577 | ndev = (struct mei_nfc_dev *)cldev->priv_data; |
578 | if (ndev) | ||
579 | cancel_work_sync(&ndev->init_work); | ||
580 | |||
581 | cldev->priv_data = NULL; | ||
582 | |||
583 | mutex_lock(&dev->device_lock); | ||
584 | /* Need to remove the device here | ||
585 | * since mei_nfc_free will unlink the clients | ||
586 | */ | ||
587 | mei_cl_remove_device(cldev); | ||
588 | mei_nfc_free(ndev); | ||
589 | mutex_unlock(&dev->device_lock); | ||
556 | } | 590 | } |
557 | 591 | ||
558 | 592 | ||
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c index cf20d397068a..bd3039ab8f98 100644 --- a/drivers/misc/mei/pci-me.c +++ b/drivers/misc/mei/pci-me.c | |||
@@ -76,12 +76,12 @@ static const struct pci_device_id mei_me_pci_tbl[] = { | |||
76 | {MEI_PCI_DEVICE(MEI_DEV_ID_PPT_1, mei_me_pch_cfg)}, | 76 | {MEI_PCI_DEVICE(MEI_DEV_ID_PPT_1, mei_me_pch_cfg)}, |
77 | {MEI_PCI_DEVICE(MEI_DEV_ID_PPT_2, mei_me_pch_cfg)}, | 77 | {MEI_PCI_DEVICE(MEI_DEV_ID_PPT_2, mei_me_pch_cfg)}, |
78 | {MEI_PCI_DEVICE(MEI_DEV_ID_PPT_3, mei_me_pch_cfg)}, | 78 | {MEI_PCI_DEVICE(MEI_DEV_ID_PPT_3, mei_me_pch_cfg)}, |
79 | {MEI_PCI_DEVICE(MEI_DEV_ID_LPT_H, mei_me_lpt_cfg)}, | 79 | {MEI_PCI_DEVICE(MEI_DEV_ID_LPT_H, mei_me_pch8_sps_cfg)}, |
80 | {MEI_PCI_DEVICE(MEI_DEV_ID_LPT_W, mei_me_lpt_cfg)}, | 80 | {MEI_PCI_DEVICE(MEI_DEV_ID_LPT_W, mei_me_pch8_sps_cfg)}, |
81 | {MEI_PCI_DEVICE(MEI_DEV_ID_LPT_LP, mei_me_pch_cfg)}, | 81 | {MEI_PCI_DEVICE(MEI_DEV_ID_LPT_LP, mei_me_pch8_cfg)}, |
82 | {MEI_PCI_DEVICE(MEI_DEV_ID_LPT_HR, mei_me_lpt_cfg)}, | 82 | {MEI_PCI_DEVICE(MEI_DEV_ID_LPT_HR, mei_me_pch8_sps_cfg)}, |
83 | {MEI_PCI_DEVICE(MEI_DEV_ID_WPT_LP, mei_me_pch_cfg)}, | 83 | {MEI_PCI_DEVICE(MEI_DEV_ID_WPT_LP, mei_me_pch8_cfg)}, |
84 | {MEI_PCI_DEVICE(MEI_DEV_ID_WPT_LP_2, mei_me_pch_cfg)}, | 84 | {MEI_PCI_DEVICE(MEI_DEV_ID_WPT_LP_2, mei_me_pch8_cfg)}, |
85 | 85 | ||
86 | /* required last entry */ | 86 | /* required last entry */ |
87 | {0, } | 87 | {0, } |
diff --git a/drivers/misc/mei/pci-txe.c b/drivers/misc/mei/pci-txe.c index 1f572deacf54..c86e2ddbe30a 100644 --- a/drivers/misc/mei/pci-txe.c +++ b/drivers/misc/mei/pci-txe.c | |||
@@ -37,6 +37,7 @@ | |||
37 | 37 | ||
38 | static const struct pci_device_id mei_txe_pci_tbl[] = { | 38 | static const struct pci_device_id mei_txe_pci_tbl[] = { |
39 | {PCI_VDEVICE(INTEL, 0x0F18)}, /* Baytrail */ | 39 | {PCI_VDEVICE(INTEL, 0x0F18)}, /* Baytrail */ |
40 | {PCI_VDEVICE(INTEL, 0x2298)}, /* Cherrytrail */ | ||
40 | 41 | ||
41 | {0, } | 42 | {0, } |
42 | }; | 43 | }; |
diff --git a/drivers/misc/mei/wd.c b/drivers/misc/mei/wd.c index b836dfffceb5..b1d892cea94d 100644 --- a/drivers/misc/mei/wd.c +++ b/drivers/misc/mei/wd.c | |||
@@ -270,15 +270,18 @@ static int mei_wd_ops_stop(struct watchdog_device *wd_dev) | |||
270 | static int mei_wd_ops_ping(struct watchdog_device *wd_dev) | 270 | static int mei_wd_ops_ping(struct watchdog_device *wd_dev) |
271 | { | 271 | { |
272 | struct mei_device *dev; | 272 | struct mei_device *dev; |
273 | struct mei_cl *cl; | ||
273 | int ret; | 274 | int ret; |
274 | 275 | ||
275 | dev = watchdog_get_drvdata(wd_dev); | 276 | dev = watchdog_get_drvdata(wd_dev); |
276 | if (!dev) | 277 | if (!dev) |
277 | return -ENODEV; | 278 | return -ENODEV; |
278 | 279 | ||
280 | cl = &dev->wd_cl; | ||
281 | |||
279 | mutex_lock(&dev->device_lock); | 282 | mutex_lock(&dev->device_lock); |
280 | 283 | ||
281 | if (dev->wd_cl.state != MEI_FILE_CONNECTED) { | 284 | if (cl->state != MEI_FILE_CONNECTED) { |
282 | dev_err(dev->dev, "wd: not connected.\n"); | 285 | dev_err(dev->dev, "wd: not connected.\n"); |
283 | ret = -ENODEV; | 286 | ret = -ENODEV; |
284 | goto end; | 287 | goto end; |
@@ -286,12 +289,12 @@ static int mei_wd_ops_ping(struct watchdog_device *wd_dev) | |||
286 | 289 | ||
287 | dev->wd_state = MEI_WD_RUNNING; | 290 | dev->wd_state = MEI_WD_RUNNING; |
288 | 291 | ||
289 | ret = mei_cl_flow_ctrl_creds(&dev->wd_cl); | 292 | ret = mei_cl_flow_ctrl_creds(cl); |
290 | if (ret < 0) | 293 | if (ret < 0) |
291 | goto end; | 294 | goto end; |
295 | |||
292 | /* Check if we can send the ping to HW*/ | 296 | /* Check if we can send the ping to HW*/ |
293 | if (ret && mei_hbuf_acquire(dev)) { | 297 | if (ret && mei_hbuf_acquire(dev)) { |
294 | |||
295 | dev_dbg(dev->dev, "wd: sending ping\n"); | 298 | dev_dbg(dev->dev, "wd: sending ping\n"); |
296 | 299 | ||
297 | ret = mei_wd_send(dev); | 300 | ret = mei_wd_send(dev); |
diff --git a/drivers/misc/pch_phub.c b/drivers/misc/pch_phub.c index 956597321d2a..9a17a9bab8d6 100644 --- a/drivers/misc/pch_phub.c +++ b/drivers/misc/pch_phub.c | |||
@@ -158,6 +158,7 @@ static void pch_phub_read_modify_write_reg(struct pch_phub_reg *chip, | |||
158 | iowrite32(((ioread32(reg_addr) & ~mask)) | data, reg_addr); | 158 | iowrite32(((ioread32(reg_addr) & ~mask)) | data, reg_addr); |
159 | } | 159 | } |
160 | 160 | ||
161 | #ifdef CONFIG_PM | ||
161 | /* pch_phub_save_reg_conf - saves register configuration */ | 162 | /* pch_phub_save_reg_conf - saves register configuration */ |
162 | static void pch_phub_save_reg_conf(struct pci_dev *pdev) | 163 | static void pch_phub_save_reg_conf(struct pci_dev *pdev) |
163 | { | 164 | { |
@@ -280,6 +281,7 @@ static void pch_phub_restore_reg_conf(struct pci_dev *pdev) | |||
280 | if ((chip->ioh_type == 2) || (chip->ioh_type == 4)) | 281 | if ((chip->ioh_type == 2) || (chip->ioh_type == 4)) |
281 | iowrite32(chip->funcsel_reg, p + FUNCSEL_REG_OFFSET); | 282 | iowrite32(chip->funcsel_reg, p + FUNCSEL_REG_OFFSET); |
282 | } | 283 | } |
284 | #endif | ||
283 | 285 | ||
284 | /** | 286 | /** |
285 | * pch_phub_read_serial_rom() - Reading Serial ROM | 287 | * pch_phub_read_serial_rom() - Reading Serial ROM |