{"id":2228605,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2228605/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/patch/20260427061720.2393355-1-wenst@chromium.org/","project":{"id":42,"url":"http://patchwork.ozlabs.org/api/1.1/projects/42/?format=json","name":"Linux GPIO development","link_name":"linux-gpio","list_id":"linux-gpio.vger.kernel.org","list_email":"linux-gpio@vger.kernel.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260427061720.2393355-1-wenst@chromium.org>","date":"2026-04-27T06:17:17","name":"pinctrl: mediatek: common-v1: Directly modify registers to set GPIO direction","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"78cf00561be27f61f5a229b5aee04288f616fab1","submitter":{"id":81844,"url":"http://patchwork.ozlabs.org/api/1.1/people/81844/?format=json","name":"Chen-Yu Tsai","email":"wenst@chromium.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-gpio/patch/20260427061720.2393355-1-wenst@chromium.org/mbox/","series":[{"id":501583,"url":"http://patchwork.ozlabs.org/api/1.1/series/501583/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/list/?series=501583","date":"2026-04-27T06:17:17","name":"pinctrl: mediatek: common-v1: Directly modify registers to set GPIO direction","version":1,"mbox":"http://patchwork.ozlabs.org/series/501583/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2228605/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2228605/checks/","tags":{},"headers":{"Return-Path":"\n <linux-gpio+bounces-35534-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-gpio@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256\n header.s=google header.b=nxZB7ckQ;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-gpio+bounces-35534-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org\n header.b=\"nxZB7ckQ\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.210.172","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=chromium.org","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=chromium.org"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g3tf43pr4z1yJX\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 16:17:48 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id CAE0F3006B7C\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 06:17:33 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id A6A7436F418;\n\tMon, 27 Apr 2026 06:17:32 +0000 (UTC)","from mail-pf1-f172.google.com (mail-pf1-f172.google.com\n [209.85.210.172])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id E699935E93C\n\tfor <linux-gpio@vger.kernel.org>; Mon, 27 Apr 2026 06:17:29 +0000 (UTC)","by mail-pf1-f172.google.com with SMTP id\n d2e1a72fcca58-82fbf5d4dc2so6027154b3a.1\n        for <linux-gpio@vger.kernel.org>;\n Sun, 26 Apr 2026 23:17:29 -0700 (PDT)","from wenstp920.tpe.corp.google.com\n ([2a00:79e0:201d:8:8f3b:cb24:e20a:84bd])\n        by smtp.gmail.com with ESMTPSA id\n d2e1a72fcca58-82f8ea02ef7sm28824635b3a.25.2026.04.26.23.17.27\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Sun, 26 Apr 2026 23:17:28 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777270652; cv=none;\n b=clS1Iud1QzYgsbuYTBjujnaqdbfYTftIQAXXoK8XEUWCbYp2U6fQ8tEfBptb1ucGQZVN0K4c6us8qNNl+ZT9dNLKS20vSCEtnUrsPJzCRku3kVSwbajapnpoUuWfSiAKSBoDYKhF+n+MlQHyJuFJ58yIMcn68NHeXzwy6kefHsA=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777270652; c=relaxed/simple;\n\tbh=WweyAjXhQsKYxr9GHwNadiW4OuHH3zASgkTPnK6u2k8=;\n\th=From:To:Cc:Subject:Date:Message-ID:MIME-Version;\n b=RyzsTXFLVXGqfhRSxBVg9I2fqpzRSYbIK3lDVirqV9Nsiia85KooFkRusV8jJfXspCaSLDMD00v+1wmo+s5EqRtRaVgJh0Gw9gYbj/tFKoueAeO/7CU+qPencrOQpbKGb+uFBEN+1JKFIZq0CPpHpuiNCbUZwSOjlDeaNG+zJnc=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=chromium.org;\n spf=pass smtp.mailfrom=chromium.org;\n dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org\n header.b=nxZB7ckQ; arc=none smtp.client-ip=209.85.210.172","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=chromium.org; s=google; t=1777270649; x=1777875449;\n darn=vger.kernel.org;\n        h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n         :to:from:from:to:cc:subject:date:message-id:reply-to;\n        bh=EIIdNRJ9w0CAu5OepNld+STP1bHH56eIhQu2O8kdVlY=;\n        b=nxZB7ckQF2rOwDvG2zQOqxtku5VS/v7SblP3O6UV4mZGDOgv9QeV8ZRV/a8R+P4l+a\n         MGPRN7yzlJVu2nLHzXjTKm6fOMje5duDy7ZCnfSGmz8rb/cUFLAPbOfAziupIOOX55CW\n         T2u6ev5uc3/5Kk3DXTxaW4HpmtKulcJVVd6+U=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1777270649; x=1777875449;\n        h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n         :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=EIIdNRJ9w0CAu5OepNld+STP1bHH56eIhQu2O8kdVlY=;\n        b=Adpg0/kz3jrpBiasUglmH24lcAAt9K/qf3eg8GIjkxbEDXkesYnshAfM5pSxGIaMzb\n         nnVj5U5VimgUjxzGpdbLjaszIczvkic2bq7yrV/WgNzUnon639/09hGhqwiyby/s/JXx\n         c20bh0qqxou+UU7bzNma/rcunBgAfPFhmX9q8jGXZsto/38G1EvJd8iALFuFswJ1VxCd\n         0BVmLEkASmeS9LI4NOQepHZhoM1I2hurA/xzbFZMZm1G6aoKwGRjbvnTBcQJX0aPvy0i\n         ExOCED3sSvGMWvzYMuTa2NMBrnpOsKDR10nfiI+UTJebh+qVNjdjSy6vthGJfceR+lyJ\n         juyg==","X-Forwarded-Encrypted":"i=1;\n AFNElJ8+vaebq2jKr6vqZDrMYk0GVRtAmk++f38rv3agnz1AQIPkCQxPIM/sExEAumUZW9I5iW/5/CsjyMW9@vger.kernel.org","X-Gm-Message-State":"AOJu0YwhkhteX6SeGBdTPJOWLudIto/Ls26eY5+4dBV3pZ8uvPXA28n5\n\t3ZFccqqZ8cehJGR6VI3SX5GLVyctx7H0VRR4P/ix+W30xphHqCCnjg2gnOl+eh6sXQ==","X-Gm-Gg":"AeBDiesbkeAQ/W/T+Dc5/yFu9uKV2QCOO0qDa4FOvD5j9nbFqldXHcpiO2jJoD8pmyY\n\tX4uu5NSUd1gbRHJ7r4zspDKenPpx4U1jfEW7LBtAc+yh1Sx3GLkTSKMuWEBsR/VnxVadOdSQ4zd\n\taiSc1ZFwkeA+hw0LMgEj3jAqJCDKLbLScIdDiBnazquBAC6l6KSOBs7Mwj7pk2pvstNB0QzC0bS\n\tiIrP+mR6sXrZ44WEME+b/9Km3zuFmxNrVii6ufC7hQPkxi97qxDJNkBbwIXypRZ3D5R9eVPMK5c\n\tKBZv7HYGoh2dyuDD0K1ahG1CL1TZcqHlRQP7ZxTniBuwFb7F3VFnULAELbKl4Lza2/LD+lrEREm\n\tJPPrD1SzLrlOvT76hQ3KyHarJAtGytSXkFEUjUpUf2br+gdnL22AIiUzOP0pgne5g4iqSzLGzfs\n\tx6vKTbBL5j/H0U9ufnq6LvvzL8OpiR9Sp9+7Krmrn+NZzmV6On/3XquKFJ3T+Ms+Kf/Jb1HKD8y\n\twf1dvYZ30vIQPE6EMLkHnWuaULypw==","X-Received":"by 2002:a05:6a00:4b4d:b0:82c:6b46:271d with SMTP id\n d2e1a72fcca58-82f8c93a983mr44134092b3a.48.1777270649269;\n        Sun, 26 Apr 2026 23:17:29 -0700 (PDT)","From":"Chen-Yu Tsai <wenst@chromium.org>","To":"Sean Wang <sean.wang@kernel.org>,\n\tMatthias Brugger <matthias.bgg@gmail.com>,\n\tAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>,\n\tLinus Walleij <linusw@kernel.org>","Cc":"Chen-Yu Tsai <wenst@chromium.org>,\n\tlinux-mediatek@lists.infradead.org,\n\tlinux-gpio@vger.kernel.org,\n\tlinux-arm-kernel@lists.infradead.org,\n\tlinux-kernel@vger.kernel.org","Subject":"[PATCH] pinctrl: mediatek: common-v1: Directly modify registers to\n set GPIO direction","Date":"Mon, 27 Apr 2026 14:17:17 +0800","Message-ID":"<20260427061720.2393355-1-wenst@chromium.org>","X-Mailer":"git-send-email 2.54.0.rc2.544.gc7ae2d5bb8-goog","Precedence":"bulk","X-Mailing-List":"linux-gpio@vger.kernel.org","List-Id":"<linux-gpio.vger.kernel.org>","List-Subscribe":"<mailto:linux-gpio+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-gpio+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit"},"content":"pinctrl_gpio_direction_input() / pinctrl_gpio_direction_output() take\nthe pinctrl mutex. This causes a gpiochip operations to need to sleep.\nWorse yet, the .can_sleep field in the gpiochip is not set. This causes\nthe shared GPIO proxy to trip over, as it uses gpiod_cansleep() to check\nwhether it can use a spinlock or needs a mutex. In this case, it ends\nup taking a spinlock, then calls pinctrl_gpio_direction_output(), which\ntakes a mutex. This causes a huge warning.\n\nSince the Mediatek hardware has separate clear/set registers, there is\nno risk of clobbering other bits like with a read-modify-write pattern.\nSwitch to directly setting the GPIO direction register bits to avoid\nthe mutex.\n\nSigned-off-by: Chen-Yu Tsai <wenst@chromium.org>\n---\nOnly compile tested. Accidentally fixed the wrong file when my target\nactually used pinctrl-paris.c\n---\n drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 12 ++++++++++--\n 1 file changed, 10 insertions(+), 2 deletions(-)","diff":"diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c\nindex 3f518dce6d23..9c258e205e39 100644\n--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c\n+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c\n@@ -806,16 +806,24 @@ static const struct pinmux_ops mtk_pmx_ops = {\n \t.gpio_request_enable\t= mtk_pmx_gpio_request_enable,\n };\n \n+static int mtk_gpio_direction_input(struct gpio_chip *chip, unsigned offset)\n+{\n+\tstruct mtk_pinctrl *pctl = gpiochip_get_data(chip);\n+\n+\treturn mtk_pmx_gpio_set_direction(pctl->pctl_dev, NULL, offset, true);\n+}\n+\n static int mtk_gpio_direction_output(struct gpio_chip *chip,\n \t\t\t\t\tunsigned offset, int value)\n {\n+\tstruct mtk_pinctrl *pctl = gpiochip_get_data(chip);\n \tint ret;\n \n \tret = mtk_gpio_set(chip, offset, value);\n \tif (ret)\n \t\treturn ret;\n \n-\treturn pinctrl_gpio_direction_output(chip, offset);\n+\treturn mtk_pmx_gpio_set_direction(pctl->pctl_dev, NULL, offset, true);\n }\n \n static int mtk_gpio_get_direction(struct gpio_chip *chip, unsigned offset)\n@@ -895,7 +903,7 @@ static const struct gpio_chip mtk_gpio_chip = {\n \t.request\t\t= gpiochip_generic_request,\n \t.free\t\t\t= gpiochip_generic_free,\n \t.get_direction\t\t= mtk_gpio_get_direction,\n-\t.direction_input\t= pinctrl_gpio_direction_input,\n+\t.direction_input\t= mtk_gpio_direction_input,\n \t.direction_output\t= mtk_gpio_direction_output,\n \t.get\t\t\t= mtk_gpio_get,\n \t.set\t\t\t= mtk_gpio_set,\n","prefixes":[]}