From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 C21C5C433F5 for ; Sun, 28 Nov 2021 19:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hlLUk5bUFAww487LELw0nn/HCowKUxnThk9DM5uFfWc=; b=KvgMvbWNErW8Ly vSwWm5tlf15RWf8oqAEfCql++3597e848eEPMNw/fBLvKrhawfnRtZmoKWgcgSJV00dVNZdLxVmhy eLQumJZ6t8Almh2aUdHYczvJ3iBDRsc0lYaZA3t1S3Wp5JCGZcXWqQux7/L5E4PdCiTup81shdzCx jXP/A2klj/vCQsjcttcC7JYZsonNpLtKsPeikeLrEqMadUhHRz0pGl5nXZMMN5UBrgBcI/qUCVrim aW0nEuKl8sncD4TZjrnpOaBbvKE8oItwHaHR5dc6vCd6SOb/i+ZU7QL4wACAfNYyOxU1cioK3syO6 V99NczjwWcQlMRz1iXqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mrPYG-00GWRS-EE; Sun, 28 Nov 2021 19:09:28 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mrPYD-00GWQ0-7K for linux-arm-kernel@lists.infradead.org; Sun, 28 Nov 2021 19:09:26 +0000 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1638126558; 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: in-reply-to:in-reply-to:references:references; bh=CjZcRIM8mi5Lga3dE0YMFAAVgRUsLCHnKUD78SK4AQQ=; b=RXQ9TCzzfl4WPtWcEJoRHxY0CML6p5j+vVn642rlvX4FXeGOQlTdOUHJA7TT/zMvTcjhsJ z2rlcikR4dPUEfkkZEyKLgBw5JNje7IukbrP5rH+IE6poqMYiao1Ca4Jv76m34iRN55Ugp 9P197uGT9ReR6cEJgyZzR2bL1i5B2LiF3G8u3m1MGyv/K7P7ZcAj693GrLpygGCZMR0zi0 0KJ7ALQY8WY49eWHTHuU3ao5WzbumtDwaMd5vjrhuQEmq6z0WkfUTzt9rSRrTjaYjKnNAh cfKsUGOras+oIgI8Eal2B4zXTACelM12H/MpiLBy/YwAKS60vXfzAPoKFbwzqA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1638126558; 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: in-reply-to:in-reply-to:references:references; bh=CjZcRIM8mi5Lga3dE0YMFAAVgRUsLCHnKUD78SK4AQQ=; b=bp81l/mvh3aNr1oJURqDKy63fAKoxH05F3XfT4StsiB+7OI2VuNNOHrlu3G2D0TFLaaxGV tRyuRxEuQqfHuuBA== To: Jason Gunthorpe Cc: LKML , Bjorn Helgaas , Marc Zygnier , Alex Williamson , Kevin Tian , Megha Dey , Ashok Raj , linux-pci@vger.kernel.org, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: Re: [patch 02/37] device: Add device::msi_data pointer and struct msi_device_data In-Reply-To: <20211128001406.GT4670@nvidia.com> References: <20211126224100.303046749@linutronix.de> <20211126230524.045836616@linutronix.de> <20211128001406.GT4670@nvidia.com> Date: Sun, 28 Nov 2021 20:09:18 +0100 Message-ID: <87czmkf675.ffs@tglx> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211128_110925_452290_CF774803 X-CRM114-Status: GOOD ( 14.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sat, Nov 27 2021 at 20:14, Jason Gunthorpe wrote: > On Sat, Nov 27, 2021 at 02:20:09AM +0100, Thomas Gleixner wrote: > >> +/** >> + * msi_setup_device_data - Setup MSI device data >> + * @dev: Device for which MSI device data should be set up >> + * >> + * Return: 0 on success, appropriate error code otherwise >> + * >> + * This can be called more than once for @dev. If the MSI device data is >> + * already allocated the call succeeds. The allocated memory is >> + * automatically released when the device is destroyed. > > I would say 'by devres when the driver is removed' rather than device > is destroyed - to me the latter implies it would happen at device_del > or perhaps during release.. Ah. Indeed it's when the driver unbinds because that's what disables MSI. >> +int msi_setup_device_data(struct device *dev) >> +{ >> + struct msi_device_data *md; >> + >> + if (dev->msi.data) >> + return 0; >> + >> + md = devres_alloc(msi_device_data_release, sizeof(*md), GFP_KERNEL); >> + if (!md) >> + return -ENOMEM; >> + >> + raw_spin_lock_init(&md->lock); > > I also couldn't guess why this needed to be raw? That lock is to replace the raw spinlock we have in struct device right now, which is protecting low level register access and that's called from within irq_desc::lock held regions with interrupts disabled. I had to stick something into the data structure because allocating 0 bytes is invalid. But yes, I should have mentioned it in the changelog. Thanks, tglx _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel