From patchwork Wed Feb 1 13:51:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurentiu Tudor X-Patchwork-Id: 13124320 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 21684C05027 for ; Wed, 1 Feb 2023 13:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date: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=bXhzWfbkJGPelyaKeeIX5JoagYB/M5zUempPJPuXqi8=; b=ZXD4UPTMxSMeq6 VqPJ7cfJK5dolHXxn3NDr5DYX5ney2bEiQWfemzbPoiHlbUGz0Tj6LHB583QCpDeIz8CMLTkwepzk FuFCN4bZ+VZe+HFu8zjqWTF7o6hHVJiXX2Bk7YltBsCy5Wz7utHxXayllQp30+nabIWA64fK4VNjH gct6eMxiXoq3VpDFVr4SD4exVc6H7GuRiLTIKvke97u/LW5oA9+veXNSxOYWpfGFM401EFSsCExpo X0LpymX2KltMqAGv8Lx0WB1LI32W5QfG1BXMjkpN7mRTgH3IAlM8a+LzzlpLUeXc0JofeaMCoaPSq steHgRnKi/McNneJ42Ug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNDWz-00C8jR-1m; Wed, 01 Feb 2023 13:52:09 +0000 Received: from mail-am6eur05on2055.outbound.protection.outlook.com ([40.107.22.55] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNDWw-00C8iP-1b for linux-arm-kernel@lists.infradead.org; Wed, 01 Feb 2023 13:52:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O4paCFIVUgmwXI9ik7WTL/KwI0HuJz1LpEGGyw+nwlF9zgkrMo4oh8PeiO+VuA9StQT0uggb+ypYY2JQ7/3m2kKPHTRM4mSrrw7/owSh3omdX6W9HmXywLQgEEoL5siZep40czICgJiLc63iAmgTcSK6cVaKlgZiWai0CdKK1eMoN9t06tC+QDc2a9/UMi3snSMUb3D5y5Nej1doyZFSY1dD3/R6yK775/+wFVslGPPPT4O0qYd/FiK/b0nrqpZ0nn9yonQwaQIQETrYzdFjdZPTu+IN8anERyeE9cTi7fTL1he1oW8RgcvkzAn5ujrW70tY+IMMDgM+XxFiYy8HdA== 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=e1z3Ou5eK7M0nRcyhu6MARM+scrpa6tijveZLWSLtW4=; b=c3+vdagU66MHl0YLChf1vCgEDFbKrCQVnrVWDxnlpj3TvKCWtgHYEhVw+/cvA5mOOpnxYH+r1lqNjjYXzqlnhHGsr5MM34k6dNFJapqay/c/dmSBwn0Qb4LsZUnEATXAd1xuqtxB28AnAwZdpOe9ddKObdXLfCbTRdIf532YQ1cdb+1hNncgr+S+f9wUklQtDNTah7QQHNk32z9I7Ixxd2JP45hEtVv7Wh8WjJ4Ink+B28X/qWEmul11OZadOlh6NPbnmVwt3iYEJmW7h0eBcpQNlace6POQ3Kw2FNP0H+CIYroP9qqhqWVpDNPMt1BmOvd6nxDvnMzh7Ry2gPVfmQ== 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=e1z3Ou5eK7M0nRcyhu6MARM+scrpa6tijveZLWSLtW4=; b=BjchVt+n9m87s4cwMV3mTfq+zIMNKABy2aCbImTYZjE/3SB919fESf8kaV1NcDIkELcLByEPk51xPzKDf9sQp0/ADZKs5VcY/+9igOaiRmEHcD1GlSp/OQeI6ePpXl0Dhxfq/uDmzQ7WOOzdcWyUlTRrPXcbjm8AiJLqgtJ35Js= 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 AS8PR04MB7925.eurprd04.prod.outlook.com (2603:10a6:20b:2a2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.24; Wed, 1 Feb 2023 13:52:01 +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 13:52:01 +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 v2] bus: fsl-mc: don't assume child devices are all fsl-mc devices Date: Wed, 1 Feb 2023 15:51:45 +0200 Message-Id: <20230201135145.18226-1-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: AS4P189CA0045.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5dd::17) To VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0402MB3405:EE_|AS8PR04MB7925:EE_ X-MS-Office365-Filtering-Correlation-Id: c838c147-c015-4c5d-14aa-08db045b7e39 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BMUZmzoAFilZtM438GZZsm1TuNs0JJuhSWClhjRvnl+xWQyf7sm+Pfol+lm6sqSYNjRhifz/GbtDnYd4cIKqbr0HGZpuW58i5c9IsNPDZKN99Xlr35YQZoCzWX0f2lLa1nolwyIy2+A0sO3bcK5yfnq9R1PQ2BN1jb1o0q0bT46a/1PmCGbIMtTcrrG2RIpgc71FGvdcLoTxXIXbs3rwoiNrePbcK9Dwa/pjH6Cjo2460GSiiU2pd/LhlhCMTMFEdBMuV6fmAwXjwUYbfvjZD1wM4tcAym/p5HPG3kqCWSu08YWG7hoPzLoJraiMO7rQ9Q6wBHUhcP44///HxBcNHNz/m6ycjJRKBBnrk5wU1BPe7K+InzRlVSLVyQQDQ/4sGxFHNnh0qqDepf5qSRG391BpiQoTuItg9HEQsBWv6Fy0ft0z2mwZ3Xkl8XMED1phSjqID/DYblEyphlBPjXjiG05brS4G1kkmpKbT73iv91ODWiwiFhFraxRr0uwbdi1vfuqs4PjE5r7S2LzPioZrE0zIDF1lt1kJ3FzFmWZuWCBuWx0tIungwniiFM7WC+vhtRLKlXnwzBODgB27zHgYgaiWZXgXzs2oHtCFzQh659lYILhext+aXj/EJuMvh0nTycT7apfSpK+mCWLBljph7RSE5qp/8PYLZYV/q5vJhAnXPlJuAtLf5w0weDRCnjF8IXlLGJRVxHX0r9QZUDs7g== 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)(396003)(136003)(366004)(39860400002)(346002)(376002)(451199018)(478600001)(5660300002)(36756003)(6506007)(2906002)(1076003)(6512007)(9686003)(26005)(186003)(2616005)(86362001)(38350700002)(316002)(38100700002)(52116002)(66946007)(4326008)(66556008)(66476007)(45080400002)(6666004)(6486002)(8676002)(8936002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cRjcRKAEZzwrGQ6DSvWmWSjScPcvmgTts9CUs24eGihiurfGdSIvswvMtkJinOBZjk0X+xz0iRBeefL1r1qw1+TQsoXwUABcFR/Y8Izr+WwhZLKg7hawXcb5ap/ap4KO92mXAVKaGKlFKzXN721NvHpbbzaoH3CPc1lMWzhN/XP2WzDNHSzuvTs68iJpkg0TaYG+4P6KlebW52TmDjdDyfk25XJr2/k46f1KjFjJWsXdAM+lSpkOSR2UQA4qXOyPW23WIMC2D8DK8IUiCAox6aNhPyCVZ5xq8i+GunFutn9Qbf3nlK4PbxuKm+8SkBImIouqj6IHSWV5beMGs47Mylxk7v6MBh+gdbE68fb5mwik6NLus8/1UAj9CHbzyF3Z9k/pz4j2GTUkPfRnTvpBNXI8u9C4vzw3pQgQtacJGRgkyJAqO6+ywiqCQ72r9gXu9KYWXWYpckao/zCrTXdM7FEM/IUhQr8WMjFCwBSbNyYER2Ms2+FzQPiVYnHPMmWmJmUaStAc9LZenFa7TzRIPvS63pm+NLAQ9zhuHc9116e84nTLKP22kaCd1JhJOfACbX39QyUSI7sT1p0+DST+DfjOkI/AsmGDMZJrPFtr/XSNtFzW3pBEP5eGbPSSbzA2SyUBPu+4A4oNKJzgZ00u4keJX3xz3jk1WBQYmSfEj7HcYUe67d8qqMUUR0um+8JxXJ4x23OY2MD2j+rs9psvo0RGYz8QIe3VXbQxf1kZA2Aejbacz1zWPftsrYYritTOewRVOX4ZJE0cHvgQdQY1Y64StPZd5TKlHq2lBtArDOTEbfalbgT3faWcKjVDZUzmelT3RXuzwrAaI6A3EeMy0x3embnsBT/rJrOxcU++7aYRizVFqtHEnHo4VQbje17tkju2KdRiT9BSCm7kBaqEDSsnnlAQtEDkig/HpRhq6/2xdGx0CyWrN6T5jKaFAN/JvxfqHPmYezytPQIL79HS7iL3lCGhxbGm7Prext0WkzEayukqnK86/gULsqJ35PZMJaAUx1NCOZQWZ1BBxAK2jGIwNiFrpYq7Zgpp5fk/yoSaOClAR4rFPDwx35yq+vStQ6h94or7AUNDtWqioN4TCWakbxO9+Gy5RoSiLkliEx0QaZo5341MR7bAFce44ggQw+AEJw1caglGQChmv4sZOn75qxYwqCVdoZNYAF7Nv5m3cVIwk1uhQVzHXOQ5SAcTuB8a0ZX7L7qvcOeDXOjQgi/Xe3NLRC1MWxlYxk+mjtjP1WnUWeDi/Z8f0UmEgE3SqqMxvMcVARmzYiljiyUxK2kV8ihfybTOdz+1A5JMNwQVHlQ0qGKtSW+/ccj7h6cLUl7dkVIVvZ3aZnnHhKc3Fz+z5XG+joZTTpPs3NaOsuFRRcmnBXtHG0fJcl23PSY9VAkuiN31cESKBjYI2gosLcpmRfWqbCCxk/SWErF13uPJrWGVDS8BBS+6zQ/1gavqzlg83+cB7V9OKpvxi9gs51F9xI1idenO76u4CdRT8xbn2z++MROQRXAgenFkXICeQ8n86ScjrvX/YB+nmja5Wokw42eBuk6Vjzbaou6SHPEPCxNQtQo3R1I78Y6OQJoa X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c838c147-c015-4c5d-14aa-08db045b7e39 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3405.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 13:52:01.1293 (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: uAJW1KqLQ1rFpRZlFnYLfRqlwMYp/Le/S0cGwuPMKLzxiH9Oowys+FUfXc+KcJXhXBM2M1kbm6OvxfHQgGPYfQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7925 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230201_055206_120650_FC9082F5 X-CRM114-Status: GOOD ( 12.44 ) 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 --- 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; }