From nobody Sat Nov 30 16:23:35 2024 Received: from mr85p00im-zteg06023901.me.com (mr85p00im-zteg06023901.me.com [17.58.23.192]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 061A817BB03 for ; Sun, 8 Sep 2024 23:38:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.23.192 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725838707; cv=none; b=oeLqOY61tRta3NqYOAcr3egqJayYl9aAYQIHIWfMcGjdELFu3p4Q+5SuJ6fiHH9mQ2rQkBeWgRJjQ6LEHtq3v8Vhq5t3rnKBW0vtGKL0oEe5DBcm4ztOXLKk+J0P24gCAjfF7jJhnXy3WwZvaHuV+jr3M1/zT9fZ7Xp26Xx7k+U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725838707; c=relaxed/simple; bh=dUab2JS0CGPKtdcnME1D1uf/v+Yi40tRx4iJ1c+MM28=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kuuATHSI5RyJ7UDMpzIYXqpyWpz+Bm8ZRl8sekBnuOgaNXKUVTT4sygmlXuX2Kd1qTaO+/6jwu8G0nWVBR6py9gYaRLcL5XHjrz6p3kso4Ls4ayfwNuYsL39ieNTpZJ9aBJJB+WxqlFnKrfWHJOy3DU7rpJa8B6A6wzqmx2v1iQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=Eg/YXkhF; arc=none smtp.client-ip=17.58.23.192 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="Eg/YXkhF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1725838705; bh=7aHm4jYsJ5MTExFzsQS3IUhNT8SYgir310bkZpfTpac=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; b=Eg/YXkhFgU9pGARG+0BDmylmbvvGZzAIK/OJqMEXzrcW1uAr0S1l7uB3cOnRxri65 KNkHea4CHCnWP+KIzTjXGB8WwTr08JKSRlOpJMpgF+xKfuTuGpqrlZeyoQ0lLTDqQh HKAMiPv57ITpU7gkKOAVhTlN+rLng3dgYkO5RbjZyEJxw4v1P7vVRBYOTfce2dm3QA yorGOi/T7OjhKi5CqoL7R/neZ9yOziCwvFwtC5DFxjyt4Uu0RalkYNlLNATjCkNo/B QG9etFyLoIFd4NQd0daNMyj+OnG0JvHXkuHuwC1ONOvs+/SPX/2VzEA8EcYfkLwnhO vZZ7e7t920cCQ== Received: from [192.168.1.26] (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-zteg06023901.me.com (Postfix) with ESMTPSA id D4BF26E02C1; Sun, 8 Sep 2024 23:38:21 +0000 (UTC) From: Zijun Hu Date: Mon, 09 Sep 2024 07:37:32 +0800 Subject: [PATCH RFC 1/3] amba: bus: Warn on adding an AMBA device without valid periphid Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240909-fix_amba-v1-1-4658eed26906@quicinc.com> References: <20240909-fix_amba-v1-0-4658eed26906@quicinc.com> In-Reply-To: <20240909-fix_amba-v1-0-4658eed26906@quicinc.com> To: Russell King Cc: Greg Kroah-Hartman , Saravana Kannan , Isaac Manjarres , Lu Baolu , Zijun Hu , linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-GUID: n9pltrmYgwNHzXq8HVDduhPjbIoOhPWK X-Proofpoint-ORIG-GUID: n9pltrmYgwNHzXq8HVDduhPjbIoOhPWK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-08_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 spamscore=0 bulkscore=0 clxscore=1015 mlxlogscore=736 suspectscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2409080205 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu In order to handle rare case that an AMBA device is added without valid periphid, it is costly for @amba_bustype's match() to try to read periphid from hardware, so remind user to configure periphid via DT|ACPI as far as possible by warning message. Signed-off-by: Zijun Hu --- drivers/amba/bus.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index 34bc880ca20b..cc3c57f83798 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -560,6 +560,9 @@ int amba_device_add(struct amba_device *dev, struct res= ource *parent) =20 /* If primecell ID isn't hard-coded, figure it out */ if (!dev->periphid) { + dev_warn(&dev->dev, + "Periphid of AMBA device '%s' is not configured, please fix it\n", + dev_name(&dev->dev)); /* * AMBA device uevents require reading its pid and cid * registers. To do this, the device must be on, clocked and --=20 2.34.1 From nobody Sat Nov 30 16:23:35 2024 Received: from mr85p00im-zteg06023901.me.com (mr85p00im-zteg06023901.me.com [17.58.23.192]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 724A017ADF8 for ; Sun, 8 Sep 2024 23:38:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.23.192 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725838711; cv=none; b=byjDtwgQ/gXAbnCQRaRuIPELN9/i5OcKfwOu+SAPt1344bODrl8lbcPXJJOmSG0xvFp9vfAybddMQ/nICzEW+LTAKzLGJcUCQuUyh5VZjd9ZpoD0z7ouuf2i25bTWwTViKFvr2e8iwEQ1Q4E/FBvcnHyMO38nqPaz4kSC8+kEPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725838711; c=relaxed/simple; bh=Nza0r+2p2M53NFDlmSkbHUa/Z7sbfus/SdT6XtKcS8A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f6pXx9g1adne1YzXrlRKDXiObKWfJ+9mLuUirqMXG2GxU/H7fGvdyatkDq1w8up6QiAkODNTW0dYehDulEawQKXWAEDTYR7pmbbskhOnGRgPCiRvyZzKQaqqkoD4i5x1u0vFSYOnCN7MPnvTD1828oUVFJvGtrWpJCC1H7RJlaY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=MV/Cn2Dj; arc=none smtp.client-ip=17.58.23.192 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="MV/Cn2Dj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1725838709; bh=R9weT10wr6KOl+Ic84Yt0g+UTCntOnJiS6nbyYbZDpE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; b=MV/Cn2DjLfIyy15UjIeE0UErNmSp/nOYr/rwN3IbiKqMIU63rYS0SYTi0z9lXE0nQ JfTA4DWz1YeiuGbUDxsVaj8EalPXTvvmdvyjZ+fCmtZbGPQ99t49O+PLCszhE0CsFu 0kn38BVJCVt7cRmp4Mx6lK0YZu6UBJZG8k8XBDf0KlVxWQ4CZx5a/b+fYsQvm4n0Xj hXLSO7krCxI8BXEidb/t8SgoQUmCPTjLKfTkKssW3GxqOlJsI2X2t9dyx6y4e3AKa9 eiDfMUJ6EFgyHdZ1GDD+ycgq3tcOVT66i3lgiR+oh93LSxDqHH7/qF9W9K/D4+rbJz hJCWnaOHWPLQw== Received: from [192.168.1.26] (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-zteg06023901.me.com (Postfix) with ESMTPSA id 063B96E0075; Sun, 8 Sep 2024 23:38:25 +0000 (UTC) From: Zijun Hu Date: Mon, 09 Sep 2024 07:37:33 +0800 Subject: [PATCH RFC 2/3] amba: bus: Move empty @amba_proxy_drv's definition to the front Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240909-fix_amba-v1-2-4658eed26906@quicinc.com> References: <20240909-fix_amba-v1-0-4658eed26906@quicinc.com> In-Reply-To: <20240909-fix_amba-v1-0-4658eed26906@quicinc.com> To: Russell King Cc: Greg Kroah-Hartman , Saravana Kannan , Isaac Manjarres , Lu Baolu , Zijun Hu , linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-GUID: Otwz0-HFEKdwUYgprpPvUxRh7smtFmli X-Proofpoint-ORIG-GUID: Otwz0-HFEKdwUYgprpPvUxRh7smtFmli X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-08_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 spamscore=0 bulkscore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2409080205 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu Move empty @amba_proxy_drv's definition to the front in preparation for referring to it without forward declaration. Signed-off-by: Zijun Hu --- drivers/amba/bus.c | 72 +++++++++++++++++++++++++++-----------------------= ---- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index cc3c57f83798..033d626aff46 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -205,6 +205,42 @@ static int amba_read_periphid(struct amba_device *dev) return ret; } =20 +static int amba_proxy_probe(struct amba_device *adev, + const struct amba_id *id) +{ + WARN(1, "Stub driver should never match any device.\n"); + return -ENODEV; +} + +static const struct amba_id amba_stub_drv_ids[] =3D { + { 0, 0 }, +}; + +static struct amba_driver amba_proxy_drv =3D { + .drv =3D { + .name =3D "amba-proxy", + }, + .probe =3D amba_proxy_probe, + .id_table =3D amba_stub_drv_ids, +}; + +static int __init amba_stub_drv_init(void) +{ + if (!IS_ENABLED(CONFIG_MODULES)) + return 0; + + /* + * The amba_match() function will get called only if there is at least + * one amba driver registered. If all amba drivers are modules and are + * only loaded based on uevents, then we'll hit a chicken-and-egg + * situation where amba_match() is waiting on drivers and drivers are + * waiting on amba_match(). So, register a stub driver to make sure + * amba_match() is called even if no amba driver has been registered. + */ + return __amba_driver_register(&amba_proxy_drv, NULL); +} +late_initcall_sync(amba_stub_drv_init); + static int amba_match(struct device *dev, const struct device_driver *drv) { struct amba_device *pcdev =3D to_amba_device(dev); @@ -456,42 +492,6 @@ static int __init amba_init(void) =20 postcore_initcall(amba_init); =20 -static int amba_proxy_probe(struct amba_device *adev, - const struct amba_id *id) -{ - WARN(1, "Stub driver should never match any device.\n"); - return -ENODEV; -} - -static const struct amba_id amba_stub_drv_ids[] =3D { - { 0, 0 }, -}; - -static struct amba_driver amba_proxy_drv =3D { - .drv =3D { - .name =3D "amba-proxy", - }, - .probe =3D amba_proxy_probe, - .id_table =3D amba_stub_drv_ids, -}; - -static int __init amba_stub_drv_init(void) -{ - if (!IS_ENABLED(CONFIG_MODULES)) - return 0; - - /* - * The amba_match() function will get called only if there is at least - * one amba driver registered. If all amba drivers are modules and are - * only loaded based on uevents, then we'll hit a chicken-and-egg - * situation where amba_match() is waiting on drivers and drivers are - * waiting on amba_match(). So, register a stub driver to make sure - * amba_match() is called even if no amba driver has been registered. - */ - return __amba_driver_register(&amba_proxy_drv, NULL); -} -late_initcall_sync(amba_stub_drv_init); - /** * __amba_driver_register - register an AMBA device driver * @drv: amba device driver structure --=20 2.34.1 From nobody Sat Nov 30 16:23:35 2024 Received: from mr85p00im-zteg06023901.me.com (mr85p00im-zteg06023901.me.com [17.58.23.192]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B8B317C208 for ; Sun, 8 Sep 2024 23:38:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.23.192 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725838716; cv=none; b=sd2bEYP09aKaR4aVFVOyr7yR0hU6HT9poTDwVP+TD4DK2xYwhZe2ODG0ROhYPP9ZJbcYtllJ7ZGjl1iR7I2lm8HkYKa++ALqIMCWVnfc5XGM4dmsRY5MjjniY86Z1Cw474Yu0wqPPFTSDlte0ZiCj2eRLg90ttfE6ZRSY64B6b0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725838716; c=relaxed/simple; bh=uWaOcfMMfJXcjYHMiEtC9LNnAQKvtt3bLCQ3Him1Y0Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=u/fzHXXEZzJsSU/BnG59jTGGh7FFiLIBYCXuGlXLeG0Ri8oubxegi6sm5wvelraMqYjxbaVCrFarHptolyJmsULMXpmEaPOVTu4VxiDD12YwRffVmsGcJXHmAJDgTuewnDGzGOD4K76+AfzDCFcVkqzmk+3mwjTXC3bQqXzYlBg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=uwXedOmV; arc=none smtp.client-ip=17.58.23.192 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="uwXedOmV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1725838714; bh=BWYyyhPkQKgvt6XCeEIJeakBSGkMZ4g54p2RGBWbFCk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; b=uwXedOmVcG3kHhm3O2rS9SQ6DOxEyBq2F9rQxVqGEM/Ny86+2t5rOhSlybiodLJUl aYWREgm+5SSpiT96UH0Qusep4FB7OZMedLM+iYITf17VlLeUxEILwNdYehdvD1dnTv p+wSAAr68ietf8NC++40wRXBqUvCLKVQpVcK+VNLOJZxGxw4QfWRbX/v4+TTR7M0+y UWVZML80Pl6tQIUMxyfOhxn3IhpgsKv5yfzw9JgG+LARFfWo08PRFP7rA8cWG7QOdG 27ntFmn591fyAGBysO1vqAeYWk0zvi7oRgJFnB638N3SdYIblx6h61xjU/EAeb6Dsr ECInCbLFuA28g== Received: from [192.168.1.26] (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-zteg06023901.me.com (Postfix) with ESMTPSA id 6EE2E6E02B7; Sun, 8 Sep 2024 23:38:30 +0000 (UTC) From: Zijun Hu Date: Mon, 09 Sep 2024 07:37:34 +0800 Subject: [PATCH RFC 3/3] amba: bus: Move reading periphid operation from amba_match() to amba_probe() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240909-fix_amba-v1-3-4658eed26906@quicinc.com> References: <20240909-fix_amba-v1-0-4658eed26906@quicinc.com> In-Reply-To: <20240909-fix_amba-v1-0-4658eed26906@quicinc.com> To: Russell King Cc: Greg Kroah-Hartman , Saravana Kannan , Isaac Manjarres , Lu Baolu , Zijun Hu , linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-GUID: yUpPkcwyxvcr_32AUNjTe1g1v9WeJe6s X-Proofpoint-ORIG-GUID: yUpPkcwyxvcr_32AUNjTe1g1v9WeJe6s X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-08_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 spamscore=0 bulkscore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2409080205 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu amba_match(), as bus_type @amba_bustype's match(), reads periphid from hardware and may return -EPROBE_DEFER consequently, and it is the only one that breaks below ideal rule in current kernel tree: bus_type's match() should only return bool type compatible integer 0 or 1 ideally since its main operations are lookup and comparison normally. fixed by moving reading periphid operation to amba_probe(). Signed-off-by: Zijun Hu --- drivers/amba/bus.c | 55 +++++++++++++++++++++++++++++---------------= ---- include/linux/amba/bus.h | 1 - 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index 033d626aff46..8fe2e054b5ce 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -188,7 +188,7 @@ static int amba_read_periphid(struct amba_device *dev) } =20 if (cid =3D=3D AMBA_CID || cid =3D=3D CORESIGHT_CID) { - dev->periphid =3D pid; + WRITE_ONCE(dev->periphid, pid); dev->cid =3D cid; } =20 @@ -246,24 +246,14 @@ static int amba_match(struct device *dev, const struc= t device_driver *drv) struct amba_device *pcdev =3D to_amba_device(dev); const struct amba_driver *pcdrv =3D to_amba_driver(drv); =20 - mutex_lock(&pcdev->periphid_lock); - if (!pcdev->periphid) { - int ret =3D amba_read_periphid(pcdev); - - /* - * Returning any error other than -EPROBE_DEFER from bus match - * can cause driver registration failure. So, if there's a - * permanent failure in reading pid and cid, simply map it to - * -EPROBE_DEFER. - */ - if (ret) { - mutex_unlock(&pcdev->periphid_lock); - return -EPROBE_DEFER; - } - dev_set_uevent_suppress(dev, false); - kobject_uevent(&dev->kobj, KOBJ_ADD); - } - mutex_unlock(&pcdev->periphid_lock); + /* + * For an AMBA device without valid periphid, only read periphid + * in amba_probe() for it when try to bind @amba_proxy_drv. + * For @pcdev->periphid, Reading here has a little race with + * writing in amba_probe(). + */ + if (!READ_ONCE(pcdev->periphid)) + return pcdrv =3D=3D &amba_proxy_drv ? 1 : 0; =20 /* When driver_override is set, only bind to the matching driver */ if (pcdev->driver_override) @@ -315,10 +305,24 @@ static int amba_probe(struct device *dev) { struct amba_device *pcdev =3D to_amba_device(dev); struct amba_driver *pcdrv =3D to_amba_driver(dev->driver); - const struct amba_id *id =3D amba_lookup(pcdrv->id_table, pcdev); + const struct amba_id *id; int ret; =20 do { + if (!pcdev->periphid) { + ret =3D amba_read_periphid(pcdev); + if (ret) { + dev_err_probe(dev, ret, "failed to read periphid\n"); + } else { + dev_set_uevent_suppress(dev, false); + kobject_uevent(&dev->kobj, KOBJ_ADD); + } + + ret =3D -EPROBE_DEFER; + break; + } + id =3D amba_lookup(pcdrv->id_table, pcdev); + ret =3D of_amba_device_decode_irq(pcdev); if (ret) break; @@ -389,10 +393,15 @@ static void amba_shutdown(struct device *dev) =20 static int amba_dma_configure(struct device *dev) { + struct amba_device *pcdev =3D to_amba_device(dev); struct amba_driver *drv =3D to_amba_driver(dev->driver); enum dev_dma_attr attr; int ret =3D 0; =20 + /* To successfully go to amba_probe() to read periphid */ + if (!pcdev->periphid) + return 0; + if (dev->of_node) { ret =3D of_dma_configure(dev, dev->of_node, true); } else if (has_acpi_companion(dev)) { @@ -411,8 +420,12 @@ static int amba_dma_configure(struct device *dev) =20 static void amba_dma_cleanup(struct device *dev) { + struct amba_device *pcdev =3D to_amba_device(dev); struct amba_driver *drv =3D to_amba_driver(dev->driver); =20 + if (!pcdev->periphid) + return; + if (!drv->driver_managed_dma) iommu_device_unuse_default_domain(dev); } @@ -535,7 +548,6 @@ static void amba_device_release(struct device *dev) fwnode_handle_put(dev_fwnode(&d->dev)); if (d->res.parent) release_resource(&d->res); - mutex_destroy(&d->periphid_lock); kfree(d); } =20 @@ -593,7 +605,6 @@ static void amba_device_initialize(struct amba_device *= dev, const char *name) dev->dev.dma_mask =3D &dev->dev.coherent_dma_mask; dev->dev.dma_parms =3D &dev->dma_parms; dev->res.name =3D dev_name(&dev->dev); - mutex_init(&dev->periphid_lock); } =20 /** diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h index 958a55bcc708..4bb3467d9c3d 100644 --- a/include/linux/amba/bus.h +++ b/include/linux/amba/bus.h @@ -67,7 +67,6 @@ struct amba_device { struct clk *pclk; struct device_dma_parameters dma_parms; unsigned int periphid; - struct mutex periphid_lock; unsigned int cid; struct amba_cs_uci_id uci; unsigned int irq[AMBA_NR_IRQS]; --=20 2.34.1