aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2013-01-08 16:07:27 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-08 19:40:47 -0500
commitadfba3220b625ce4bee08e7e6f48c8a27aac23bb (patch)
treebe763cb3537e28f43bb43df856bdbe82bc2bdbbd
parent528c8eb4e7c08c5531533de62a558aaf3d076ebb (diff)
mei: don't use cached value for hcsr in mei_hw_reset
Open code mei_hw_reset to avoid using cached hcsr. Using cached hcsr can cause unwanted side effects. Move mei_hw_restet function to hw-me.c as it is hw dependent Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/misc/mei/hw-me.c35
-rw-r--r--drivers/misc/mei/init.c28
-rw-r--r--drivers/misc/mei/mei_dev.h1
3 files changed, 36 insertions, 28 deletions
diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c
index 1e82e3311ea2..ec4ab895f03d 100644
--- a/drivers/misc/mei/hw-me.c
+++ b/drivers/misc/mei/hw-me.c
@@ -132,6 +132,41 @@ void mei_disable_interrupts(struct mei_device *dev)
132 mei_hcsr_set(dev); 132 mei_hcsr_set(dev);
133} 133}
134 134
135/**
136 * mei_hw_reset - resets fw via mei csr register.
137 *
138 * @dev: the device structure
139 * @interrupts_enabled: if interrupt should be enabled after reset.
140 */
141void mei_hw_reset(struct mei_device *dev, bool intr_enable)
142{
143 u32 hcsr = mei_hcsr_read(dev);
144
145 dev_dbg(&dev->pdev->dev, "before reset HCSR = 0x%08x.\n", hcsr);
146
147 hcsr |= (H_RST | H_IG);
148
149 if (intr_enable)
150 hcsr |= H_IE;
151 else
152 hcsr &= ~H_IE;
153
154 hcsr &= ~H_IS;
155
156 mei_reg_write(dev, H_CSR, hcsr);
157 hcsr = mei_hcsr_read(dev);
158
159 hcsr &= ~H_RST;
160 hcsr |= H_IG;
161 hcsr &= ~H_IS;
162
163 mei_reg_write(dev, H_CSR, hcsr);
164
165 hcsr = mei_hcsr_read(dev);
166
167 dev_dbg(&dev->pdev->dev, "current HCSR = 0x%08x.\n", hcsr);
168}
169
135 170
136/** 171/**
137 * mei_interrupt_quick_handler - The ISR of the MEI device 172 * mei_interrupt_quick_handler - The ISR of the MEI device
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
index 2391832bfa6f..5c2054d06f6b 100644
--- a/drivers/misc/mei/init.c
+++ b/drivers/misc/mei/init.c
@@ -170,22 +170,6 @@ out:
170} 170}
171 171
172/** 172/**
173 * mei_hw_reset - resets fw via mei csr register.
174 *
175 * @dev: the device structure
176 * @interrupts_enabled: if interrupt should be enabled after reset.
177 */
178static void mei_hw_reset(struct mei_device *dev, int interrupts_enabled)
179{
180 dev->host_hw_state |= (H_RST | H_IG);
181
182 if (interrupts_enabled)
183 mei_enable_interrupts(dev);
184 else
185 mei_disable_interrupts(dev);
186}
187
188/**
189 * mei_reset - resets host and fw. 173 * mei_reset - resets host and fw.
190 * 174 *
191 * @dev: the device structure 175 * @dev: the device structure
@@ -207,20 +191,8 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled)
207 dev->dev_state != MEI_DEV_POWER_DOWN && 191 dev->dev_state != MEI_DEV_POWER_DOWN &&
208 dev->dev_state != MEI_DEV_POWER_UP); 192 dev->dev_state != MEI_DEV_POWER_UP);
209 193
210 dev->host_hw_state = mei_hcsr_read(dev);
211
212 dev_dbg(&dev->pdev->dev, "before reset host_hw_state = 0x%08x.\n",
213 dev->host_hw_state);
214
215 mei_hw_reset(dev, interrupts_enabled); 194 mei_hw_reset(dev, interrupts_enabled);
216 195
217 dev->host_hw_state &= ~H_RST;
218 dev->host_hw_state |= H_IG;
219
220 mei_hcsr_set(dev);
221
222 dev_dbg(&dev->pdev->dev, "currently saved host_hw_state = 0x%08x.\n",
223 dev->host_hw_state);
224 196
225 if (dev->dev_state != MEI_DEV_INITIALIZING) { 197 if (dev->dev_state != MEI_DEV_INITIALIZING) {
226 if (dev->dev_state != MEI_DEV_DISABLED && 198 if (dev->dev_state != MEI_DEV_DISABLED &&
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 88fa194ca30e..8692ac8c98d4 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -385,6 +385,7 @@ void mei_watchdog_unregister(struct mei_device *dev);
385 * Register Access Function 385 * Register Access Function
386 */ 386 */
387 387
388void mei_hw_reset(struct mei_device *dev, bool intr_enable);
388u32 mei_hcsr_read(const struct mei_device *dev); 389u32 mei_hcsr_read(const struct mei_device *dev);
389void mei_hcsr_set(struct mei_device *dev); 390void mei_hcsr_set(struct mei_device *dev);
390u32 mei_mecsr_read(const struct mei_device *dev); 391u32 mei_mecsr_read(const struct mei_device *dev);