Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp241130lqp; Mon, 10 Jun 2024 02:34:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW4fAdwAmBYwrRzOo5j4w0PXe1Gur/VFOy1H8DEQaJl9WR3ZJKj47Hk1okuCxe0hsdyk/ugMsJjtaF79ISASMaZ9MtolNRtWRnQZXUlFQ== X-Google-Smtp-Source: AGHT+IGe3LYMwArHBAhVvkcIGCU39Y0HDT2usUnLzy3UDYcru+kXEudUIvwU7UTQ7nKgT6GKUNRJ X-Received: by 2002:a17:902:f68c:b0:1f7:167d:e289 with SMTP id d9443c01a7336-1f7167deb3fmr30459895ad.55.1718012087254; Mon, 10 Jun 2024 02:34:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718012087; cv=pass; d=google.com; s=arc-20160816; b=GsexOS7AUc94QO8c0YUI0F9O3V1JCJAix8FCvnAjz93EPeldO0Pu0TeFeirfjpb1hn 2CSe+kxIIMKQGYL/v4QCER2itg6XnwZ99AY9NbCaVm3xbD7XbLM2nV9qEuNG/bt1P9rN xjzhJuZxbiZYf+p3t9PH53HXGZfbAk33PuvoHRofGxTgnZyQcnvlFRsa99R7Rc0sVfJr QoASaATmR/oJ/+HLXsf1BGjakqBCfBah/uUVEvdUnCzQltovcmVUylM30OzSet0hwIr/ SU/0q845HMFq4vRIpYYW48tEnpa4L3NcHXGbnpMrIY6yOJZHyiTIj3ERF1/0z6TULUcY vE0Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=YC1P2jDfqZ/b0bhQ66lkvDoa/VkJd5IY0GIkzmrgRyA=; fh=HuNacB59YoYRG8im1h672cKDPUUVF0BuRZCBtpYhwxs=; b=sV62BY/BCVsRK1GHe56ctrEo5AlxUkCHkB04gxP4FiRUaawht0mzCJeXvKM2cZ6phy 5Hpl/G04yizQmTXJJZ4FucH/O3FSN9DCYGvCf/l8hRrbg8/DreCp6RSSnuQkX5P+d6/X 2+KAV2zQG4mQMLBCV8ZqR9EoAFTb2tAgFPmBP8UBDpnVhzFTPCMNhNV0Ga9YSOVItB8k f3Tx3vlx7kqebt1ABwXIM8b9MniYViZQ/PbMfzIWW8i5NNAllo57kWHVRyzbw/ns8Myk 0ZiBQ3JFOodRNeowtvXMFgp9smbJkWYvXkAyFcwli7keOQyNpZScNYOxJpeoA58fT+I0 srBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Dn7L1JqD; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-207945-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207945-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f71bed7d62si6072555ad.495.2024.06.10.02.34.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 02:34:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207945-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Dn7L1JqD; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-207945-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207945-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EE02E2874B1 for ; Mon, 10 Jun 2024 09:33:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 32C477BAF4; Mon, 10 Jun 2024 09:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Dn7L1JqD" 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 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-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: 8bit 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 *res) if (this->restore_intx) pci_intx(dev, this->orig_intx); - if (pci_is_enabled(dev) && !this->pinned) + if (pci_is_enabled(dev) && !dev->pinned) pci_disable_device(dev); } @@ -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 = find_pci_dr(pdev); - WARN_ON(!dr || !pci_is_enabled(pdev)); - if (dr) - dr->pinned = 1; + pdev->pinned = true; } EXPORT_SYMBOL(pcim_pin_device); 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(struct 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 */ -- 2.45.0