From patchwork Tue Feb 8 14:59:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurentiu Tudor X-Patchwork-Id: 12738838 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 4F52FC433EF for ; Tue, 8 Feb 2022 15:01:25 +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:References:In-Reply-To: Message-Id:Date: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=2ZsknmXNp3o5O3YfbJ72/mzPgFzSDuAKb/xmm2ofCp0=; b=ZQe99G6cUSdsfy X7tbRLsC9TVKlpn4StAT52mptF0egbyfNYIzjqrTLnwbEaMv811RP2BZF17Yg3pW/P2NewUAtG/9G jH8K7K4s3cR3PnSe64riN5B85QiVIFDC7A4ZB01pFbMtX9xceW+3/0+g3s/pKP4VzdslCUEfzR8Yj pTLRYP7yZUJkNsxOss79CZ8HVRimA9jm2BumFZd2NmOum5nkcjaq9Cde63c03YYMmio0Gkgug3oG5 u/ZIfEqSKJjPqdrXwMSYD5MlgSJ1V1bGCEMl7VsaXAzVskoZxj5RFSPCLHWyk8EfjONfjPghXzxR3 DGDP4ywG5fbT5mrttTVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHRy7-00ELgK-QW; Tue, 08 Feb 2022 14:59:48 +0000 Received: from mail-vi1eur04on060f.outbound.protection.outlook.com ([2a01:111:f400:fe0e::60f] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHRy4-00ELeg-Sf for linux-arm-kernel@lists.infradead.org; Tue, 08 Feb 2022 14:59:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FKQIrKk6Ul4+E/eaPlhNHS3lvTgHuwMF9gOcBp4iatTxefqV81QpJ9fj7YJvB9jxJzYLtn87CXFcrxcA8dOLsBT0FDQNehedbNdcVkchE/lEzrqjBG8tyEqCBWHgv2l1gFHXS5TVx6k/+76eiz43/5qCK8L2ubdJkmsAWFFjkeu+CX5R4rhHXmnvl596ez+J/evJ+Y7sz660DvhUjaz52c8hOFklVwRyPaTbEo1Wuytr9RMk/3T5WTJ0bfBhiZGxb+Wc+t+vlcWm+m/frOjJ1yL9sdfh/IczpFTs86kUvaeoW9dQT+RhXhPNvcMrg8EALHDKFNp5I46wCTgMewwCmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LEuM3YgEWeSsvt0p3Fvd4aWbqb5k/DDi7+HQiqQHn9Y=; b=OdwiJ6Z5kwdnoLS8ZrYFiJZYFspDQNwLzQxHTLEzYJvdWYTNM9w2nR736qdxVOou8NNcwXh8rLRB/1x88fvBW/1Eryc82MV5IxH+D28fJ7+Q8AY7sJaOnv0jR6FMmlEKssy603I6TGzCumhWXHvfNwkC5SDjDQ3FPlrSYzszvFeVXnOa7zm56qP9LG5RJCpZYkZPk4LqAsnQDRGHEu1eSiQ93UP4grAy2ARq8OwCafNKuaOIf873cDHIhUNa5UzEron747Tbacn1bE3AfI5s4YGPA1YHESCtlOaaVR5EukziJE+GZn+eWk4+A22cmhrwYEy/TbV/a6CaF4PxYsFQRQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LEuM3YgEWeSsvt0p3Fvd4aWbqb5k/DDi7+HQiqQHn9Y=; b=LWMtDZ9l9oYFofL5kEtUnGhwzma5g5blPGn/RT0KTognQ8p1JjpFYqZQFd9CsmNvxpxGVQANf9D9ufvb2iSf2KoU6raUUOaBtQ0RW6/axTK6MpWJuNM0/vN0yDAA6OHP4zwxnE8hzM2JiZVCmaIp+Bm2QN7ND328fb+xOxm8I0Q= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) by AS1PR04MB9381.eurprd04.prod.outlook.com (2603:10a6:20b:4db::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Tue, 8 Feb 2022 14:59:39 +0000 Received: from VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::f826:3bf6:b77d:5a53]) by VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::f826:3bf6:b77d:5a53%7]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 14:59:39 +0000 From: laurentiu.tudor@nxp.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: ioana.ciornei@nxp.com, diana.craciun@oss.nxp.com, jon@solid-run.com, Laurentiu Tudor Subject: [PATCH 1/6] bus: fsl-mc: drop useless cleanup Date: Tue, 8 Feb 2022 16:59:23 +0200 Message-Id: <20220208145928.12468-2-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220208145928.12468-1-laurentiu.tudor@nxp.com> References: <20220208145928.12468-1-laurentiu.tudor@nxp.com> X-ClientProxiedBy: AM0PR08CA0025.eurprd08.prod.outlook.com (2603:10a6:208:d2::38) To VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d62104aa-dfc4-4bcf-bc6b-08d9eb13a152 X-MS-TrafficTypeDiagnostic: AS1PR04MB9381:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xiZCkghGTHu6yI4yynmWBKvj3gSD5A5t5W5TlNpM+N54scpLdNnd0DLSzvIsczf47iINUQ5vHBh4Qh1uI/EeC/7kLZrULIEe62gPZruYxcJ9QJPu+bBoxQhwLAWwTtWFvyZtPLlHUAkIQRQIwo8NbKVUQ/GFqcLP2z4jusn2rLs25gCQs+nKINRQiLr0EZNpSDq3Bqe9HtDMOwNGIxLw1U6ZpnxXmVrgY+xBQu3c7nwJGb9UHVHXKThirwlLuhm08aPK3wt0qf60h4U/4i6Pu33CGb8PtSeIPdEErxlXYlvEhlii5zowWODOftB6MsNXpfx0hWn2AqDR9g365S3f2skO2Bz/maEPj9SCB47ADJHoKwtE0ie9/6LP7bTlvZ+HP6IPq/wBvmjeXxrHFenVQFqppQW5gHZu/OIDn2EYo9DJ7DWckGBMOq8J1ziNe0oQODN+AyIxEYuQsKivrq+f5x5HCHfCu3Zqr00YKjKspdXkn62Lo8mVsi8gikoL+agBtVDrUNf5x02j//XMs76ViJkBK9CzceG0cpIh/Ld0hQWxOizyv6o7XtqVtsIj3APDGEX+GNH9oQBuWkVPPf+Kt9yEuySMOTAGic5ft0dxt56pQJxPNaU79hlpabGXvfw1rXiij8OKY+DcC+UETnVuXitSax3DIQDQ9b6fRsjpmkJVNEeRKcny+a/p2GfEbNZGSVtyq2NuGBGBFsojBkdj1w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0402MB3405.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(66476007)(6506007)(6666004)(4326008)(38100700002)(8936002)(83380400001)(66946007)(508600001)(8676002)(66556008)(2906002)(186003)(36756003)(6486002)(86362001)(2616005)(5660300002)(6512007)(9686003)(26005)(1076003)(52116002)(316002)(38350700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5vJhwT888Z7k02UTpQwYqQ1O49oiXT9ZYfRUP6i0daFCoUyMN1bVhO29M9tQXxSPgscSdQ8tttbx3c7ai9duNwrADpMJbpCSgN/ve269GU6MnfVib6XA8bhfxloxWkdRJnat0ltBglFFGTRW8UVlI4rDLhlBqZU0u1QVsS80sBiULCJvDBDdfCaU7/crpeyHdhbV7Zice+4mLF0ya8rHUenuHsrBuqD/o4dUGtUvzwEdcDPJqwukBVSm+JG75SKbpnUTimMXqB7XuCNjxBFHtuNqBbarB0wMKj1qYHswhazUPfklNz4Sb8bMSBnP92+5p21RbvK+Jc9aEWIkXfWO4YOphwgnQMmL41eGob3kc489kpGREkWGp8wCxyZ68OBB8nEb2TYLNqG7Jjf9lTMPPNHC7dlxOVHFYxhQSAheOgeYDvz1M6mTRBVoERXb7mBqxnfLI3HqJkU+vZLcvo8bI25pPUFphpsh3D2eX3J71P2gFPctrm1fL8KHv6vVoHtxC5ysTinVzR30Fccp/ndmU+Zr/h/75Wzu4xxcAzgaClxJmaROJi2fHyruR+3VYD3byI0zARM5JLaQE8JUJV044gItfTDYVIfJ0qQP9UQq5mt1iJsE1DmODmCIQ2oZ//sU0GU4zA6h19i10dVENfSpxBddMA61qv8C9jEZZRSQ9dQYruNhVdfETY0ntUpzoEwDyZHrJRnF3fJfRL30LCvX6eIeWGEuhHKYMz+GlcRQ5zaPB4r17WhnrFeXuZDQfUqIpxI/nW+JlvaLTYesNMWBESH0nNjwrNMerPnuA/ocqEzlYbAaBgLsaXC2HvICNd7GiUPREm0xKNh1LZS+JcZF7oJwgEi3VZnKYr6Mcf4j7zflSZBkfnJcVqsQfKcA/N/OSTkAfT27SNbuYzlBd319Ynk1pi7//qy3UF6zme/IcqJ6WM0sITBUVfG6jiKQ9K8SlKcxWTu2mN/pNnw4iykLYWvzcMk4gZLGJv+XJklnh/ALrQ3jm24Mhtqd3fGUDACT3lN4zxeiCT7L6Tvirh6gXw1BDw/3K9iEFkFABu36Onv1Sv1Dnkaniqq9TSd5fbYZnzN3CqugFOD6AVhp/fXRXWbh0JWBGh53+FSD2TJLiItbYn7TAOkPXfZzQ61cIW1jbcbzINIyB8wT3vIRV2Oh/npmM3b6mU1tY2A7JMkCeVW6KXgSYAjpua6GjQZ89kvrGXNxZ/QFmOV4RVFZlGQzLnnrZuhr1xKpNcoWYO/0upj4vGiHpOENSQ/M9rAIUhl+zRKsdtwYD9NLdLBmdltZ8JtnfT7Xa1yedd7Q8Pl7UltWRbWVfVEYUk2tE1MC0mm/IBP3pCsCXNZ9pdGDs8kVDW9k1eArB68qN/aR+zUyZasQo+q7zQyNjwo2S/vP0Q1o3O2hNUEq4C7DgXkgWP7qvG2ZUZQfxZdy42tGRK275dOuaHG36/ABhbCFb37/tVnRQwVcIMwLTQp54z/Tc+E30dQIZHqaXfxC6M+5T9sfXvqeHe/7JFnqHvixJyt5WSB3JR6kwWMePvk3zKO6eovcBNioRON80LG5EcgNncqqNj/8amDCr+9TzhATczfUwakVFcXsmIwLZnRWBh8Ls3tGWw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d62104aa-dfc4-4bcf-bc6b-08d9eb13a152 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3405.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 14:59:39.4814 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vA/dBFd8emr15TlxAyPBDaGh1K73gZHM5YxKTo5jvvv1TwgZ0gaq38SuQKlFKre/nEwt/WFxfTqHYTsgUy2Ohg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9381 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_065944_973447_AEE4F774 X-CRM114-Status: GOOD ( 11.88 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Laurentiu Tudor This cleanup is actually a no-op because the resources are freed when the device objects are removed from the allocator at driver remove time. Signed-off-by: Laurentiu Tudor --- drivers/bus/fsl-mc/dprc-driver.c | 2 -- drivers/bus/fsl-mc/fsl-mc-allocator.c | 24 ------------------------ drivers/bus/fsl-mc/fsl-mc-private.h | 2 -- 3 files changed, 28 deletions(-) diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c index 5e70f9775a0e..36681cf7c42e 100644 --- a/drivers/bus/fsl-mc/dprc-driver.c +++ b/drivers/bus/fsl-mc/dprc-driver.c @@ -801,8 +801,6 @@ int dprc_cleanup(struct fsl_mc_device *mc_dev) dev_set_msi_domain(&mc_dev->dev, NULL); } - fsl_mc_cleanup_all_resource_pools(mc_dev); - /* if this step fails we cannot go further with cleanup as there is no way of * communicating with the firmware */ diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c b/drivers/bus/fsl-mc/fsl-mc-allocator.c index dced427ca8ba..9fa2a8c28a2d 100644 --- a/drivers/bus/fsl-mc/fsl-mc-allocator.c +++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c @@ -549,30 +549,6 @@ void fsl_mc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev) } } -static void fsl_mc_cleanup_resource_pool(struct fsl_mc_device *mc_bus_dev, - enum fsl_mc_pool_type pool_type) -{ - struct fsl_mc_resource *resource; - struct fsl_mc_resource *next; - struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev); - struct fsl_mc_resource_pool *res_pool = - &mc_bus->resource_pools[pool_type]; - int free_count = 0; - - list_for_each_entry_safe(resource, next, &res_pool->free_list, node) { - free_count++; - devm_kfree(&mc_bus_dev->dev, resource); - } -} - -void fsl_mc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev) -{ - int pool_type; - - for (pool_type = 0; pool_type < FSL_MC_NUM_POOL_TYPES; pool_type++) - fsl_mc_cleanup_resource_pool(mc_bus_dev, pool_type); -} - /* * fsl_mc_allocator_probe - callback invoked when an allocatable device is * being added to the system diff --git a/drivers/bus/fsl-mc/fsl-mc-private.h b/drivers/bus/fsl-mc/fsl-mc-private.h index b3520ea1b9f4..450af2bf7de7 100644 --- a/drivers/bus/fsl-mc/fsl-mc-private.h +++ b/drivers/bus/fsl-mc/fsl-mc-private.h @@ -635,8 +635,6 @@ void fsl_mc_allocator_driver_exit(void); void fsl_mc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev); -void fsl_mc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev); - int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus, enum fsl_mc_pool_type pool_type, struct fsl_mc_resource From patchwork Tue Feb 8 14:59:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurentiu Tudor X-Patchwork-Id: 12738839 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 D5FC6C433EF for ; Tue, 8 Feb 2022 15:01:45 +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:References:In-Reply-To: Message-Id:Date: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=MAjrEi6206XqW7uZM1jxUvfb1kKzreRAwtKG0IbUUt4=; b=qYixcUVaQHP4WR tc8Z3qoT+JvFeCkJsbYe9jW+V9L2NtCqMhuGe3e5TEx+ZhMS90Oyur6z3VLNeKChiQbtaOuCJjrVK TzKMtanJKwPu1WB/A8wLlBaqcrhq87WtD8OiTHqGxw6hIQ2JOOZh+GzT2D8D+drIpLHSNV0GXq7vw oj58daOZw3I4QTMpsUzx/DhBJnPgY4b1YK9onuHeHC+ltx0+iR1JxCrUdEHRGm8SNV0pbGYRfJiig VAt+dHe/XlJetCmMC/En2ktTSze6xNMEluAR9W9dVXBGEaEVrGiz4+QZElHxvyTOKBXD9rZbE6plF 6Yy2KHAaXbSbCDGE9Ppg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHRyL-00ELmf-F3; Tue, 08 Feb 2022 15:00:01 +0000 Received: from mail-vi1eur04on060f.outbound.protection.outlook.com ([2a01:111:f400:fe0e::60f] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHRy6-00ELeg-L1 for linux-arm-kernel@lists.infradead.org; Tue, 08 Feb 2022 14:59:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BCPXgsnnG9Twt2g+LdIvu8gj+Ypv7yFgrzVoI7+WIYGXqd8mcCMBF/a+sIDlfn9Sea0/O24iAj8UQj8279XU67JvukZEywg55qmt4JLMhvXaLsVX+ZYQirfpWXrI132rzi1MDVxpKOByEaaqKCuATKlU1OUW42CZMFKVTtrgi7HvN9fXCuDRqb47joWOX0AnzHnstiF5OoZgOYG3rrfkY9FYbBwAiMH2NRDzFjU90KWViCUZbr2cBOZSrhbtds9nvPieFLNuxRdGhctK3gWKzreHDIe7FF2qOKCTJxgbY8p49vveIHT14BW/3oYePweMIcwm7WZorkspcg8Jk/WnHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KEiP/ywqN9yMvcn/2KHSElXcnlQrXeO8JiGoouRU/uk=; b=LWIjdrCQ5aioiICIHVBA9mL7DMUCzFD+bvOtQu6Weo5osQQLpr+RAm9I98AUx7aOY/Q0BphOejqFrSzwKYH+PQV4IlW4YZRsUuPdujJyBwjzDRbxU7LsfYssmuDDWsnIwMCwQNs6Rb3HfZlM2WG6vOpqQxk2RJiQ8cWVJWbXFCtcjT0m+3p8CvgI5ZKVuKW8kdHni0eSKeW/IxzRw6sZEAXsvmqa8Sn2aGU+vHnnCl3+r5fFZw5EHnLRDwpWez5kRzz8ApkKffDcMtRSxOl2FymizeX98IB7HUT/lPFhENpM6kTYcJEkAvjqgv+fnfiY19x4rOsA7rHUd67gksnEPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KEiP/ywqN9yMvcn/2KHSElXcnlQrXeO8JiGoouRU/uk=; b=lgyYfc6zJw06UHl2sco25CM5X3Txm9mnBnynUcnknb6wIp2DQ6wEZTfU6sJ0lGSta8Xko92FBiVn9XxwCvliXWXTwWHSjU2TfTPPG01tgK9jJQ91kTnmdCP669wyhx3jixK0yEeCKJB05o1dSNAjI4MjAEWW8K9qEI+l9tQIPJE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) by AS1PR04MB9381.eurprd04.prod.outlook.com (2603:10a6:20b:4db::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Tue, 8 Feb 2022 14:59:40 +0000 Received: from VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::f826:3bf6:b77d:5a53]) by VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::f826:3bf6:b77d:5a53%7]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 14:59:40 +0000 From: laurentiu.tudor@nxp.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: ioana.ciornei@nxp.com, diana.craciun@oss.nxp.com, jon@solid-run.com, Laurentiu Tudor Subject: [PATCH 2/6] bus: fsl-mc: fix a use-after-free issue Date: Tue, 8 Feb 2022 16:59:24 +0200 Message-Id: <20220208145928.12468-3-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220208145928.12468-1-laurentiu.tudor@nxp.com> References: <20220208145928.12468-1-laurentiu.tudor@nxp.com> X-ClientProxiedBy: AM0PR08CA0025.eurprd08.prod.outlook.com (2603:10a6:208:d2::38) To VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ffb46b98-8915-4316-64db-08d9eb13a1df X-MS-TrafficTypeDiagnostic: AS1PR04MB9381:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:785; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h0TLp/o3YCDWqWDbuoMWri5QtwYAVR6Ebd5czgQ73lTprNEmMGIhqCheprPFpmzpGxkiEus5/pT42DOYXKgSO4QzWasPanq2HlOdfiD9mLMhNA5coKxkWBJC8J7m3j4gv2ov/gMZjUD43Aye1i0ri8EmEIkl8gFYyunoPGCLeqfaQVj1ULhdpkSPO8jASk+kcxtNlCbjr2v8PzN0pmxGid1qmj9fnSc3U4vYe3XOfK8rhlRWA6lq8RjNAH5uYM/SEsPGcMTNa5U2YDG5Gu4MBBeS2NZg13d3IK3FUAkyxs8SvZGq0ikywu1MdF4CZmtdNds8yIS92J/1YSewY/uoZ4nUT5G8fodgq5UFcsbGddMbIP/5fnN2UdIjlmF3PMMbwjZ3ByqZa3FO+fHrTmSwqFlUf5bB9WMLSQRCh7M8hpfuHXz6BhNq+/pTix7rXxBYgURP0SduS6h/9S3JBNpq9z0qR4/qMzRP3/BqrEV5NO/lhhYPLAjvckrHHSWS1CXfkb8fJ8TsGbJqU6l3s5oAjyVzZXfK849beEA1nz588J6m/me4YjCgdfavJCQiNrcNjkO+yhIskvFj5UQd0pCKXNYLClYktoTYT4pNwTpD/sZ2Ox7kbQkeKY54KKYa9eJKTEDBRMVmAdR10uerEVfCBnMSAXF+SJwnIkLroAkJetrtivWKHNjr6y/FVl6XXlyzReHLPYwi2FKaX6GgtG8+og== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0402MB3405.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(66476007)(6506007)(6666004)(4326008)(38100700002)(8936002)(83380400001)(66946007)(508600001)(8676002)(66556008)(2906002)(186003)(36756003)(6486002)(86362001)(2616005)(5660300002)(6512007)(9686003)(26005)(1076003)(52116002)(316002)(38350700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: J6H42U7skdzkdoc9dsw9mM8HkwnHKeC/DyoqoY37QrgzN4aUTSnbfUntQB0LGtI2tLKE6HpgxSmc4YyRozEMWvxxxvpR/JWryPZfUkIKa33ON/9Y9pQtoJUdo8Ly/MxeiSpKjFidzRpC7t3EcGOmC86E0s6CzQeNp9AFlGCYKL6Oe51buemjSGQpDwMWvJ1yf8hK8g/ccVsURCFaJep9r9HNpdQrm3muh9CEtktJEgLqZLyi52KMRWIUxTs+iQl4pvcUlBwK3Rp8xX9uKS9wU+76s+mk/6W/VCPBUreNS4grJ1hDolltFTcUaU9xRLgQhxdPtwixBBZYmdWDCsFPNMCyum3Jz/BxkZuNz/MQrJQY/F3bHIhZt6EO5Fl1xbaTJ15ceO4iCCL/8Ic5hyTigRBngvlrGchNSs1vAIvYFLMNkxMxqziqNrlnghm192tFezBn0bdPN7hNF/Z4EyN1O3wX7j5SISnVsHCfKMl5nIA+N79bqKxPcawK56X2CMDqrOKbfmlJK7Fwn9XjQVW0I7ZODcatKsGY48Bt3a9gXqIb/mEIk5OMYJ8ckZFQE5k84m3PRj8Zcs2+UM0gsGaAJAwDfIaBPLDhb6AjONbB6nAXjMOTEv0PTC+fHuQzvedkqgNeS+btXUENEK3LPDdbnrGciHmOFGC6REcbu+iJK0jr25XNIODEqIApyqSdA+eXPLcs8AolTOaQu7bgWUimDPwKoX7Ks9O2U0vQlNJxScLtP69kSHnv3LBWDCFH38UpdtXsO9cQ1bQVXXQd55g4IQ2vmdfh9XNPWxgLQ2j4Oz4JYfPPpFWLavrCHvU2FLz7+w0K11XsqTZfeEzuaM7uF8ySi2Le8bJRxI/abjanC4pmxBQkspnynaeObW0uqzyOIkYmsKpchiJ2h/bYM9Bj8CpNc19/oOBtq4qoaoJWVLj86BLm9Hc6m8tK3ly/JQ7XFKFLN3iUGpYp7wO/q6tH/4ejU8Y/CvfsmQW57dIcNssHzxUu/xrmeM61KnR+ecJGrRAuOWRDgAINdqKyOrW6LEWEU+GS/WUiprnxP5JqLSmjsUbxg/fyPslmMGddX1n/T45HEWgToohSwNTFpdf9Yaw+gArSqH3DYfdwO5jtYMWhZ10N4aGdGW5q2xwzeSPCVLr6obWyqt8hn3P/+7IOMxQm/4ftdijPdCXceg06l1adSOmflBHpLPCceJW50l7UHHaVX64/knzZeVvf8oPSjogKIEyoi7kTkUyTQl72tZzj5fuO45JnMLuqEbzo4siHI0TFa5DpUmrRe4Gg0jlD5EjzGT6hJ9TaOuDIiH6LtapV3CymDZ4b1M1Opa8MEp2xCjCXTgwvAu6KKiMi6qSeezqL7J/RhiMEzd5Bu2D8rAuOFdLJSEMHa0+iv+stZti38g4LH5R7ajzpqcHWaU1c2mhPqKixJzzDbEZreh8l5zXU1sE8VXkAq0cxFQG7LxSnvMMZgTWXs0s4C4J1E2OX/gnB2xW6hUIU1L1Gaivdw/2U5Dgmlo3A+T9do6DZRhXYqFuvUphyNedTd+uYnE/F2g1MgtTvFcHHW5rw/mJ6U/mfHQ3o+itNbbjSjDQyAO6Pi2a7W+Y42VhpxfJXyavZsg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ffb46b98-8915-4316-64db-08d9eb13a1df X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3405.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 14:59:40.3876 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: a3dhwc/jnSKpCQw38FBhgKELyQdSqerIw5jYD4Yv/i8OJRbe8RmipeJvWwUOR5CnTqO1dyqMKENHrSF+GSMa3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9381 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_065946_725341_6E525BEE X-CRM114-Status: GOOD ( 12.59 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Laurentiu Tudor Lets keep a reference to the MC IO object before deleting the containing device structure, so that we can safely free it. This fixes the below use-after-free kasan warning: ================================================================== BUG: KASAN: use-after-free in fsl_mc_bus_remove+0xb8/0x198 Read of size 8 at addr ffff00203a304300 by task reboot/1362 CPU: 8 PID: 1362 Comm: reboot Not tainted 5.14.0-rc1-00218-g23d67ae4b6d7-dirty #111 Hardware name: NXP NXP LX2160ARDB Platform, BIOS EDK II Apr 16 2021 Call trace: dump_backtrace+0x0/0x2a4 show_stack+0x1c/0x30 dump_stack_lvl+0x68/0x84 print_address_description.constprop.0+0x74/0x2b8 kasan_report+0x1e0/0x24c __asan_load8+0xa4/0xd0 fsl_mc_bus_remove+0xb8/0x198 fsl_mc_bus_shutdown+0x14/0x24 platform_shutdown+0x44/0x54 device_shutdown+0x1f0/0x430 __do_sys_reboot+0x290/0x31c __arm64_sys_reboot+0x58/0x70 invoke_syscall+0x60/0x190 el0_svc_common+0x84/0x130 do_el0_svc+0x88/0xa4 el0_svc+0x24/0x34 el0t_64_sync_handler+0xa8/0x130 el0t_64_sync+0x198/0x19c Allocated by task 7: kasan_save_stack+0x2c/0x60 __kasan_kmalloc+0x90/0xb4 fsl_mc_device_add+0x104/0x8f0 fsl_mc_bus_probe+0x400/0x650 platform_probe+0x90/0x110 really_probe.part.0+0xec/0x480 __driver_probe_device+0xd4/0x180 driver_probe_device+0xf8/0x1e0 __device_attach_driver+0x120/0x190 bus_for_each_drv+0xec/0x15c __device_attach+0x168/0x250 device_initial_probe+0x18/0x24 bus_probe_device+0xec/0x100 deferred_probe_work_func+0xe8/0x130 process_one_work+0x3b8/0x650 worker_thread+0x3cc/0x72c kthread+0x1f8/0x210 ret_from_fork+0x10/0x18 Freed by task 1362: kasan_save_stack+0x2c/0x60 kasan_set_track+0x2c/0x40 kasan_set_free_info+0x2c/0x50 __kasan_slab_free+0xdc/0x140 kfree+0xd4/0x360 fsl_mc_device_release+0x30/0x40 device_release+0x54/0x110 kobject_put+0xac/0x180 put_device+0x18/0x30 fsl_mc_device_remove+0x48/0x5c fsl_mc_bus_remove+0x84/0x198 fsl_mc_bus_shutdown+0x14/0x24 platform_shutdown+0x44/0x54 device_shutdown+0x1f0/0x430 __do_sys_reboot+0x290/0x31c __arm64_sys_reboot+0x58/0x70 invoke_syscall+0x60/0x190 el0_svc_common+0x84/0x130 do_el0_svc+0x88/0xa4 el0_svc+0x24/0x34 el0t_64_sync_handler+0xa8/0x130 el0t_64_sync+0x198/0x19c The buggy address belongs to the object at ffff00203a304000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 768 bytes inside of 2048-byte region [ffff00203a304000, ffff00203a304800) The buggy address belongs to the page: page:00000000c0d8f504 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x20ba300 head:00000000c0d8f504 order:3 compound_mapcount:0 compound_pincount:0 flags: 0xbfffc0000010200(slab|head|node=0|zone=2|lastcpupid=0xffff) raw: 0bfffc0000010200 0000000000000000 dead000000000122 ffff002000002a00 raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff00203a304200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff00203a304280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff00203a304300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff00203a304380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff00203a304400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== Signed-off-by: Laurentiu Tudor --- drivers/bus/fsl-mc/fsl-mc-bus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c index 8fd4a356a86e..8cbac1b4b60e 100644 --- a/drivers/bus/fsl-mc/fsl-mc-bus.c +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c @@ -1236,14 +1236,16 @@ static int fsl_mc_bus_probe(struct platform_device *pdev) static int fsl_mc_bus_remove(struct platform_device *pdev) { struct fsl_mc *mc = platform_get_drvdata(pdev); + struct fsl_mc_io *mc_io; if (!fsl_mc_is_root_dprc(&mc->root_mc_bus_dev->dev)) return -EINVAL; + mc_io = mc->root_mc_bus_dev->mc_io; + fsl_mc_device_remove(mc->root_mc_bus_dev); - fsl_destroy_mc_io(mc->root_mc_bus_dev->mc_io); - mc->root_mc_bus_dev->mc_io = NULL; + fsl_destroy_mc_io(mc_io); bus_unregister_notifier(&fsl_mc_bus_type, &fsl_mc_nb); From patchwork Tue Feb 8 14:59:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurentiu Tudor X-Patchwork-Id: 12738841 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 11067C433EF for ; Tue, 8 Feb 2022 15:02:26 +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:References:In-Reply-To: Message-Id:Date: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=UEj/LwTTS7wxg9syav2+LPgXlM4hkqeAnOdqv1MncHE=; b=YHc9lyO6NhIXuF r7iids1pkaGChM6mF+a1oSCU8+C4+lsv+fX+kmGtu3RovL53Pbm+lRE9+MXP+88VZArELHT/OqbnK 0y95LXC3SxG5RwYu4KKOhg2/hJNc2RdX112bf4ya2L+Xk0U7KoDFnixZKXmdsNs2w8HfAzIQauCxO SBJPRHVQY0r5DserVWCBcuPCgXIeN/d9IcyJHp3Bf/0ULBnR0EwvGQhDW+6scxewgPnYpEzhNyWEE x9iZYeYsKMjiCh+MSPshF0I1ntYyR6BAAM76RZvp8HCUWC6IgSbFlfySTGtn09ScP9OQ124kvDQ6j IET7wL7byJG0MIyRYMDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHRyl-00ELwh-RR; Tue, 08 Feb 2022 15:00:28 +0000 Received: from mail-eopbgr30046.outbound.protection.outlook.com ([40.107.3.46] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHRyA-00ELgd-LM for linux-arm-kernel@lists.infradead.org; Tue, 08 Feb 2022 14:59:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SiYpMkffwm2zrxRQjIhX/REi2uL9gNBMqGASD2ayWWbiIRWd4PRu1fQ7zX6oo9HCwe/2Qd+96f2M2dyBZQzlt4/Z6u9Eu22csN70EgjeGbZ6vHAKLauSNQQrSv7Vd5MVN6qhnAbzXfShd8ev0WCxFB6xRPW64zHoTwtTJqwPdRKDh1Oj/wXCuHd1P8PZ9ZuZ41qB1soU6z5ivjCYqj4WTiYHyLRIRD6Af8B50VxSjnXLZe8BfEdyJcGzY4s+suP+yxEpT2NaS0UvObLp32O9Q9Qn3yK+Gky1SpSLhhXA3RwjveBMa7VzDOUjlArV9HT3BxNkjM6X1cLlTjGcsz0BDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zp9WvG8u/m3csNO8MZjMsh5YCHzDETXae6QZMPRyjO8=; b=k3OpI2LH3992IkBe7tBdxfZ1AkgQRs9BRsG30CtOBqYknIdDSwUWqQYNXq6cEHd9Y0ixBCpqIzrOJc/WFFudjby8FQz2awxjgWvoAIa01T4IZLREkqoC5UlNM7vC+zDUhzfLmOt9zbONoRXjJBm4ytJ9uEa27DH+S05s4jUI1Irmts76WAAngFDcJkVZTkHUj7SGvNWtxmJMGYV6vbFHUclq+4K5oQrro0JieTL6k26u5vow3RzqCKBQTaOYpX6ya0WdPUwwEcPGBBubo5oy1yL+l9gmzu/SFr2j0378huNrM4VYox+bs+93oMK7sPavjafrgrO5q1KJYsA3icGqEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zp9WvG8u/m3csNO8MZjMsh5YCHzDETXae6QZMPRyjO8=; b=sUturYqMswkxYNujlxmCH6IvGiOrd1dghuM0/rqILK/5G14IdVwbnFaJmVbZ+44M0b2Uc7rd9k9AoDbdORukgzodLumpNRrP5ha2FYO3G1Af3B5zSIOtIFN7eg5JCRWZPvw7dNK56EVnOxGKWILvu1y9NciFRFsIg0PEIhNerCw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) by HE1PR04MB3018.eurprd04.prod.outlook.com (2603:10a6:7:1f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Tue, 8 Feb 2022 14:59:41 +0000 Received: from VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::f826:3bf6:b77d:5a53]) by VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::f826:3bf6:b77d:5a53%7]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 14:59:41 +0000 From: laurentiu.tudor@nxp.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: ioana.ciornei@nxp.com, diana.craciun@oss.nxp.com, jon@solid-run.com, Laurentiu Tudor Subject: [PATCH 3/6] bus: fsl-mc: fix double free of the root DPRC fsl-mc device Date: Tue, 8 Feb 2022 16:59:25 +0200 Message-Id: <20220208145928.12468-4-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220208145928.12468-1-laurentiu.tudor@nxp.com> References: <20220208145928.12468-1-laurentiu.tudor@nxp.com> X-ClientProxiedBy: AM0PR08CA0025.eurprd08.prod.outlook.com (2603:10a6:208:d2::38) To VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0405d3db-4b5c-411a-6fa5-08d9eb13a26e X-MS-TrafficTypeDiagnostic: HE1PR04MB3018:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e6RvCam0YohuF74l6b/LSpzDvmO1t/lhxjKOQ3gWKqHzzGTibbb0JSR/JHU12S7I+43a8UUmpmnyZEmlw/KBk41oiIk6+1yc1cyWbSxnfo3Ql25CaWOAyVtMa0cxvB/tAWNu/y9wxao1Rvh1tuTS+jd/kFRvpH4hyCk0iQiYG4T+3CJzt6x9FwzavhqK/G201aPusdclDb4iFwV9neLdHIJaTcgWCbZGnXQTPe4rRzHtgrDl1BKN8XoX5kY7h+FBB2cxgaw617Ob2KV6OlKTRQLs5ntr/o3GEc2VRVq0UPpS0HEvbiZpVE9/YAR05oiFHriGl6cpK3G4VOeg5QAp1Udd0d/0Bi14c8eHM/auY+LCEBSmEWiME0PVB7dFC/xh5d3555A1Y1K1ui4yGKKla5jw3QX1d0ydEy4/QGQcafBlkV65pzB4t4GE8CB2dhKLOuxtCg8yGsqYXxKzXi0XCtZIYAGjKOQjKBuWiF9w5YQ0kV13n9bdTel3QvZkH76FSady8zzlLpx7PKsD+4WIgWWt97VhfhQTXMVBxrkdxfkiqaw3mezrpn0AQrbYleUVyyXV3iDCmizh00YSkYg/EwrfDQ11pujGsvBoMl3xhJ/DG7eQYgKVz8VK5Jja+RJTtc5LDR5jahP0akv2HO6UfqBggn+6cbakdLyJ4T4RL3941AvUGsFjK4EhY0JEvehA9QB+Vf3SpTHJlFTa0kPRuA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0402MB3405.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(2616005)(6666004)(66476007)(316002)(9686003)(66556008)(508600001)(52116002)(186003)(6506007)(2906002)(6512007)(1076003)(45080400002)(26005)(5660300002)(6486002)(8676002)(66946007)(4326008)(86362001)(36756003)(83380400001)(8936002)(38350700002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XX2XmiL39mOa9QE6k5bpY8+2SgV+NsVEPFH/MYbONRIScs7F8g4FMN4UFvi8FcSR1TilZ8KRDckLyxn4ZVyByTplT74+/hHRJU91EZNL7xUspo98zc4Yr5o3NZ0XCwrjhWTndzgbFmbjEnINyoj1odxTYu1BucXkVaYEwEhXrskUhL9c3M8rqinbUI0CVcDtkV5R0COyUvkoxRbeg47mQBuWlGhESMdiTElD+LSyKs6PZWBq7cEYGV3QXyJG+2p+jWKz5+akanJQwypEG1SgmlE/dcsYyMAu+OnYHoXPvcc0jR4mDkG4XqN7qXzhT29QepgBli6OAvpa5CQmJEW3RjTV7lhdkiz9wyMfhoQA7q4cfsywrX/2Bpe1t/SMTQZ5qx7T4AVmHzX3NCJKXGbwQ9ezSCGmrVxWcG18e23wcZZkDALqJAV6ceNG3tcxkhCCaBXzSw27UciSQj+zBVGGpn1QmYJ3vMh5RET3CHGOFGX8jPpH5Ap5n/7DSt3Xxk5dA9kaIgUJuiF81Vfx1jo7zW5eevD2RdnWmD3l4acDR7HHU3ZwEx1HzfdAtA/UORsqPC3HZHxR2Amyi7D2MYiPywqCZIom0R0Aaado+7UygcBxoS0w5q3OvX1FZhNRFykLr444PMx9XDQtf9frrB++RwTru6jnFCkOmak7x5krPKlxuYTk6N3LwUFEnE6IIgASBZbgPOsuvNErIQ43qPEKLabT6/BJ8wNMYtwX1DgKsTrFWaZi4fBG6DZNd27WkkwozF4FEGLKCcvjjuIR6DHp5NRGRCAJpDOhMUM7dU1vvOVRHm676QcdpZ7aONUIzXdwcbZct4SJb3Wzk0IrVv79C/9jCnfHyLcawRr0sI9xuNW6wPonb1mj/QtrlB0P0LLyIUUut4Yegemd22tGvWVfC76oGudgOCBxwmXFb2puIfzB0cvcjC0R1SfVdxeTyN4fxccDLbTyaFGhk5HEoSfdudi5z+eIuOVYAJKSFztvmX46GCRhPcyNdHjY6/Ikrbecehr/md3YKAioCdW4ntVNJ7yH2aGLp2B6IZB+HkNg7giZZeCCKbJ7g+pThVxh/niqFvJy8FRBZfAxUIY52IQ/2RpKITEY594zjpsw0YJhDyVpcy3MrV02BwnBcEvzKmM6JF7OEU5aSvhQvbe4gGXUJUrdlNkcaY3Y0iWv4dOKTM+ZpqBCCFsN0w8C2Tz6CP5z+ImKh1TUZgC0bVQwP7nq65bIeMNWx90sQVO5xDuv7H4+70vqbPjRloWXa+q5/jfsDBmoAryFn+KTLmb1q8JnLmf91FXeWQdW9ArLdcQLwYVC05XHV/tL2cid0ObllU92gejFqWYJz5mhxOyWz2TgYPs12rHfJwMQXclBKigVF7/IDOgjAjDNopudK8Med4Zwft29WX04O8P+DJTaJtSXPvTek5XzS4ABBsUIxkQhvp9TCgIYppuC59cfLqbWQJ1o+jnzTy8bAl5I71NXe2r/NzgMWY5dyoii5Blww5UAP+BLq4JozqhqGg8B0KlIka5hJc2Zeex4jmkXE7aWsNC9i3ic+6cC34UE6qCcqHixoYo7CzkH7TB2ku0+hXvhAIGGIJB/RRxZyAjzRgKN8qNRNQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0405d3db-4b5c-411a-6fa5-08d9eb13a26e X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3405.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 14:59:41.3406 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +YWhMnxvzfym0wRAXXYNYiU0nv4LUDNZ3iIlwlKw0mkShBFyRIwNYxeIP1NzSMzClg/ASZM8ONpHMHVi/Bz0YQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB3018 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_065950_769610_0730B327 X-CRM114-Status: GOOD ( 14.90 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Laurentiu Tudor By simply calling remove() op from shutdown() op we end up deleting twice the root DPRC fsl-mc device. This causes various issues such as the crash below [1], on reboot. Re-arrange the code in shutdown and remove callbacks so this does not happen any more. Unable to handle kernel NULL pointer dereference at virtual address 0 Mem abort info: ESR = 0x96000006 EC = 0x25: DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 FSC = 0x06: level 2 translation fault Data abort info: ISV = 0, ISS = 0x00000006 CM = 0, WnR = 0 user pgtable: 4k pages, 48-bit VAs, pgdp=00000081086db000 Internal error: Oops: 96000006 [#1] PREEMPT SMP Modules linked in: CPU: 1 PID: 977 Comm: reboot Not tainted 5.14.0-rc1-00221 Hardware name: Freescale Layerscape 2088A RDB Board (DT) pstate: 60000005 (nZCv daif -PAN -UAO -TCO BTYPE=--) pc : sysfs_remove_link_from_group+0x28/0x94 lr : iommu_device_unlink+0x94/0xb4 sp : ffff800012b3b8c0 x29: ffff800012b3b8c0 x28: ffff24f8e061a940 x27: 0000000000000000 x26: 0000000000000000 x25: ffffb43783811228 x24: ffff24f840a882f0 x23: ffff24f8400cf000 x22: 0000000000000003 x21: ffffb43783bb6e10 x20: ffff24f8c9641040 x19: 0000000000000000 x18: ffffffffffffffff x17: 3236366535672d31 x16: 323230302d316372 x15: ffff800092b3b537 x14: 0000000000000004 x13: 0000000000000000 x12: ffff24f840467af8 x11: ffff24f8404c7d98 x10: ffff24f840467908 x9 : ffff24f840064b98 x8 : ffff24f840467930 x7 : ffff24f8e061a940 x6 : ffff24f840453b30 x5 : 0000000000000001 x4 : 0000000000000000 x3 : ffffb43784442d28 x2 : ffff24f8c9641040 x1 : ffffb43783bb6e10 x0 : 0000000000000000 Call trace: sysfs_remove_link_from_group+0x28/0x94 iommu_device_unlink+0x94/0xb4 iommu_release_device+0x34/0x94 iommu_bus_notifier+0xc0/0xd4 blocking_notifier_call_chain+0x70/0xac device_del+0x2f4/0x424 fsl_mc_device_remove+0x4c/0x80 __fsl_mc_device_remove+0x14/0x2c device_for_each_child+0x5c/0xac dprc_remove+0x44/0x70 fsl_mc_driver_remove+0x4c/0xa0 __device_release_driver+0x188/0x22c device_release_driver+0x30/0x50 bus_remove_device+0x10c/0x140 device_del+0x16c/0x424 fsl_mc_bus_remove+0xb8/0x160 fsl_mc_bus_shutdown+0x14/0x20 platform_shutdown+0x28/0x40 device_shutdown+0x15c/0x360 __do_sys_reboot+0x218/0x2a0 __arm64_sys_reboot+0x28/0x34 invoke_syscall+0x48/0x114 el0_svc_common+0x40/0xdc do_el0_svc+0x2c/0x94 el0_svc+0x2c/0x54 el0t_64_sync_handler+0xa8/0x12c el0t_64_sync+0x198/0x19c Code: aa0203f4 f90013f5 aa0103f5 b5000060 (f9400002) ---[ end trace 1a98489358f432bb ]--- /etc/rc6.d/S90reboot: line 15: 977 Segmentation fault reboot -d -f Signed-off-by: Laurentiu Tudor --- drivers/bus/fsl-mc/fsl-mc-bus.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c index 8cbac1b4b60e..459947988e0d 100644 --- a/drivers/bus/fsl-mc/fsl-mc-bus.c +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c @@ -1230,21 +1230,18 @@ static int fsl_mc_bus_probe(struct platform_device *pdev) } /* - * fsl_mc_bus_remove - callback invoked when the root MC bus is being - * removed + * fsl_mc_bus_shutdown - callback invoked when the root MC bus is being + * shutdown */ -static int fsl_mc_bus_remove(struct platform_device *pdev) +static void fsl_mc_bus_shutdown(struct platform_device *pdev) { struct fsl_mc *mc = platform_get_drvdata(pdev); struct fsl_mc_io *mc_io; if (!fsl_mc_is_root_dprc(&mc->root_mc_bus_dev->dev)) - return -EINVAL; + return; mc_io = mc->root_mc_bus_dev->mc_io; - - fsl_mc_device_remove(mc->root_mc_bus_dev); - fsl_destroy_mc_io(mc_io); bus_unregister_notifier(&fsl_mc_bus_type, &fsl_mc_nb); @@ -1258,13 +1255,24 @@ static int fsl_mc_bus_remove(struct platform_device *pdev) (GCR1_P1_STOP | GCR1_P2_STOP), mc->fsl_mc_regs + FSL_MC_GCR1); } - - return 0; } -static void fsl_mc_bus_shutdown(struct platform_device *pdev) +/* + * fsl_mc_bus_remove - callback invoked when the root MC bus is being + * removed + */ +static int fsl_mc_bus_remove(struct platform_device *pdev) { - fsl_mc_bus_remove(pdev); + struct fsl_mc *mc = platform_get_drvdata(pdev); + + if (!fsl_mc_is_root_dprc(&mc->root_mc_bus_dev->dev)) + return -EINVAL; + + fsl_mc_device_remove(mc->root_mc_bus_dev); + + fsl_mc_bus_shutdown(pdev); + + return 0; } static const struct of_device_id fsl_mc_bus_match_table[] = { From patchwork Tue Feb 8 14:59:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurentiu Tudor X-Patchwork-Id: 12738842 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 97894C433EF for ; Tue, 8 Feb 2022 15:02:55 +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:References:In-Reply-To: Message-Id:Date: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=2t+NSKYCp/HvRSb5powmJPbPcbOfR24RgZO9MxTe7sA=; b=0xd3EKYP9YcqOH lqZEXtX7Kv3izct2tGSz4gKEvTbw53+TB/ZB3Qq3ZDDaTHXhwx/CSzJ24B31em9UbqrDm6eUrEC6b oH7cjAOi9yY8HQjJAI8zi03SUl2ZPuPF9HtOj3BK21uVRck7oBjPYbsZfqu1ttY7B4a4yP/WHej1E a/Fq8jdlBbbSjwW9yr7NDhcJq4ihChqDG4pr4sw7/vdrBGsgoeb77hVs/e1dKcgs1rGgii5oF4cLD GrkVV9ke03O1/Kc4CtXAGFfgvVr5lYoenke7PSiFGC+vGe9GkIE8v9qhMLZSMxF/MGGljW89VGjn5 bfqDTdEQTj11znIeJGnw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHRyz-00EM1M-80; Tue, 08 Feb 2022 15:00:41 +0000 Received: from mail-eopbgr30046.outbound.protection.outlook.com ([40.107.3.46] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHRyE-00ELgd-0b for linux-arm-kernel@lists.infradead.org; Tue, 08 Feb 2022 14:59:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R3OTk3X/Ol+i+yhjgkS0fO//41Boswx+sheh0IhuvNnYraNt94baVYj5KEcxLLysdcXFGaJDpnSOxVLqBojoa9Of7TepsOt2DbQClNWGSNdB+5nQh0ZIImqxXi4QmsE03G7ovsy+dpE5kHniTuqKOkRX+KLrCAYYvGpXTRk71R74tuPxkTzO3kjzv9xzNBizKABWswoC6LaDdj9NBXT/YpwQe3fLr8m8lp20on7DJbCbB+7xnslt8pDStAG89G3/ZLOvd6qT+oSAfnGzCd8NnuWMPCgHdf7hGt7ENN5RMBpPuaMjMxcs9gMCSUTrUfFkRwiXaaX+wWUeBtviSQSlEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l3+UUk7P/HeWsYRBBgClihoYA38mPviFCIkotfl5XKc=; b=CQAqaNhwpaeEdC6osb+r8sRVtfFoaNZiPcKPok+AJCWReIvxqpf2a1+GpV7yUdfkgvUYSsHIGRQhNpnSFmBDHiJbO0PUYFo2GOXeA3fh1gq0hsVZdLFDojEaBjyP9YtYcYrAx+hXi3WkQHaCKzbbo3bdwwcDP89rlSYVMxObBnhTknGEAHch2iDKfwKPMq+RCObyh+2VSxfnmDm9GYS9FL2wztAOGWyI3rSKrZ9h6x0hj31jcTGcRrpAbgZGqtRD5rBPUCKsODBF+0qglVF+Q/gbQ0PfyMqR18fQVw2Oej5ZYpcx/Jhy+Wg8ZZN3Y4hvoVyx3vbOpS8MDeYMTGLzWQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l3+UUk7P/HeWsYRBBgClihoYA38mPviFCIkotfl5XKc=; b=NW53n2gGlSH95WjCKktBE+sicJBmgFl1J/Fpdj/fJXaykGrVxiQu/Dqici4K83zU+1vlCRgkEIPWJ77D/+5UKWq5Pbk8bEXJrcovC5vjO9z+Vt/gQRzVS3iofIuEoP9tir52JciJ40Mx50cx5AHJBZxy34Cg0haGiPMqLMHyrtE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) by HE1PR04MB3018.eurprd04.prod.outlook.com (2603:10a6:7:1f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Tue, 8 Feb 2022 14:59:42 +0000 Received: from VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::f826:3bf6:b77d:5a53]) by VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::f826:3bf6:b77d:5a53%7]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 14:59:42 +0000 From: laurentiu.tudor@nxp.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: ioana.ciornei@nxp.com, diana.craciun@oss.nxp.com, jon@solid-run.com, Laurentiu Tudor Subject: [PATCH 4/6] bus: fsl-mc: check for null irq array Date: Tue, 8 Feb 2022 16:59:26 +0200 Message-Id: <20220208145928.12468-5-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220208145928.12468-1-laurentiu.tudor@nxp.com> References: <20220208145928.12468-1-laurentiu.tudor@nxp.com> X-ClientProxiedBy: AM0PR08CA0025.eurprd08.prod.outlook.com (2603:10a6:208:d2::38) To VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bcd9d908-8bb8-4a7f-dcc9-08d9eb13a2ff X-MS-TrafficTypeDiagnostic: HE1PR04MB3018:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0yG6LTDfYWvugyU3jGCNrxKjuGaAyIC2XzrttiPrf1qR2+eofuyHRbcjc/IshY9iuO/45UHHM+TizQEyjREl02rjpMzVaB8MP1Q4Z+OD8SmLeLTJJcld98f67AhOSH6ATC1EHccgGxi88B9WEpcO6EnrFrm2vE0YMO+cAgC548kN/9NS7DjlSr17kwY+nXYDg+N8LZOeVZkbxRqHOP30w/P2uMFv43co7rgt46zuq61qGxG7mSDEZ/gAuGiBuP4N190xcXeMDwpcPoM9Qzj05nTE8LslHKzaxZld5xVgPn70ikbJQrSLoJr3YBmK0NonRFrV5tP7LJ0KODgIt6TFEnDp618SINZ541wH7pdc0j0tPaAXp4NlH6buGRjrpr/igp+1UCKv1oaDvPwB/LRGAkqNLsC3VC1g9L5ew+HsCQWSGHFHuIEccbnNQNAhCieatwAjgn1dN7Z5o5bGh13zDFaloa+vg5S3RfHYOOBgEoTFiITP1MFqDpqO4SdCa8+10B5ATUVvM/LBORVyDja98kvPGYzSVZvFnE26uPHtSY32voWl4fL8UE1TewEUsa9li4QcF9g6EO7O9dUzoDeylVi0UwxMoXeDRzdmNeuSlmWzV8Yuiz/r2GQwmVSGyH7EUusmPSw5mTKtHPOcBhA7RXEkqa2TmKP6QhGV/omPVMjnbK5TV2/KdrfHDnYld/juI977WYY1l/hgZZOEcI/cdw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0402MB3405.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(2616005)(6666004)(66476007)(316002)(9686003)(66556008)(508600001)(52116002)(4744005)(186003)(6506007)(2906002)(6512007)(1076003)(26005)(5660300002)(6486002)(8676002)(66946007)(4326008)(86362001)(36756003)(83380400001)(8936002)(38350700002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9XpURDw7C0KEm6/9YuKzx3rW+ZYooivs7K3WiE20AgGqpc0CgyitpLE2OsgtcxWKHb0SjIRgXh/998nV5hCeXAjUfNS52E44kpr2Pgf2MEoLtOjdVoRl+5j5pvinVx4PUlTan+HmY+3KnWUJky7umbKcdVrV6wwzVaF+fUQIKNxD8H7A7P7F/2Gnpb1TdMTt6XfOV0ZQgzXVdmuSbIopPhpigzq0sLV3WSS1hxSujzwz+ktWOZQIn5WnYYKH/GFYyXOihY1ph2q/W+1SfPoR/LyZ0IOphCMmM+A9bFWajohtQvD2ymlefRkQS3fmPqMOs80Eo3dzxNoYvwzo4EnLGSGf605xodEjSRPMrvUqN6PkXb/G39gh0jB2vgLRzhpnztyI8Ij3viiRqKSRfrNPhljjNXzeWWzwSIZAkk5vBx7WCahkPPZeVJdEHpybhfdqZnlMuhe1VcJ8fyAUB3d2kwwQ+LFNQuAq2IXnOMUpJGgfHDMwJx7VSMbEvvkZKh+cjrxz7sgGpQ81Nt7bFAhsFv0HBDz/zC/TxISunoO3AedFUdknf0Vsk5IPGTs5/NXOCF0jb45dj2AlHGJxTgvhe5rdafYdGQQmdVFrw8WS7wLG+lkBt69+4226NgfOwUliMFIu6Qnmobmp9urFgN0ybpgwy+W8vtTFmpR7QMqbi239OrKyeHy2WblPiYyYF42346rug85GfV5ZQLfVR/WY9ZpbPWvFglm9xIGwsO3FLHQ9MEO24hUvMm1Z/aQg/B8fNTYTjOwGgOtxPzR2vozJfuuwglAiaCXXSRVn4S+UFQ1JKLuGk9XOGMt9QLvNHv5nrP3EjtTfWvSt9fndvRtcSFN91xzxx4DnTWHMZ/ngqhv8tu9qNuJJp105Y2UEF/8shGtiaI4NPuqc97eKVZQNZF7ekuNJwI3qe0GPjWTfn9UCKV5axhBCnS7Z3I629JEkF2zW+Khh83G4S/X55tBzdpu61mYme2n2i1VyMyi86yyU9r2hSoEGw0Yf3ocvUZ1wOcGNMviL0c+qFK7j5sz+5jcjmFXCQj8MNVp9fxIrgOkRzKJIgt+uPSXDrM+vc1asuPH0jD+/nWDcxF71UjNjP5R11V/YNItqpZnykSgUjRcR8pzwet9oE+uceXfAxsANb2k9hMvgJWVZ1uYML3464syibzaQvfoUhXdNlu/zE8h6n/Tk4j9d678dM8LcxJ6iLN7gmJDSiogu9MnocxouhxtQXi85gYQZDjlW46wXUSpzgnPebbbqSLcTr1fBzKGfbfQAEpG7EcUk1yTCAEHv3kWgv++Xt1vD3PcjbrJfxMZaw2hZH5pgNpLmajdBpWZSV1Txjn2yE7EumSeOHsY5Rc3AGLYTFRppMxxlJN0FkgXT2rsG+7LY9GVMX8IE8tD7zjsEaLmhvmgOo2w5B3IqqG2l7QamKSFIm4GI3DeiuLvoHvjBFRu0WZHvYwVo/RCeV4I5PmA74xuqM9ogfuHMuXw9TdMGnRKbAsiK8oBJ9WgwvD0ssGL90tfb82sM729gemMYaEw3UF6RYO+z4xl9oHuYlpjBPEm/QwOemlMI2DoB+HUTR8XHe+dXX/N2Sbp1LDAUDzYx8g7RZigbanEvYg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bcd9d908-8bb8-4a7f-dcc9-08d9eb13a2ff X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3405.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 14:59:42.3250 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qQDPiXpdRoWDE2SZQpUSyl7+jo+J9rXq6wzRBQt/vSh7mcSGgDn2BGOcCKZd5e538DveANctoHlGBPiPowrbeA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB3018 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_065954_115540_5D14C029 X-CRM114-Status: GOOD ( 11.20 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Laurentiu Tudor In VFIO case, the irq array in the fsl_mc device is not initialized, so given that in upcoming patches this code will also get called by VFIO add a check for null in the irq teardown function. Signed-off-by: Laurentiu Tudor --- drivers/bus/fsl-mc/dprc-driver.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c index 36681cf7c42e..8482c4fca835 100644 --- a/drivers/bus/fsl-mc/dprc-driver.c +++ b/drivers/bus/fsl-mc/dprc-driver.c @@ -767,7 +767,12 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) */ static void dprc_teardown_irq(struct fsl_mc_device *mc_dev) { - struct fsl_mc_device_irq *irq = mc_dev->irqs[0]; + struct fsl_mc_device_irq *irq; + + if (!mc_dev->irqs) + return; + + irq = mc_dev->irqs[0]; (void)disable_dprc_irq(mc_dev); From patchwork Tue Feb 8 14:59:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurentiu Tudor X-Patchwork-Id: 12738843 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 3C406C433F5 for ; Tue, 8 Feb 2022 15:03:10 +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:References:In-Reply-To: Message-Id:Date: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=zDr4k8J6tWrTZEfU1AQ58xyuD6856ap9GpJdu6mZ7to=; b=F4+ut7rNfZ4KjY 5EHVgWlG+MMUZtnfxk/eMmfpUus6/CIUdY0WqL6uXanbe95R8fk4D89ktoCjxUOmPolFO68joCXzu RmJxSTJFnzi+Jtlkn/WymJAjJ/L3E8mYVXTLzPr+uI+CdrBAFXZoWDc5AAcv7tu2NyQPI+VlZ8KxA LgRa5XU8DZHFpMeN/fT3QRYP4fHm4p9hOZy6B977xRcPTyx37zLaSVsLxYwiYH89VgmN9MY1B0x/b wk8lWiUqbIZvFr6PbRy53fRqH+LeMvAxf+tDYkPiYEREh2EQcuoX46yya3922Ot/lSCMf2PVds+B0 Q//S4rKej/lnSQ2Jy7VQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHRzK-00EM9N-3T; Tue, 08 Feb 2022 15:01:04 +0000 Received: from mail-eopbgr30046.outbound.protection.outlook.com ([40.107.3.46] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHRyG-00ELgd-5e for linux-arm-kernel@lists.infradead.org; Tue, 08 Feb 2022 14:59:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WRUIgZgl/GxGXMTzpqZ0vkgWAIZ6AG2B1P91hme5dk8hKepLj6tAiITOGUHS//6WrOiw7kr4lef34l7vzrpG396LDW+J2w8pxqoKpmu19Jr5+nzQP300DG9Gz0Ci9qVhXL9GUHpm+j91CsZO/ypV+I7cOcJtpDOj1iJI1zLDNQDs01PADfUiTkuzDjH+ETiilOkQ1ILyfx9wvahjGEmOCEVXiYhYRO42kM3M8zmPzamQyKip+oNmvveZhxF1EkAk1KMYkoWcY+gktRkQJuaWPWwmIeY1MYFGsPnhHmug94RAhUgSkTBHogKFC+KwfsJzaOLt751FY5d7A6TvuihppA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=I4O2Lagv7O1pf5L/VLtiBzyR7q63fNy3Dyk1iOpkkUQ=; b=dE6XFCl/Gy+sDMNxiJzt3/a5SvXEF7WOWZZcHEH+7C3vEUlOCk5uVV13PtWblTHkuaxVoKQ+8Lr6667Z5JKpt93rhtt7I0/zOGHHtuOKDbCg0BHk+ruasM4RwZlzahojzxKXTu6/OOqcBL5WtfVADLGNlne4ZfEjoSu/6L+mHItp9HZCvEi0MLr+A5xs/mTvqXNm7F+sN0u8GQ52DWcf6V61YWDDQgHDdGF4cTnW5E6YOJpq5ItabPkPn/yoJIjbcM61gR/5I7ewFIQjYcp7bHuDJDkkAnpW16/p28G9LEbSYbevl4hiZmvCbeGJGWxiigAYFdovblbScA7uPbrOgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I4O2Lagv7O1pf5L/VLtiBzyR7q63fNy3Dyk1iOpkkUQ=; b=eTU7Rxo4XJnZ+e+y+1XXlMo+qrhgbfJki4ajAvRrzSucNpXguZXbt8uVs1Ac0VKO2gVV278efftJcdkZSpXyEE9nrU9d1yVAmK5ZnEdm6mUy/2eink59ZtCm+BCJj2aCtdruLzsdRHW7570ksAVT4oLwm7pF/qLPO99YlTU7a34= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) by HE1PR04MB3018.eurprd04.prod.outlook.com (2603:10a6:7:1f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Tue, 8 Feb 2022 14:59:43 +0000 Received: from VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::f826:3bf6:b77d:5a53]) by VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::f826:3bf6:b77d:5a53%7]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 14:59:43 +0000 From: laurentiu.tudor@nxp.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: ioana.ciornei@nxp.com, diana.craciun@oss.nxp.com, jon@solid-run.com, Laurentiu Tudor Subject: [PATCH 5/6] bus: fsl-mc: move uapi misc dev create/remove in probe and remove Date: Tue, 8 Feb 2022 16:59:27 +0200 Message-Id: <20220208145928.12468-6-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220208145928.12468-1-laurentiu.tudor@nxp.com> References: <20220208145928.12468-1-laurentiu.tudor@nxp.com> X-ClientProxiedBy: AM0PR08CA0025.eurprd08.prod.outlook.com (2603:10a6:208:d2::38) To VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dd72cb19-e644-4aad-49dd-08d9eb13a391 X-MS-TrafficTypeDiagnostic: HE1PR04MB3018:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1148; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9QU6Ws9pPBCg1ESsLQTOu4cDhEv63KWtvs7TxWhLudutEfwis/YikAJN/WF29KLEYjW5GKcCp3IY0gNkcuiDiD1NPtRcuJLAJc/mBGOWbanPIAwsLtzJsluzIEhykLvOhQtMHT5XdqFKPh5vvCA0tDPMt7qEowWSmehREgyWbiQcTvs/QxvJNrwNqy1lYJQqQsZEWm8Xj4YOHmLBY+fCPR01uBvQOUpVZd+og/UvQGl+knM3DuiUpVJ/hpM5ggTY17g0Qikni7oCUUyrhwuUGkXG1AC4F7pwpLEARKAgKCYO2X+r0xUDAb9yLWOEnaTiDyNEChQxC7ydc9B7duLO8p3W3ugq0KyU5GkIoRANpBcD9rc0BEf5KhZwU7pEOycVXhSOyrbyxbRlAzfTifkCA6NiAWbiYLK2eXRJk1r6i3d26U8466o8v4k8zGE+XUCYws/lnKSOed3v/mDc8NHyDneE+c5pDWpsw2iS+RAu5sxfNIAzpZXR7KhZPoNvCcVEhBo9AEX54TghETTDz7eMpy7qd0JXYLiky1ExhogW3COwH4wmQgSlhZNmbpTqRc2tcYyBQR2y6dYF2zVPPE8sunJ6R0wYJm6EDW+bKcKlSwsnDzI8WVtHLcZ371D7gSu1HACTfOFD6vNBP8ASGrlPlBiXMm/pu9yS0BKN9T2y/t8rBBIto0zEx3LsFejrmv6dJR3koUoLSAKk7pX8i/h60A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0402MB3405.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(2616005)(6666004)(66476007)(316002)(9686003)(66556008)(508600001)(52116002)(186003)(6506007)(2906002)(6512007)(1076003)(26005)(5660300002)(6486002)(8676002)(66946007)(4326008)(86362001)(36756003)(83380400001)(8936002)(38350700002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bPc9ZkscoVtNMpfH1wHqFaVZm27rDo3Qvs41mH/vMnjNrqWVXjLyQpzjRojQUu4E7ZIeRC2olBnzhIgQchNSu5LxtXGSMSVZYB2+YMxCyX+uqNLFN4RGinHBCsPhWY18sdEOX6pjy79od0bok8qffsNv63ldV/xAB2hbmYwi38chpm6RRtP1kt7eiLDnPTHo92y8cUyHx0fzGXj6KROe+P4O29YVTXLXX7t+BTTx84sEhXplNnYCEwvGVWeIVNGUH/xgjG5Mo7kvqQLpwSAzPUaUpG3ckxF3gsl3J13eOKPOe/99Gag1XktLZJb445aKDspNM7eMRQV2WiUZL8aYGpkWEQwyZHKT5B2Be1yLlaYjkOd1ypMSBYzCFQw3xZguqMLg/hyxB4M+SHG44H7SJUvCSwAffyE1lBRsmje379bkDepMt/08yfW94o7aKRIpeSaTNWvv49EmqpbAE0N7krB06k1joc2j+ubP+huUdUZ4b7e45vHFslZ7wR9vJkU7rkmJbJ2EzI3+vGOfFEzq5rIj7o7EnGbIIC7H3NP3Xj9XC2upqE6S5RJk/VN/ro7IshbUVgIqFI0NNjM6MtICMgodnUw1irzpwRbv3N3ftkKhe2HJC6a0fB+xITgEB4F55tjS035f9C2cRJCIhne5YPbyDxZiQQ3ENH86+Mh9vLokVM1IuUn9kP5O1UqUCkPmd7vztwSPktv8Dv29t04ZoQYdnuZKkopCkXUXctrnxf/dgmjKEbAXSF7Z+tiM/3eMzxUQWtE9iSAcRED+cEYKZ3slWDjDglCXbcx21Zpp3T44GDuzNWujnjeRfvVZLd55nKP4xqLipsagYr91VRwUPzIW9ljxLZh4SVVyH9OxxnnGandYKCMkSypBbVvO45AqmtNnGpoQqbYyVuRb4uFw6hs45lXLfYUSNGigiCuWcs5yyaeSnuJUk1bHlifPKrlYrmx2KHQY5eYREYT34+YWDwHBgR3Q6oKk4eLA2/Ody53sqATvSLrWZpkVYjmgnkVF9k/KVe5KNI3LNAK6fsZppA0VNrSPpZDQI3Q7gYzi0r43Fc8jWBq7cwHo3qJ0WaTsAsNu4Vgr0qbJKs4o+emVYa/sfneYNIMa8C1j3QWHQTbGUqYSCI1L6fCPZ+to9ZlMA518fKN4qijaKUTsQgRzjhvXHOB+t18jfVWOCeEkQjlp0oJIjdpUgGSS2AkiP24pWqfrZw03Zxa1a8TWy1kfuQLL5zV2WSBVN/RSYmnu1fWxXYLDwiasCpD4fH2C+3Za8spNzB2x3Y9TL16yahexh0KMt4KoSMKOfu55kjKoQDaLpKQXqqe4m88ULH4TngyyFUYS7lYKk3M39wTqAadfPvABV69CryRu/19j/sAbWqoeq13jooV1ewosaM01M3mYvMiWyyQiSmswQGFM7RHWnxpFwjMNdIhRoIMcF048T1OuusH+McnTzDg2pNlMxMY9OvramLOrHbFia+w8hDpeKcoMMopTbxM6THtCjSKOV6Ueb6DofvvvysBJyHr4rxTotZPkprezndiHABBME0o8AGUBfqLomlkujebdjLEJjBFKl9LM2afUVeHsVYd3a8TyaiLXb7HLphf8mqn9FoklUw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd72cb19-e644-4aad-49dd-08d9eb13a391 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3405.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 14:59:43.2312 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7h/Va3q6pmSgjd/zbNuMffUz5E/fSCH+3FsUH91KLPBbbE6Dora1qIfDr/0npnGV9Q1ooKtg2wdSG9Cnk1tU4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB3018 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_065956_249558_0C5E9ED9 X-CRM114-Status: GOOD ( 13.50 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Laurentiu Tudor When devices are owned by VFIO lets not allow user-space to play with them through the restool management interface thus breaking isolation. Drop restool misc device creation and destruction from the common dprc_setup() and dprc_cleanup() functions (shared with fsl-mc VFIO) and open code it drpc driver's probe and remove ops. Signed-off-by: Laurentiu Tudor --- drivers/bus/fsl-mc/dprc-driver.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c index 8482c4fca835..82bf3fe09273 100644 --- a/drivers/bus/fsl-mc/dprc-driver.c +++ b/drivers/bus/fsl-mc/dprc-driver.c @@ -618,7 +618,6 @@ int dprc_setup(struct fsl_mc_device *mc_dev) struct irq_domain *mc_msi_domain; bool mc_io_created = false; bool msi_domain_set = false; - bool uapi_created = false; u16 major_ver, minor_ver; size_t region_size; int error; @@ -651,11 +650,6 @@ int dprc_setup(struct fsl_mc_device *mc_dev) return error; mc_io_created = true; - } else { - error = fsl_mc_uapi_create_device_file(mc_bus); - if (error < 0) - return -EPROBE_DEFER; - uapi_created = true; } mc_msi_domain = fsl_mc_find_msi_domain(&mc_dev->dev); @@ -713,9 +707,6 @@ int dprc_setup(struct fsl_mc_device *mc_dev) mc_dev->mc_io = NULL; } - if (uapi_created) - fsl_mc_uapi_remove_device_file(mc_bus); - return error; } EXPORT_SYMBOL_GPL(dprc_setup); @@ -734,9 +725,15 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) { int error; + if (fsl_mc_is_root_dprc(&mc_dev->dev)) { + error = fsl_mc_uapi_create_device_file(to_fsl_mc_bus(mc_dev)); + if (error < 0) + return -EPROBE_DEFER; + } + error = dprc_setup(mc_dev); if (error < 0) - return error; + goto uapi_cleanup; /* * Discover MC objects in DPRC object: @@ -759,6 +756,10 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove); dprc_cleanup: dprc_cleanup(mc_dev); +uapi_cleanup: + if (fsl_mc_is_root_dprc(&mc_dev->dev)) + fsl_mc_uapi_remove_device_file(to_fsl_mc_bus(mc_dev)); + return error; } @@ -792,7 +793,6 @@ static void dprc_teardown_irq(struct fsl_mc_device *mc_dev) int dprc_cleanup(struct fsl_mc_device *mc_dev) { - struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); int error; /* this function should be called only for DPRCs, it @@ -821,8 +821,6 @@ int dprc_cleanup(struct fsl_mc_device *mc_dev) if (!fsl_mc_is_root_dprc(&mc_dev->dev)) { fsl_destroy_mc_io(mc_dev->mc_io); mc_dev->mc_io = NULL; - } else { - fsl_mc_uapi_remove_device_file(mc_bus); } return 0; @@ -854,6 +852,9 @@ static int dprc_remove(struct fsl_mc_device *mc_dev) device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove); + if (fsl_mc_is_root_dprc(&mc_dev->dev)) + fsl_mc_uapi_remove_device_file(to_fsl_mc_bus(mc_dev)); + dprc_cleanup(mc_dev); dev_info(&mc_dev->dev, "DPRC device unbound from driver"); From patchwork Tue Feb 8 14:59:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurentiu Tudor X-Patchwork-Id: 12738844 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 C133BC433FE for ; Tue, 8 Feb 2022 15:03:26 +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:References:In-Reply-To: Message-Id:Date: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=h/Xi02cxtZ/yPIKyg025SGz8mHyy/+Pmwl8MWhfo5zY=; b=TCD/Rh5a7HwE6w R9XbCdVdB3+bmBU+iLZjJrZUz725Kiy3IDyeM7G7j7Bn6GatGlqViJyZDmjPvViKE02kmA5430eL4 92yDvzFkL7gNg6QNYhqqRhhpwiqmDozxc0l85xAzm4fnZphYXqHfLJHrIwquauAMRsHAPqk9a97Fw LKv5HJ3ZcOMplYRq5GYG3ZgTxcH2Ss65XRbXL3m/cvecx7BJGbxxHbJkaf2sbvvwBlSQDt5DxHr3W RZzI2IqxdkrNaRml/v12Q4T+4L1tnRm0UNxc0quTf1goouZSzvSAx9fqMKOpup8CpecGaCMAHXuIC ++Aky//2SGtyjZLZTBig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHRzi-00EMKE-Vw; Tue, 08 Feb 2022 15:01:27 +0000 Received: from mail-eopbgr30046.outbound.protection.outlook.com ([40.107.3.46] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHRyI-00ELgd-41 for linux-arm-kernel@lists.infradead.org; Tue, 08 Feb 2022 14:59:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=foGVUmmSDbgAp8bOkccqNb3mzIX1opRbXJIOO2lAGaypBc1IE269UhlvbRPm11JjNQtuxD+WtDM0yV+za8x1/Kzzbk1/mxwpEiS+wZPFc/aD6NpYvlaiVjIj1MLlhkm9D+aCj4FrgHt9yqYZh7vdibQjeMOkV/jarAA8xHpI/ZMj4Wk52LGQXo/nVe7D5P5NRpRIrRSPuoAZJbe9DBYZF/5lHmfd8xrRAUU7KplHj1Me5I1NH4cn02bV+7Rl5OAwNLIwDLyqf/BPnkLWhpoZbM3cO8Qg3l7Ua+DubA9rC5gcSDZrUPgF1sTJj5pX/OUZc2NBufTYXDphvhAA2qzG+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oWxulmt5pKpIYfZj8l1bKz1fd617C0peC5yCF3jz4VY=; b=cKu49UAJKVduXjRoh9vyDjVeCBNiBOZbyEflohHMgBKmue9Uau+v4TbnENXx67UiKja1p8Ofrd/PWwRNXWZWDySVIIDhn57OD+EJsoOtX6DZMusXaa/5cTUxa5Dn48keesNo8oAhIOOw5TGZ1W1enl0izuYiruBxytfaj1VZR8IR5ifo8SzKcDE29yQKN6q1wovq5F6QK9lHszE+E4JZlX8ZGwNIuL1pWeDGzoepXG5nreOmE1s58fO69R5Bgz1dS8tcQcCjUFOJVfOp7yrPCiqH6L8I/JY5tezsYGr3t2CBudf4rdpnqhldG3T/rjn4osMuLqQM/Zeee+HQ8ILexw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oWxulmt5pKpIYfZj8l1bKz1fd617C0peC5yCF3jz4VY=; b=FnRy0GEQQfy8quL+vK3xj/o3klycUdg3I0H2d0O5bdUaju9zhGgRajWQl06MV1WfVmhOi8uHgh/FNzYJGusiq6LVtLtDTDzGtbvuZ919HfPJyE+i3xOpFJCAs0vKe4FA6qJwjig2OYNq9dnjhQHJv4U2wuxG2QlWW3Etxqw8QoY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) by HE1PR04MB3018.eurprd04.prod.outlook.com (2603:10a6:7:1f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Tue, 8 Feb 2022 14:59:44 +0000 Received: from VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::f826:3bf6:b77d:5a53]) by VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::f826:3bf6:b77d:5a53%7]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 14:59:44 +0000 From: laurentiu.tudor@nxp.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: ioana.ciornei@nxp.com, diana.craciun@oss.nxp.com, jon@solid-run.com, Laurentiu Tudor Subject: [PATCH 6/6] bus: fsl-mc: add .shutdown() op for DPRC driver Date: Tue, 8 Feb 2022 16:59:28 +0200 Message-Id: <20220208145928.12468-7-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220208145928.12468-1-laurentiu.tudor@nxp.com> References: <20220208145928.12468-1-laurentiu.tudor@nxp.com> X-ClientProxiedBy: AM0PR08CA0025.eurprd08.prod.outlook.com (2603:10a6:208:d2::38) To VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 63b4a48b-8a9b-443e-8fef-08d9eb13a41b X-MS-TrafficTypeDiagnostic: HE1PR04MB3018:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7p9FBeJabpVRIQJslyEuag/K1QPdQp8jHkZu2vUVPAXkWxOIXvuRoabrDE4ZGpe3GIgAkgiNj87M5Fp/qkXysXwkp5RwGxF3+hwsqaxIu9rz/RneR3dg6xTH63LsE618jk4hQmTmQUlL++6iFtzC+4s1mKW7EXojx/HaDEQn4vnDwO26sydlvcsoN9PzBAsxXHWb0dMutS7ekwPGVrpkpcNJD/i9TczePdx8a7AS32JGk9fRxWzy4I9KM38HplovgbY+JvmQKgBLVKeY6ivI7ysufFpupIh/A6M+3+Ft8J5SMMG/MJTZykpBGWZ5pVbWlUPNpGDlAE61i/icOkKaS6qck3euQFLTCJn/qWZVDC30dkukzdWc8Ihi09xY4SjqU43kdAl2o3RlB8ORZ6/vIBg+Mf4oUesaMQXovGcN/cfUliLI+EAJybusyU1JV4vnOdz09UYS+LNurnYCofVa5fX4MgwLoedEW64fBz4yDEoI0tuHKMPNd84Zxo99h4BoWGFkZIRN+BtmyhtsJq4SgpPjYGVo4bs3+KPArQpl0Ikj5duj5o/mHDmRPtFafcFES6RqWSYIMv8spWe8Wm0lGfqnlZkGGgz9O/vYxMh9CqlzIB4A8bopIrQodDym/pnQcV9e04CaYecO954G779JDwTzO25bMBCE01EYTtFhO/+tv+4GJEjCUTTDsKr8B8589TFujh0xcLWAlurKLyZPo4I00puHjt3yR8zTPwE30Ms= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0402MB3405.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(2616005)(6666004)(66476007)(316002)(9686003)(66556008)(508600001)(52116002)(186003)(6506007)(2906002)(6512007)(1076003)(26005)(5660300002)(6486002)(8676002)(66946007)(4326008)(86362001)(36756003)(83380400001)(8936002)(38350700002)(38100700002)(142923001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: D7V2S6EemvJLobL8U24ZPeRpXVeEykQrUbzUQa71Axm0iDXAyjolR8ffglcd/ck27xADVKHV3Yb5vyTW1qj1TgOW//Mypw/e4BOiwxv1rDlYbdb/EkK/If9yq2auAb5HZ5mNfzeOJ5J+Od0Al5hGeCoX2uAu9DXc55pwBKs/1mG+n6o0xXY0vBBIgzqZazsXIQKeaMKXCmsFctrm87eb9yQGVFAJqWQECBOZCzAc28x2yDIrux1gpLv5u+o7TOrGzgAQRvhpfdx/DqMqMxl1eIsrI+wsjLtTEdcrtb1yqf3Wg9QPLhnCOaFRpJatY3uMGUDYQMl6F6nSPNULGF0FOKF4dwJaIjK/Dtkl3V4meVeKOprzzIFHqcI6VFUL539XIAtPrDv/U8mNDqbCgfChDJnDeB6j+HjocEAoDfh3XfvZsly9swr8T/pU/yoYl3GonkVyTRg1nYPBmGeuCERS7o+l+WTreVxEtIfQK+emMqyRr+rq1MoYmDkvbvHDbNn1gxSXk++yt3wEDuNEcGVxDAXjdfhGUFKiJbOE4JMEAEvAbkTOC2QaICFWMYCN25or0nJ5Y8c6gMOI0X/k74BlgM2dOVFMPnAlM4VQ4w0CKL8cbTsJLHQH4Og3ysnj2/TOj3CJ/5w5Qq+TvkQFmS1cZ74h3NomaOL8vcdxLVNuPfwHHp1QoI4z92WdBHaRcoPYN7YACynse4iSRXswonBmO3g9O8NWc8AmxItqGwQJKn8Z7umM3q2S40RuxggggHzNntqLA4ez6CLJo3TEgNwfpnSaaUFdWjrFE4BMUND0AauzsSaEeyd25gKOwMsc7p3Hor3wu7fGFjBZhYg5Drq3Li2DxIMONQ4aeAnbxHqbhJ6V0hUHPp3NI82SgfyWslPdVpJERKntupfzkk7uT/yNlaWozGXLAEwiMhEdGmJXmPbafcXEW8PYc7+2naVEoRBnnyM8sNyJAGBI76l15K+yXDUFlgkU8pElXx9qKxIM9bILJnf4aEMrX6VbhSD4zoBzAsR8hEga8KfcYYg12mNfJN38GHcKJvFI+RVq+sWftfe/jge2HC4GaiURVGJwPyLyvf+VOP0fRz3t/Oyu/NhDA+erZdx8NDhJCrAeITgfeTdEspKy0OdGGOf03LwYVAWsTabwkzx3a1T3kfWkHh2V9YkajxZ23Jq7uBTJTvG3E3adsa5d3CF3RZ3k0hTnScWjp9LZbzD20jEmeg14N6gOrMmdL6nYiWMd9dcC5s9i0zOlg2fYsMwNX41ZGA98teW6PnvtPdEOA45oJkiMO2ffk5LMxdTKRmzYD0W6JErVGsfawgFkkRXM7YksWF0D7knyfx3p5g+RyrEvnYRa8kEzfpigLOlEuLuRtH1siHeQAeeSHyQJJXj2/IX9zm4xIUZ9qndijOKvXitZF+Zy+5lOnGjiBapkzQON2MjaeYXmj9v7AD8RmkdLL9w+onchkSYFroUepG0mtbW/gIZElNM/Qvt9m5+fTw6zDYKlSlt0EeVv8BkAulNaKXc2bXXBTsx+MLJJxSxdhQcoUpmPyvVtDmLf+mNlk+srt4MiP/IjGm55KMlIrD7WEmVNLx68DZjfHsD5/qYR0TeEltvmXzBcMQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63b4a48b-8a9b-443e-8fef-08d9eb13a41b X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3405.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 14:59:44.1530 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ueabyqt34p5Suf3eGPHZRC5NiivLa11BA6uULrV88a/Al7JIDgEE3cRIOQ+oD449j+pf6H8cZg6fbNKxqhO95Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB3018 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220208_065958_207200_592BB606 X-CRM114-Status: GOOD ( 13.11 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Laurentiu Tudor In order for kexec scenarios to work, implement a .shutdown() op for the DPRC driver. Signed-off-by: Laurentiu Tudor --- drivers/bus/fsl-mc/dprc-driver.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c index 82bf3fe09273..405cd054c2ea 100644 --- a/drivers/bus/fsl-mc/dprc-driver.c +++ b/drivers/bus/fsl-mc/dprc-driver.c @@ -861,6 +861,30 @@ static int dprc_remove(struct fsl_mc_device *mc_dev) return 0; } +/** + * dprc_shutdown - callback invoked when a DPRC should be quiesced + * + * @mc_dev: Pointer to fsl-mc device representing the DPRC + * + * Closes the DPRC device in the MC. + * It tears down the interrupts that were configured for the DPRC device. + * It destroys the interrupt pool associated with this MC bus. + */ +static void dprc_shutdown(struct fsl_mc_device *mc_dev) +{ + struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); + + if (!is_fsl_mc_bus_dprc(mc_dev)) + return; + + if (!mc_bus->irq_resources) + return; + + dprc_cleanup(mc_dev); + + dev_info(&mc_dev->dev, "DPRC device shutdown"); +} + static const struct fsl_mc_device_id match_id_table[] = { { .vendor = FSL_MC_VENDOR_FREESCALE, @@ -877,6 +901,7 @@ static struct fsl_mc_driver dprc_driver = { .match_id_table = match_id_table, .probe = dprc_probe, .remove = dprc_remove, + .shutdown = dprc_shutdown, }; int __init dprc_driver_init(void)