From nobody Sun Jun 21 08:02:46 2026 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F2A0219EB for ; Sun, 26 Apr 2026 22:25:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777242351; cv=none; b=ZgjZa1n8gFJyKZD+rTzCXePflwZ8pkFQOdBjEkW3hRk4Z3bqUjUgPNhEFX3EnOVEjouDeyoF2x2BbbZIDwhaIVgIh7T/Yuje53UM3S+YeRiJ4PG2DPxZGz0u6G4SsfYCGrKi3G9qRMK/lyBSg/5DYPvf4K79+ExaxAkM5Z+NMYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777242351; c=relaxed/simple; bh=8YI7bTE6VqWepiB/YeSkG1B2cIOvT5K5YoVGg2N1S7I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Ido8wx5rFReDTMTDnLc6nzplZLe76Cwe31oXJMpmVgTJJ5eyinGQomZRuL2IpxWCv0jkPkBVo+4WmAJuA/RAzVL8NHoWmrjW6/BnXPsAmHwnocNC0NftWo0Q2IAnw250VvRbKa6sQCgfFLLYOY0rdhCkgdI2ZMpBrtS//MxPVRU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eBehDcra; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eBehDcra" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-43d7e23defbso5644365f8f.0 for ; Sun, 26 Apr 2026 15:25:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777242348; x=1777847148; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=uAV7QfybA/MYDdGSOXKDNQ25mr+F/ZwYCIZ6fu/YUyY=; b=eBehDcra+yVlp360bu2YR1Im9zPlKQdSjpdPyzjgpGT94VDEZCjPzenQPjF96d/icU 3gnyXJB2KcgYp+dnNcoqgokLXSFhnVQpFc/jiiqlAztszREO9qsiM/yo0cyNi2PN4jbr 2INSInW1iRQxGgWFxXuS5BIcLdx01UVlwRGVQo6z+pUL/WY3hVhWQChPqNsBMO0UCLLJ wmlFcE7BSRfQe9c2Z4V9gQUa5MCVCcZeBlWCnzwzKy/0GyV7g74Qh99FqBCbzBuergn0 NGCaNMFpak//Nvwr/MfR7RlPHYx/YiMR/m/DtcLihX06t7Xo0FFNO1LSVLM9Ao9WvAz9 llqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777242348; x=1777847148; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=uAV7QfybA/MYDdGSOXKDNQ25mr+F/ZwYCIZ6fu/YUyY=; b=ZUMqGs1+shwVxT74qxYKByWxuXpXOxKWzoiL48MPfdL55Yq8Z+EzGqI4PtdRphCwgq fpQVBu1QAOvJO004Sieko23dFApUOPpOnufxomkCzKf4S+WEhn/6/szLNFbjsvnBoHWv 3FJIDPXdI0O7jq0leLY7GkslqoML4an9RJxTHw6DmOiQFoBHHy4wFm0mWVDbx39FuBqt HGFx6ma0k6UVAUikDMfCGmTx9Z1JgSaqGyPhR2aJYWwMT0NvCihR7PnR7pSPq6wJpAH2 AeuD+cBLtgwp0v/FdZR4kt5U9Sn+lPua6vWmXv1yLyQZEeg5hlswBjEv92v0lf/W6t2I 4btQ== X-Forwarded-Encrypted: i=1; AFNElJ9MxxPxaO15Z4OuGlKn3nmyVcTvDL9KowcLLzjBgfbDxfkUe5k+hCeZ/TOuqzjUKnFdjk2HIaC2rtT9icY=@vger.kernel.org X-Gm-Message-State: AOJu0YzDYGQP48RRtYqORp6SSLf6jIbvc/2o83Zr+g+cqb8f+dpELF5n hrUGQyvzpJBn9HB5y1EGPQwRkOrwhIb+bjOc+PnLMRfjHvFljbdiWhY= X-Gm-Gg: AeBDieukvWiG9Y8H8YhLSVam4potak6OKl1TdxrszmAJoQS1h4Dvjxn4tkBo7Ljf2SJ i1W7jwctVL8tLlvy12xAuyPG99PI3uPnVjm19oCinR6rNrX2eIkUBhdlz03lXRYHOMqJ5Pp7sOT HPf6CIPTRQai8KGo6SCSOurSS7bNsxTNUZZbtrY2I1/58nJqIVVdY2YFm+eudWRmCiARJQX03aS 8N4QFkrcMPXrOJ5eD/+qA16lFp9JZkTH7bcTXmvfi28DYpy880K5V+J6cAv6e/FwmjUHiNaeuc6 fvu0Y+ziqJP+yn2RlpKBUGJj1OEA6jzO4vRCR8mBbqfgdQeVgUjQLgg92Tfeg6kOSaZ/L6W1osL kZaCgGVKPCDksd7Hp/Ok6wGjmKdooBIv2rjo53FzLnk+Fb3O0jQHB2uOAdl+BUV6YXYnV4Xv5Fo 6ro6XLR68Iz9nheoAXh350RggiXzKIg/8kFKreU0WAeBd1HxNqnu4h6Dc0aTfXaqCf5ECABmzEF Fh9rsgj4MzcTFS4CLY= X-Received: by 2002:a5d:5d0b:0:b0:43d:1c4a:37c with SMTP id ffacd0b85a97d-43fe3db3c6dmr61754552f8f.4.1777242347804; Sun, 26 Apr 2026 15:25:47 -0700 (PDT) Received: from localhost ([2a02:810d:4a94:b300:d98f:f308:9025:fa5f]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-43fe4e3a341sm81678663f8f.24.2026.04.26.15.25.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 26 Apr 2026 15:25:47 -0700 (PDT) From: Florian Fuchs To: linux-sh@vger.kernel.org, John Paul Adrian Glaubitz , Rich Felker , Artur Rojek Cc: Adrian McMenamin , linux-kernel@vger.kernel.org, Florian Fuchs Subject: [PATCH v2] sh: maple: fix empty port handling Date: Sun, 26 Apr 2026 23:27:14 +0200 Message-ID: <20260426212714.2286437-1-fuchsfl@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Fix the handling of empty ports, to restore the ability to use the device with less than 4 populated ports and also be able to hot-plug new devices in empty ports at runtime. Explicitly cast the response code in maple_response_devinfo() to s8 so that 0xFF from the device gets interpreted as signed and flows like the NONE response, previously it was considered unknown response code, which blocked the maple bus. Remove the locking variable from maple_vblank_handler() as there is no locking information returned from maple_add_packet() and it lead to only ever check exactly one empty port. Update maple_response_devinfo() to explicitly check for empty ports on unit 0, to be able to hot-plug devices in empty ports. Signed-off-by: Florian Fuchs Acked-by: Artur Rojek Tested-by: Artur Rojek --- v1->v2: Don't break hot-plugging of new devices to empty ports. Explicitly cast the response code to s8 to use the existing logic, that relies on signed chars. In the case of 0xff (all 1s, DCs TIMEOUT response) that was interpreted as 255 unknown response code, which blocked the maple bus, as busy was never reset. Add condition to maple_response_devinfo() to process the devinfo=20 for currently empty ports. v1: https://lore.kernel.org/all/20251112190444.3631533-1-fuchsfl@gmail.com/ Note that the removal of peripherals is possible, the ports get marked as empty, but the driver is never detached. That means a peripheral can be removed, but the port keeps "reserved" for this peripheral and can't be reused with another peripheral. VMUs can't be removed at runtime, as MTD keeps a reference to it, so that mdev->can_unload() is never true. But the same peripheral can be inserted to the same port again. drivers/sh/maple/maple.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c index 5585f220e495..8e7bb42aef07 100644 --- a/drivers/sh/maple/maple.c +++ b/drivers/sh/maple/maple.c @@ -445,7 +445,7 @@ static int setup_maple_commands(struct device *device, = void *ignored) /* VBLANK bottom half - implemented via workqueue */ static void maple_vblank_handler(struct work_struct *work) { - int x, locking; + int x; struct maple_device *mdev; =20 if (!maple_dma_done()) @@ -474,13 +474,10 @@ static void maple_vblank_handler(struct work_struct *= work) if (!mdev) break; atomic_set(&mdev->busy, 1); - locking =3D maple_add_packet(mdev, 0, + maple_add_packet(mdev, 0, MAPLE_COMMAND_DEVINFO, 0, NULL); - if (!locking) - break; - } } - + } maple_pnp_time =3D jiffies + MAPLE_PNP_INTERVAL; } =20 @@ -578,7 +575,8 @@ static void maple_response_devinfo(struct maple_device = *mdev, char *recvbuf) { char submask; - if (!started || (scanning =3D=3D 2) || !fullscan) { + if (!started || (scanning =3D=3D 2) || !fullscan || + ((mdev->unit =3D=3D 0) && empty[mdev->port])) { if ((mdev->unit =3D=3D 0) && (checked[mdev->port] =3D=3D false)) { checked[mdev->port] =3D true; maple_attach_driver(mdev); @@ -644,7 +642,7 @@ static void maple_dma_handler(struct work_struct *work) recvbuf =3D mq->recvbuf->buf; __flush_invalidate_region(sh_cacheop_vaddr(recvbuf), 0x400); - code =3D recvbuf[0]; + code =3D (s8)recvbuf[0]; kfree(mq->sendbuf); list_del_init(&mq->list); switch (code) { base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f --=20 2.43.0