From patchwork Mon Apr 8 08:44:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Stanner X-Patchwork-Id: 13620802 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2C645CD1292 for ; Mon, 8 Apr 2024 08:45:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 851C61122C1; Mon, 8 Apr 2024 08:45:00 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="WQ2EQaNI"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 199C41122C3 for ; Mon, 8 Apr 2024 08:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712565893; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cfte4b3wPijsP9MEYyJuLZ+mSeCcAqIklzESx/bINtI=; b=WQ2EQaNIa5H9FeFghVKeqdZ+nwOSQExZj1EEP961MheG7Ldgmtpd456oqE8qPVBiHTKeXd R1Xv2xbXh8HRzbb7ZR50MDNcx9Pd6LlR+Apv88IRxKv6dhmhz3wbjzkuau/FfB/ZZGJkjB irATCKNsNyRPYxprOhyMDwoIFDTV1Oo= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-462-mT4UXmN6PLOHFpFqugIt2g-1; Mon, 08 Apr 2024 04:44:42 -0400 X-MC-Unique: mT4UXmN6PLOHFpFqugIt2g-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-78d670996e4so2635585a.1 for ; Mon, 08 Apr 2024 01:44:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712565882; x=1713170682; 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=cfte4b3wPijsP9MEYyJuLZ+mSeCcAqIklzESx/bINtI=; b=gM3nxx+XVnOnGIh51JpMtfoMV8wdVIaRLA506oAFAC68tt+mbcij4b8Vwsg9s+RGoS 3HvMA++VvhsPqNoWCmNY2EYWIuscPvLKNowdHEXNeu0EH5OmJ8lSSMfccT9iI1QnLWL+ +qV5Az+0V7hPtsZWoa6tvtBxYl6466UUJEjk0RRp7oipiJbSDNJLqEjQ1bFGJbuo1E1D rNB3jTG+YRaNBs7EQ3WqmdENE0u1qnQOLW9u6Iza/msPFrZsYpHWJ3+qb9iyMdzqx7Df Yns+TYDLJLI6RmN20opPLa55ZqvPWzOtjE71KkRzT93gr9bmy+nYKbUdzgtbcAjn8ZSk Hp/Q== X-Gm-Message-State: AOJu0YzPkYvUj1jF0XSZtpYJEkwG15bzl9Wpw1BXouQkNRioAveSLKzw 8x4vjY+j7B0u3XuBhQDpV/GM77kIWeqK5wwRO1XHFBYfXPIJ1KSL9w8NfH87/X0zNNWhJejt2CE PUXNvujCxAJ8rmm/TFw5ay5Idg8aBunMY4gqPYQlK8gL3rzx6drltgPL8OZQQoGTFBA== X-Received: by 2002:a05:620a:450e:b0:78b:ea64:e0fa with SMTP id t14-20020a05620a450e00b0078bea64e0famr9523807qkp.4.1712565881742; Mon, 08 Apr 2024 01:44:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3mwwm/R12WcmH2kE9iBLa1vhhd3RLItPquJFca7C9FUCjE4MBkJwpaP0CUP/2AT65JzFDBQ== X-Received: by 2002:a05:620a:450e:b0:78b:ea64:e0fa with SMTP id t14-20020a05620a450e00b0078bea64e0famr9523787qkp.4.1712565881410; Mon, 08 Apr 2024 01:44:41 -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 oo15-20020a05620a530f00b0078d54e39f6csm2036989qkn.23.2024.04.08.01.44.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 01:44:41 -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 v6 06/10] PCI: Move pinned status bit to struct pci_dev Date: Mon, 8 Apr 2024 10:44:18 +0200 Message-ID: <20240408084423.6697-7-pstanner@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408084423.6697-1-pstanner@redhat.com> References: <20240408084423.6697-1-pstanner@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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, because it allows for checking that device's pinned-status directly through 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 623e27aea2b1..fb9e4ab6bcfe 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 (!this->pinned) + if (!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 || !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 2b6c0df133bf..a080efd69e85 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 95cdd1bc73c4..9d85d2181083 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 */