From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796428330; b=JR5s18dNZ+wpskJ2iquWUfAOlpJ0/Qk++QK1OiQqqLwz451wY3orULh3/LMx7SAsuzkl IyHqp8Zq4i6Ry8mCA5gqYNfBaQflpM5K/OHlTvMgEugfcMi/LAuxjwDQ7F5BcPbFdCn6x 9El+DiPCdHKbhH+ZM3T8ShRX/lFHp/RKo7Rxou+n87m1y5i7Nza4CbE+IVXQi5YUfHHmF vLU900dwLPZmyyjDif9wri5p4ZjJxGwBwUvdx7Bx1JcQJxlRsk/6QLszaQuA+Si0OrK8a XzsxSTal7PhSQQXNaZvi0jn2t+/uPJ6EFeoApFMuZObuT1S56t0muXSH9pPForu8Mlg== 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=1xYmzaKK8htKCd9JE5tRdG1R2/dlWtvPXQ9qkFFsaVv3X1GfLQQO1cQtsP5O+ROI8ell gY9z2ABQxZhe7rgTmJ7xJCG5WJkRIY6WQtbvqOu9Bz+Au9GSf82SQ9EQA5GdC9WmOYPzS 4v47r5+GD4Nh2RHk9tkkV/cPo2Bs7WvR8rh1adGFqVO/iJq5e4qHkSWA1mfbBFBBlioYA bDOks2471rYWMcgOTy78Iul3C2oCPDrMKb0/w8nDGHA8tDo4A3su4w5KwkuelsPLWD9Sj Bn7iwOnT+uqHXiCXk3FhNOfbBM999SazOI4h9dyZukEnABxhw9S8XqsSOlvrADR3DVg== 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.45 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (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 3B09E606A322 for ; Fri, 4 Dec 2026 23:52:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3B09E606A322 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-f45.google.com with SMTP id 98e67ed59e1d1-3b51a9606e8so1096330a91.3 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=d6PMZLlDGcjFdYXEycL0liij8BHMYY9L+6qTEA4svBa0QJ3e9rq3+Ug2vdOPzo222M hKtW32qeyY76GByvurvWe+UYztvhaWaMgyv8WPnl7bbdkhQhelwON/fJZpPJKJNj3Cz5 gWFCFv8mRWxZzHEjH+L6Htb/iS2Kz+0It8UVcTcfnXzcbRyyfnBh5PGwZx05wdK4Zskc MLuZzd+cycDyKBSh5j9iTLbo5ZlH7L7JHRMvQbOtEcQu+QpEGJX28W/mGpjPDuA7nGwK xDeJ1c15asjtFa4jUFzKyfQ1orvTbjyADURPzHermwxI2OvH1+XJTdKICzd3fUMNILOh hT9w== X-Forwarded-Encrypted: i=1; AL+hErEmvN2C8gjVzsrNpSQ7PZldu4TIgah87nHojmGyxXs6K54Q3GQ1T9Ivk/QISb02AkHGrTzKX0k9oNY=@vger.kernel.org X-Gm-Message-State: AB4q+uEp7Natp3df86/LE2QsDsZx5DSHRfiKTSIIveQddYFzZ9MLwEBL VTx36i0vu1wLR5//dwbbISr7r+BOI5xhq4PXQ8py9hKQUwb5NTt3NE33vONwRWT6gg== X-Gm-Gg: AZFdTZfJ/uaqCJ31zbjrf1kU7Zt1Z+BJJzJeEpUuzekzbDtrrIltB2sNa9MNlgUD8D3 bWVROk79vqjzaOp/Sehrf5ODwCAA1DiNnV9Rl6r54ZDMVx4ehMITPiDmoEfYWU01+HZ46gAehzG Rtg45umIiUZ/GWsFmEYHuHw3vmrWXLbVWiLY69V3HAOd9SurO7nVGst8r+RM7LB9wgeSwjDGumw shHenVpbQ//3Dn1mPXJm0fj3xw9PATBRQnSh2cce16+02nyBMBOwNYczJpLCm5uwQ71USWoJJri csYDWMRvjDtgVT3+u93Dbveu17Uc5svi6ct2n+nC5Goay00AmNh5Uq6aehXO7CrgVSnrosozYhx 4Etg30a150EwdoB1Vcnd6dCYi7Aw75IOTfNpaR4FdrWxThKqw09dz7huI4eiyQNqksZT2LStrM9 8EbIt9wa2vAcuwUlOL+RQXaDtnZil+GJbZ+SMEzI8T9wLhkBRsiEZiqMhoLb6odGa8xIuCUf7rR L52ObVjaOJ8LOA+WnU7kz71W9tMSSdp7cUuFayf32XSO72W0t70iJujCqpNa6oFQrvYKiSF8H30 B4XPzw/oOQ7d3qK/CpMmc/rMjarJDjfYGu4C5pql6PFbR/+9rbdtbGVqbSSVdzYJ 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-pci@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?