RE: [EXT] Re: [RFC PATCH v2 2/4] cxl: Add default timeout for bg mailbox commands

Srinivasulu Opensrc
2024-10-17T17:25:52Z

Micron Confidential

Micron Confidential
>-----Original Message-----
>From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
>Sent: Thursday, October 17, 2024 9:02 PM
>To: Ravis OpenSrc <Ravis.OpenSrc@micron.com>
>Cc: linux-cxl@vger.kernel.org; dan.j.williams@intel.com; dave.jiang@intel.com;
>Srinivasulu Opensrc <sthanneeru.opensrc@micron.com>; john@jagalactic.com;
>Ajay Joshi <ajayjoshi@micron.com>
>Subject: [EXT] Re: [RFC PATCH v2 2/4] cxl: Add default timeout for bg mailbox
>commands
>
>CAUTION: EXTERNAL EMAIL. Do not click links or open attachments unless you
>recognize the sender and were expecting this message.
>
>
>On Wed, 16 Oct 2024 04:59:58 +0000
>Ravis OpenSrc <Ravis.OpenSrc@micron.com> wrote:
>
>> Allows 5s wait when no timeout parameter is explicitly mentioned.
>>
>> It is useful for mailbox commands to be executed in background
>> when initiated from userspace.
>>
>> Link:
>>
>https://lore.kernel/
>.org%2Flinux-
>mm%2F20240215123410.00003b8c%40Huawei.com%2FT%2F&data=05%7C02%7
>Csthanneeru.opensrc%40micron.com%7Cb92d2c58a0e14335108508dceec0e378
>%7Cf38a5ecd28134862b11bac1d563c806f%7C0%7C0%7C638647759553538421
>%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTi
>I6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=3mRf9MkO9GO2L%2F%
>2B7Vz9h92vVpVmX2AX%2Ba2unp5mBzKU%3D&reserved=0
>>
>> Signed-off-by: Ajay Joshi <ajay.opensrc@micron.com>
>> Signed-off-by: Ravi Shankar <ravis.opensrc@micron.com>

This patch mostly of resend of previous version from https://lore.kernel.org/linux-mm/20240215123410.00003b8c@Huawei.com/T/
Hence, need to add original author's s/o.

Signed-off-by: Srinivasulu Thanneeru <sthanneeru.opensrc@micron.com>

>Other than patch formatting, this seems reasonable to me.
>
>Jonathan
>
>> ---
>> drivers/cxl/pci.c | 13 +++++++++++++
>> 1 file changed, 13 insertions(+)
>>
>> diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
>> index 188412d45e0d..d5d6142f6aa3 100644
>> --- a/drivers/cxl/pci.c
>> +++ b/drivers/cxl/pci.c
>> @@ -41,6 +41,10 @@
>> /* CXL 2.0 - 8.2.8.4 */
>> #define CXL_MAILBOX_TIMEOUT_MS (2 * HZ)
>>
>> +/* Default timeout for background operations */
>> +#define CXL_BG_POLL_CNT 5
>> +#define CXL_BG_POLL_INTERVAL_MS 1000
>> +
>> /*
>> * CXL 2.0 ECN "Add Mailbox Ready Time" defines a capability field to
>> * dictate how long to wait for the mailbox to become ready. The new
>> @@ -317,6 +321,15 @@ static int __cxl_pci_mbox_send_cmd(struct
>cxl_mailbox *cxl_mbox,
>> dev_dbg(dev, "Mailbox background operation (0x%04x) started\n",
>> mbox_cmd->opcode);
>>
>> + /*
>> + * Add a default timeout of 5 seconds when background operation
>> + * starts but no timeout is specified.
>> + */
>> + if (!mbox_cmd->poll_interval_ms) {
>> + mbox_cmd->poll_interval_ms = CXL_BG_POLL_INTERVAL_MS;
>> + mbox_cmd->poll_count = CXL_BG_POLL_CNT;
>> + }
>> +
>> timeout = mbox_cmd->poll_interval_ms;
>> for (i = 0; i < mbox_cmd->poll_count; i++) {
>> if (rcuwait_wait_event_timeout(&cxl_mbox->mbox_wait,