From nobody Thu Jan 20 10:35:10 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5E76919733C6; Thu, 20 Jan 2022 10:35:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Jff671Ykkz4hsM; Thu, 20 Jan 2022 10:35:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642674911; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZD7DlfcffrZzi9spZ0/DAEc3b4mLkcIHbKQsX3v6Fmk=; b=jwVp/sEvwsxNQLmuCnyt7XiSbN4ZGjGf6fRpQPps9ho4O0O4AZtY0gcPZOmskDTiwYzoUi 4ox58nSa28yxhQAbZeqlOuZJt9PQl3o+msd2mJzEWJdi63X7JiYdAZ4XZaxMWb2GQM4hNr 75lG1lLfjFExk0WHko4pdAAeUxK9PXZXE4dpYVeNn1FaKfcQ3TpG5hojvpcfmY7TEzp9X0 o7DLOXZQ5ny3T1zSpBZafT9GFhfDJlV3MFFFT2QouKEgC780fLZfYFf8AJ3rX3OAmQkc0a FqlhPOhJuo2jD1BXZGZcLtIyKrMLRpln8ZI9KNo4XjoALmVsl7YkPBnIzDtHxw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 094C226AB4; Thu, 20 Jan 2022 10:35:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20KAZAFY031707; Thu, 20 Jan 2022 10:35:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20KAZAft031706; Thu, 20 Jan 2022 10:35:10 GMT (envelope-from git) Date: Thu, 20 Jan 2022 10:35:10 GMT Message-Id: <202201201035.20KAZAft031706@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michal Meloun Subject: git: 139afdb1721f - stable/13 - simple_mfd: switch to controllable locking for syscon provider. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mmel X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 139afdb1721fbb31d39e7cb8992dcc5369a17d5f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642674911; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZD7DlfcffrZzi9spZ0/DAEc3b4mLkcIHbKQsX3v6Fmk=; b=amcoY6fOeMjR31pmyYuaWjMdJfADmqD1x74WF6jP0XnoSep+CjcGgUN/LbHxB42KZXs3L4 izOMztlnPAWUqgTm6yTYmX56Z2OATIaicHRUcbNWm/HndUFLlBmFynX2pSNQnok6+QMP+Q Xi6I4rfrV9Qrt5LuOQIwkKIF/0ewUEHPdweBJtEQDzRsQuTtZ6UtaFPPibQKODMmBESG7H g2jD0PT9WtXpuqZUBVtEQ5YwJj30zVlpoLCU9jV5rArMshAfDycOJ9AAajJPAcTu/sBFB0 btH5WZfxRauobJGDIQJk7EkGeeny3WxdsDEDlH5LLawZMoQ5N4yuYfxx+VQ59g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642674911; a=rsa-sha256; cv=none; b=h/n1xXLd71DrbfP9LTbPMIdJy3QIkgiPvJTfZdFGBlMPWPX5cPn2JQIpL/MlPQ2SF7wudL xBaPSXuwEh2WxS5J7YyVrqPrgtesVEf/Doc3ETP8U+ftGKDcFgKPiz1hAVy7HtLo/YOD10 7TmfvA4Sa41dhnx5VhR3tBIennqp7wEgobHTtVgs18iLzRpMKDlo9AYdmrOJoMfKt6S5sz mVMvJ6ocYHD6VekSThyY6HdB6J/IaUpMbVyy9OQBKknuUObKnfyOA7RNqeSE5OYl1sdXxi 06Z/3lPQYQJnZ05k/eWj0wHs1Z3gEu/zr7Pyj8VTWq1dpEoCpSY+VIS3U5le+Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mmel: URL: https://cgit.FreeBSD.org/src/commit/?id=139afdb1721fbb31d39e7cb8992dcc5369a17d5f commit 139afdb1721fbb31d39e7cb8992dcc5369a17d5f Author: Michal Meloun AuthorDate: 2021-03-04 14:09:32 +0000 Commit: Michal Meloun CommitDate: 2022-01-20 10:34:28 +0000 simple_mfd: switch to controllable locking for syscon provider. MFC after 3 weeks (cherry picked from commit f97f57b51855cecb9b497a90dfed06dac2c21111) --- sys/dev/fdt/simple_mfd.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/sys/dev/fdt/simple_mfd.c b/sys/dev/fdt/simple_mfd.c index 752740cf705e..aedada3079e8 100644 --- a/sys/dev/fdt/simple_mfd.c +++ b/sys/dev/fdt/simple_mfd.c @@ -73,9 +73,9 @@ static int simple_mfd_syscon_modify_4(struct syscon *syscon, bus_size_t offset, #define SYSCON_ASSERT_UNLOCKED(_sc) mtx_assert(&(_sc)->mtx, MA_NOTOWNED); static syscon_method_t simple_mfd_syscon_methods[] = { - SYSCONMETHOD(syscon_read_4, simple_mfd_syscon_read_4), - SYSCONMETHOD(syscon_write_4, simple_mfd_syscon_write_4), - SYSCONMETHOD(syscon_modify_4, simple_mfd_syscon_modify_4), + SYSCONMETHOD(syscon_unlocked_read_4, simple_mfd_syscon_read_4), + SYSCONMETHOD(syscon_unlocked_write_4, simple_mfd_syscon_write_4), + SYSCONMETHOD(syscon_unlocked_modify_4, simple_mfd_syscon_modify_4), SYSCONMETHOD_END }; @@ -89,10 +89,8 @@ simple_mfd_syscon_read_4(struct syscon *syscon, bus_size_t offset) uint32_t val; sc = device_get_softc(syscon->pdev); - - SYSCON_LOCK(sc); + SYSCON_ASSERT_LOCKED(sc);; val = bus_read_4(sc->mem_res, offset); - SYSCON_UNLOCK(sc); return (val); } @@ -103,10 +101,8 @@ simple_mfd_syscon_write_4(struct syscon *syscon, bus_size_t offset, struct simple_mfd_softc *sc; sc = device_get_softc(syscon->pdev); - - SYSCON_LOCK(sc); + SYSCON_ASSERT_LOCKED(sc); bus_write_4(sc->mem_res, offset, val); - SYSCON_UNLOCK(sc); return (0); } @@ -118,15 +114,14 @@ simple_mfd_syscon_modify_4(struct syscon *syscon, bus_size_t offset, uint32_t val; sc = device_get_softc(syscon->pdev); - - SYSCON_LOCK(sc); + SYSCON_ASSERT_LOCKED(sc); val = bus_read_4(sc->mem_res, offset); val &= ~clear_bits; val |= set_bits; bus_write_4(sc->mem_res, offset, val); - SYSCON_UNLOCK(sc); return (0); } + static int simple_mfd_syscon_get_handle(device_t dev, struct syscon **syscon) { @@ -139,6 +134,24 @@ simple_mfd_syscon_get_handle(device_t dev, struct syscon **syscon) return (0); } +static void +simple_mfd_syscon_lock(device_t dev) +{ + struct simple_mfd_softc *sc; + + sc = device_get_softc(dev); + SYSCON_LOCK(sc); +} + +static void +simple_mfd_syscon_unlock(device_t dev) +{ + struct simple_mfd_softc *sc; + + sc = device_get_softc(dev); + SYSCON_UNLOCK(sc); +} + static int simple_mfd_probe(device_t dev) { @@ -293,6 +306,9 @@ simple_mfd_add_device(device_t dev, phandle_t node, u_int order, static device_method_t simple_mfd_methods[] = { /* syscon interface */ DEVMETHOD(syscon_get_handle, simple_mfd_syscon_get_handle), + DEVMETHOD(syscon_device_lock, simple_mfd_syscon_lock), + DEVMETHOD(syscon_device_unlock, simple_mfd_syscon_unlock), + /* Device interface */ DEVMETHOD(device_probe, simple_mfd_probe), DEVMETHOD(device_attach, simple_mfd_attach),