On 2024/11/19 20:51, Roger Pau Monné wrote:
> On Wed, Nov 13, 2024 at 04:00:27PM +0800, Jiqian Chen wrote:
>> +static void cf_check rebar_ctrl_write(const struct pci_dev *pdev,
>> +                                      unsigned int reg,
>> +                                      uint32_t val,
>> +                                      void *data)
>> +{
>> +    uint32_t ctrl, index;
>> +    struct vpci_bar *bars = pdev->vpci->header.bars;
>> +
>> +    ctrl = pci_conf_read32(pdev->sbdf, reg);
>> +    if ( ctrl == val )
>> +        return;
>> +
>> +    ctrl &= ~PCI_REBAR_CTRL_BAR_SIZE;
>> +    if ( ctrl != ( val & ~PCI_REBAR_CTRL_BAR_SIZE ) )
>> +        return;
>> +
>> +    index = ctrl & PCI_REBAR_CTRL_BAR_IDX;
>> +    bars[index].size = (1 << ((val & PCI_REBAR_CTRL_BAR_SIZE) >>
>> +                              PCI_REBAR_CTRL_BAR_SHIFT)) *
>> +                       PCI_REBAR_CTRL_BAR_UNIT;
> 
> One further comment: you also need to reset addr and guest_addr here
> (possibly by reading them from the BAR register), as the specification
> states that:
How about just set them to 0, since the addr will be re-assigned by system and 
the addr of BAR register is also out of date.

> 
> "After writing the BAR Size field, the contents of the corresponding
> BAR are undefined"
> 
> Hence the cached addr and guest_addr are stale after a write to the
> control register.
> 
> Thanks, Roger.

-- 
Best regards,
Jiqian Chen.

Reply via email to