public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: alexey.kodanev@oracle.com
To: gaowanlong@cn.fujitsu.com
Cc: vasily.isaenko@oracle.com, ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] device-drivers: pci: fix PCI_EXP_CAP_CONFIG test-case
Date: Thu, 31 Oct 2013 12:40:54 +0400	[thread overview]
Message-ID: <52721796.7010001@oracle.com> (raw)
In-Reply-To: <5271B4A7.4060006@cn.fujitsu.com>

Hi!
On 10/31/2013 05:38 AM, Wanlong Gao wrote:
> On 10/30/2013 07:21 PM, Alexey Kodanev wrote:
>> There is another way to check that PCI Express config space of pci devices
>> can be read successfully.
>> Firstly, find out if a device has a PCI Express Capability: we should get
>> a correct config address offset from the dev's structure (dev->pcie_cap).
>> Using the offset, read a PCI Express header. Check if we can get the right
>> PCI Express CAP ID from the header (it must match the PCI_CAP_ID_EXP macro).
> This can PASS here, thank you.
>
> Why did the original method always FAIL?

The original code has wrong offset, should be reg = 0x100 at least (as 
it written in comment):
> int reg = 100, len = 4; /*PCI-Exp enhanced config register 0x100, 4 
> implies dword access */

I don't know about that magic number 0x14011 in the original code. 
Comments said that we can find a constant value from that offset, but in 
truth, we can find any of the PCI_EXT_CAP_ID_* macors in the first 16 
bits or none if device doesn't have Extended Configuration Space. It can 
be AER (ERR in the macro) and it could be any other ID (it depends on 
the device).

better find a particular offset using the kernel function, for example:
pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); /* it will find 
Advanced Error Reporting structure */

Then get the header (first 4 bytes). First 16 bits should be AER_ID, 
that it is to say 0x0001. From bit 16 to bit 19 - capability version 
(can be 1h or 2h). The other bits contain the offset to the next PCI 
Express Capability structure or zero if it is the last one. That kind of 
header will never equal to 0x14011, that's is why the original method 
will always fail even with the right offset.


------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  reply	other threads:[~2013-10-31  8:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-30 11:21 [LTP] [PATCH] device-drivers: pci: fix PCI_EXP_CAP_CONFIG test-case Alexey Kodanev
2013-10-31  1:38 ` Wanlong Gao
2013-10-31  8:40   ` alexey.kodanev [this message]
2013-11-01  3:13     ` Wanlong Gao
2013-11-01  3:15 ` Wanlong Gao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52721796.7010001@oracle.com \
    --to=alexey.kodanev@oracle.com \
    --cc=gaowanlong@cn.fujitsu.com \
    --cc=ltp-list@lists.sourceforge.net \
    --cc=vasily.isaenko@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox