Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6141660rdb; Mon, 1 Jan 2024 10:12:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFaVy+wKe3W/qt3p06Gp3JT/u7S0XvCJjOCF5/M/PyQCr7v7gyRd/Yy6BcXwY2mW9WPoYON X-Received: by 2002:a17:902:ebcd:b0:1d4:91ac:ce9a with SMTP id p13-20020a170902ebcd00b001d491acce9amr9721018plg.135.1704132729920; Mon, 01 Jan 2024 10:12:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704132729; cv=none; d=google.com; s=arc-20160816; b=OyM8iSSd3J0S1rvxUHV2qaHViKg+ftVNBB6Y8jDva2dw3D+oz2kfey4+BGrmXCGCSh /XTPCRmsmjpp25i17HqvYFkgndxQkM4INP+ipWjzK8+Yw3JpookPMQDL+hFbvfdQeeaF QdJL60b23bZwdOc3ydlNC5tf0NxVaaNRSk/8eMxIE62sGnN0RdeDbxrMsfJUR3ECKSMa Aitofwaf58aty+PvgV1et9pxFqeZWfVCQiXkVv7xhdfrxVABolEG5hP9EVLjpa/by8De 1SSCKVKs4MVc0f/um5eGOW40k/wl3FJ+xTofg+TRBJs85g9KHGkhAmPUGbVyaJnSDu3b /2Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:references:message-id:subject:cc:to:from:date; bh=MJg2jSx5fkF/LAjsLWdN4UMg8jWgchWBtjDD1gp9628=; fh=vlRGUsBy0j9/BaHOaFituJ6FkezermbqQhX6NEhjBGI=; b=YmUZf8y5zi+X5xvY92ASDuMWRGRBq37L06fu8F/qrNiswUcNhLzTL9AZN+G0lhmKFk sj+S34QcY9ungwiH5NgBNas4znsNFjXSiG7RtqRZv3QPtMNBiZ2n1ogpBqm9BvT6m+hl pmW8a4hxnFdzkWTx83YD5d6Ih2aky7DUn2nGOzxE+SMULIz+kbBEAM0H3QkBRPpF6VDc JDdBDl6y2D+gP7niwRr250o3uHrub6F0RR3waW663FFoxcAcCPE00Yxm481GoX4NjWXd IPIx2I51/iGiIA3tOqnoyFRiGpD1xgA3KwYzxOJ64Bk0aJDTItFjUihvAs7OZNBjyVQu bQMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13923-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13923-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b14-20020a170902d50e00b001d3b083f82csi13998079plg.470.2024.01.01.10.12.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 10:12:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13923-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13923-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13923-linux.lists.archive=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 7F136B21148 for ; Mon, 1 Jan 2024 18:12:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DBED4BE72; Mon, 1 Jan 2024 18:11:58 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from bmailout1.hostsharing.net (bmailout1.hostsharing.net [83.223.95.100]) (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 3D0E79464; Mon, 1 Jan 2024 18:11:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wunner.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=h08.hostsharing.net Received: from h08.hostsharing.net (h08.hostsharing.net [IPv6:2a01:37:1000::53df:5f1c:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "*.hostsharing.net", Issuer "RapidSSL TLS RSA CA G1" (verified OK)) by bmailout1.hostsharing.net (Postfix) with ESMTPS id B644B300002C4; Mon, 1 Jan 2024 19:11:46 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 9770D4E76C; Mon, 1 Jan 2024 19:11:46 +0100 (CET) Date: Mon, 1 Jan 2024 19:11:46 +0100 From: Lukas Wunner To: Ilpo =?iso-8859-1?Q?J=E4rvinen?= Cc: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , Krzysztof Wilczy??ski , Alexandru Gagniuc , Krishna chaitanya chundru , Srinivas Pandruvada , "Rafael J . Wysocki" , linux-pm@vger.kernel.org, Bjorn Helgaas , LKML , Alex Deucher , Daniel Lezcano , Amit Kucheria , Zhang Rui Subject: Re: [PATCH v3 07/10] PCI/LINK: Re-add BW notification portdrv as PCIe BW controller Message-ID: <20240101181146.GA26390@wunner.de> References: <20230929115723.7864-1-ilpo.jarvinen@linux.intel.com> <20230929115723.7864-8-ilpo.jarvinen@linux.intel.com> <20231230155810.GB25718@wunner.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) On Mon, Jan 01, 2024 at 07:37:25PM +0200, Ilpo J?rvinen wrote: > On Sat, 30 Dec 2023, Lukas Wunner wrote: > > On Fri, Sep 29, 2023 at 02:57:20PM +0300, Ilpo J?rvinen wrote: > > > + pcie_capability_write_word(dev, PCI_EXP_LNKSTA, PCI_EXP_LNKSTA_LBMS); > > > + pcie_capability_set_word(dev, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_LBMIE); > > > > I'm wondering why we're not enabling LABIE as well? > > (And clear LABS.) > > > > Can't it happen that we miss bandwidth changes unless we enable that > > as well? > > Thanks. Reading the spec, it sounds like both are necessary to not miss > changes. I guess this is an artefact of Alex' original patch. I don't know why he enabled one but not the other. > > > + ret = request_irq(srv->irq, pcie_bw_notification_irq, > > > + IRQF_SHARED, "PCIe BW ctrl", srv); > > > > Is there a reason to run the IRQ handler in hardirq context > > or would it work to run it in an IRQ thread? Usually on systems > > than enable PREEMPT_RT, a threaded IRQ handler is preferred, > > so unless hardirq context is necessary, I'd recommend using > > an IRQ thread. > > Can I somehow postpone the decision between IRQ_NONE / IRQ_HANDLED > straight into the thread_fn? One LNKSTA read is necessary to decide > that. > > I suppose the other write + reread of LNKSTA could be moved into > thread_fn even if the first read would not be movable. You can just use request_threaded_irq(), pass NULL for the "handler" argument and pcie_bw_notification_irq for the "thread_fn" argument. Because of the NULL argument for "handler", the hardirq handler will then become irq_default_primary_handler(). Which does nothing else but return IRQ_WAKE_THREAD. And the decision between IRQ_NONE and IRQ_HANDLED is then indeed postponed to the IRQ thread. Alternatively you can split the IRQ handler, move the check whether PCI_EXP_LNKSTA_LBMS is set to the hardirq handler and keep the rest in the IRQ thread. Means you won't have unnecessary wakeups of the IRQ thread if the interrupt is caused by something else (I understand it's always shared with PME and hotplug). But you'll spend more time in hardirq context. In practice bandwidth notifications may be more frequent than PME and hotplug interrupts, so unnecessary wakeups of the IRQ thread will be rare. Hence not splitting the IRQ handler may be better. Dunno. Ask Thomas Gleixner or Sebastian Siewior. :) Thanks, Lukas