Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1361935pxb; Fri, 13 Nov 2020 10:37:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNaJPWR1FxKGV5TFAUUCbBmSHksLBZllGCV+cvqUz0lCnUTH37mvPdkBdv6Uys9xo9xrMV X-Received: by 2002:a17:906:3a49:: with SMTP id a9mr3330717ejf.95.1605292676279; Fri, 13 Nov 2020 10:37:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605292676; cv=none; d=google.com; s=arc-20160816; b=BiC8IKwocMk2Cs6V2MDZuda6U3r2w1zNyoOVeWVRIsWwS976F4A2Kj09pc5+3G6u87 pROQCaCpTIlzaHIw59Ei0UuD8bkY1mMCqp6QagEkSLjK5aiPkGmuKqC9fWTXAEOifUMw jZYvDzEi/kO/lfR7tWZe+1UeTg7X4bAU6CwllUrgoH6nfjC/E4Nf0mmF92aB4Vh5ecsf SqSDfcaJYJJwlSAfsPWRxP3elKfVNPpgK8XQa4aEfRz7+ubb9f9k2/zRfUJIT4gZyC+8 L/1buiDZ4Ck+XuEU1vskeUHJoxY3ltRF9GngR51/wbn9oB6Of+XAB0SN0JASTmIPsLNZ YnVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=y80JKGcPRl87wGOpYSNSeaJ75SC/iqp241wVY11g8UE=; b=crficcBatWyhm8RS3Q2gihxhYK0WBOl7/vZo+z9/CRPnve6i2krWpTKpwvWM6dSZPV xdxNtm8naGQF6xIKJuTxOROv81+qXUTriyuvIDnIbBpPUs3hkJu7+bKlrF4AErKH49Gk 4YlNOiIJZZYZA6+ojfKh9PzWoXBUwrGkgvS3RoyoKnN6O/VeT+Ga5KIPri7ue6dOa45F R3pryWnrCqP5fglx7IFDPwDXTIiBCfob0QGrVJGS5q+lDxNqtrSdgmqiKX9Y1+/FNPRR pzoZmV9blAQXbI/ycldbo2xCghelWRrudRUDvcWnZxwrN5x+vUC6QckxIym8l8msZfsx eYwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dk7Smdan; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s18si7053271eji.422.2020.11.13.10.37.33; Fri, 13 Nov 2020 10:37:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dk7Smdan; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726240AbgKMSe5 (ORCPT + 99 others); Fri, 13 Nov 2020 13:34:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:33564 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726081AbgKMSe5 (ORCPT ); Fri, 13 Nov 2020 13:34:57 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 07DBE206F9; Fri, 13 Nov 2020 18:34:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605292496; bh=NjIgaEmcqEk+hSMRlvqRq2+FFxaz59TQCu7jBWCq3/M=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Dk7SmdanUHZwEU/WTEThter6vvoetvehsyeLAZGWUluC2PFNDTL6lmxm0xvfdMaFC AERnaujT/LtPQhGdbSfLwilCwuMt6Ch5CSUxyeDOyXKiNWtOPQnTM+n5s90A3+ME29 3Hve4pAYPR2UhPC4Cr+N1/4aNspAGCXbWzXOvQBs= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1kdduP-00AQ40-Tg; Fri, 13 Nov 2020 18:34:54 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Fri, 13 Nov 2020 18:34:53 +0000 From: Marc Zyngier To: Alexey Kardashevskiy Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , =?UTF-8?Q?C=C3=A9dric_Le_Goater?= , Michael Ellerman , Qian Cai , Rob Herring , Frederic Barrat , =?UTF-8?Q?Michal_Such=C3=A1ne?= =?UTF-8?Q?k?= Subject: Re: [PATCH kernel v3] genirq/irqdomain: Add reference counting to IRQs In-Reply-To: <20201109094646.71565-1-aik@ozlabs.ru> References: <20201109094646.71565-1-aik@ozlabs.ru> User-Agent: Roundcube Webmail/1.4.9 Message-ID: X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: aik@ozlabs.ru, linux-kernel@vger.kernel.org, tglx@linutronix.de, clg@kaod.org, mpe@ellerman.id.au, cai@lca.pw, robh@kernel.org, fbarrat@linux.ibm.com, msuchanek@suse.de X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alexey, On 2020-11-09 09:46, Alexey Kardashevskiy wrote: > PCI devices share 4 legacy INTx interrupts from the same PCI host > bridge. > Device drivers map/unmap hardware interrupts via irq_create_mapping()/ > irq_dispose_mapping(). The problem with that these interrupts are > shared and when performing hot unplug, we need to unmap the interrupt > only when the last device is released. > > This reuses already existing irq_desc::kobj for this purpose. > The refcounter is naturally 1 when the descriptor is allocated already; > this adds kobject_get() in places where already existing mapped virq > is returned. > > This reorganizes irq_dispose_mapping() to release the kobj and let > the release callback do the cleanup. > > As kobject_put() is called directly now (not via RCU), it can also > handle > the early boot case (irq_kobj_base==NULL) with the help of > the kobject::state_in_sysfs flag and without additional > irq_sysfs_del(). > While at this, clean up the comment at where irq_sysfs_del() was > called. > > Quick grep shows no sign of irq reference counting in drivers. Drivers > typically request mapping when probing and dispose it when removing; > platforms tend to dispose only if setup failed and the rest seems > calling one dispose per one mapping. Except (at least) PPC/pseries > which needs https://lkml.org/lkml/2020/10/27/259 > > Cc: Cédric Le Goater > Cc: Marc Zyngier > Cc: Michael Ellerman > Cc: Qian Cai > Cc: Rob Herring > Cc: Frederic Barrat > Cc: Michal Suchánek > Cc: Thomas Gleixner > Signed-off-by: Alexey Kardashevskiy > --- > > This is what it is fixing for powerpc: > > There was a comment about whether hierarchical IRQ domains should > contribute to this reference counter and I need some help here as > I cannot see why. > It is reverse now - IRQs contribute to domain->mapcount and > irq_domain_associate/irq_domain_disassociate take necessary steps to > keep this counter in order. What might be missing is that if we have > cascade of IRQs (as in the IOAPIC example from > Documentation/core-api/irq/irq-domain.rst ), then a parent IRQ should > contribute to the children IRQs and it is up to > irq_domain_ops::alloc/free hooks, and they all seem to be eventually > calling irq_domain_alloc_irqs_xxx/irq_domain_free_irqs_xxx which seems > right. > > Documentation/core-api/irq/irq-domain.rst also suggests there is a lot > to see in debugfs about IRQs but on my thinkpad there nothing about > hierarchy. > > So I'll ask again :) > > What is the easiest way to get irq-hierarchical hardware? > I have a bunch of powerpc boxes (no good) but also a raspberry pi, > a bunch of 32/64bit orange pi's, an "armada" arm box, > thinkpads - is any of this good for the task? If your HW doesn't require an interrupt hierarchy, run VMs! Booting an arm64 guest with virtual PCI devices will result in hierarchies being created (PCI-MSI -> GIC MSI widget -> GIC). You can use KVM, or even bare QEMU on x86 if you are so inclined. I'll try to go through this patch over the week-end (or more probably early next week), and try to understand where our understandings differ. Thanks, M. -- Jazz is not dead. It just smells funny...