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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7511C433EF for ; Thu, 9 Dec 2021 16:36:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239464AbhLIQkE (ORCPT ); Thu, 9 Dec 2021 11:40:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232484AbhLIQkE (ORCPT ); Thu, 9 Dec 2021 11:40:04 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80F1CC061746; Thu, 9 Dec 2021 08:36:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EX9CGudp8dcrlnGUunc7sBtpaUqex0FFLoIEdm/NNQU=; b=1AYxprNzJk2VftgVMiVW/BLBep vIpgmJxPO2bvW0MGvbcaflTRDzV3VdEwGaxvKeLiIqzyWgfv12g6XBir6C9JaDHZRFhbX0inyyPDt qp7Tza9iJpPjLuokDAtbqlRz8mQILYqgr9QnQshPKNXjWtCqLF/F2UHFfoPk3DayCYn87+DozNeDE hnU165KADK8FXw58uYX74kau994C0SqWf2EJ4sxRgR/DSe16iOTfu2/ocE0pBLv4n3zTPy41Ackkh 0cEltJltMwnwi3KbVfUIe4Hvnz2Qj31D0Plu5TsnqPyLja/0iI/zU/+tnj0cS9sEGsA5nb6/k3LHu ORUe9O0g==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:56206) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mvMP5-0000Es-DK; Thu, 09 Dec 2021 16:36:19 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1mvMP1-0007Lr-Uo; Thu, 09 Dec 2021 16:36:15 +0000 Date: Thu, 9 Dec 2021 16:36:15 +0000 From: "Russell King (Oracle)" To: Ilkka Koskinen Cc: lorenzo.pieralisi@arm.com, guohanjun@huawei.com, sudeep.holla@arm.com, rafael@kernel.org, lenb@kernel.org, robert.moore@intel.com, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devel@acpica.org, patches@amperecomputing.com, scott@os.amperecomputing.com, darren@os.amperecomputing.com Subject: Re: [PATCH 2/2] ACPI: AGDI: Add driver for Arm Generic Diagnostic Dump and Reset device Message-ID: References: <20211203024311.49865-1-ilkka@os.amperecomputing.com> <20211203024311.49865-3-ilkka@os.amperecomputing.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211203024311.49865-3-ilkka@os.amperecomputing.com> Sender: Russell King (Oracle) Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Hi, On Thu, Dec 02, 2021 at 06:43:11PM -0800, Ilkka Koskinen wrote: > +static int __init agdi_init(void) > +{ > + int ret; > + acpi_status status; > + struct acpi_table_agdi *agdi_table; > + struct agdi_data *pdata; > + struct platform_device *pdev; > + > + if (acpi_disabled) > + return 0; > + > + status = acpi_get_table(ACPI_SIG_AGDI, 0, > + (struct acpi_table_header **) &agdi_table); > + if (ACPI_FAILURE(status)) > + return -ENODEV; > + > + pdata = kzalloc(sizeof(*pdata), GFP_ATOMIC); Why does this need to be GFP_ATOMIC? Also, struct agdi_data is a single int in size, why do you need to kzalloc() it? > + if (!pdata) { > + ret = -ENOMEM; > + goto err_put_table; > + } > + > + if (agdi_table->flags & ACPI_AGDI_SIGNALING_MODE) { > + pr_warn("Interrupt signaling is not supported"); > + ret = -ENODEV; > + goto err_free_pdata; > + } > + > + pdata->sdei_event = agdi_table->sdei_event; > + > + pdev = platform_device_register_data(NULL, "agdi", 0, pdata, sizeof(*pdata)); platform_device_register_data() uses kmemdup() internally with the platform data, meaning it takes a copy of the platform data. There is no need for the pdata allocation to persist past this point. Hence, given that it is a single int in size, you may as well put "struct agdi_data" on the stack. Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! 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 3CAB1C433F5 for ; Thu, 9 Dec 2021 16:39:00 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XZAd3cO3onkDkC2S0KUcvQdXQGu4eVNQZOMtnYox2iE=; b=0BZyX5cGp20WTn P7gsGtl1GzW/GpPHLVimg/CUYgq/y/Gkkv0CJNGEHqTBYPtK0pnHoWMzSu5bj142HWhl6bDPL7j4e RubIbTenIfBC2LtXu1lC6yciPqjCEoxcBlMAAMo31JykoX7Y7nKqH+ql25X9GYGr9SJOrWfEBeBe0 zB5XqIBvQPi4+ld6falJwIM5J5zlOzipTkU1R03OCmAZX2F7mTCKz77p6eeJ4MJ59VuGpY5K6zawh 1b4ld6CNg5XNbxeiabFG1i5uH4XZx0GrSrI696X0cxHFY28Mqa+9g9yf2z9TQMQPk+nw8+IoBfvhb KQcv7T30HYEHRecAczig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvMQC-00GhFL-PF; Thu, 09 Dec 2021 16:37:29 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvMPI-00Ggv6-QF for linux-arm-kernel@lists.infradead.org; Thu, 09 Dec 2021 16:36:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EX9CGudp8dcrlnGUunc7sBtpaUqex0FFLoIEdm/NNQU=; b=1AYxprNzJk2VftgVMiVW/BLBep vIpgmJxPO2bvW0MGvbcaflTRDzV3VdEwGaxvKeLiIqzyWgfv12g6XBir6C9JaDHZRFhbX0inyyPDt qp7Tza9iJpPjLuokDAtbqlRz8mQILYqgr9QnQshPKNXjWtCqLF/F2UHFfoPk3DayCYn87+DozNeDE hnU165KADK8FXw58uYX74kau994C0SqWf2EJ4sxRgR/DSe16iOTfu2/ocE0pBLv4n3zTPy41Ackkh 0cEltJltMwnwi3KbVfUIe4Hvnz2Qj31D0Plu5TsnqPyLja/0iI/zU/+tnj0cS9sEGsA5nb6/k3LHu ORUe9O0g==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:56206) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mvMP5-0000Es-DK; Thu, 09 Dec 2021 16:36:19 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1mvMP1-0007Lr-Uo; Thu, 09 Dec 2021 16:36:15 +0000 Date: Thu, 9 Dec 2021 16:36:15 +0000 From: "Russell King (Oracle)" To: Ilkka Koskinen Cc: lorenzo.pieralisi@arm.com, guohanjun@huawei.com, sudeep.holla@arm.com, rafael@kernel.org, lenb@kernel.org, robert.moore@intel.com, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devel@acpica.org, patches@amperecomputing.com, scott@os.amperecomputing.com, darren@os.amperecomputing.com Subject: Re: [PATCH 2/2] ACPI: AGDI: Add driver for Arm Generic Diagnostic Dump and Reset device Message-ID: References: <20211203024311.49865-1-ilkka@os.amperecomputing.com> <20211203024311.49865-3-ilkka@os.amperecomputing.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211203024311.49865-3-ilkka@os.amperecomputing.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211209_083632_884629_5308573E X-CRM114-Status: GOOD ( 13.66 ) 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 Hi, On Thu, Dec 02, 2021 at 06:43:11PM -0800, Ilkka Koskinen wrote: > +static int __init agdi_init(void) > +{ > + int ret; > + acpi_status status; > + struct acpi_table_agdi *agdi_table; > + struct agdi_data *pdata; > + struct platform_device *pdev; > + > + if (acpi_disabled) > + return 0; > + > + status = acpi_get_table(ACPI_SIG_AGDI, 0, > + (struct acpi_table_header **) &agdi_table); > + if (ACPI_FAILURE(status)) > + return -ENODEV; > + > + pdata = kzalloc(sizeof(*pdata), GFP_ATOMIC); Why does this need to be GFP_ATOMIC? Also, struct agdi_data is a single int in size, why do you need to kzalloc() it? > + if (!pdata) { > + ret = -ENOMEM; > + goto err_put_table; > + } > + > + if (agdi_table->flags & ACPI_AGDI_SIGNALING_MODE) { > + pr_warn("Interrupt signaling is not supported"); > + ret = -ENODEV; > + goto err_free_pdata; > + } > + > + pdata->sdei_event = agdi_table->sdei_event; > + > + pdev = platform_device_register_data(NULL, "agdi", 0, pdata, sizeof(*pdata)); platform_device_register_data() uses kmemdup() internally with the platform data, meaning it takes a copy of the platform data. There is no need for the pdata allocation to persist past this point. Hence, given that it is a single int in size, you may as well put "struct agdi_data" on the stack. Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel