From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.54 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796428330; b=C0SJa/2s5w6uGam6yE8h6Lca4XNCZ9rTwoHuh0b3GTquF5NJz95FDMsluAaQSO4AP+FN wFgaKeCHWeICTIiYRaRI9kD74qsjE/Mcod/Er0xNUB4GpHE6NXlp9Kp1wwaPanCIr3vyP 3b9Vs9nwqn7Nz0WBuVAZDooel47M4hZvbw7YY+kHWoLplpZ3g+SC9mEM/ggBSFsk2Q2Is DgZNiEjY0vVhzva5shI06Gz27vkSbn+9CVEIjFBOKpmSISw5irmDm+Mi6XWPiaaDxm9Qo 9qOOOch9cmLV90nz4pEzzE/KTQtlA/gDJvpzg6uzvSQWhgyDi8iI0kj+IVt89YuLo7A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796428330; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Mime-Version:Content-Transfer-Encoding:Content-Type:Date:Message-Id: Subject:From:To:Cc:X-Mailer:References:In-Reply-To; bh=mWTxaFRGc8JV+Vg03A2tGLcG6B8RzsnjQaf9kK7P+bk=; b=sdZE6B9+KdcAf0P46XO6yhxzH84MAmQHdNht4FNXS5JzWAL30JcMP7ZuqWrlb44mt0gI RbQV/dtbHuX2UeAxL3v+ngxyNrf/L1t7STUSgVSZO161jv0AzSyvLIJ736YJhemlnp9tN xqnfno/e3Ad72IZ3RWvGSINbnGKB8M1TVA19e/x+rl20wP3mduqfhOsmZL9UuIXB3Sf5c psKTHLNsONvcpFlNFvgCDSlH+/te+MrRNZBirgqHoB3JskIFVC2bMzqHaDe1ifp9dYXUJ OWqFXejICSesDN4SBsnePEO4uJflLRfo3QW7vTb7PNtFzTDwMfsc7iPrWC9+iwC3byg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Wog9aUOw; arc=none smtp.remote-ip=209.85.216.54 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4636A606A32C for ; Fri, 4 Dec 2026 23:52:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4636A606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Wog9aUOw Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-3b402824d07so909660a91.1 for ; Fri, 04 Dec 2026 15:52:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796428329; x=1797033129; darn=vger.kernel.org; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-type:content-transfer-encoding:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=mWTxaFRGc8JV+Vg03A2tGLcG6B8RzsnjQaf9kK7P+bk=; b=Wog9aUOw7LZupVxwZXFIACJU0BKpZx/0EChq0q18MDWpQonZhq+RPP62PPEwnZbzrR B34hNBA4NdCDcYG+k01wWP89jxo+7zjRCzt1vgEb7n7tTEzDiWojRhD6W/XFr0UkikQi ZiR2L2Xdvx0uJnqp2QJF08QitWgJo5C5dPbBmhw4Zglaybo7Zl1hxY1BHpwJ0mtBf4/f JL8wPji11ARqCVvGP4IiIU9ifvMYFDdn0KOtVkUBy/Z693mvrtu5Ip/BDzrVPg9lZh7/ EF2WrG2/OJr2dEdIBf/sk/0jHGOZqZLBTKQ5+C4Tprr1x56mtPEVEcsDqmCQuc2uGEoh HdMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796428329; x=1797033129; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-type:content-transfer-encoding:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mWTxaFRGc8JV+Vg03A2tGLcG6B8RzsnjQaf9kK7P+bk=; b=nMrK0wp6ne+Rgxd6ujwc2ancikUWndDIQP5SBE4kTLDDIuq1dJV5LgvFxWCU5dYiHR 5PG9LWGsXW+ciu8JoE05KTEohTfuS7P52hwQiNXn5dUsmtdHJtu5FJxm0TuAf4NKmUEL CZr8N03ghB3DN/0Fd/yCdokbb1pDe7Vh8fLyphPUJNQx/KBDp3yA37o2Ni8UnzsO0MZo hpvap7tgM1Z8Gd5nLv4t3Q/1m3Fwc9QUQVIzQDkW8Tk4JGZatho2Gn4YVHO1sYF44pDO mLF5Nc1PwnHFW8QeWSymzV9NL7StLmUfW85XmA64C0hAd7qyxTCkPt2yWW6Ecuv190Pp ujlQ== X-Forwarded-Encrypted: i=1; AL+hErFv8FAj7KR1r2juP/kExTiAo7o30/YanCTVhHQmOuAj4DBGKxKjB9ZDgjmUxZC7pm4OM5GtsJbVBKxSfDY=@vger.kernel.org X-Gm-Message-State: AB4q+uEtRhD/YyVF5Yhwjg4LJ18meCLeV6SX02UPipXgeWfhDgZcTzyJ pEozVmbJ0R0YCBIUVZxvjX5yYZMqEcYjvsnTdCU5Zotim/02k+9oFLSRYJtdswtGDq5jfrsMERo o1O9nqg== X-Gm-Gg: AZFdTZd+pOG4AUBhvv7w263bIQjyT8t4NHMCnl92bz1kJfNnWgfXuXoZytp9L9gHhnz 3mc/NlWFYA//YaQVNi9wrHQEgIHaZin3F7IMJzkz1bQUcEmpKy1Rbu6lJQHF/20Z7w/9+pTc3nT s6ia0LbmG8/Qy+cPfk4SWdZY7k1SX/VAUBul56vg+EoKHIxgaE7SQIe1FlIBHWDuqowivUwCat4 qXCrbFAggtCNAKpbnKe4jjfP5j6O7GwRF+2k7PWAAIu2u2WaDlHb/oAcrPB4o4/3xk/ovGR6mTj EssqVwx0VvIrE6hCwTv1kcas9J0WR2N0IYa0oNTn2Qg47ilzpCldatKgj25IXJclN2qPht0TLMw sihKhE2YmQvVLZgu2p9VP4dnxocbvxDkBbnpMOhV9D14S7NfLlHXptYnK3kk/pEE3IiYYgfTIa9 F09xPQQdozcASEJrUGVRsU0+pq0R5aghCFjVuSkPzKpjrlKlFN0qBzZtVGCcYNIN6HRA88AYJk8 PPS/UxRdm0VDUWKJoeFaGNHA/lk/IG9STiG54EzBBC4XBKO4Am6+9fW4vFyO/uptBV5o4+C57zS ojnimZxXUlC4HDAekaDYMINl9wMAY2LGDCunccMcFS6fqcR3c0qSis9CrguEI/3Y X-Received: by 2002:a17:90b:1a84:b0:3aa:6b5d:a00a with SMTP id 98e67ed59e1d1-3b5e069989bmr3270082a91.53.1796428328904; Fri, 04 Dec 2026 15:52:08 -0800 (PST) Received: from localhost (33.79.127.34.bc.googleusercontent.com. [34.127.79.33]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8de12eb05d3sm2434892b3a.38.2026.12.04.15.52.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Dec 2026 15:52:07 -0800 (PST) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 04 Dec 2026 15:52:05 -0800 Message-Id: Subject: Re: [PATCH v2 2/2] PCI/DOE: Poll briefly for a response before sleeping From: "David Matlack" To: "Michal Clapinski" , "Bjorn Helgaas" , Cc: "Lukas Wunner" , , "David Matlack" X-Mailer: aerc 0.21.0 References: <20261103163101.1696520-1-mclapinski@google.com> <20261103163101.1696520-3-mclapinski@google.com> In-Reply-To: <20261103163101.1696520-3-mclapinski@google.com> On Tue Nov 3, 2026 at 8:31 AM PST, Michal Clapinski wrote: > +static int pci_doe_wait(struct pci_doe_mb *doe_mb, unsigned int *delay_u= s) > { > + if (test_bit(PCI_DOE_FLAG_CANCEL, &doe_mb->flags)) > + return -EIO; > + > + if (*delay_us <=3D PCI_DOE_POLL_SPIN_MAX_US && > + !hrtimer_highres_enabled()) { > + udelay(*delay_us); > + *delay_us *=3D 2; > + return 0; > + } > + > + if (*delay_us < jiffies_to_usecs(PCI_DOE_POLL_INTERVAL)) { > + fsleep(*delay_us); > + *delay_us *=3D 2; > + return 0; > + } > + > if (wait_event_timeout(doe_mb->wq, > test_bit(PCI_DOE_FLAG_CANCEL, &doe_mb->flags), > - timeout)) > + PCI_DOE_POLL_INTERVAL)) > return -EIO; > return 0; > } I think this could be simplified to a fixed busy-poll followed by the existing wait_event_timeout(): - Backing off exponentially doesn't buy much while we're spinning, since the CPU time is spent either way, and it means a response can sit unnoticed for longer. Instead, re-poll the DOE Status register every couple of microseconds for a fixed budget (e.g. ~250 us), which notices a response almost as soon as it's ready. - Do this unconditionally rather than only until high resolution timers are enabled. That bounds the wasted CPU time to the same budget per wait, behaves the same at boot and at runtime (including with CONFIG_HIGH_RES_TIMERS=3Dn, where hrtimer_highres_enabled() is always false), and avoids depending on hrtimer_highres_enabled(), which as far as I can tell has no other users outside of kernel/time. - After the budget, fall back to the existing wait_event_timeout() with PCI_DOE_POLL_INTERVAL. Operations that take longer than the budget behave the same as they do today, so there's no regression for slower devices, and this keeps the change small. A finer-grained sleep between the two could always be added later if a device needs it. Something like this (untested): static int pci_doe_wait(struct pci_doe_mb *doe_mb, unsigned int *polls) { if (test_bit(PCI_DOE_FLAG_CANCEL, &doe_mb->flags)) return -EIO; if ((*polls)++ < PCI_DOE_POLL_SPIN_COUNT) { udelay(PCI_DOE_POLL_SPIN_US); return 0; } if (wait_event_timeout(doe_mb->wq, test_bit(PCI_DOE_FLAG_CANCEL, &doe_mb->flags), PCI_DOE_POLL_INTERVAL)) return -EIO; return 0; } where callers start with polls =3D 0, so they don't need to know about a minimum delay. One thing to watch out for is that this does more config reads during the busy-poll. On devices where the DOE mailbox is handled by the same firmware that services config requests, polling too aggressively could slow down the response. Could you measure a couple of step sizes (e.g. 2 us vs 5 us) on the B200 and see if it affects the response time?