From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.169 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796426359; b=iTarlybXNxC/xV6Ete+7AbLBWc6YHpC3cJ6wKc7H2tOLRxihpEgRDbYlEaNJgJNddJ5k hW45+oS4AKeP2W3IEflpAJrtBytQVRAtkzFLANAh9Hs2Oy2FW8nyQkGDKh1YRDZRh45Ab +k81h6ZBf6bID2oOW+g1bId6UHIGqkTp4ShaNSfOGmT8/Kaa8kKGgRobfmBg/XirWBG5j D/aggnvlBoi1HT9kdkHjBDy75QMTBIK1/fwsJ8vWrP8kYuN7hhJRFx0WQyozjeOH+DDu4 0o2kQnwhHRZyHX9OaIDSSFfhglIgtPnrfyJf6Fd3Yxj7asYq6pP2MpDYI7lITg1K8bQ== 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=BoZ7QwAi1Le15//hJyeESdCixLn3uh8XF+TELLDTSbjmpBVfEeU+P3lCu/6dfmT7NcNk 8AR7ySp5Xv6M2v5eXYDoP9ULLD/W7Iv47ARuPYOWaUzQoETzLLld9ZDFql0XpZv5dTHMr ARwsUagxtW7LsekCpzqmf2yLA2ClDasJbCdqBg7OJ0EJYa8eF0q5cV0U4z6nE66sZRfLx VpZTxQDFOQHLFdyybeGZbbOgTddz+RJ+DQpSFqW0FihWTqa990nlu0geCgq5vyGE0roTy 9mTuMANNZsr/6pS5pFTqiK2P2yYY87UBiU5qKf/270nXyKCUESNT0EFp/x/R+RIkUzw== 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.169 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 C2D38606A32C for ; Fri, 4 Dec 2026 23:19:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C2D38606A32C 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-f169.google.com with SMTP id d9443c01a7336-2f02f04a426so11133625ad.1 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=ZMRD2nQVq3znifMU8KRfz9KDs+YS/FZtHr3gOQWD1z3suyqrvcTnqCLtCVwNx5mCAV d4jNFEUmR3TcWbJYtfAa3angDYw/B2Pn9u0msQ3dsN16RZAaE2j/FCBrOMG+WDA5L6ET oHuuSfYoZ7q/iPi2K34wF52i1SBAKFheRz/uXBSsK98/TCb5vJEwN3W3xFsm1TV1LtP2 dK5bvBpUeYt2IVjUTS5fbs5GF4zJ+L8Erfgxd2Lb5ipFo766upRElteKeDutovUBovXb EWBX+O18IoPOL2VdymRYONqMV8vdRi5MAm8zPEaBYgkib1x/iyuh34phAGhkTCtw0zeE w0Vg== X-Forwarded-Encrypted: i=1; AL+hErG0mutc3S1itXfL34YA/ZhHWGp6rnT9GiURcI8AUcBI2uGu8rclXR57bGL8G9+9+GSE/2ooroCEHr4=@vger.kernel.org X-Gm-Message-State: AB4q+uHADdoKvOjrLoGIFJc8vvGSBHBBI3mRsox9FEvNML+oppeYmJ+f VtdyYiU7XdpM/EpywM/RPiIM1qs3gGTDJ46qF0EpBmnC62igm0kSEv/Ltu6v11lEHg== X-Gm-Gg: AZFdTZfeDTa0OyFbdgQuqvofcfZ49KC3Bphehh6NsOPF1A9mNDw/9X96NLf1btX/usJ 9ytZXc+4gPOD3R0Z7O51jJN+mGg2d9Kf45KAf/PEfR7k7moupuSdCfGUlWKqVvLLChnRSF88FaT VN2Or7k9A1fBNCH+LTQ+Nap05kt977R3OG/DaXGiLoJrFp970wIBtuI0YAUv/kailbCdINR2LTj yCjWm9kSk+pz4uUYk6mKoaJIWv2seTNbzqpcQwcYjRQakcpUuxZpY0Jhytt3VEl6SlVLXIz8+R1 VwWkU2kl1aAttusSOhuqkDlyUAf1lTqIRQuYNVgvGlSgUxU7Upwc1S9xivj595grMEEi/WbyD1Q nP5d9yRgE94sEiMy5+jUwv3yZjwo6qzK5yctLoiPOndMFh2h16qpOfq+SIxdhdtasJ3AoLBWGQ8 w8A9UuoC2BgKT8HNtSvoertofBDHTCC2M+UN6HbOWVkzKRL65ZIG94uCU79jwZiQp8dOUWbr18V 9CGPQe5TupKeOZBGuMb76PG9za19CfcuUB4bGZULYFMIvm2lnhH6EpfI1AqdsQa77nk3PmtjeX8 rLp/skSbzdHZWdiml3gij8ghRIgG1MTwiXtD73GLUekKrWw0UwU1guuLMF0m3jCD 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-doc@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.