From patchwork Thu Jul 11 08:18:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 13730164 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (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 E6F4014885D; Thu, 11 Jul 2024 08:18:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720685932; cv=none; b=ZMCL0gbpD1+AG0hkrecWpDnTBnl8pDECBHzDUdNzcknlUeonq/0qmupiyy2IARkiGVD28cKkY0ElrD14FC8KwDKRQVdGPvZu/JcfnrDvXbsxvy8KE5K05YNdBtZ/bkVncoDfUu7FywerHp9tpvWsroLn5TvbrbFTUQiW0+U5I+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720685932; c=relaxed/simple; bh=eBSnAndKGBLv4fIbpoUVrnd4r0rXqY15awgPqI5yCz0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W+FkRJHoBIRhd2Cjp3dtLLRkBG3wMuC7EV0dE7l/5ESJVKyQKQohlBwNkIjGw+BO3LmFsgWikF8C2Z4EbB+3uFDbReq8IAEKFvkQlE2L5K19ByJwKmvCc8MAnwYQ4hx+R6+R/L8GZm39V+9PqpnkOTUq/GaV34jn3lnlG42+GHM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=BDhNy7fe; arc=none smtp.client-ip=217.70.183.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="BDhNy7fe" Received: by mail.gandi.net (Postfix) with ESMTPA id CBF4A40006; Thu, 11 Jul 2024 08:18:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1720685922; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ii1N3RozxM4/rtfCLZ6uvIsvYlMTNZJP3+qKjDNPUhw=; b=BDhNy7feKOZF98MnmYw4Sdj32jMvGncfiHb/rckxxNZlm0Tf1VwfBcnaIrNOVi1NAoM6Qy CG7rpzko417cEOxihe6hLXgH2X7w70d03m8Ya7fQ2g1DSCDtl4k4KEYyaCSTvPjPWR5WPa pnRvCTdhiIqJl5WL4HSUdemaHYH3VQDQC8UDhsArc+y0ErUs+uMWp6Dm18a8BrWxaTy944 ZRIiRRAuhsUJvGW3D+M1QChfYBvVsxjIgmhjjokka2VnuDVk/WlspCxkJndrz5giO/retD F/NQHtCpi3MpCgDvUKrdISRSlPMQHgqq6S3WxQgbPta4uq0CEEvN2uK7d6RVtg== From: Bastien Curutchet To: Ulf Hansson , Linus Walleij Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , Christopher Cordahi , Bastien Curutchet , stable@vger.kernel.org Subject: [PATCH 1/2] mmc: davinci_mmc: Prevent transmitted data size from exceeding sgm's length Date: Thu, 11 Jul 2024 10:18:37 +0200 Message-ID: <20240711081838.47256-2-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240711081838.47256-1-bastien.curutchet@bootlin.com> References: <20240711081838.47256-1-bastien.curutchet@bootlin.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com No check is done on the size of the data to be transmiited. This causes a kernel panic when this size exceeds the sg_miter's length. Limit the number of transmitted bytes to sgm->length. Cc: stable@vger.kernel.org Fixes: ed01d210fd91 ("mmc: davinci_mmc: Use sg_miter for PIO") Signed-off-by: Bastien Curutchet --- drivers/mmc/host/davinci_mmc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c index d7427894e0bc..c302eb380e42 100644 --- a/drivers/mmc/host/davinci_mmc.c +++ b/drivers/mmc/host/davinci_mmc.c @@ -224,6 +224,9 @@ static void davinci_fifo_data_trans(struct mmc_davinci_host *host, } p = sgm->addr; + if (n > sgm->length) + n = sgm->length; + /* NOTE: we never transfer more than rw_threshold bytes * to/from the fifo here; there's no I/O overlap. * This also assumes that access width( i.e. ACCWD) is 4 bytes From patchwork Thu Jul 11 08:18:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 13730165 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (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 8167714F9EA; Thu, 11 Jul 2024 08:18:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720685932; cv=none; b=fP9j7GCW8QwPN4zV9E9heYqFTAWn1P1Dp/RddMV46TaUcO4/JNY/EEAf/QN6t/7RYQwCoyAqUhqkI5skxJa9CsVoEPIP5A9BKbUJeLqCutTIwPaYmqJDSoPevAoTxfQbmVtCFLz9uMCHDMmrdGvfH2hFkYGmz1eN05gAomzPCFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720685932; c=relaxed/simple; bh=CwDci9vRjYo9CAjJdyXJrVoCQNKghc/BQ7rniuB/qaw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZRpfQmwscCtMmPzXAXOKboCldROuOkU8zee+7bbUiYz6esphMR9johlllkQBuTWdU6Rep+zckpXOnjGnJaKc65IvhXvdiLuM6O1iSfnC7iRcWq9WNlYevxTYl48VPIaiqkef4aKDqkfgvsaoebcG6JGn+4a1p+NTaLEMgV/D72M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=DqyP4sZN; arc=none smtp.client-ip=217.70.183.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="DqyP4sZN" Received: by mail.gandi.net (Postfix) with ESMTPA id 2703C4000F; Thu, 11 Jul 2024 08:18:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1720685923; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=40fIdy34lgcI2e31bZTL+O/QYbIYmqzcDPmH5hhaCkQ=; b=DqyP4sZNOUv6eIBbdwi3KnrS6C+0OSmH2iVrxWVmXp3YBHD86ZDtEomoVp7GBD/dB1uwW9 AeT+VRJg6V6eAER8s3K626rqHAuWdduTjzK24Ly5IC5R1wAXR/pE90epYlEeNpnYTrqXV9 BzcT0M3aRxc0Y6Fa+jcoD8DiwCPbBdSJvUmPeILi5o8KTlGX+DxOFmo+8mmZwJCZQImD5T BNbmtmoUB0DeWyE+V1fDkh+wBG2+ppep1Zs5A3RfmZiH1Yr3KeZ+XzSNo+QOdPQJ3VbxcE ySuITjVKLuyjopgmKWXn57LAOkuyWIX95ukISQDLXWoO1x+Ljz7yf2qW0B++sg== From: Bastien Curutchet To: Ulf Hansson , Linus Walleij Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , Christopher Cordahi , Bastien Curutchet Subject: [PATCH 2/2] mmc: davinci_mmc: report all possible bus widths Date: Thu, 11 Jul 2024 10:18:38 +0200 Message-ID: <20240711081838.47256-3-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240711081838.47256-1-bastien.curutchet@bootlin.com> References: <20240711081838.47256-1-bastien.curutchet@bootlin.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com A dev_info() at probe's end() report the supported bus width. It never reports 8-bits width while the driver can handle it. Update the info message at then end of the probe to report the use of 8-bits data when needed. Signed-off-by: Bastien Curutchet --- drivers/mmc/host/davinci_mmc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c index c302eb380e42..9cbde800685d 100644 --- a/drivers/mmc/host/davinci_mmc.c +++ b/drivers/mmc/host/davinci_mmc.c @@ -1187,7 +1187,7 @@ static int davinci_mmcsd_probe(struct platform_device *pdev) struct mmc_davinci_host *host = NULL; struct mmc_host *mmc = NULL; struct resource *r, *mem = NULL; - int ret, irq; + int ret, irq, bus_width; size_t mem_size; const struct platform_device_id *id_entry; @@ -1317,9 +1317,14 @@ static int davinci_mmcsd_probe(struct platform_device *pdev) rename_region(mem, mmc_hostname(mmc)); + if (mmc->caps & MMC_CAP_8_BIT_DATA) + bus_width = 8; + else if (mmc->caps & MMC_CAP_4_BIT_DATA) + bus_width = 4; + else + bus_width = 1; dev_info(mmc_dev(host->mmc), "Using %s, %d-bit mode\n", - host->use_dma ? "DMA" : "PIO", - (mmc->caps & MMC_CAP_4_BIT_DATA) ? 4 : 1); + host->use_dma ? "DMA" : "PIO", bus_width); return 0;