diff options
author | David Flater <dave@flaterco.com> | 2013-05-10 08:37:43 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-05-21 18:21:02 -0400 |
commit | bdf0eb3a026922dbf57f6839f3184c8d2ecc5f2e (patch) | |
tree | 1b51f2f6791f8ffe8b2b3ef4551f854513c9acbc /drivers/pnp | |
parent | c7788792a5e7b0d5d7f96d0766b4cb6112d47d75 (diff) |
pnp: restore automatic resolution of DMA conflicts
To fix a 5-year-old regression, reverse changes made by commit
7ef3639 (PNP: don't fail device init if no DMA channel available).
As an example to show the problem, my sound card provides a
prioritized list of PnP "dependent sets" of requested resources:
dependent set 0 (preferred) wants DMA 5.
dependent set 1 (acceptable) will take DMA 5, 6, or 7.
...
dependent set 4 (acceptable) doesn't request a high DMA.
If DMA 5 is not available, pnp_assign_dma has to fail on set 0 so that
pnp_auto_config_dev will move on to set 1 and get DMA 6 or 7.
Instead, pnp_assign_dma adds the resource with flags |=
IORESOURCE_DISABLED and returns success. pnp_auto_config_dev just
sees success and therefore chooses set 0 with a disabled DMA and never
tries the sets that would have resolved the conflict.
Furthermore, this mode of "success" is unexpected and unhandled in
sound/isa/sb and probably other drivers. sb assumes that the returned
DMA is enabled and obliviously uses the invalid DMA number. Observed
consequences were sb successfully grabbing a DMA that was expressly
forbidden by the kernel parameter pnp_reserve_dma.
The only upside to the original change would be as a kludge for
devices that can operate in degraded mode without a DMA but that don't
provide the corresponding non-preferred dependent set. The right
workaround for those devices is to synthesize the missing set in
quirks.c; otherwise, you're reinventing PnP fallback functionality at
the driver level for that device and all others.
Signed-off-by: David Flater <dave@flaterco.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/pnp')
-rw-r--r-- | drivers/pnp/manager.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c index 95cebf0185de..9357aa779048 100644 --- a/drivers/pnp/manager.c +++ b/drivers/pnp/manager.c | |||
@@ -211,6 +211,12 @@ static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) | |||
211 | res->start = -1; | 211 | res->start = -1; |
212 | res->end = -1; | 212 | res->end = -1; |
213 | 213 | ||
214 | if (!rule->map) { | ||
215 | res->flags |= IORESOURCE_DISABLED; | ||
216 | pnp_dbg(&dev->dev, " dma %d disabled\n", idx); | ||
217 | goto __add; | ||
218 | } | ||
219 | |||
214 | for (i = 0; i < 8; i++) { | 220 | for (i = 0; i < 8; i++) { |
215 | if (rule->map & (1 << xtab[i])) { | 221 | if (rule->map & (1 << xtab[i])) { |
216 | res->start = res->end = xtab[i]; | 222 | res->start = res->end = xtab[i]; |
@@ -218,11 +224,9 @@ static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) | |||
218 | goto __add; | 224 | goto __add; |
219 | } | 225 | } |
220 | } | 226 | } |
221 | #ifdef MAX_DMA_CHANNELS | 227 | |
222 | res->start = res->end = MAX_DMA_CHANNELS; | 228 | pnp_dbg(&dev->dev, " couldn't assign dma %d\n", idx); |
223 | #endif | 229 | return -EBUSY; |
224 | res->flags |= IORESOURCE_DISABLED; | ||
225 | pnp_dbg(&dev->dev, " disable dma %d\n", idx); | ||
226 | 230 | ||
227 | __add: | 231 | __add: |
228 | pnp_add_dma_resource(dev, res->start, res->flags); | 232 | pnp_add_dma_resource(dev, res->start, res->flags); |