From patchwork Wed Feb 1 16:59:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurentiu Tudor X-Patchwork-Id: 13124746 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 1C3D3C05027 for ; Wed, 1 Feb 2023 17:01:01 +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:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=eOLiXpN4qkDN1a2NUMzoOrmDxwyHniw3kLN9DqiK/CU=; b=Uzya/OnC8NNcWU OFOyfBsd0ld7XuGpNVOlsXyrOYtKq7q9SjIymrWYhK7mH2YbougiNj0koAAYvgF7NEzXgFRuCrbQG /EsDm2wZYHcJAbphwS2RVW8r1eJnq5pN0lxKKcFSlu2MUnGbBgda+qeCJrTAiuFgDZL1XvHcSP9tL 7KpYyL4KUyEDTZQwXLm/vZRVVLVPleeaQ/dHPlxkjiZ6Xb2U54EBu2QuaDy/Y5jKNe8bzQfR645Yo L9xVOp9CuDhJOlrMB8K28P8UXE6El8hgjvWoVG6mfvWH1W4Q59Ri2s7yhG2y1djld9bJu1AL8Iz4o dEdNJesl4miG29B1F8qA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNGSb-00Cvlo-Dy; Wed, 01 Feb 2023 16:59:49 +0000 Received: from mail-he1eur04on0631.outbound.protection.outlook.com ([2a01:111:f400:fe0d::631] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNGSX-00Cvjp-2s for linux-arm-kernel@lists.infradead.org; Wed, 01 Feb 2023 16:59:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UqCe6V+a9lMxcSTbflInt8S5bpvAjwcNAa+ehm3q5pzYcYrCzdajwAsfDI1IhMwmDunsz/RlpRzP1/NzI1RRC1fv24gPoVJOXhsbNvtxCfck4dugij2bRngUYExtCLNeFYAivxlqytBuT6I2wCfCjkkyNAUoVRd4T0z0nYCFeFCu1ns3ttS1w5Eq4+ANaCshnyKIOwIfIuNWtqUCuUdDsT35SCC49T7fQ3LIt2M7be/VC+2FcMjmMhohCL4zNpBXFNHp29SoRmwysMVOF5p1ufXNBQYZhHqA6j6lnI202gNo3wYC+nTg5mz+SzEu3IUc9cdf0HyKq360UhwX21+jtQ== 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=8UiDIPD4Tc3SUHFPgT6u1E5yWtU/fuZtw3BohiBxrOs=; b=BVS1KU7F2y/6U6hxyL5MSvbDRvhr1EEdeWkQnQEB+dTSJDYD6+Ru9o2vo0IXGLjWiTgX0QdbAGJ+Ufy++ExBcx7y43e6/FfwuhLmVdgkpyebuK5Wh33Ovb3wUTt6KGVflS3GvaAAr1Yo+d3vT7LxPUMqEDUTklE4Ys6wGe/+E+p7DXXTN30Wikq6HPRKjU4mCX7MhhYPRZvVqxsXHUF8pNiYGWYtZ/beGvoM8wbg1MUMmwfWuhH4NPv1JvH5L9aDSl4GQMyJy900jWkHGJt1bGN8W6PTCEWbH7OMI355wv2U2Ins6CUz+AfECb7tKfxIQ9zDtY/a1JrYCyUqAnHh8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; 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=8UiDIPD4Tc3SUHFPgT6u1E5yWtU/fuZtw3BohiBxrOs=; b=B/Er0ToUA9AIB7n+WIe86Rlmmf5kwpyUq+SjresKiK7qN527u0mIbMilkueipqwLosGOWbrgCZcebD/5ymCV2gCFW23pSngQNFPHdQIxe58IKnmcQ1lVg5J1HfeWSR5SRuCKsbrKkDegfQ85y2k8AF8bbwCRWVZ3VNrkO/bIHeY= 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 DU2PR04MB9051.eurprd04.prod.outlook.com (2603:10a6:10:2e6::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22; Wed, 1 Feb 2023 16:59:39 +0000 Received: from VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::f469:ba5b:88ad:3fa0]) by VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::f469:ba5b:88ad:3fa0%3]) with mapi id 15.20.6064.024; Wed, 1 Feb 2023 16: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, Laurentiu Tudor Subject: [PATCH v3] bus: fsl-mc: don't assume child devices are all fsl-mc devices Date: Wed, 1 Feb 2023 18:59:23 +0200 Message-Id: <20230201165923.19369-1-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: AM4P190CA0004.EURP190.PROD.OUTLOOK.COM (2603:10a6:200:56::14) To VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0402MB3405:EE_|DU2PR04MB9051:EE_ X-MS-Office365-Filtering-Correlation-Id: 970b820e-7709-4e19-588f-08db0475b4e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 42hnDOxz67+iX6e5hGpz/BLyfJ3ocjdYgQJY3D1qCtvI+meXg7xdUefdQauGss955Tt3PW7aLMRxapskO7YskERJnWFI7DBleJIFfFalM9LwmZIDdorz4gpZAuCzA9VmncnEbX2spREvYdIaGdFvn9UPm2HtsbUilGgziCwMIMZz1DFVuFsUDdIEOahgosu7S3YQn6Upj7HnHCj5RXE3M2YoWkp311gWKZrIJXOrGNF12gNNzg2Rq8YAjTY8xaAIgo58B+WEpl1eALFn6W9b6xwdZaZ9H5T/3/iNdnA9YXry6R3NQ+rquuKhuYMxLYCeFZNcb+lmvBlWg7WeYKfEfkH3xF/YgNU8thMfT+EakQsCVI5XErbGg6okGJksyjaFVdvTGuz3MYSAqRU4hL3LVigfi18LsVzWB/R5vh3Ok2R7dqAa/ViHGlqFM3gbYFy/kzNVJ7l71mrjqwJg/HfPsYrbuEfPAmygizoVU6w15hECRPO/w6REXcPn5cgkz+7u3RNNu+fX8Pn/KFYOuEHmgKU15AM7Pik6CuM0BKz1B9UUVUqpnOHCe0uTIWwttMTvxdIyD9N0OaM1rvRXLAgM4aLwNPFitla8TJ+0iJPiJIK3O3nVFMqNUqJqISKE7rV7cumbtIehYB/HAi8069sZEc3s3drEvL+rTAOJCackrHL2LgMAcEXA0ipYHIta6AtIis6qHAcjAjNd8npIL0IOtg== 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:(13230025)(4636009)(376002)(136003)(39860400002)(346002)(396003)(366004)(451199018)(26005)(316002)(66476007)(41300700001)(4326008)(8676002)(66946007)(38100700002)(66556008)(38350700002)(36756003)(86362001)(45080400002)(6506007)(186003)(1076003)(6486002)(9686003)(6512007)(5660300002)(2906002)(52116002)(8936002)(6666004)(2616005)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zIseN3Gz0dSIYTAodFZCnT+khmjJaBV+6uiaHzfwTJ452zU40njVkK88uzpRgwkx9afZdBuLh+CBdTilOG3/8QX6HrDG0Tc5Vzw7ax+ihxWVWfTN2LHol257Bs5SRaIRRd/BDEHWCnuIMgK+8EBKHBrHHpC1FSGJMJxP8EElUOnWQ5makineKpHc1z6wZwzEoV71qKExhPtFtEtZZSfpjUFP1kQvcPRDyC9XWWZsIb3DrLhNF963/D9yi8e+lbEef1G2NENOVGwsMQPky8Wmc5gV39CfDuT9MfsiSqJUtpYbpbrq+lW1zW2H8QrvZxbokuuo7XiCQB510LJCBhRE99HYqH2WNxj2eRqUfMnBi267k0B2x9JZlCYhRsPU29cLeBADBw8HfKVMlP6ECmYu9zq1Z7ePRm/xK6FznTQz+1RXpuwANu85j6LCeQ7CqRFdN4uOyxU3y39uNrsi/wI9vvRp47f7jyRlF7Tc/6OdBHUbOyKgvhApQUmJkIe8d6SHAAebR/XVKc5wpZ3fk+3PKXD0P5iLJl/k9swTN84Oc1GZi11QQu8W2MkSlH5RJRt5Jn8XJ6dTfikBuaHuyVTntHbylRm4sQfEfXEdrZwXMurcypzb3Lfk7ktaw3Wyw4JlM+W62Qv+Fu1XFGL2VvSi+c1qW06QSoQZc6RM3TXONYkyTUdCWhHfjswxF5jc9sFgQ1d1wLrTgzZXj5UTxETlIy5WVivRNqagh/OpA6TMxztLz3h5CRWNO0YUdzgL12/VgzG1r9+K39AsiO+gwEmbk1NtEEZiQ0+nMw+NBlUmfu3EKgr84XSsMbxZLmVFWoCQwOa2ecCK7gy1vupZ+Lm2biDEi4Ll1kTh719B0ZYLTqU9sHWplmGBoffZXBCeiDIHI0R+ML0p/3PsODFzklInpgXMV1krXm0EIJazsuR2NPWCDTWM2ORbCYNyPgPvvsNeQkHL8hRqz6bzufHJuCtn+1NXIptwLin1+IacHRlcQi0pMZcx9M+V2aOCNworcHkssu/ByQefu2D2sxOHFqdOBPDLH6nIVHQkB1vFPVDUvUGCnzUHVGb7XTYDjnPuauhZdDNWPW8oxIAkzXqm4cr4FyC43z0FjD66S2ZFNIaXZbkCuRX1ZfUOAL7Zu8iQfQI1GwWNFa3eNGeySGRZD5zSWwZkCFAObcOZdIK/U7/C5v+A7vdc2vTeVyrYQwSU5CTRvdrw0vdS+VwQvzxA2VvZ1woJ9gU9RBQOv8NBFKqRsEIwtE6HTpqkmoSbAShcBG9qbSNuyIbm8BRA9AY8zkKVZiv327UACT6TMRfU5ZW/LFqywgi4jrLjzAMUBC18I4S/DyKWXbr5oZsVHjlYIxrdLEdr0VtQm9WcX6w7eRXrLwNh38quDqMediIR7uTHrL6KlAui2WJEelaamM0y2cpeoxt617nr6QTos6sh2kG2FkUzuB7sXksU47HsgFYUqcvHUfxoWOkal65hQOSD0Qej93Zc7zMj+SXG+D7MBqMcIo/wB+rvLN7CDr8ebbajL8NetcQLeXN+q5Fw0fERxMWh7j7G1xFzQlT89dSiuVYmJWDX1KqHIbL+WPn8fYutHEE/ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 970b820e-7709-4e19-588f-08db0475b4e4 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3405.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 16:59:39.7949 (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: Lx0TpHtytNsg2L9/syUXCIrtWjW+hcLKsJfMk67CqFSQHQ9+93BjYMDAOhlyP8p7pXgASGeO/cTHJvFU4tHESA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB9051 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230201_085945_348567_DF3956AA X-CRM114-Status: GOOD ( 12.30 ) 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 Changes in VFIO caused a pseudo-device to be created as child of fsl-mc devices causing a crash [1] when trying to bind a fsl-mc device to VFIO. Fix this by checking the device type when enumerating fsl-mc child devices. [1] Modules linked in: Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP CPU: 6 PID: 1289 Comm: sh Not tainted 6.2.0-rc5-00047-g7c46948a6e9c #2 Hardware name: NXP Layerscape LX2160ARDB (DT) pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : mc_send_command+0x24/0x1f0 lr : dprc_get_obj_region+0xfc/0x1c0 sp : ffff80000a88b900 x29: ffff80000a88b900 x28: ffff48a9429e1400 x27: 00000000000002b2 x26: ffff48a9429e1718 x25: 0000000000000000 x24: 0000000000000000 x23: ffffd59331ba3918 x22: ffffd59331ba3000 x21: 0000000000000000 x20: ffff80000a88b9b8 x19: 0000000000000000 x18: 0000000000000001 x17: 7270642f636d2d6c x16: 73662e3030303030 x15: ffffffffffffffff x14: ffffd59330f1d668 x13: ffff48a8727dc389 x12: ffff48a8727dc386 x11: 0000000000000002 x10: 00008ceaf02f35d4 x9 : 0000000000000012 x8 : 0000000000000000 x7 : 0000000000000006 x6 : ffff80000a88bab0 x5 : 0000000000000000 x4 : 0000000000000000 x3 : ffff80000a88b9e8 x2 : ffff80000a88b9e8 x1 : 0000000000000000 x0 : ffff48a945142b80 Call trace: mc_send_command+0x24/0x1f0 dprc_get_obj_region+0xfc/0x1c0 fsl_mc_device_add+0x340/0x590 fsl_mc_obj_device_add+0xd0/0xf8 dprc_scan_objects+0x1c4/0x340 dprc_scan_container+0x38/0x60 vfio_fsl_mc_probe+0x9c/0xf8 fsl_mc_driver_probe+0x24/0x70 really_probe+0xbc/0x2a8 __driver_probe_device+0x78/0xe0 device_driver_attach+0x30/0x68 bind_store+0xa8/0x130 drv_attr_store+0x24/0x38 sysfs_kf_write+0x44/0x60 kernfs_fop_write_iter+0x128/0x1b8 vfs_write+0x334/0x448 ksys_write+0x68/0xf0 __arm64_sys_write+0x1c/0x28 invoke_syscall+0x44/0x108 el0_svc_common.constprop.1+0x94/0xf8 do_el0_svc+0x38/0xb0 el0_svc+0x20/0x50 el0t_64_sync_handler+0x98/0xc0 el0t_64_sync+0x174/0x178 Code: aa0103f4 a9025bf5 d5384100 b9400801 (79401260) ---[ end trace 0000000000000000 ]--- Fixes: 3c28a76124b2 ("vfio: Add struct device to vfio_device") Signed-off-by: Laurentiu Tudor --- Changes in v3: - added changelog Changes in v2: - added "Fixes:" tag drivers/bus/fsl-mc/dprc-driver.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c index 4c84be378bf2..ec5f26a45641 100644 --- a/drivers/bus/fsl-mc/dprc-driver.c +++ b/drivers/bus/fsl-mc/dprc-driver.c @@ -45,6 +45,9 @@ static int __fsl_mc_device_remove_if_not_in_mc(struct device *dev, void *data) struct fsl_mc_child_objs *objs; struct fsl_mc_device *mc_dev; + if (!dev_is_fsl_mc(dev)) + return 0; + mc_dev = to_fsl_mc_device(dev); objs = data; @@ -64,6 +67,9 @@ static int __fsl_mc_device_remove_if_not_in_mc(struct device *dev, void *data) static int __fsl_mc_device_remove(struct device *dev, void *data) { + if (!dev_is_fsl_mc(dev)) + return 0; + fsl_mc_device_remove(to_fsl_mc_device(dev)); return 0; }