From nobody Thu Feb 12 19:02:59 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D9B6745F4 for ; Mon, 10 Jun 2024 09:32:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718011933; cv=none; b=sloErZp+qmCEiD+oE37DLXdTLjsMIRZH5tEiItcHrfaS7wIn3mG5lpSAynOEPexv02ptwyl02pRyXlEVueAX5wGo7U1HjZWHC+qgt+FgJOvJZvazLAGUpOQWA0OMDmqedkRe6qZh7tbfh6frdktfXxpVE6OCekSuYV8YSIIPg/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718011933; c=relaxed/simple; bh=JZ0qVkY2AySl55GbKU4MmbsmlZou/0KAge/Bt6uyTGY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZOpc6/E3OnpV3XAc4LwfcMxCmNSmcTnfocohJRzSdq1bcPKnYSAwcYwMXhZ0Z62t7MdtNtk/z7OSsCHibDD6cv6KS0q9M4TeUlHF2XnR7jN5lKm8X/TuZLq4U3iCCrz8qa6/oQ9or9Tk0sgfEjlRx1WT+VxzEiJkv1p0IqwP7hI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Dn7L1JqD; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Dn7L1JqD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718011930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YC1P2jDfqZ/b0bhQ66lkvDoa/VkJd5IY0GIkzmrgRyA=; b=Dn7L1JqDp3+Q4JxSXAAabidSnjVOSlTRBd5w7JxvSSxauJjB/xKyPaCEQYb05AD0Ihd+oM h9fBQACMHmtTmjWUJd6aPyzOTlyp/IqUh/4whHWHNHpRaoSMgULzS0dC9goSpvcBF7j2cM +1dvotHuNiBFMTDLVJyosebP6HbvjCY= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-OAHgm70cNDW_DAj3mbtYww-1; Mon, 10 Jun 2024 05:32:09 -0400 X-MC-Unique: OAHgm70cNDW_DAj3mbtYww-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-42180ddc0b9so1691965e9.0 for ; Mon, 10 Jun 2024 02:32:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718011928; x=1718616728; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YC1P2jDfqZ/b0bhQ66lkvDoa/VkJd5IY0GIkzmrgRyA=; b=iFVWsBBPXo3oCMkOJY6SRTOX5mfeFBlkTkYrqFU2aR4y2UXUiuAU2DAQMf4KQRZAaq KCwDSlfb/encqNtzvADaTCU+cSkCQho8g5bvZQYtmnE7iu/tBGtLAy+zS+AVhWz71YvO w1dvy7Fa5VNWLmm97sTNKGDGZPZWxNsDmvwFYm48lNo3+81x5ijxcX9viYwx1GXKZBQD mMd396RFFaokA0Et2fHmnrZnYHe8zCqIZPbFge2y047bgtN3oqitpH5Enz6vuBaKWsZR j49KVf1vk6wCEi5PHXDuwemeU4v50Ub3ao3sg7Dm9cNHC6VRWxJQiKvH/02Ta2sZC434 9c1Q== X-Forwarded-Encrypted: i=1; AJvYcCU7WoKAef7f504klwzEhPP+/j991kZ7ByYi8dPkMBSJXsnvKcsq8chnSBClS28hp2iSq5B+fMEkm77FE53AKkTqrxobUtlsmJULVKLw X-Gm-Message-State: AOJu0YwXkM6PR9eLnfYzPLqbS9Gct7OO6SbmRZsHrfwIn7NPTcYD5LKc LDq2pQL6Ai1YR+6EETPd83fpfW+1RjvVEjV0s4r0IUjgXzeq99ArDYxDCwt5/V1scGoHlVxzmL+ 8pvemluI7L7J/1yCOmKmSNprCKuZ23iZZxzm7CwE42uXNGXZnJ8Ti8VtZMQ/01Q== X-Received: by 2002:a5d:6c65:0:b0:354:fa7d:dcf5 with SMTP id ffacd0b85a97d-35efea7e189mr6469036f8f.0.1718011928180; Mon, 10 Jun 2024 02:32:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHVJwLx4/C+jduwDhQw/dzOe6oYBT02eJHjQK+Qoax/SQHHf7G+cPrhRcc8vOfgRdZ1mMl4TQ== X-Received: by 2002:a5d:6c65:0:b0:354:fa7d:dcf5 with SMTP id ffacd0b85a97d-35efea7e189mr6469015f8f.0.1718011927762; Mon, 10 Jun 2024 02:32:07 -0700 (PDT) Received: from pstanner-thinkpadt14sgen1.muc.redhat.com (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35f0ce4b62fsm7257545f8f.80.2024.06.10.02.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 02:32:07 -0700 (PDT) From: Philipp Stanner To: Hans de Goede , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Bjorn Helgaas , Sam Ravnborg , dakr@redhat.com Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Philipp Stanner Subject: [PATCH v8 08/13] PCI: Move pinned status bit to struct pci_dev Date: Mon, 10 Jun 2024 11:31:30 +0200 Message-ID: <20240610093149.20640-9-pstanner@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240610093149.20640-1-pstanner@redhat.com> References: <20240610093149.20640-1-pstanner@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The bit describing whether the PCI device is currently pinned is stored in struct pci_devres. To clean up and simplify the PCI devres API, it's better if this information is stored in struct pci_dev. This will later permit simplifying pcim_enable_device(). Move the 'pinned' boolean bit to struct pci_dev. Restructure bits in struct pci_dev so the pm / pme fields are next to each other. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 14 ++++---------- drivers/pci/pci.h | 1 - include/linux/pci.h | 4 +++- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c index 9d25940ce260..2696baef5c2c 100644 --- a/drivers/pci/devres.c +++ b/drivers/pci/devres.c @@ -403,7 +403,7 @@ static void pcim_release(struct device *gendev, void *r= es) if (this->restore_intx) pci_intx(dev, this->orig_intx); =20 - if (pci_is_enabled(dev) && !this->pinned) + if (pci_is_enabled(dev) && !dev->pinned) pci_disable_device(dev); } =20 @@ -459,18 +459,12 @@ EXPORT_SYMBOL(pcim_enable_device); * pcim_pin_device - Pin managed PCI device * @pdev: PCI device to pin * - * Pin managed PCI device @pdev. Pinned device won't be disabled on - * driver detach. @pdev must have been enabled with - * pcim_enable_device(). + * Pin managed PCI device @pdev. Pinned device won't be disabled on driver + * detach. @pdev must have been enabled with pcim_enable_device(). */ void pcim_pin_device(struct pci_dev *pdev) { - struct pci_devres *dr; - - dr =3D find_pci_dr(pdev); - WARN_ON(!dr || !pci_is_enabled(pdev)); - if (dr) - dr->pinned =3D 1; + pdev->pinned =3D true; } EXPORT_SYMBOL(pcim_pin_device); =20 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index d7f00b43b098..6e02ba1b5947 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -821,7 +821,6 @@ static inline pci_power_t mid_pci_get_power_state(struc= t pci_dev *pdev) * then remove them from here. */ struct pci_devres { - unsigned int pinned:1; unsigned int orig_intx:1; unsigned int restore_intx:1; unsigned int mwi:1; diff --git a/include/linux/pci.h b/include/linux/pci.h index fb004fd4e889..cc9247f78158 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -367,10 +367,12 @@ struct pci_dev { this is D0-D3, D0 being fully functional, and D3 being off. */ u8 pm_cap; /* PM capability offset */ - unsigned int imm_ready:1; /* Supports Immediate Readiness */ unsigned int pme_support:5; /* Bitmask of states from which PME# can be generated */ unsigned int pme_poll:1; /* Poll device's PME status bit */ + unsigned int enabled:1; /* Whether this dev is enabled */ + unsigned int pinned:1; /* Whether this dev is pinned */ + unsigned int imm_ready:1; /* Supports Immediate Readiness */ unsigned int d1_support:1; /* Low power state D1 is supported */ unsigned int d2_support:1; /* Low power state D2 is supported */ unsigned int no_d1d2:1; /* D1 and D2 are forbidden */ --=20 2.45.0