From patchwork Fri Jan 27 13:16:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurentiu Tudor X-Patchwork-Id: 13118706 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 73D38C54EAA for ; Fri, 27 Jan 2023 13:46:15 +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=no47TzJQ04HESS/d6Ij1Wb8hRN9VDaqRNuct6lc/nQI=; b=WcjvPc3wGeYhsw v4qfq4Pjr6rWTQpldDLvOkEVkGJ+mRMLaHpeDW/lTpshUfrl8QroeJYFyj96j+++co+UMYyp6zdW1 g5Kvs/UVQZN07zeDOh1uNZsC9OB9y/mjKlag4xGIE3RZ+YjYD8ke3mXOhoQD8m0gt+h+s6uT6cApk xtmcFGw78k0tltr4riKVdJm0MCzYe6rynQl5UF4VUCmhBFTfaxY/RnWETgenTiK+FcpV5UPDJZk/W 4B1P+pnab4UrrJMlqFur+QHmwL0u/xUV1j35eNlgd3zY31f8DrQEX7D/5ikk71fi3KqqHrCIqp+WH aSo6s96og8cpKdiT1s0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLP27-00F6Du-6K; Fri, 27 Jan 2023 13:44:48 +0000 Received: from mail-db5eur02on2056.outbound.protection.outlook.com ([40.107.249.56] helo=EUR02-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLOb9-00EvTT-Ia for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 13:16:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DGo45ZgZleA1xRwZWxej4G3wc5a7lau/W6RkHKxlrTHrOGih5TvOuwxEM5vUbycS+Qza1w6AP8u02YemsJbQXXtCzxW2fGz0y15nPGmQKZyE5sULQ205/Rz26l5m93J0xV6A/Ih2u+vz5G3sf3NXYWnD6dPn2HXwSBxEz+mlm/M/OhZgeu8PFzLv2US0iCJD+bfDZKW3RncJrlrHNuB4y801n3Ec3XnOJxWHjAmp7rlcWPgnH8I2x1GHm4K5LjqSAX1theD2ZPNvMoiR1ehI5vuCZF1cfmGo6Qn4QjqUIrw5i7kBczlfk/jb7Dn3Xm6VXOzYnzIqfWLz8TEkt1SsSA== 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=T4LgLzp9jG3/vLZSiKnpfoiS8CWfVOJL17sXyJ+h/Yw=; b=evr0baYyudu2DC2XY8pwThE1PhYMIIa1D82JXkTTnKofZChvcn4YxJWcnLHjRihenqy0LuWoYiM8EDG2aP3MTyq+HSvby6ps/S2Iuul3XljmdnUjVf9ED6rPbVkru7VW3KNbHjvlga8kzCPNTExgkcI9JOfbrtSvfepLdvNlVIBr6FP6JeA0tS0XyRiJv75muRfqQ5To/KPh8GpWRmo6UqQXVl55LbbqP1V51LZx/J59QEhdMpUfz68EiUs/+OMlGB6WcgkIKPlYrleBNLQ8sqUsvfHuT8Mx4dyoPq31ZGrptcb6NzZQOKtwZZISVuuK2+g3WJ4OuJ5RmJeMlBpg+A== 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=T4LgLzp9jG3/vLZSiKnpfoiS8CWfVOJL17sXyJ+h/Yw=; b=RVyOerFLR9CnN3BzLdOV5sR/8PX67VpzaKlnGIQL6bZ6Gso12zlZtjFga/RHwB0Py6ivi9ShY+J38nfr4rjdW4YZqv23CdMKbG4buQo5Mm2Pq9no9JZg+WdLhPNiM5DPiKcskc9Bzb6ljI87Rkf/GbmncdGrr9hU6H/DmYquvdM= 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 AS8PR04MB8451.eurprd04.prod.outlook.com (2603:10a6:20b:347::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 13:16:49 +0000 Received: from VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::88f2:10b3:3980:a051]) by VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::88f2:10b3:3980:a051%7]) with mapi id 15.20.6043.023; Fri, 27 Jan 2023 13:16:49 +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] bus: fsl-mc: don't assume child devices are all fsl-mc devices Date: Fri, 27 Jan 2023 15:16:36 +0200 Message-Id: <20230127131636.20889-1-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: AM0PR01CA0113.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::18) To VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0402MB3405:EE_|AS8PR04MB8451:EE_ X-MS-Office365-Filtering-Correlation-Id: 4863a673-13ce-4f61-544c-08db0068bf73 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V6j4K7bmZpaJtiyiJQh7yPD4w4q+ptWOKnMwGf94IO1LnHOQSWGMfZTx13+NhnRvXsW6+DLZ2r04zKtV8WOH+B8DX04nzO/ga1mb8ABO6priTpuk/CUc3p5Y5oinFihEH19/fq5wRzkbEvv0zEkEWfRbDShAF1q9Re60SUpoXxHMz/TAzFVxn0MKVtXZanL4Xqc3a73CA8J4b7y1ATCvA9WS87Vn8PsDDuTs9SLEu7yhwwowiqy4xpcE83JXYFVOFjnFT90DLHIBh+cS1cvHR92n1m3R/PXKhieKoqqcx+CHgX1gj5VBzBwOio2yxhdumE2vU4mXmIMVxNc7HczS6z80s3fJp3V0I206lt67eTDgM0gGm2do6e9PkU8xRg7OkLCOyrXGKsGd8cXL1AsX+ElBSDSgheKUfrR7Ot4eV4W1u3UOqToXWJNd9VR6w7DmA3emQFfHiyLZUxNslgmmturiN9zZKxQF/JS6ggXRKEZDjR4GDVYhbsie5LwrLwdDOceaZENnZ8687rc2wYd9rEMS6USkS9jxEFTpkBpVTSch82Xics91N2ZglGZuIXI4lkT3MI+Ms1EW1793uXoXHRdPpWeRnoG4/V1kkYkeSiZSBHFNMhMKoJvNPmJOCLvD0iTVuyOKJ36nol5wP3wmz/ZWcjr6j5TvEzUkFtldZjImEmb5i7UAjNPZG8ZxI5dU1ZYcAMVcsHqkevAsSc2Tew== 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)(366004)(39860400002)(396003)(346002)(376002)(136003)(451199018)(2906002)(41300700001)(8936002)(5660300002)(6486002)(478600001)(1076003)(2616005)(26005)(186003)(9686003)(6512007)(6506007)(8676002)(6666004)(4326008)(86362001)(38350700002)(38100700002)(66556008)(66946007)(52116002)(66476007)(45080400002)(316002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eCZtJtWllWKLMyAbx1xv3FeiCrZ2P6h7mNAIGp/JRLUcMPDrcOOFhbbRhOmuUIMi/X/xOFHEGXs52/Bju/XnjMSW6hhzJWXUbARXhO3Iq8PwYh+M1i1BFO8oV4IBof5DOQTnkxD88e8LaVErBmHPCCdoeAwn1m2Y+79b1a0LxL69jkPgW6qC3/zgW5bPJH2htD6F4oSykry3XbdulMtoCoat7BLoL2nn/R4lWbvPM3L+QMEk24MIna9kN6MhCXcdY0fu5ZugVXLM7D7jBPy9oZMxlOIShhVEnR6bcYRIkNWKoZ7QFmgt5KP24Ez9bIIuZwZ7JBGQsliMMiLsRyt5HSNnUv6xvguk/jNmtEl723I42Ls8mMPjqK2poI3WhyWALicfapTakieM+bLTFghQAsfv5Dxe7vjRyp4aZaWWgnQSEvDy8+uCEt/XHuDL+Je/rY+myfhqct4k7n9I4sxL7f5NStOi8gzTAI+RRoTGXdIzN4z8lddXIY+rh3Q/aIlBXoOIHsnXqS/AY/eo6qRSm07gNxBZGRZh8deSaZ3tEi5RwDoLovmr6WR3YvhFc+3gFj2LXC+hirw3HrnCi0T/FumVJblu6N66/PmkBbDAFSpK9HB2bsqLPgUpu2Lk/MPEcIunaXSZpVKOWST0fPQ3PkpAAiCImiZWmEuNfi23woV1vAXxew9hnxa2nAqd+onTk+h6Ie8ef5ITHwPT15CkUbJiXiqQe2xvbxRHrITnfMTBq0OTkCcKXXPL1V4owak3ogEoF7WqVo+xDsBeGMoHhRX+rm9Tmfr+YeJlQEuIubs5w/v8D1yicne1AYHQxoE3Q6WLyCcjnPnnYK0jPMjL7iUDSPNh3IlzQzP7qxQJh87RCdJNctawq7Gocr6lvgDRwI8WRkvMU7T6n1p5/zr6fZfSA7nUFUUi2uPezK4rNXxwLUytDnrsZiwqFFMaulqmVTzjpjJABIozOHfsn7M0RRtUkJ19PzzkVlhxYAEFBiY2LEtD+94RKf65b7liguoS6sET5vYqrgExpekFbABObVxFXLkCxVHUDComGo/7nMO7Mv3H2zaaoWOyLN/Ir/RJAS59sMtdzV4ikjGj/StNbXojVDNcblW4rW0hHzgvDh1MJVgG75VNxV3Dcnpz7DrW5jnoGdV6MTHzALPSvl2d51Fy4EPyPALl5OIemlzimOFrUJFjexFKPcpgl9DsAv6c9HfGkp5NdcJcYV0tFH9KzcchQGCJFMAtGIKVaEN1Jiccq4eURjwvysLqG0RsZvWqBvE2pBfWmoUBTqWzxR3rySlcyguznFq0DttA8H8sYk8l/I9xPpy+4vrtumNFzmXx8GSiTzglfbI4HeXU40F6mZvR+RuXu+cWLjtdWRJ/asf4y4V0W0P1YfyL1LIkGf58zU6RvIyq+Xgw624q1pK+UbG7JdhPSSWnoD+PP1Af643jOPXByX9uE7cXpr9Ei1lQVygZBnHLsisSpXeLBNdbWjOnzjA/8pw7CTDdLM6LTrphaONsSIa0tzpTL7zRG4AC1VSvMWDtYNd1/7VuEFC3oc3pIWjjx+l/re9r9S/xpjqYIq+3EkX/wIfEmovK23OT X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4863a673-13ce-4f61-544c-08db0068bf73 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3405.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 13:16:49.5412 (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: TFeHIvaYdqbq/hN9AP7FpJLI9WISVxN5bRRdvawXYicm/8dVUlMfGRtnUwwKqNlOOPx2Selna0n+txoGhKB7TA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8451 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_051655_945444_756634B2 X-CRM114-Status: GOOD ( 11.68 ) 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 ]--- 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; }