Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3040677rdb; Tue, 6 Feb 2024 05:42:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdtkI3tVqYNzEJwojsEZpM45nQqVXvwRg1ZhgLh5bmuO6XoGEp89nfsIns7+7CupOj5dp3 X-Received: by 2002:a17:90b:1b45:b0:296:d85:d3d2 with SMTP id nv5-20020a17090b1b4500b002960d85d3d2mr2484165pjb.34.1707226965710; Tue, 06 Feb 2024 05:42:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707226965; cv=pass; d=google.com; s=arc-20160816; b=ydt0ldh5sEBUik0udKewt+oK1zth0aGR4HumgD/XwLGq3uWWyxiDLmIPnj3BDgRgIX bGJfkJ6h5nCob9lzDtjCZB7UeEwxa8Ys2w9WtHPTrPr9vzxn6XO4YO/sS6FPc0o4FvWk e5/TtCCsFNhZTY3AtgLGbqXRWSLxaS7vOTC8fVLbuSBkrt1HpWaBX8fwzIp8pKR+FLaq 3iDKUqIr+wCugqu4ojaB7CPyPzE+xL8zTKYTJYHseboBNZtLZFfkY9kBxoTJ20Qy9Hxr rc7ZIv6v5FQZ9l9DlWb+Vl99mKGq9AcEUT0M5qbh//YFAl+//jzF6/07M5Buamw+V7Sr ssJg== 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=7AZZPeDLSIQhGpyqdXYj5Wako5b4bPLUCKUFeVUAK8s=; fh=LdrW/vCzelA2mrw55EaY9vjJNB1Ye+IZfqZZhemcoJo=; b=DA3hIl6seFdPjQAglV9WSMvZ+N5Qqs3/rpLJUhKKM5s1thrdIh+K02xpaMcC/cmZn9 uSe2x6umD6HswYH5kptDmPwU9oYXxBMqkbf7qbrPGBWXYI7HmliKUypjgvbzVVhc52DY +8mIocZcq6K7GClD1eR3UGwdhgRk+nBpTrvAtZaNqoyq1bKy+Kto2ZN9PJFFR8Q4TZKz Ehi/leJHiIbO9R2dAXdm2JT94vt2UQzNj+cbL8E8Gu0VvRDfHK1IUUq7ixQr6P4HYAuK c79p4/hv9RIkLr2sO/sa07x98oGw7G3ZswCPTEF0qophp7jsg1shZO6EGF8e4Adt2elQ AMmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XFd525EK; 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-55037-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55037-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCVz2qDabeG1DLFOvsLzGCtVq/pmg3KsrVewYxWF+e44S15CRJ27cUSRYW7FRYajIn9M1QC5SPu9VXunwM1MHb5jJS2OMI/M8gDQJYKZsg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id mj16-20020a17090b369000b0029620517a5bsi1144408pjb.179.2024.02.06.05.42.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:42:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55037-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=XFd525EK; 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-55037-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55037-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 5975D288351 for ; Tue, 6 Feb 2024 13:42:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1034133298; Tue, 6 Feb 2024 13:40:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XFd525EK" 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 30EF5132C3E for ; Tue, 6 Feb 2024 13:40:53 +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=1707226854; cv=none; b=aCvUCRWIEs9wEBC33SPuF/0gFa8ss/mlLmy94UAWesQKTyRFr2zEEqxyQCU4Pyn/pjxtxXStQy3KrL3kNaThmZ8d1dmTD971SmCPIqRDL2tH6DzASWzGiC/ZEDOunsDVWCbGwnIAv9ntu/n4U/oUPxL8g+KpOAJMGbqkQeUiS94= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707226854; c=relaxed/simple; bh=TowMgeLUGRs1hnMQjk19y8O1hjjTxf8YbaaZY8r8KoQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RPMjxRo0+wdvSBQesmOvPiZVbCgbTrk35DFqadeDrNVAuW772y0+tddM3Um5IgLCPezDfOm/XN9XRayW1RIqnOlEQZ7YkPn3in+EseehgJyUIREdxYMJii+ztw2xn80muxe7BJngNAhAMG8hA4QUsTQmBvLN2D5dc++5mWlrfJU= 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=XFd525EK; 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=1707226852; 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=7AZZPeDLSIQhGpyqdXYj5Wako5b4bPLUCKUFeVUAK8s=; b=XFd525EKNU941PY4TR7tWf0fqCh5xH/+RSJCoUnI6btaiRGKfaforjM7am0AYUqYBHuHNT 2kPIi5Y8hal9KZhvCtuQ24PXaIxgSZfiG/HiG6BEezN4oHpmZP3vK+U4ApeO9RSe7WJXqY mTzmckK2v1D0nn0J4k0KnmXQi/0KPPY= 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-48-cvgGnh0fONqZ-uptnKCWIw-1; Tue, 06 Feb 2024 08:40:51 -0500 X-MC-Unique: cvgGnh0fONqZ-uptnKCWIw-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-7853449295cso25887085a.0 for ; Tue, 06 Feb 2024 05:40:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707226850; x=1707831650; 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=7AZZPeDLSIQhGpyqdXYj5Wako5b4bPLUCKUFeVUAK8s=; b=AKBKcCobXVN6RUGUzwQrtVikA/sDtaCA1innv5U0H2VjWQlqy/iMjrJdOg/hbi7tna OIKBIa51cRNlvkhXylIshauU34qlHNNv3BUT5vlSg2cOQJwro95R32f4gVR58vG9BwTF 5qezUnZ32VOXyeUzxKMjhfAFvvJmvoZZC5yS5k8QZPf8gp3088EbpLAyQwLbECdAZluK Gdni2ha/KwK1PlylPe1cuekdxz4EnXm5mYqA8zabhbxNRqionXrSYqGJCdxpRNg9Wuh6 1dZ4Fp/KGRmKQ/p44i7Dz7dOM3zkbmx/PEEHHD9ljXWnP1rHHPSXHciTEw248mlwTEJR peaA== X-Gm-Message-State: AOJu0YxpjAVTY8fGT8SbK9JwLrSXiMNJsWJArMR5JC9oxKumX74yRBTR FRX1olDk1fWvgOITpTBqbZM2e+Ls1uik+9e+ubhCR2vGybNl4AoueC+KVuhfpEWr+fHaVJ3cZO5 SuXksmme7OMpiLvd402TBXokG3iiA3KjSbXJRMx8+SgO6HKonmACp/oL9sFB+V2C5nuYq5w== X-Received: by 2002:a05:620a:4714:b0:785:65bc:6cc1 with SMTP id bs20-20020a05620a471400b0078565bc6cc1mr2808221qkb.5.1707226850503; Tue, 06 Feb 2024 05:40:50 -0800 (PST) X-Received: by 2002:a05:620a:4714:b0:785:65bc:6cc1 with SMTP id bs20-20020a05620a471400b0078565bc6cc1mr2808193qkb.5.1707226850162; Tue, 06 Feb 2024 05:40:50 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWxKz2AS2kCg26W1YFQSCC6cN1TQFyl00vI8SJusbemv44LJDN294ZNx81ZJTllVzo6lrDYzd9cB9u2oUv/09MqwrPZMkh+cmCIjsyWL/V5LIkRYx150ArqnQekZaEu9Gw4ZKQmIPFG9mFjy2eFjaoHxoZpj9Wqas5mrNDPaAXdH9g0P2JNNqXBvb7aD1Df5LmUywY3BqqckFtKGmHWfGl8JxXokTkpbxqEo2LGQmOidzl6+nkC5S7gyDkomYtorhMcYCQVaRM8RTMnAqh8VFdCPAeK8I/tAPufT5yUwq22SxbR/clnAu17itZMQbSGnNxW4FjnviRCGUWOqd6zxcI/CtVYyCazSInsFGpRzGpoO9yDr58I+rPaTOhNNcGAS2YJojI3 Received: from pstanner-thinkpadt14sgen1.remote.csb (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id vu4-20020a05620a560400b0078544c8be9asm903791qkn.87.2024.02.06.05.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:40:48 -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 v3 07/10] PCI: Give pcim_set_mwi() its own devres callback Date: Tue, 6 Feb 2024 14:39:53 +0100 Message-ID: <20240206134000.23561-9-pstanner@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206134000.23561-2-pstanner@redhat.com> References: <20240206134000.23561-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 Managing pci_set_mwi() with devres can easily be done with its own callback, without the necessity to store any state about it in a device-related struct. Remove the MWI state from struct pci_devres. Give pcim_set_mwi() a separate devres-callback. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 29 ++++++++++++++++++----------- drivers/pci/pci.h | 1 - 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c index 628cde665e77..89d2d6341b19 100644 --- a/drivers/pci/devres.c +++ b/drivers/pci/devres.c @@ -370,24 +370,34 @@ void __iomem *devm_pci_remap_cfg_resource(struct device *dev, } EXPORT_SYMBOL(devm_pci_remap_cfg_resource); +static void __pcim_clear_mwi(void *pdev_raw) +{ + struct pci_dev *pdev = pdev_raw; + + pci_clear_mwi(pdev); +} + /** * pcim_set_mwi - a device-managed pci_set_mwi() - * @dev: the PCI device for which MWI is enabled + * @pdev: the PCI device for which MWI is enabled * * Managed pci_set_mwi(). * * RETURNS: An appropriate -ERRNO error value on error, or zero for success. */ -int pcim_set_mwi(struct pci_dev *dev) +int pcim_set_mwi(struct pci_dev *pdev) { - struct pci_devres *dr; + int ret; - dr = find_pci_dr(dev); - if (!dr) - return -ENOMEM; + ret = devm_add_action(&pdev->dev, __pcim_clear_mwi, pdev); + if (ret != 0) + return ret; + + ret = pci_set_mwi(pdev); + if (ret != 0) + devm_remove_action(&pdev->dev, __pcim_clear_mwi, pdev); - dr->mwi = 1; - return pci_set_mwi(dev); + return ret; } EXPORT_SYMBOL(pcim_set_mwi); @@ -397,9 +407,6 @@ static void pcim_release(struct device *gendev, void *res) struct pci_dev *dev = to_pci_dev(gendev); struct pci_devres *this = res; - if (this->mwi) - pci_clear_mwi(dev); - if (this->restore_intx) pci_intx(dev, this->orig_intx); diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 586b2047c275..eaec3b207908 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -813,7 +813,6 @@ static inline pci_power_t mid_pci_get_power_state(struct pci_dev *pdev) struct pci_devres { unsigned int orig_intx:1; unsigned int restore_intx:1; - unsigned int mwi:1; }; struct pci_devres *find_pci_dr(struct pci_dev *pdev); -- 2.43.0