<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/pci/access.c, branch v4.10</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>PCI: Warn on possible RW1C corruption for sub-32 bit config writes</title>
<updated>2016-11-21T22:25:39+00:00</updated>
<author>
<name>Bjorn Helgaas</name>
<email>bhelgaas@google.com</email>
</author>
<published>2016-10-31T21:00:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=fb26592301200dbbe4a9943fe188b57a46716900'/>
<id>fb26592301200dbbe4a9943fe188b57a46716900</id>
<content type='text'>
Hardware that supports only 32-bit config writes is not spec-compliant.
For example, if software performs a 16-bit write, we must do a 32-bit read,
merge in the 16 bits we intend to write, followed by a 32-bit write.  If
the 16 bits we *don't* intend to write happen to have any RW1C (write-one-
to-clear) bits set, we just inadvertently cleared something we shouldn't
have.

Add a rate-limited warning when we do sub-32 bit config writes.  Remove
similar probe-time warnings from some of the affected host bridge drivers.

Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Enthusiastically-Acked-by: Russell King &lt;rmk+kernel@armlinux.org.uk&gt;
Acked-by: Shawn Lin &lt;shawn.lin@rock-chips.com&gt;	# rockchip
Acked-by: Thierry Reding &lt;treding@nvidia.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Hardware that supports only 32-bit config writes is not spec-compliant.
For example, if software performs a 16-bit write, we must do a 32-bit read,
merge in the 16 bits we intend to write, followed by a 32-bit write.  If
the 16 bits we *don't* intend to write happen to have any RW1C (write-one-
to-clear) bits set, we just inadvertently cleared something we shouldn't
have.

Add a rate-limited warning when we do sub-32 bit config writes.  Remove
similar probe-time warnings from some of the affected host bridge drivers.

Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Enthusiastically-Acked-by: Russell King &lt;rmk+kernel@armlinux.org.uk&gt;
Acked-by: Shawn Lin &lt;shawn.lin@rock-chips.com&gt;	# rockchip
Acked-by: Thierry Reding &lt;treding@nvidia.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>PCI: Add pci_set_vpd_size() to set VPD size</title>
<updated>2016-04-15T18:00:11+00:00</updated>
<author>
<name>Hariprasad Shenai</name>
<email>hariprasad@chelsio.com</email>
</author>
<published>2016-04-15T18:00:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=cb92148b58a49455f3a7204eba3aee09a8b7683c'/>
<id>cb92148b58a49455f3a7204eba3aee09a8b7683c</id>
<content type='text'>
After 104daa71b396 ("PCI: Determine actual VPD size on first access"), the
PCI core computes the valid VPD size by parsing the VPD starting at offset
0x0.  We don't attempt to read past that valid size because that causes
some devices to crash.

However, some devices do have data past that valid size.  For example,
Chelsio adapters contain two VPD structures, and the driver needs both of
them.

Add pci_set_vpd_size().  If a driver knows it is safe to read past the end
of the VPD data structure at offset 0, it can use pci_set_vpd_size() to
allow access to as much data as it needs.

[bhelgaas: changelog, split patches, rename to pci_set_vpd_size() and
return int (not ssize_t)]
Fixes: 104daa71b396 ("PCI: Determine actual VPD size on first access")
Tested-by: Steve Wise &lt;swise@opengridcomputing.com&gt;
Signed-off-by: Casey Leedom &lt;leedom@chelsio.com&gt;
Signed-off-by: Hariprasad Shenai &lt;hariprasad@chelsio.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
After 104daa71b396 ("PCI: Determine actual VPD size on first access"), the
PCI core computes the valid VPD size by parsing the VPD starting at offset
0x0.  We don't attempt to read past that valid size because that causes
some devices to crash.

However, some devices do have data past that valid size.  For example,
Chelsio adapters contain two VPD structures, and the driver needs both of
them.

Add pci_set_vpd_size().  If a driver knows it is safe to read past the end
of the VPD data structure at offset 0, it can use pci_set_vpd_size() to
allow access to as much data as it needs.

[bhelgaas: changelog, split patches, rename to pci_set_vpd_size() and
return int (not ssize_t)]
Fixes: 104daa71b396 ("PCI: Determine actual VPD size on first access")
Tested-by: Steve Wise &lt;swise@opengridcomputing.com&gt;
Signed-off-by: Casey Leedom &lt;leedom@chelsio.com&gt;
Signed-off-by: Hariprasad Shenai &lt;hariprasad@chelsio.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>PCI: Sleep rather than busy-wait for VPD access completion</title>
<updated>2016-03-10T20:24:48+00:00</updated>
<author>
<name>Bjorn Helgaas</name>
<email>bhelgaas@google.com</email>
</author>
<published>2016-02-22T20:58:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=c521b014cd51da94ae16c3decf1c407c3e0518f6'/>
<id>c521b014cd51da94ae16c3decf1c407c3e0518f6</id>
<content type='text'>
Use usleep_range() instead of udelay() while waiting for a VPD access to
complete.  This is not a performance path, so no need to hog the CPU.

Rationale for usleep_range() parameters:

  We clear PCI_VPD_ADDR_F for a read (or set it for a write), then wait for
  the device to change it.  For a device that updates PCI_VPD_ADDR between
  our config write and subsequent config read, we won't sleep at all and
  can get the device's maximum rate.

  Sleeping a minimum of 10 usec per 4-byte access limits throughput to
  about 400Kbytes/second.  VPD is small (32K bytes at most), and most
  devices use only a fraction of that.

  We back off exponentially up to 1024 usec per iteration.  If we reach
  1024, we've already waited up to 1008 usec (16 + 32 + ... + 512), so if
  we miss an update and wait an extra 1024 usec, we can still get about
  1/2 of the device's maximum rate.

Tested-by: Shane Seymour &lt;shane.seymour@hpe.com&gt;
Tested-by: Babu Moger &lt;babu.moger@oracle.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use usleep_range() instead of udelay() while waiting for a VPD access to
complete.  This is not a performance path, so no need to hog the CPU.

Rationale for usleep_range() parameters:

  We clear PCI_VPD_ADDR_F for a read (or set it for a write), then wait for
  the device to change it.  For a device that updates PCI_VPD_ADDR between
  our config write and subsequent config read, we won't sleep at all and
  can get the device's maximum rate.

  Sleeping a minimum of 10 usec per 4-byte access limits throughput to
  about 400Kbytes/second.  VPD is small (32K bytes at most), and most
  devices use only a fraction of that.

  We back off exponentially up to 1024 usec per iteration.  If we reach
  1024, we've already waited up to 1008 usec (16 + 32 + ... + 512), so if
  we miss an update and wait an extra 1024 usec, we can still get about
  1/2 of the device's maximum rate.

Tested-by: Shane Seymour &lt;shane.seymour@hpe.com&gt;
Tested-by: Babu Moger &lt;babu.moger@oracle.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>PCI: Fold struct pci_vpd_pci22 into struct pci_vpd</title>
<updated>2016-02-29T23:47:36+00:00</updated>
<author>
<name>Bjorn Helgaas</name>
<email>bhelgaas@google.com</email>
</author>
<published>2016-02-22T20:09:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=408641e93aa5283e586fefd4dc72e67c92aae075'/>
<id>408641e93aa5283e586fefd4dc72e67c92aae075</id>
<content type='text'>
We only support one flavor of VPD, so there's no need to complicate things
by having a "generic" struct pci_vpd and a more specific struct
pci_vpd_pci22.

Fold struct pci_vpd_pci22 directly into struct pci_vpd.

[bhelgaas: remove NULL check before kfree of dev-&gt;vpd (per kfreeaddr.cocci)]
Tested-by: Shane Seymour &lt;shane.seymour@hpe.com&gt;
Tested-by: Babu Moger &lt;babu.moger@oracle.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We only support one flavor of VPD, so there's no need to complicate things
by having a "generic" struct pci_vpd and a more specific struct
pci_vpd_pci22.

Fold struct pci_vpd_pci22 directly into struct pci_vpd.

[bhelgaas: remove NULL check before kfree of dev-&gt;vpd (per kfreeaddr.cocci)]
Tested-by: Shane Seymour &lt;shane.seymour@hpe.com&gt;
Tested-by: Babu Moger &lt;babu.moger@oracle.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>PCI: Rename VPD symbols to remove unnecessary "pci22"</title>
<updated>2016-02-29T23:47:31+00:00</updated>
<author>
<name>Bjorn Helgaas</name>
<email>bhelgaas@google.com</email>
</author>
<published>2016-02-22T19:58:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f1cd93f9aabe3b8dcac53de1c88279dbd8e529c3'/>
<id>f1cd93f9aabe3b8dcac53de1c88279dbd8e529c3</id>
<content type='text'>
There's only one kind of VPD, so we don't need to qualify it as "the
version described by PCI spec rev 2.2."

Rename the following symbols to remove unnecessary "pci22":

  PCI_VPD_PCI22_SIZE	-&gt; PCI_VPD_MAX_SIZE
  pci_vpd_pci22_size()	-&gt; pci_vpd_size()
  pci_vpd_pci22_wait()	-&gt; pci_vpd_wait()
  pci_vpd_pci22_read()	-&gt; pci_vpd_read()
  pci_vpd_pci22_write()	-&gt; pci_vpd_write()
  pci_vpd_pci22_ops	-&gt; pci_vpd_ops
  pci_vpd_pci22_init()	-&gt; pci_vpd_init()

Tested-by: Shane Seymour &lt;shane.seymour@hpe.com&gt;
Tested-by: Babu Moger &lt;babu.moger@oracle.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There's only one kind of VPD, so we don't need to qualify it as "the
version described by PCI spec rev 2.2."

Rename the following symbols to remove unnecessary "pci22":

  PCI_VPD_PCI22_SIZE	-&gt; PCI_VPD_MAX_SIZE
  pci_vpd_pci22_size()	-&gt; pci_vpd_size()
  pci_vpd_pci22_wait()	-&gt; pci_vpd_wait()
  pci_vpd_pci22_read()	-&gt; pci_vpd_read()
  pci_vpd_pci22_write()	-&gt; pci_vpd_write()
  pci_vpd_pci22_ops	-&gt; pci_vpd_ops
  pci_vpd_pci22_init()	-&gt; pci_vpd_init()

Tested-by: Shane Seymour &lt;shane.seymour@hpe.com&gt;
Tested-by: Babu Moger &lt;babu.moger@oracle.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>PCI: Remove struct pci_vpd_ops.release function pointer</title>
<updated>2016-02-29T23:47:24+00:00</updated>
<author>
<name>Bjorn Helgaas</name>
<email>bhelgaas@google.com</email>
</author>
<published>2016-02-22T19:58:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=da006847231b2b2ce443b29f1d3df6df7415030d'/>
<id>da006847231b2b2ce443b29f1d3df6df7415030d</id>
<content type='text'>
The struct pci_vpd_ops.release function pointer is always
pci_vpd_pci22_release(), so there's no need for the flexibility of a
function pointer.

Inline the pci_vpd_pci22_release() body into pci_vpd_release() and remove
pci_vpd_pci22_release() and the struct pci_vpd_ops.release function
pointer.

Tested-by: Shane Seymour &lt;shane.seymour@hpe.com&gt;
Tested-by: Babu Moger &lt;babu.moger@oracle.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The struct pci_vpd_ops.release function pointer is always
pci_vpd_pci22_release(), so there's no need for the flexibility of a
function pointer.

Inline the pci_vpd_pci22_release() body into pci_vpd_release() and remove
pci_vpd_pci22_release() and the struct pci_vpd_ops.release function
pointer.

Tested-by: Shane Seymour &lt;shane.seymour@hpe.com&gt;
Tested-by: Babu Moger &lt;babu.moger@oracle.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>PCI: Move pci_vpd_release() from header file to pci/access.c</title>
<updated>2016-02-29T23:47:16+00:00</updated>
<author>
<name>Bjorn Helgaas</name>
<email>bhelgaas@google.com</email>
</author>
<published>2016-02-22T19:58:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=64379079a9e37ab9e1c755921d7ff1c4fa3ac486'/>
<id>64379079a9e37ab9e1c755921d7ff1c4fa3ac486</id>
<content type='text'>
Move pci_vpd_release() so it's next to the other VPD functions.  This puts
it next to pci_vpd_pci22_init(), which allocates the space freed by
pci_vpd_release().

Tested-by: Shane Seymour &lt;shane.seymour@hpe.com&gt;
Tested-by: Babu Moger &lt;babu.moger@oracle.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Move pci_vpd_release() so it's next to the other VPD functions.  This puts
it next to pci_vpd_pci22_init(), which allocates the space freed by
pci_vpd_release().

Tested-by: Shane Seymour &lt;shane.seymour@hpe.com&gt;
Tested-by: Babu Moger &lt;babu.moger@oracle.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>PCI: Move pci_read_vpd() and pci_write_vpd() close to other VPD code</title>
<updated>2016-02-29T23:47:11+00:00</updated>
<author>
<name>Bjorn Helgaas</name>
<email>bhelgaas@google.com</email>
</author>
<published>2016-02-22T19:57:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=fc0a407e9eb8667f93820298a06a85050c42354e'/>
<id>fc0a407e9eb8667f93820298a06a85050c42354e</id>
<content type='text'>
pci_read_vpd() and pci_write_vpd() were stranded in the middle of config
accessor functions.  Move them close to the other VPD code in the file.
No functional change.

Tested-by: Shane Seymour &lt;shane.seymour@hpe.com&gt;
Tested-by: Babu Moger &lt;babu.moger@oracle.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
pci_read_vpd() and pci_write_vpd() were stranded in the middle of config
accessor functions.  Move them close to the other VPD code in the file.
No functional change.

Tested-by: Shane Seymour &lt;shane.seymour@hpe.com&gt;
Tested-by: Babu Moger &lt;babu.moger@oracle.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>PCI: Determine actual VPD size on first access</title>
<updated>2016-02-29T23:47:04+00:00</updated>
<author>
<name>Hannes Reinecke</name>
<email>hare@suse.de</email>
</author>
<published>2016-02-15T08:42:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=104daa71b39614343929e1982170d5fcb0569bb5'/>
<id>104daa71b39614343929e1982170d5fcb0569bb5</id>
<content type='text'>
PCI-2.2 VPD entries have a maximum size of 32k, but might actually be
smaller than that.  To figure out the actual size one has to read the VPD
area until the 'end marker' is reached.

Per spec, reading outside of the VPD space is "not allowed."  In practice,
it may cause simple read errors or even crash the card.  To make matters
worse not every PCI card implements this properly, leaving us with no 'end'
marker or even completely invalid data.

Try to determine the size of the VPD data when it's first accessed.  If no
valid data can be read an I/O error will be returned when reading or
writing the sysfs attribute.

As the amount of VPD data is unknown initially the size of the sysfs
attribute will always be set to '0'.

[bhelgaas: changelog, use 0/1 (not false/true) for bitfield, tweak
pci_vpd_pci22_read() error checking]
Tested-by: Shane Seymour &lt;shane.seymour@hpe.com&gt;
Tested-by: Babu Moger &lt;babu.moger@oracle.com&gt;
Signed-off-by: Hannes Reinecke &lt;hare@suse.de&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Cc: Alexander Duyck &lt;alexander.duyck@gmail.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
PCI-2.2 VPD entries have a maximum size of 32k, but might actually be
smaller than that.  To figure out the actual size one has to read the VPD
area until the 'end marker' is reached.

Per spec, reading outside of the VPD space is "not allowed."  In practice,
it may cause simple read errors or even crash the card.  To make matters
worse not every PCI card implements this properly, leaving us with no 'end'
marker or even completely invalid data.

Try to determine the size of the VPD data when it's first accessed.  If no
valid data can be read an I/O error will be returned when reading or
writing the sysfs attribute.

As the amount of VPD data is unknown initially the size of the sysfs
attribute will always be set to '0'.

[bhelgaas: changelog, use 0/1 (not false/true) for bitfield, tweak
pci_vpd_pci22_read() error checking]
Tested-by: Shane Seymour &lt;shane.seymour@hpe.com&gt;
Tested-by: Babu Moger &lt;babu.moger@oracle.com&gt;
Signed-off-by: Hannes Reinecke &lt;hare@suse.de&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Cc: Alexander Duyck &lt;alexander.duyck@gmail.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>PCI: Use bitfield instead of bool for struct pci_vpd_pci22.busy</title>
<updated>2016-02-29T23:46:57+00:00</updated>
<author>
<name>Bjorn Helgaas</name>
<email>bhelgaas@google.com</email>
</author>
<published>2016-02-22T20:04:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=c5563887a96912f84efe5c1322bfbc4f9a30e882'/>
<id>c5563887a96912f84efe5c1322bfbc4f9a30e882</id>
<content type='text'>
Make struct pci_vpd_pci22.busy a 1-bit field instead of a bool.  We intend
to add another flag, and two bitfields are cheaper than two bools.

Tested-by: Shane Seymour &lt;shane.seymour@hpe.com&gt;
Tested-by: Babu Moger &lt;babu.moger@oracle.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Make struct pci_vpd_pci22.busy a 1-bit field instead of a bool.  We intend
to add another flag, and two bitfields are cheaper than two bools.

Tested-by: Shane Seymour &lt;shane.seymour@hpe.com&gt;
Tested-by: Babu Moger &lt;babu.moger@oracle.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;</pre>
</div>
</content>
</entry>
</feed>
