Message ID | 20230213140103.1518173-11-vsementsov@yandex-team.ru |
---|---|
State | New |
Headers | show |
Series | pci hotplug tracking | expand |
On 13/02/2023 16:00, Vladimir Sementsov-Ogievskiy wrote: > *_by_mask() helpers shouldn't be used here (and that's the only one). > *_by_mask() helpers do shift their value argument, but in pcie.c code > we use values that are already shifted appropriately. > Happily, PCI_EXP_SLTCTL_PWR_ON is zero, so shift doesn't matter. But if > we apply same helper for PCI_EXP_SLTCTL_PWR_OFF constant it will do > wrong thing. > > So, let's use instead pci_word_test_and_clear_mask() which is already > used in the file to clear PCI_EXP_SLTCTL_PWR_OFF bit in > pcie_cap_slot_init() and pcie_cap_slot_reset(). > > Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Reviewed-by: Anton Kuchin <antonkuchin@yandex-team.ru> > --- > hw/pci/pcie.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c > index ccdb2377e1..db8360226f 100644 > --- a/hw/pci/pcie.c > +++ b/hw/pci/pcie.c > @@ -373,8 +373,8 @@ void pcie_cap_slot_enable_power(PCIDevice *dev) > uint32_t sltcap = pci_get_long(exp_cap + PCI_EXP_SLTCAP); > > if (sltcap & PCI_EXP_SLTCAP_PCP) { > - pci_set_word_by_mask(exp_cap + PCI_EXP_SLTCTL, > - PCI_EXP_SLTCTL_PCC, PCI_EXP_SLTCTL_PWR_ON); > + pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTCTL, > + PCI_EXP_SLTCTL_PCC); > } > } >
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index ccdb2377e1..db8360226f 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -373,8 +373,8 @@ void pcie_cap_slot_enable_power(PCIDevice *dev) uint32_t sltcap = pci_get_long(exp_cap + PCI_EXP_SLTCAP); if (sltcap & PCI_EXP_SLTCAP_PCP) { - pci_set_word_by_mask(exp_cap + PCI_EXP_SLTCTL, - PCI_EXP_SLTCTL_PCC, PCI_EXP_SLTCTL_PWR_ON); + pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTCTL, + PCI_EXP_SLTCTL_PCC); } }
*_by_mask() helpers shouldn't be used here (and that's the only one). *_by_mask() helpers do shift their value argument, but in pcie.c code we use values that are already shifted appropriately. Happily, PCI_EXP_SLTCTL_PWR_ON is zero, so shift doesn't matter. But if we apply same helper for PCI_EXP_SLTCTL_PWR_OFF constant it will do wrong thing. So, let's use instead pci_word_test_and_clear_mask() which is already used in the file to clear PCI_EXP_SLTCTL_PWR_OFF bit in pcie_cap_slot_init() and pcie_cap_slot_reset(). Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> --- hw/pci/pcie.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)