Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp143188lqr; Wed, 5 Jun 2024 01:19:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWZ7hbpBvFtVDiduMuqRjziM4S7y9ip0tBBc9F6QSByyKr9bjMqhAqPuxYKgJKEkTay5FpNfVankN68o6v5lFmoMczasNHCIQ/lb3MzRQ== X-Google-Smtp-Source: AGHT+IF0lczpRwhIkPEe+IuegZaScb+r3PfaJsRZZpf2GFT6ET85Q45gS4Vn2blfJDeuG5OnwvdG X-Received: by 2002:ac2:4d9a:0:b0:52b:81de:1126 with SMTP id 2adb3069b0e04-52bab4f5e5bmr1162004e87.49.1717575551429; Wed, 05 Jun 2024 01:19:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717575551; cv=pass; d=google.com; s=arc-20160816; b=WkC1Xi8h6J3BlN68lJP2jkEZeRwUwZpR7dgd3hQJvPrLIr4Yb+0M2rIBkuDysjA/+f 9Gpidq1mHp3nV7lY4+/EHcYshlEV33/6tysrnQ0IvtZcuN+SIRUOxAEbuhnkXqT7l+nN Lgud8BiMt4S0QXHmm5mq5MBHAnNx4CfhIHcMsb/ktwQvDbe3nFXzsd8SLkd5QSpNuuyE H+BbuuiLuUbilJNs971lfbPZjlZZTeB6IzGNu+jgCwFbh/Pc2Kt40BjYFJha0j/g/YF2 7tHrmDkVEsjJn2YRHiCwF0AMs4dcvmgqYb81T6XvrmRs/2vX7KV+0bw0HKxqg6z0c1l3 U2gg== 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=ADSvqA1AO3nQbqjqWDmd4LNpBLOwxbzjerhA1UP/7Ik=; fh=KJIrl55XO+CYkh6ur3fQz5fHe1GSdUg5QMff5uqnbjg=; b=QLkNm2wNyEjYcLtgDsp+sRGbsPtiWd759tAnzCAnbTB9iQ2OHaPMg5XjRwbgdLWGwU XPDpejEyIsA8pxYQM22Z8duu42BoLl6rAGz6iR6/7O++jYzILZAinjRbGFyrFnKy/bGw DbMGkj4hsySTXuMZOc1HMwD3tLdW/XwtHVqVtt3LahBmPPbBcYqZ1E9pFRAkdCXqC+Tj Qa51i0CDI502Zm3bLHXVkP78hKYD1jGvcDVgaKg/0T2u4021rcSK9KDMTPEYNkVF6NIV A+045N6rSEsg55Dc4xMcVRGLkxQWsmG9A07Vr95gC4Ys8e49HJ7nGCRvryj42Jg9U54x TjTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Hgz8oD+R; 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-201962-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201962-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a85d49bc6si1296011a12.67.2024.06.05.01.19.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 01:19:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201962-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Hgz8oD+R; 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-201962-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201962-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 am.mirrors.kernel.org (Postfix) with ESMTPS id F0D5B1F226DC for ; Wed, 5 Jun 2024 08:19:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D6861922E7; Wed, 5 Jun 2024 08:16:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Hgz8oD+R" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 5083F190045 for ; Wed, 5 Jun 2024 08:16:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717575390; cv=none; b=ongRaisnr1Mf9mm4fSDJybPgJVP4YfQxLUec0xTREOO7nPshJ93W2ZvFM1VWdD9GATwVow6GshWB5XzRrx/6xdU2JYQxvcsR3HdkQCkpESfgUhDhSmdfjk6yt8fNWgcS//q2FvyitI8AaUFHBg/c/H2jpVssm/B6RpmL263W/Kc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717575390; c=relaxed/simple; bh=xl9J8hI645BO4dJlrgq+iFLF1dby15q/VE4JCvZfbaU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mGG9e6tKKJZCEp8sdk0lNsHX+X7HyIzKe8GMm4h8X9jIBBz5dpnBq4HS0VQlvercE9EBtSjilJU3dIO+zZiAjpi49iRZ9d+Hs6e7Lvvz0Q4vBjozahw0jE6GOJyM34d7u7oXRmukrhjVNZtKI7nW0BF94B3UbnTH4AKHq2UHUEc= 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=Hgz8oD+R; arc=none smtp.client-ip=170.10.133.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=1717575387; 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=ADSvqA1AO3nQbqjqWDmd4LNpBLOwxbzjerhA1UP/7Ik=; b=Hgz8oD+RKFLss3YnHpzDmPSc5vv5+/WVDTilLt7g3rQSNZqlaYeYhRxbIvWBxqkdlasgd1 lVN+aBGrUTqmx6W2D/L39w/34MOejhepJwv0RCTqqJ93S5IonqMX077q+trBs1F8eYWv1L JUgZ3W0RRdtrot10gNWrwXY9e9fa1Qw= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-176-0wnIqw-RPguA2OqWd-f6vg-1; Wed, 05 Jun 2024 04:16:25 -0400 X-MC-Unique: 0wnIqw-RPguA2OqWd-f6vg-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-354dfd4971dso300787f8f.0 for ; Wed, 05 Jun 2024 01:16:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717575384; x=1718180184; 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=ADSvqA1AO3nQbqjqWDmd4LNpBLOwxbzjerhA1UP/7Ik=; b=DVXrhv1GXuo64GkdAzGS/tpEGmPq5HRJHvOg/VB9reXl5Q+ZfYFQwUmovtuvw6Gb5L PtqrMw5xXzIPPJRmF2wpUGupwOAZkYlN8n4lkhPL7gSeom69mhEjJPQBGFc0DJ6ILjG/ bk8wekuflUQaDQvbjZuuZKSYHci43/9n4mcTzOMsTQpuLEPqP59jgiwKzVmolm201UEe W0oONtk9+Z1g2VAUvN3TO61sf4hQSQirdc9vHnYqmP8PeXVgPB6tKMFD8L2AmZuw48TQ HKFvO37EGQE91LQwk6Ot46JL5cJqzf+IzJZGMtvOAuM4YG6SpJR5vHDOyUy7+sOjl/8W jgTA== X-Forwarded-Encrypted: i=1; AJvYcCWHd5MWAiLMFdgHa6DCF3rnuiw8sJVrtLDN+cL/vk9cQLAIYD225Y4DggEYLIrz9rKaL2Sl86jFOzTWuW8pWTUY8pLK4xoNBqSs6mj+ X-Gm-Message-State: AOJu0YzvtY9odMIEmrveY0D5iGXFQ5nSZbVAKr/UXv8W1ehA9SV6kmJa CT10FT2zGVx9R+7DIkUq9jomyYrroi4Uik/V9LRIUJ4e1KpxmTYoMi5Uxlfxa13zWoePrnBXe/f FSvCts/4gHw3rk0XMdzVfGfk/FuK9HUD6arEIkWgYicTlGU2e4kyJ3IWtRlQgtw== X-Received: by 2002:a5d:4a8f:0:b0:354:fa0d:1423 with SMTP id ffacd0b85a97d-35e840559afmr1138376f8f.2.1717575384546; Wed, 05 Jun 2024 01:16:24 -0700 (PDT) X-Received: by 2002:a5d:4a8f:0:b0:354:fa0d:1423 with SMTP id ffacd0b85a97d-35e840559afmr1138356f8f.2.1717575384289; Wed, 05 Jun 2024 01:16:24 -0700 (PDT) Received: from pstanner-thinkpadt14sgen1.fritz.box ([2001:9e8:32e6:e600:c901:4daf:2476:80ad]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd0630010sm13739163f8f.76.2024.06.05.01.16.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 01:16:23 -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 v7 08/13] PCI: Move pinned status bit to struct pci_dev Date: Wed, 5 Jun 2024 10:16:00 +0200 Message-ID: <20240605081605.18769-10-pstanner@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240605081605.18769-2-pstanner@redhat.com> References: <20240605081605.18769-2-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 | 5 +++-- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c index ea590caf8995..936369face4b 100644 --- a/drivers/pci/devres.c +++ b/drivers/pci/devres.c @@ -398,7 +398,7 @@ static void pcim_release(struct device *gendev, void *res) if (this->restore_intx) pci_intx(dev, this->orig_intx); - if (!this->pinned) + if (!dev->pinned) pci_disable_device(dev); } @@ -454,18 +454,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 || !pdev->enabled); - 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 e223e0f7dada..ff439dd05200 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -823,7 +823,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 110548f00b3b..3104c0238a42 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -367,11 +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 enabled:1; /* Whether this dev is enabled */ - 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