From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796426359; b=NcOx/Yn5Tc4JSzE0ldSXO9W5YPrCc+k/L/g2zrs0uTaB8p0nOy5z9uRkgM6lBI8kOf/v B7rijV81XLgJpBF3q26SOyx8w+T7USa0rQoox32lvmb6vBTKCumpiBBCJ1IHNmNW5Rm4p 8LBLh0RZFkyxsHuHh29IhFxGgfdlb6ZIRQ2qJqyjlSDsDzo2bPY9wSor1oSy9C3lBUprZ BjXCet0+vCgyRlH1s1Lvcr9IWZxIPobdIdw9gU4RMZSoaSOYto4C/GZs4sgD2oW0/2dR7 kp+0tmeuuit+DljxNjXxA589ssXNuyQoO1C/ygl8nkcSrsY9ikq9ajTIGdc4K2pBr1Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796426359; 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: Cc:Subject:From:To:X-Mailer:References:In-Reply-To; bh=BU9jcQblcKB2wLI25o/UXrd5D8l9ELFkIu4EJD24G3A=; b=tIMRpzIlrd5eDyOVRsCKKB4mAdn934OM1ChY4NxwdkZJ7roK8SDTZcjzJdw0fGswJkZd 6Xx4QTooSajptClpo0q+zrfXsavd+OLu6bCtc9qntziKAv4Yd7ASK4A7fpaF5FwwcXWLO 5Y4NkKZTP1ojht3Me/5q71LHPHVSax19MXHqiJmyOGfqkuLG6mn0XCis6FqS2vs7JP6zh eAqre80kT5R6PFP1lhofPk0jGPIt3MxAdhBxUwiFV/OeWAwsDTwXxCnNJj64rVHoukuhu AJvDcrW3kmxCu3FZkF5aCXRbO7i+Yq8hgCjmlvqYea50OMxF5NIj+eqMiOSIMEWyncw== 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=OyLx4jth; arc=none smtp.remote-ip=209.85.214.172 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 C2982606A322 for ; Fri, 4 Dec 2026 23:19:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C2982606A322 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=OyLx4jth Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2f037bc348dso10837795ad.0 for ; Fri, 04 Dec 2026 15:19:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796426358; x=1797031158; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-type:content-transfer-encoding:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=BU9jcQblcKB2wLI25o/UXrd5D8l9ELFkIu4EJD24G3A=; b=OyLx4jthb24GQsF3Ns6ariPkPOYACaA2X+Ggenfrshyjj/KDCyPIDmnLtg430oN18v X3oj0D+yPmN+/8/QpOvtlaOiolxrhjCctomGBFLzu+LBl77vlnnlCNobcweiMi6uRECo pyAdQAaOl5vzjh3fMNUCkP/FoBaf9r6IAB/5kjuFCd3W534mtk5jwmQtuLKnUKYuJIbL zyLqWHN07wrqdH56BdKj3xWy4LaRC/QkQgtjV2HK0mNnmRcAWtwEumoMnXfqaJTiu10w AZfW020nBYYRocz9YJ8eC/f2GNmZ0l3H63eb4KD7nDSACR3xVPSGv7mne60Q6uuryFm1 m3Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796426358; x=1797031158; h=in-reply-to:references:to:from:subject:cc: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=BU9jcQblcKB2wLI25o/UXrd5D8l9ELFkIu4EJD24G3A=; b=quh8se+Wb+vykJd2VcbZ7A5m9quZDeR4Jy1cIWc5XdSee/kn4r3DOq+co/YkYslAEI TrcQBcxZ0vnkhowpVc1AH7aVLt7Patzc/V68O21w86n5L1lpf007pvbZOfiiPxfv5thU Uu9CmpWKxmZFYV8L+QT/0povFRxbWZcQrYnqbaTK5pVzh744gD9AzGId8YgbeENwbBJ0 4ulS+k/aiskntNPDJoci8r+C8RrHsVcmCWdhtFVfYLvExRiIUrWg5xNAOrMHSHeSqwvC oH5PSkkB24FoedPocQ4XEZcNasEDv9f8e6HPNzSIbEd+L0dcagUhV/xU49KLEYpvweyR IN+A== X-Forwarded-Encrypted: i=1; AL+hErEYHZ1ybpuVX6NSCPxuuSGvcxxzvBySsZ+GsOkaff//mSiUENQReS49wP2QtMcl9U/X7dHDG6adsrhxc6E=@vger.kernel.org X-Gm-Message-State: AB4q+uEx2eHqCV9md4206wos7zAah4Coflvn9bv/BBqut+z2FNrxJnTs Ql/8TF99AJX5sNaiVL0CD1OcxfcW8QL+9Ih2em9hpp+aKHG9ILN0gS7dB1TRNMImFw== X-Gm-Gg: AZFdTZdOyxPPbtRLjk1gK1Kd2/Aa7wQ6gDP7/kzDiJgENvh8yIOYQWxe9oQobm2XO+0 5ZOKfdxv5beE3xdrWFsgiprJxIWNaEUDz35AnTSiH41byhRYczpbIyJtRNzEi5k6ufNce3fPMtd ZHdKs+ABCzkTwHS3Ffe692NVT8a69kIETdY7gKvESKe4KfKgoNuFBCpV3YGiN298xzsGEkgvzr6 rYSOH7rc7e5c7E2xQswQbXSMsuxFzyR15VhulKOeYs7UA8XqN7KcMf5vlgoMBve17atyxJ7tWui B+fEPmgcePAbYPoU2bBdzNPll8MlQQhY1w0aRVJ+I7NRIfBmnLvW3/5eoVfWtadpIsfPGsEqMtg fBjaE8rb5s0vXP52lIjexfOPF6exKK/aRva/XXOBs60UBpj/eYZ0za/hoLLSy1M/+mL34+MMi9v VQXMYzDADToENAI87fGGJvvyi70dO28GqdLitwtOl7UOMCbgUXXigGCTsaNi75U34prQ5KfA+st f70Y6Vh1Lg34n/tH7/ZUArFRRwrfh23mDAKvzK3lamCZ6jQ/vWkhpNK+8GpQMaJnh/AzYcwrbn3 E2VjGeY/q/e4gjhyOitd6+5QeIXeNAgnNSWllT5yXuDbihrkMvRbExJfamFVed63 X-Received: by 2002:a17:903:9cf:b0:2ef:dc24:c71f with SMTP id d9443c01a7336-2f1ba22acfcmr32820355ad.56.1796426357407; Fri, 04 Dec 2026 15:19:17 -0800 (PST) Received: from localhost (33.79.127.34.bc.googleusercontent.com. [34.127.79.33]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f1b793f321sm19387825ad.46.2026.12.04.15.19.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Dec 2026 15:19:16 -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:19:16 -0800 Message-Id: Cc: , , , , , , "Alexander Graf" , "Alex Williamson" , "Bjorn Helgaas" , "Jason Gunthorpe" , "Jonathan Corbet" , "Josh Hilke" , "Mahesh J Salgaonkar" , "Mike Rapoport" , "Oliver O'Halloran" , "Pasha Tatashin" , "Pratyush Yadav" , "Randy Dunlap" , "Samiullah Khawaja" , "Shuah Khan" , "Vipin Sharma" Subject: Re: [PATCH v2 02/17] PCI: Add an offset-indexed store for saved capability registers From: "David Matlack" To: "Lukas Wunner" , "David Matlack" X-Mailer: aerc 0.21.0 References: <20261106004218.604799-1-dmatlack@google.com> <20261106004218.604799-3-dmatlack@google.com> In-Reply-To: On Fri Dec 4, 2026 at 4:17 AM PST, Lukas Wunner wrote: > On Fri, Nov 06, 2026 at 12:42:03AM +0000, David Matlack wrote: >> Embed the bitmap in struct pci_dev rather than allocating it. Every >> device needs one during enumeration, so allocating it separately saves >> nothing and only adds a failure path that every caller has to tolerate. >> The values remain the one allocation, since their number is not known >> until enumeration is complete. > > Pardon for being dense, but I don't understand the last sentence > in that paragraph at all. Oof, that sentence is terrible :) I meant to say that the memory that holds the saved capability register values in the store is still dynamically allocated, since the amount of memory needed isn't known until pci_init_capabilities(). >> +++ b/include/linux/pci.h >> @@ -334,6 +334,35 @@ struct pci_vpd { >> u8 cap; >> }; >> =20 >> +/* >> + * Reservations are tracked for the largest configuration space a devic= e can >> + * have, since quirks can still change pci_dev.cfg_size after the devic= e has >> + * been enumerated. >> + */ >> +#define PCI_CFG_SPACE_EXP_DWORDS (PCI_CFG_SPACE_EXP_SIZE / sizeof(u32)) > [...] >> + unsigned long dword_map[BITS_TO_LONGS(PCI_CFG_SPACE_EXP_DWORDS)]; >> +}; >> + >> struct irq_affinity; >> struct pcie_bwctrl_data; >> struct pcie_link_state; >> @@ -521,6 +550,7 @@ struct pci_dev { >> spinlock_t pcie_cap_lock; /* Protects RMW ops in capability accessors= */ >> u32 saved_config_space[16]; /* Config space saved at suspend time */ >> struct hlist_head saved_cap_space; >> + struct pci_saved_caps saved_caps; /* Saved capability registers */ > > A few thoughts: > > * The first 64 bytes of config space (the Type 0 or Type 1 Configuration > Space Header) are already stored in saved_config_space[]. > Yet saved_caps allocates bits for those dwords. It would be nice > to replace saved_config_space[] with the new store for consistency > and to avoid wasting those bits in saved_caps. Agreed, I'll do that in v3. And I'll keep it embedded so that it's guaranteed to exist like today. Since the store will no longer hold only capability registers, I'll also rename it, e.g. to struct pci_saved_config and saved-config.c. > * Conventional PCI and PCI-X Mode 1 devices only have 256 bytes of > config space. Can we somehow avoid allocating the extra > (4096 - 256) / 4 =3D 960 bits =3D 120 bytes? Or do you think that's > not worth it? If you think it's not worth it, maybe document that > design decision in the commit message? Yes, I think we can. Looking at it again, the comment above is wrong: the quirks that change cfg_size are all early or header fixups, which run before pci_init_capabilities(). So in v3 I'll allocate the bitmap there, sized by cfg_size, instead of embedding it in struct pci_dev. If the allocation fails, the device just ends up with no saved capability state, the same as when allocating the values fails today, and the header is still saved since it stays embedded.