<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/firewire/ohci.c, branch v2.6.39</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>firewire: Fix for broken configrom updates in quick succession</title>
<updated>2011-05-02T20:55:22+00:00</updated>
<author>
<name>B.J. Buchalter</name>
<email>bj@mhlabs.com</email>
</author>
<published>2011-05-02T17:33:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=2e053a27d9d5ad5e0831e002cbf8043836fb2060'/>
<id>2e053a27d9d5ad5e0831e002cbf8043836fb2060</id>
<content type='text'>
Current implementation of ohci_set_config_rom() uses a deferred
bus reset via fw_schedule_bus_reset(). If clients add multiple
unit descriptors to the config_rom in quick succession, the
deferred bus reset may not have fired before succeeding update
requests have come in. This can lead to an incorrect partial
update of the config_rom for both addition and removal of
config_rom descriptors, as the ohci_set_config_rom() routine
will return -EBUSY if a previous pending update has not been
completed yet; the requested update just gets dropped on the floor.

This patch recognizes that the "in-flight" update can be modified
until it has been processed by the bus-reset, and the locking
in the bus_reset_tasklet ensures that the update is done atomically
with respect to modifications made by ohci_set_config_rom(). The
-EBUSY error case is simply removed.

[Stefan R:  The bug always existed at least theoretically.  But it
became easy to trigger since 2.6.36 commit 02d37bed188c "firewire: core:
integrate software-forced bus resets with bus management" which
introduced long mandatory delays between janitorial bus resets.]

Signed-off-by: Benjamin Buchalter &lt;bj@mhlabs.com&gt;
Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt; (trivial style changes)
Cc: &lt;stable@kernel.org&gt; # 2.6.36.y and newer
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Current implementation of ohci_set_config_rom() uses a deferred
bus reset via fw_schedule_bus_reset(). If clients add multiple
unit descriptors to the config_rom in quick succession, the
deferred bus reset may not have fired before succeeding update
requests have come in. This can lead to an incorrect partial
update of the config_rom for both addition and removal of
config_rom descriptors, as the ohci_set_config_rom() routine
will return -EBUSY if a previous pending update has not been
completed yet; the requested update just gets dropped on the floor.

This patch recognizes that the "in-flight" update can be modified
until it has been processed by the bus-reset, and the locking
in the bus_reset_tasklet ensures that the update is done atomically
with respect to modifications made by ohci_set_config_rom(). The
-EBUSY error case is simply removed.

[Stefan R:  The bug always existed at least theoretically.  But it
became easy to trigger since 2.6.36 commit 02d37bed188c "firewire: core:
integrate software-forced bus resets with bus management" which
introduced long mandatory delays between janitorial bus resets.]

Signed-off-by: Benjamin Buchalter &lt;bj@mhlabs.com&gt;
Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt; (trivial style changes)
Cc: &lt;stable@kernel.org&gt; # 2.6.36.y and newer
</pre>
</div>
</content>
</entry>
<entry>
<title>firewire: ohci: Misleading kfree in ohci.c::pci_probe/remove</title>
<updated>2011-03-14T22:30:57+00:00</updated>
<author>
<name>Oleg Drokin</name>
<email>green@linuxhacker.ru</email>
</author>
<published>2011-03-11T01:17:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=d838d2c09af0820e306e3e9e31f97e873823b0b4'/>
<id>d838d2c09af0820e306e3e9e31f97e873823b0b4</id>
<content type='text'>
It seems drivers/firewire/ohci.c is making some optimistic assumptions
about struct fw_ohci and that member "card" will always remain the first
member of the struct.
Plus it's probably going to confuse a lot of static code analyzers too.

So I wonder if there is a good reason not to free the ohci struct just
like it was allocated instead of the tricky &amp;ohci-&gt;card way?

Signed-off-by: Oleg Drokin &lt;green@linuxhacker.ru&gt;

It is perhaps just a rudiment from before mainline submission of the
driver.

Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It seems drivers/firewire/ohci.c is making some optimistic assumptions
about struct fw_ohci and that member "card" will always remain the first
member of the struct.
Plus it's probably going to confuse a lot of static code analyzers too.

So I wonder if there is a good reason not to free the ohci struct just
like it was allocated instead of the tricky &amp;ohci-&gt;card way?

Signed-off-by: Oleg Drokin &lt;green@linuxhacker.ru&gt;

It is perhaps just a rudiment from before mainline submission of the
driver.

Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>firewire: ohci: omit IntEvent.busReset check rom AT queueing</title>
<updated>2011-03-14T22:30:56+00:00</updated>
<author>
<name>Stefan Richter</name>
<email>stefanr@s5r6.in-berlin.de</email>
</author>
<published>2011-02-26T14:08:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=b6258fc1feabda868694ad5fdc7ca8edf3ef30ec'/>
<id>b6258fc1feabda868694ad5fdc7ca8edf3ef30ec</id>
<content type='text'>
Since commit 82b662dc4102 "flush AT contexts after bus reset for OHCI 1.2",
the driver takes care of any AT packets that were enqueued during a bus
reset phase.  The check from commit 76f73ca1b291 is therefore no longer
necessary and the MMIO read can be avoided.

Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since commit 82b662dc4102 "flush AT contexts after bus reset for OHCI 1.2",
the driver takes care of any AT packets that were enqueued during a bus
reset phase.  The check from commit 76f73ca1b291 is therefore no longer
necessary and the MMIO read can be avoided.

Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>firewire: ohci: prevent starting of iso contexts with empty queue</title>
<updated>2011-02-26T14:11:04+00:00</updated>
<author>
<name>Clemens Ladisch</name>
<email>clemens@ladisch.de</email>
</author>
<published>2011-02-23T08:27:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=44b74d909dc943fd9384930a141450cb17133511'/>
<id>44b74d909dc943fd9384930a141450cb17133511</id>
<content type='text'>
If a misguided program tried to start an isochronous context before it
has queued any packets, the call would appear to succeed, but the
context would not actually go into the running state, and the OHCI
controller would then raise an unrecoverableError interrupt because the
first Z value is zero and thus invalid.  The driver logs such errors,
but there is no mechanism to report this back to the program.

Add an explicit check so that this error can be returned synchronously.

Signed-off-by: Clemens Ladisch &lt;clemens@ladisch.de&gt;
Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If a misguided program tried to start an isochronous context before it
has queued any packets, the call would appear to succeed, but the
context would not actually go into the running state, and the OHCI
controller would then raise an unrecoverableError interrupt because the
first Z value is zero and thus invalid.  The driver logs such errors,
but there is no mechanism to report this back to the program.

Add an explicit check so that this error can be returned synchronously.

Signed-off-by: Clemens Ladisch &lt;clemens@ladisch.de&gt;
Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>firewire: ohci: prevent iso completion callbacks after context stop</title>
<updated>2011-02-26T14:11:03+00:00</updated>
<author>
<name>Clemens Ladisch</name>
<email>clemens@ladisch.de</email>
</author>
<published>2011-02-16T09:32:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e81cbebdfc384f9c2ae91225f16ef994118e5e2c'/>
<id>e81cbebdfc384f9c2ae91225f16ef994118e5e2c</id>
<content type='text'>
To prevent the iso packet callback from being called after
fw_iso_context_stop() has returned, make sure that the
context's tasklet has finished executing before that.

This fixes access-after-free bugs that have so far been
observed only in the upcoming snd-firewire-speakers driver,
but can theoretically also happen in the firedtv driver.

Signed-off-by: Clemens Ladisch &lt;clemens@ladisch.de&gt;
Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
To prevent the iso packet callback from being called after
fw_iso_context_stop() has returned, make sure that the
context's tasklet has finished executing before that.

This fixes access-after-free bugs that have so far been
observed only in the upcoming snd-firewire-speakers driver,
but can theoretically also happen in the firedtv driver.

Signed-off-by: Clemens Ladisch &lt;clemens@ladisch.de&gt;
Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>firewire: ohci: log dead DMA contexts</title>
<updated>2011-01-23T11:31:00+00:00</updated>
<author>
<name>Clemens Ladisch</name>
<email>clemens@ladisch.de</email>
</author>
<published>2011-01-10T16:21:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f117a3e3004381ccadadc5156178c283815ca393'/>
<id>f117a3e3004381ccadadc5156178c283815ca393</id>
<content type='text'>
When a DMA context goes into the dead state (and the controller thus
stops working correctly), logging this error and the controller's error
code might be helpful for debugging.

Signed-off-by: Clemens Ladisch &lt;clemens@ladisch.de&gt;
Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When a DMA context goes into the dead state (and the controller thus
stops working correctly), logging this error and the controller's error
code might be helpful for debugging.

Signed-off-by: Clemens Ladisch &lt;clemens@ladisch.de&gt;
Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>firewire: ohci: fix compilation on arches without PAGE_KERNEL_RO</title>
<updated>2011-01-13T14:48:29+00:00</updated>
<author>
<name>Clemens Ladisch</name>
<email>clemens@ladisch.de</email>
</author>
<published>2011-01-13T09:12:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=1427130425c1239d977e8891c3a8923f53a6e352'/>
<id>1427130425c1239d977e8891c3a8923f53a6e352</id>
<content type='text'>
PAGE_KERNEL_RO is not available on all architectures, so its use
in the new AR code broke compilation on sparc64.

Because the read-only mapping was just a debugging aid, just use
PAGE_KERNEL instead.

Signed-off-by: Clemens Ladisch &lt;clemens@ladisch.de&gt;

James Bottomley wrote:
&gt; On Thu, 2011-01-13 at 08:27 +0100, Clemens Ladisch wrote:
&gt;&gt; firewire: ohci: fix compilation on arches without PAGE_KERNEL_RO, e.g. sparc
&gt;&gt;
&gt;&gt; PAGE_KERNEL_RO is not available on all architectures, so its use in the
&gt;&gt; new AR code broke compilation on sparc64.
&gt;&gt;
&gt;&gt; Because the R/O mapping is only used to catch drivers that try to write
&gt;&gt; to the reception buffer and not actually required for correct operation,
&gt;&gt; we can just use a normal PAGE_KERNEL mapping where _RO is not available.
[...]
&gt;&gt; +/*
&gt;&gt; + * For archs where PAGE_KERNEL_RO is not supported;
&gt;&gt; + * mapping the AR buffers readonly for the CPU is just a debugging aid.
&gt;&gt; + */
&gt;&gt; +#ifndef PAGE_KERNEL_RO
&gt;&gt; +#define PAGE_KERNEL_RO PAGE_KERNEL
&gt;&gt; +#endif
&gt;
&gt; This might cause interesting issues on sparc64 if it ever acquired a
&gt; PAGE_KERNEL_RO.  Sparc64 has extern pgprot_t for it's PAGE_KERNEL types
&gt; rather than #defines, so the #ifdef check wouldn't see this.
&gt;
&gt; I think either PAGE_PROT_RO becomes part of our arch API (so all
&gt; architectures are forced to add it), or, if it's not part of the API,
&gt; ohci isn't entitled to use it.  The latter seems simplest since you have
&gt; no real use for write protection anyway.

Reported-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
PAGE_KERNEL_RO is not available on all architectures, so its use
in the new AR code broke compilation on sparc64.

Because the read-only mapping was just a debugging aid, just use
PAGE_KERNEL instead.

Signed-off-by: Clemens Ladisch &lt;clemens@ladisch.de&gt;

James Bottomley wrote:
&gt; On Thu, 2011-01-13 at 08:27 +0100, Clemens Ladisch wrote:
&gt;&gt; firewire: ohci: fix compilation on arches without PAGE_KERNEL_RO, e.g. sparc
&gt;&gt;
&gt;&gt; PAGE_KERNEL_RO is not available on all architectures, so its use in the
&gt;&gt; new AR code broke compilation on sparc64.
&gt;&gt;
&gt;&gt; Because the R/O mapping is only used to catch drivers that try to write
&gt;&gt; to the reception buffer and not actually required for correct operation,
&gt;&gt; we can just use a normal PAGE_KERNEL mapping where _RO is not available.
[...]
&gt;&gt; +/*
&gt;&gt; + * For archs where PAGE_KERNEL_RO is not supported;
&gt;&gt; + * mapping the AR buffers readonly for the CPU is just a debugging aid.
&gt;&gt; + */
&gt;&gt; +#ifndef PAGE_KERNEL_RO
&gt;&gt; +#define PAGE_KERNEL_RO PAGE_KERNEL
&gt;&gt; +#endif
&gt;
&gt; This might cause interesting issues on sparc64 if it ever acquired a
&gt; PAGE_KERNEL_RO.  Sparc64 has extern pgprot_t for it's PAGE_KERNEL types
&gt; rather than #defines, so the #ifdef check wouldn't see this.
&gt;
&gt; I think either PAGE_PROT_RO becomes part of our arch API (so all
&gt; architectures are forced to add it), or, if it's not part of the API,
&gt; ohci isn't entitled to use it.  The latter seems simplest since you have
&gt; no real use for write protection anyway.

Reported-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>firewire: ohci: consolidate context status flags</title>
<updated>2011-01-04T07:48:33+00:00</updated>
<author>
<name>Stefan Richter</name>
<email>stefanr@s5r6.in-berlin.de</email>
</author>
<published>2011-01-01T14:17:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=693a50b511818e07a131efc944cba1a504b63d3d'/>
<id>693a50b511818e07a131efc944cba1a504b63d3d</id>
<content type='text'>
"firewire: ohci: restart iso DMA contexts on resume from low power mode"
added the flag struct context.active and "firewire: ohci: cache the
context run bit" added struct context.running.

These flags contain the same information; combine them.
Also, normalize whitespace in pci_resume().

Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
"firewire: ohci: restart iso DMA contexts on resume from low power mode"
added the flag struct context.active and "firewire: ohci: cache the
context run bit" added struct context.running.

These flags contain the same information; combine them.
Also, normalize whitespace in pci_resume().

Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>firewire: ohci: cache the context run bit</title>
<updated>2011-01-04T07:48:33+00:00</updated>
<author>
<name>Clemens Ladisch</name>
<email>clemens@ladisch.de</email>
</author>
<published>2010-12-24T13:42:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=386a4153a2c1455e424f280d636efa3c91864466'/>
<id>386a4153a2c1455e424f280d636efa3c91864466</id>
<content type='text'>
The DMA context run control bit is entirely controlled by software, so
it is safe to cache it.  This allows the driver to avoid doing an
additional MMIO read when queueing an AT packet.

Signed-off-by: Clemens Ladisch &lt;clemens@ladisch.de&gt;
Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The DMA context run control bit is entirely controlled by software, so
it is safe to cache it.  This allows the driver to avoid doing an
additional MMIO read when queueing an AT packet.

Signed-off-by: Clemens Ladisch &lt;clemens@ladisch.de&gt;
Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>firewire: ohci: flush AT contexts after bus reset - addendum</title>
<updated>2011-01-04T07:48:33+00:00</updated>
<author>
<name>Stefan Richter</name>
<email>stefanr@s5r6.in-berlin.de</email>
</author>
<published>2011-01-01T14:15:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=78dec56d6a56322e1b728d51f3a7def416d36b34'/>
<id>78dec56d6a56322e1b728d51f3a7def416d36b34</id>
<content type='text'>
Add comments
  - on why bus_reset_tasklet flushes AT queues,
  - that commit 76f73ca1b291 can possibly be reverted now.

Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
Acked-by: Jarod Wilson &lt;jarod@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add comments
  - on why bus_reset_tasklet flushes AT queues,
  - that commit 76f73ca1b291 can possibly be reverted now.

Signed-off-by: Stefan Richter &lt;stefanr@s5r6.in-berlin.de&gt;
Acked-by: Jarod Wilson &lt;jarod@redhat.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
