Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp304402yba; Mon, 20 May 2019 09:01:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3yFbhRmWY8xJXNnBN336wVeFOPVuKb91Nwkx9lhloG+dVRM1MbLrxkm7AXlhUaTwGVl5j X-Received: by 2002:a17:902:c01:: with SMTP id 1mr37871729pls.142.1558368095006; Mon, 20 May 2019 09:01:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558368094; cv=none; d=google.com; s=arc-20160816; b=HwYNMYlVSeTYKU1vlrv3+1blvlEUKiPoPBF5rZanhiQv1ebHwt71hQCJngE9WrTQoe cBubcVROT8feqSAGJtNN7l1P604zi6nd1KFoiaAksP1p2wGNwd2hgByJP0j3YlGJkhBC JMOOptyWLpKYL90aXTlGUyNIyJoxArLhwXu4K5ovnT8WPdij54uyUX601zl2FvYZ4d4x H/AJZ8uHNUHaLmVW81MsGf3mlvuMVBYez3BKs+0GBzFdrAilTT4eQ+MPkM+zmeT81BCg 4fYDVBaoc7RFjAi93zuPIngVdRYQrmlSYvCUfV8Lm9RvzmgHhNK7w2GzxXS08qs/yaRo 7U7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OUbzVVtM7MQ/wSAhao3nimC9tkKycQItCXsObbSuRNg=; b=DdOJ5zmhZFMhSU4zhQkq+Z9z/rQCbXA2Np/LKwd45sol9f6EUCCCHxD6ZWg1eX3jDO 4o+fkj+l0OuCqRxrsszDhEdgLYVMrS45bl8hY4v8WOZv4fUucY1YWawBGuw6A+iAN01S iebUJQ6A/S/+xTUdMQ+oZb4HH/eDr7/SAPBFqgbZXFj9w8+U+9FwB+d2nbqcFGTZ1DRR oTzLAvTXWSdwcQ4l2KVIfIrPyvhqTaEhHZ9OEw188AbugBUT1GuR6RILZQP+V4PV/MwU GYrBBB922kg1vaMX6qxcqZd/8WFw3H/VLiywHNVpi6SnGh6RXt+vZQ0AmyctVwzz9zF0 eEHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XjRwu3rG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i123si21274991pfc.60.2019.05.20.09.01.17; Mon, 20 May 2019 09:01:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XjRwu3rG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389745AbfETM2q (ORCPT + 99 others); Mon, 20 May 2019 08:28:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:44624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387876AbfETM2n (ORCPT ); Mon, 20 May 2019 08:28:43 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4DDD4214DA; Mon, 20 May 2019 12:28:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355322; bh=5QImTVuc0lxp89bL2HI9b6Gh4NBrFme6P7Laz59P0CI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XjRwu3rGpTDPD/rykJO7z6Cxo1q1LFG/UesZJJWrC8FQYNE+XFPREfjGN8UGckz5S C3wFZgmAWKYZ8f/BMojCuNJf3xyIAHQbIwv0ylUiIP+ye9gFvsd6WhGkZTYLCiyRHo yCH/R6yGeBqajN/BVSzK6sc44T6gK5N4V5lY5Sno= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Romain Porte , Pascal Fabreges , Alexander Sverdlin , Tudor Ambarus , Mika Westerberg , Miquel Raynal Subject: [PATCH 5.0 076/123] mtd: spi-nor: intel-spi: Avoid crossing 4K address boundary on read/write Date: Mon, 20 May 2019 14:14:16 +0200 Message-Id: <20190520115249.901773602@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115245.439864225@linuxfoundation.org> References: <20190520115245.439864225@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Sverdlin commit 2b75ebeea6f4937d4d05ec4982c471cef9a29b7f upstream. It was observed that reads crossing 4K address boundary are failing. This limitation is mentioned in Intel documents: Intel(R) 9 Series Chipset Family Platform Controller Hub (PCH) Datasheet: "5.26.3 Flash Access Program Register Access: * Program Register Accesses are not allowed to cross a 4 KB boundary..." Enhanced Serial Peripheral Interface (eSPI) Interface Base Specification (for Client and Server Platforms): "5.1.4 Address For other memory transactions, the address may start or end at any byte boundary. However, the address and payload length combination must not cross the naturally aligned address boundary of the corresponding Maximum Payload Size. It must not cross a 4 KB address boundary." Avoid this by splitting an operation crossing the boundary into two operations. Fixes: 8afda8b26d01 ("spi-nor: Add support for Intel SPI serial flash controller") Cc: stable@vger.kernel.org Reported-by: Romain Porte Tested-by: Pascal Fabreges Signed-off-by: Alexander Sverdlin Reviewed-by: Tudor Ambarus Acked-by: Mika Westerberg Signed-off-by: Miquel Raynal Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/spi-nor/intel-spi.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/mtd/spi-nor/intel-spi.c +++ b/drivers/mtd/spi-nor/intel-spi.c @@ -632,6 +632,10 @@ static ssize_t intel_spi_read(struct spi while (len > 0) { block_size = min_t(size_t, len, INTEL_SPI_FIFO_SZ); + /* Read cannot cross 4K boundary */ + block_size = min_t(loff_t, from + block_size, + round_up(from + 1, SZ_4K)) - from; + writel(from, ispi->base + FADDR); val = readl(ispi->base + HSFSTS_CTL); @@ -685,6 +689,10 @@ static ssize_t intel_spi_write(struct sp while (len > 0) { block_size = min_t(size_t, len, INTEL_SPI_FIFO_SZ); + /* Write cannot cross 4K boundary */ + block_size = min_t(loff_t, to + block_size, + round_up(to + 1, SZ_4K)) - to; + writel(to, ispi->base + FADDR); val = readl(ispi->base + HSFSTS_CTL);