Re: [PATCH V2 5/8] soundwire: amd: add soundwire manager interrupt handling

From: Pierre-Louis Bossart
Date: Tue Feb 14 2023 - 14:22:58 EST



>>>> +update_status:
>>>> + sdw_handle_slave_status(&amd_manager->bus, amd_manager->status);
>>>> + if (amd_manager->status[0] == SDW_SLAVE_ATTACHED) {
>>>> + if (retry_count++ < SDW_MAX_DEVICES) {
>>>> + acp_reg_writel(AMD_SDW_IRQ_MASK_0TO7, amd_manager->mmio +
>>>> + ACP_SW_STATE_CHANGE_STATUS_MASK_0TO7);
>>>> + acp_reg_writel(AMD_SDW_IRQ_MASK_8TO11,
>>>> + amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_MASK_8TO11);
>>>> + amd_sdw_read_and_process_ping_status(amd_manager);
>>>> + goto update_status;
>>>> + } else {
>>>> + dev_err_ratelimited(amd_manager->dev,
>>>> + "Device0 detected after %d iterations\n",
>>>> + retry_count);
>>>> + }
>>>> + }
>>> this seems rather inspired by the Cadence code, but is there really a
>>> case where you need to re-check for devices? In the Cadence case, this
>>> was added because we have a logical OR and new devices would not be handled.
>> As mentioned in V1 set, we have corner cases during enumeration sequence.
>> We observed device alerts are missing during peripheral enumeration sequence
>> when multiple peripheral devices are connected over the same link.
>> This is not inspired by Intel code.
>>
>> As per V1 version review comment, we have included retry_count logic to address
>> faulty case.
>>
>> We forgot to include comment. we will fix it.
> Slight correction in the explanation.
>
> During the peripheral enumeration sequence, the soundwire peripheral interrupts
> are masked.
> If soundwire interrupts are not masked, it will cause side effects when multiple
> peripheral devices connected over the same link.
> As interrupts are masked, during device slot programming for each peripheral,
> soundwire manager driver won't receive any interrupts.
>
> Once the device number programming is done for all peripherals, the soundwire
> interrupts will be unmasked. Read the peripheral device status from ping command
> and process the response, which will invoke the peripheral device initialization sequence.
> This sequence will ensure all peripheral devices enumerated and initialized
> properly.

Humm, the explanation is difficult to follow, it's not clear on which
side the interrupts are masked. Are you talking about the peripheral
being prevented from generating interrupts, or about the manager not
detecting peripheral state changes with an interrupt-based mechanism?

I am not sure what 'side effects' can happen, during enumeration all
devices show up as device0 and the SoundWire bus provides a mechanism to
enumerate without conflicts.