From patchwork Fri Mar 1 11:29:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Stanner X-Patchwork-Id: 208810 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp1016939dyb; Fri, 1 Mar 2024 03:41:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV+r17C1yINNd/Ux68G1Hn7R1QHPi52Vug6dCGHSSau2m9NcyyRyQmMeU15kQLJxDx5PQKnW/4B2FPtqwZdBFoCZF5rUQ== X-Google-Smtp-Source: AGHT+IG/aeaXCl8zdn2Fijur7xVkQPFk12Cyux0zRQUzkD/1aXc/Sy5FCZz2e6uSNsm0n9f7Zk/0 X-Received: by 2002:a05:6a00:27a0:b0:6e5:584d:e511 with SMTP id bd32-20020a056a0027a000b006e5584de511mr1608107pfb.17.1709293307843; Fri, 01 Mar 2024 03:41:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709293307; cv=pass; d=google.com; s=arc-20160816; b=iChjxzTep68MzeK2sPZr20hg+Oc94TyuuLFe6DWurQEKeCNpO/iQbXuN602wBg3unV c5g8JsRsiqcxZgdjWxS3rVOitAudB3Zes/0t3eBM4EJKz4z/ArsG9EecUsicgLcPUluw rV3LY8qcqEHtOchQC+rvlHlLvoO5VlRYY7XsFnk7jUMwx8Z2XDTnALyj5QYxBg0F4P1h r8s7fyHQlN8iHYKyx1k4RyU1zv/ADM6T8NIt1v8xPqZ8x/zMJihJ8qHs+t0J04QngZWD TChRRSRLH9g5tToiQfueJuOLNWeq6NSf4143go8zJqBJjBEf81u+rQ96kOjImxL4EPWO YOdw== 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=ivdu8iiMoXpDkyzYV+DyKD6eGNB0PhvUs/32A1olwX8=; fh=y+OmJQHmMNsvWt/COTcnw8HYcgDX/CKLeVlVoTXwAac=; b=KvKUjolJNtU1Bg7DfJ+78MgrDJZ7qsYe8SFG1h3JnmxGn81m+yJ5yMVupSwZ+bb2Yz 9Or6YsbTGcKr/+SLHLZx4mSb1phV1Fhua0tOoZLOmN8QEZS/Hp1Vo7d++pp4LEzkru/F 4P814zJ5TGkHBcjekx+n5S8JmGAbdZRDHrUQ9ExcHoBpPPDT/clnKkKPU6nI32kMmQWx wjLif+Fu3efwumPttC02Xe1QGttwGBUhV+ZxLJeFmes7xjfXybqAuRL6AolPPEU/EuK7 2z4zJodfH45jSs6TLUNyU0T3t3s5HjwkIOb8q9U0UVNUDhenC0cOtmkYmttroRpiiW9Q Vuow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hYBECC5y; 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-88350-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88350-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e16-20020a635010000000b005dbcff42ee2si3359921pgb.536.2024.03.01.03.41.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 03:41:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88350-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hYBECC5y; 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-88350-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88350-ouuuleilei=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 9EF1128A081 for ; Fri, 1 Mar 2024 11:32:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E3A56F08A; Fri, 1 Mar 2024 11:30:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hYBECC5y" 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 583956E60B for ; Fri, 1 Mar 2024 11:30:25 +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=1709292627; cv=none; b=Cao/I7XUWCd4idlEDCRhLM0QBLoR1u8T/+axKMN11pnXdnU06jXkda7gLb+POwpaGOi6XG4ev6NwM4K+lCc4wYs7HD1gIqgycbWivEDOsJDrcQyMsuUfw6MuKrJ8n7/kmKjgmGRayRHmCbARJcb5ZmoYLpQ6StZNqSQ9AnFaT9Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709292627; c=relaxed/simple; bh=FDNHRtLE6hNHjH2r39UrBWAZWNGYNFSj11RRKynJczI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SG0y/TiT7Crt4tUEQCG+kzCrsTrlLDmxxCH3sUW1kV5OSBqcep303vGf6QX0ZNnBOoOPKAjmFa4oqIv5qmIriK90Xgju7jTfwD9pBr4qp8KEzTB7gv1ffQhEP/nRM/PWGYIrIejkbS8dJole9M3RmJ71SWzO1YiLeFuuKV3pdiE= 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=hYBECC5y; 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=1709292624; 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=ivdu8iiMoXpDkyzYV+DyKD6eGNB0PhvUs/32A1olwX8=; b=hYBECC5y47gKaTfp76/fyMWM/1w5jnTzIp3C2ObD/YhiRsSRo2BCbv1bkfOwDPCM7uB5p/ qR245levPb96xEjX8SZyw2EsS0skM0RGB3D642UYEyrPD4LEFIRvV/B/AgM0vpubdL0/p4 u63zD5xBBdkwhGj8Kw6r25pcIcwToAs= Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-IrlbSC6RNu2Myrql8Fomiw-1; Fri, 01 Mar 2024 06:30:23 -0500 X-MC-Unique: IrlbSC6RNu2Myrql8Fomiw-1 Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-3c1d23a5a67so44277b6e.0 for ; Fri, 01 Mar 2024 03:30:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709292622; x=1709897422; 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=ivdu8iiMoXpDkyzYV+DyKD6eGNB0PhvUs/32A1olwX8=; b=U8HFiJUoTDF3EnfXcPPirBngFacBL2UAEvWh7nOTHPWhie4S3e5NedXzOs6oHmNBW/ XST6afoNJEqw0Bob/HnZ9Gj/UlRwMtSzVE0z0kMTwEOkmn8pJo7gyIv5xLvptX2kpDGH LnlEpsVwHfp8bXlzBjsS65z+4E3U7kzgcF6yMuxy02o642PXJdXO0StjKiB2uWfbSSvL 0kAB9oCpVQZmOhOrSByLgEWP0e5/BYOaYb1Yy0QOSrTbG3MQ76IkWcObJiIdFtPdF3m1 vwGLttlGZ2onrcEY5rZzRe7zZZ18c0Gob7IDk35LxtaWzmeKzdzMTmgm2zyew5ezBrx0 l3Tw== X-Forwarded-Encrypted: i=1; AJvYcCVBefBZ7UUr2ZH4uuNZkHYg7/VcQf7oBZ4Y56u3ejAv9p4g7/87qgKzHyj6+wQcKjVjfoqVZS+YY8MJ5e54w0u+VuPM4ukeCvNtwE3L X-Gm-Message-State: AOJu0YxXf6VmL84/N+d9uq41pAyvtL1UEBeRRzXpe2lL4U9jM+eIqmGL NjWYs9FTqNc4ftKkfv4ye4TyDqNZ40+oWPBzIlTAuoY5SPKXpWdr3d/KaGe4dCgKLPxy29hkd76 eCdUkDKMcxspRUyPjbltFUai+vwt+PWeX93KQO6HFd8OI7hK1emJrg1TnD/ixUQ== X-Received: by 2002:a05:6870:1b89:b0:21e:be91:ae48 with SMTP id hm9-20020a0568701b8900b0021ebe91ae48mr1406127oab.1.1709292622691; Fri, 01 Mar 2024 03:30:22 -0800 (PST) X-Received: by 2002:a05:6870:1b89:b0:21e:be91:ae48 with SMTP id hm9-20020a0568701b8900b0021ebe91ae48mr1406108oab.1.1709292622384; Fri, 01 Mar 2024 03:30:22 -0800 (PST) Received: from pstanner-thinkpadt14sgen1.remote.csb (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id b1-20020ac86781000000b0042eb46d15bbsm1596239qtp.88.2024.03.01.03.30.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 03:30:22 -0800 (PST) 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 v4 06/10] PCI: Move pinned status bit to struct pci_dev Date: Fri, 1 Mar 2024 12:29:54 +0100 Message-ID: <20240301112959.21947-7-pstanner@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240301112959.21947-1-pstanner@redhat.com> References: <20240301112959.21947-1-pstanner@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792323939376730961 X-GMAIL-MSGID: 1792323939376730961 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 6bf93c6cbb66..076362740791 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 97bd1c074d26..0a4220aa303e 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -825,7 +825,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 f29c9289b378..fdf579e0d6ec 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 */