From nobody Tue Nov 26 04:29:37 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 AC37619B3EE for ; Tue, 22 Oct 2024 10:53:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729594437; cv=none; b=qoCAqAwEHNMhTmjguoK3NmG760dRheaRkpSjoTfZshgsnqM7aMbb2+0XSXlRTS53bRDl4KCQdlqk8xP9bGOvM1bkjhOnV5up79Qb4ERqw/rdkzOhAXmTn147CbstiLZsBKituE+VSq+YF48LbF51bc7cSBpx5Um7a5Zeacrnv7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729594437; c=relaxed/simple; bh=torsyGLfl3n5n85YhXlFTvXr/Lht7lxmZbx5KlrzZgU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qg/RIEXHoIYWRyUy3EL9l3boT9U3oI3vM/BrZCoVILhHP+iiSk/PT/AVTA7u6GIc3bs2U1uXwOR1MNinEKy2AwcK7PPQrJKtkn4DMUSP/H7d8aIgNfAvqi0zhNUSVY5BPqoQxchMaHV8NInr2VbiB3fpR5pmJvp7tWduODEppJk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ExOMVZmN; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ExOMVZmN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729594436; x=1761130436; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=torsyGLfl3n5n85YhXlFTvXr/Lht7lxmZbx5KlrzZgU=; b=ExOMVZmNntiKI8qAGolUmMOsVbzBesO9H4vFQRmyWR5tS3jPsxJBcHt3 moaqWdetyGrEgxxoSE8fuCX0QU5akeFb1GkaxvJuD7SVLpHznaTZ5yPyM LwNA6M0BKoerg5dw5MbiGD1eqrGeLUiVcKJY2kBcE0xfR+WOAjtBQ6lHI We3se07vaPb/Lk7Cx9VFk+m8Vg8xxneSc/b+5DHg1ryXE5G/IbLwO/lEU QDCi7hM6Hyd2uOiythBvTnkG14nOnN8EDK7arLF+AO597qGLIhbWYRrVo shB3PrGCeP1zRncrYIUhdvHJAt7qLe+gxk8d0jJvUJZ25Qbe6+tFxojUo w==; X-CSE-ConnectionGUID: PA+I6QTfTAOsxK9sFyD7Qw== X-CSE-MsgGUID: dX+zYcFpQD2k+RcZVpl1qw== X-IronPort-AV: E=McAfee;i="6700,10204,11232"; a="39705037" X-IronPort-AV: E=Sophos;i="6.11,223,1725346800"; d="scan'208";a="39705037" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2024 03:53:47 -0700 X-CSE-ConnectionGUID: vUpuTgXsRHWTvXP2NIGq+w== X-CSE-MsgGUID: kzS1+BB1R4+60Avq0+4J4w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,223,1725346800"; d="scan'208";a="79847647" Received: from sannilnx-dsk.jer.intel.com ([10.12.231.107]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2024 03:53:31 -0700 From: Alexander Usyskin To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Lucas De Marchi , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Rodrigo Vivi , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Jani Nikula , Joonas Lahtinen , Tvrtko Ursulin Cc: Oren Weil , linux-mtd@lists.infradead.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Alexander Usyskin Subject: [PATCH 05/10] mtd: intel-dg: align 64bit read and write Date: Tue, 22 Oct 2024 13:41:14 +0300 Message-ID: <20241022104119.3149051-6-alexander.usyskin@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241022104119.3149051-1-alexander.usyskin@intel.com> References: <20241022104119.3149051-1-alexander.usyskin@intel.com> 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" GSC NVM controller HW errors on quad access overlapping 1K border. Align 64bit read and write to avoid readq/writeq over 1K border. Signed-off-by: Alexander Usyskin --- drivers/mtd/devices/mtd-intel-dg.c | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/mtd/devices/mtd-intel-dg.c b/drivers/mtd/devices/mtd-i= ntel-dg.c index 2efcb4d64ebf..4951438e8faf 100644 --- a/drivers/mtd/devices/mtd-intel-dg.c +++ b/drivers/mtd/devices/mtd-intel-dg.c @@ -239,6 +239,24 @@ static ssize_t idg_write(struct intel_dg_nvm *nvm, u8 = region, len_s -=3D to_shift; } =20 + if (!IS_ALIGNED(to, sizeof(u64)) && + ((to ^ (to + len_s)) & GENMASK(31, 10))) { + /* + * Workaround reads/writes across 1k-aligned addresses + * (start u32 before 1k, end u32 after) + * as this fails on hardware. + */ + u32 data; + + memcpy(&data, &buf[0], sizeof(u32)); + idg_nvm_write32(nvm, to, data); + if (idg_nvm_error(nvm)) + return -EIO; + buf +=3D sizeof(u32); + to +=3D sizeof(u32); + len_s -=3D sizeof(u32); + } + len8 =3D ALIGN_DOWN(len_s, sizeof(u64)); for (i =3D 0; i < len8; i +=3D sizeof(u64)) { u64 data; @@ -297,6 +315,23 @@ static ssize_t idg_read(struct intel_dg_nvm *nvm, u8 r= egion, from +=3D from_shift; } =20 + if (!IS_ALIGNED(from, sizeof(u64)) && + ((from ^ (from + len_s)) & GENMASK(31, 10))) { + /* + * Workaround reads/writes across 1k-aligned addresses + * (start u32 before 1k, end u32 after) + * as this fails on hardware. + */ + u32 data =3D idg_nvm_read32(nvm, from); + + if (idg_nvm_error(nvm)) + return -EIO; + memcpy(&buf[0], &data, sizeof(data)); + len_s -=3D sizeof(u32); + buf +=3D sizeof(u32); + from +=3D sizeof(u32); + } + len8 =3D ALIGN_DOWN(len_s, sizeof(u64)); for (i =3D 0; i < len8; i +=3D sizeof(u64)) { u64 data =3D idg_nvm_read64(nvm, from + i); --=20 2.43.0