Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VPCI code cleanup/reorg #3334

Merged
merged 6 commits into from Jun 27, 2019
Merged

VPCI code cleanup/reorg #3334

merged 6 commits into from Jun 27, 2019

Conversation

donsheng
Copy link
Contributor

@donsheng donsheng commented Jun 27, 2019

Remove unused function find_pci_pdev
Add get_offset_of_caplist() function to return capability offset based on header type
Add union pci_bar and is_64bit_high to struct pci_bar
Add uint32_t nr_bars to struct struct pci_pdevpci_vdev to track # of bars

Tracked-On: #3241
Signed-off-by: dongshen dongsheng.x.zhang@intel.com
Acked-by: Eddie Dong eddie.dong@intel.com

find_pci_pdev is not used any more, remove it.

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
Add get_offset_of_caplist() function to return capability offset based on header type:
For normal pci device and bridge, its capability offset is at offset 0x34
For cardbus, its capability offset is at offset 0x14

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
union pci_bar uses bit fields and follows the PCI bar spec definition to define the
bar flags portion and base address, this is to keep the same hardware format for vbar
register. The base/type of union pci_bar are still kept to minimize code changes
in one patch, they will be removed in subsequent patches.

define pci_pdev_get_bar_base() function to extract bar base address given a 32-bit raw
bar value

define a utility function pci_get_bar_type() to extract bar types
from raw bar value to simply code, as this function will be used in multiple
places later on: this function can be called on reg->value stored in struct
pci_bar to derive bar type.

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
nr_bars in struct pci_pdev is used to store the actual # of bars (
6 for normal pci device and 2 for pci bridge), nr_bars will be used in subsequent
patches

Use uint32_t for bar related variables (bar index, etc) to unify the bar
related code (no casting between uint32_t and uint8_t)

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
And put the checking in vdev_pt_write_cfg instead to have less nesting in
vdev_pt_write_vbar to improve code readability.

Rename function:
vdev_pt_remap_generic_bar --> vdev_pt_remap_generic_mem_vbar

vdev_pt_read_cfg's function declaration is merged into one line instead of 2
lines

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Use nr_bars instead of PCI_BAR_COUNT to check bar access offset.
As while normal pci device has max 6 bars, pci bridge only has 2 bars,
so for pci normal pci device, pci cfg offsets 0x10-0x24 are for bar access,
but for pci bridge, only 0x10-0x14 are for bar access (0x18-0x24 are
for other accesses).

Rename function:
 pci_bar_access --> is_bar_offset

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
@acrnsi
Copy link

acrnsi commented Jun 27, 2019

OK to verify

@acrnsi
Copy link

acrnsi commented Jun 27, 2019

Can one of the admins verify this patch?

@ghost
Copy link

ghost commented Jun 27, 2019

7 new potential violations to the coding guideline detected. Please help check. Thanks!
<1> config:common filename:/hypervisor/dm/vpci/pci_pt.c func:vdev_pt_remap_generic_mem_vbar offset:177
reason:Casting operation to a pointer. : (void* to unsigned long*): ( uint64_t * ) vm -> arch_vm.nworld_eptp
<2> config:common filename:/hypervisor/dm/vpci/pci_pt.c func:vdev_pt_remap_generic_mem_vbar offset:177
reason:Casting operation on a pointer. : (void* to unsigned long*): ( uint64_t * ) vm -> arch_vm.nworld_eptp
<3> config:common filename:/hypervisor/dm/vpci/pci_pt.c func:vdev_pt_remap_generic_mem_vbar offset:185
reason:Casting operation to a pointer. : (void* to unsigned long*): ( uint64_t * ) vm -> arch_vm.nworld_eptp
<4> config:common filename:/hypervisor/dm/vpci/pci_pt.c func:vdev_pt_remap_generic_mem_vbar offset:185
reason:Casting operation on a pointer. : (void* to unsigned long*): ( uint64_t * ) vm -> arch_vm.nworld_eptp
<5> config:common filename:/hypervisor/dm/vpci/pci_pt.c func:vdev_pt_write_cfg offset:248
reason:Logical conjunctions need brackets.
<6> config:common filename:/hypervisor/include/hw/pci.h func:is_bar_offset offset:230
reason:Static procedure is not explicitly called in code analysed. : is_bar_offset
<7> config:common filename:/hypervisor/include/hw/pci.h func:bdf_is_equal offset:294
reason:Static procedure is not explicitly called in code analysed. : bdf_is_equal

No New Name Conflict

No New Function Declaration/Definition Mismatch

@ghost ghost added Coding Guidelines: PASS Coding Guidelines Manual Check and removed CI: no coding guideline labels Jun 27, 2019
@acrnsi acrnsi added the Auto_Merge_Pass it is ready to merge label Jun 27, 2019
@wenlingz wenlingz merged commit f7c4d2b into projectacrn:master Jun 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto_Merge_Pass it is ready to merge Coding Guidelines: PASS Coding Guidelines Manual Check Tracked On Pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants