Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4489147ybx; Mon, 4 Nov 2019 14:16:16 -0800 (PST) X-Google-Smtp-Source: APXvYqx9umpg1kDGs51EqJCf5T/bKyvEdZi/PXLZmz355s0wCO6oMY7x1O57RdyTcHvEanyX+2uJ X-Received: by 2002:a05:6402:168b:: with SMTP id a11mr3726017edv.107.1572905776683; Mon, 04 Nov 2019 14:16:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572905776; cv=none; d=google.com; s=arc-20160816; b=NECDt3/jRsl+TO7IZ5eDkTYyL0TGo7RG/x6QuOux6FPqWz8bgEBlC6gaJCCQHKgjVC WbzANOAXVf+xa8+T13TTz8UanZ6/o773avWYpraNfJqD5MDrP3BKB0iMIxz1cIS8hrxk ZeRpWNMMaBAE1VvKNvaFEtrft5iwhw6n4dm6ryIoeSyAwuTmHJr/tuMG6lcAVuBjmV1I GK8udL34Xu+AUQwY06rnf+5d4eoCyjUoO0lrreA2MuOgcZvMC9/tzI1SSCDpmV0kuYWI oZVV4SGEy48DWy0o6Hf+UTCF2MTZTizHh0JyY9YrUR7bRyP/dDnrIQHOARcRA67sONOd 4FkQ== 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=e46HqpvPm+/8E21WE6HZuarZfyraNM68U8Jd172Zzy4=; b=Z+5MS2h74qqK7x+Ujgq+OLzvkn3OJuLYLi0mUpwW286XymXn/GdrpKjSFlXV5BtU59 fV1j2pXaw12b/7vqEIyDCxC2OsWGXOjl/kTQQf19vkCyGQWVnLFyiScO8y/IH35K33r1 yD/oRPKJ5GLOr1iTOz+hNZR00Mx9L5OGgIDuKkT9DmRUHdf/VenePXFdNX45Gtjgagyx hPvBS6D4zFSBtJ8vYjnIRzah08emhMWpFwQqyAxORzP+XV5wtT+vvA6JMoiwj7bCLVJp l+gZ1z34wkhUuIy7F9uAyvrAMLqnYDS7QzNs55fA86ox8LB77CnJJAvtfi0YXS7GeYrF qTJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Kk3lZuLk; 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 w1si7963607eda.433.2019.11.04.14.15.49; Mon, 04 Nov 2019 14:16:16 -0800 (PST) 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=Kk3lZuLk; 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 S2389152AbfKDWI6 (ORCPT + 99 others); Mon, 4 Nov 2019 17:08:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:41904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388158AbfKDWI4 (ORCPT ); Mon, 4 Nov 2019 17:08:56 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (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 42DF3214E0; Mon, 4 Nov 2019 22:08:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572905335; bh=LCcfkCOh2sKhl+CJURGrELfHhNY9DuqerqxwPCTQnJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kk3lZuLkpbxF0jhoC5YKVcNljSMivdw9xalQaX+G/gPBjHiNWejjLJUF9nuDC4T3q Ai+vN0BnRjgTv2aTwhOzH15j3sY1l0cHvfhrN7loFNGP1JjkzcW3shtQD5Ltr703rd Ytk7Gst+gesrnucEUUdmhEAJ/Lqq+4TTDbOwo9xg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mika Westerberg , Yehezkel Bernat , Mario Limonciello , Sasha Levin Subject: [PATCH 5.3 093/163] thunderbolt: Use 32-bit writes when writing ring producer/consumer Date: Mon, 4 Nov 2019 22:44:43 +0100 Message-Id: <20191104212146.895567720@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212140.046021995@linuxfoundation.org> References: <20191104212140.046021995@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: Mika Westerberg [ Upstream commit 943795219d3cb9f8ce6ce51cad3ffe1f61e95c6b ] The register access should be using 32-bit reads/writes according to the datasheet. With the previous generation hardware 16-bit writes have been working but starting with ICL this is not the case anymore so fix producer/consumer register update to use correct width register address. Signed-off-by: Mika Westerberg Reviewed-by: Yehezkel Bernat Tested-by: Mario Limonciello Signed-off-by: Sasha Levin --- drivers/thunderbolt/nhi.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c index 27fbe62c7ddd4..9c782706e652f 100644 --- a/drivers/thunderbolt/nhi.c +++ b/drivers/thunderbolt/nhi.c @@ -143,9 +143,20 @@ static void __iomem *ring_options_base(struct tb_ring *ring) return io; } -static void ring_iowrite16desc(struct tb_ring *ring, u32 value, u32 offset) +static void ring_iowrite_cons(struct tb_ring *ring, u16 cons) { - iowrite16(value, ring_desc_base(ring) + offset); + /* + * The other 16-bits in the register is read-only and writes to it + * are ignored by the hardware so we can save one ioread32() by + * filling the read-only bits with zeroes. + */ + iowrite32(cons, ring_desc_base(ring) + 8); +} + +static void ring_iowrite_prod(struct tb_ring *ring, u16 prod) +{ + /* See ring_iowrite_cons() above for explanation */ + iowrite32(prod << 16, ring_desc_base(ring) + 8); } static void ring_iowrite32desc(struct tb_ring *ring, u32 value, u32 offset) @@ -197,7 +208,10 @@ static void ring_write_descriptors(struct tb_ring *ring) descriptor->sof = frame->sof; } ring->head = (ring->head + 1) % ring->size; - ring_iowrite16desc(ring, ring->head, ring->is_tx ? 10 : 8); + if (ring->is_tx) + ring_iowrite_prod(ring, ring->head); + else + ring_iowrite_cons(ring, ring->head); } } @@ -662,7 +676,7 @@ void tb_ring_stop(struct tb_ring *ring) ring_iowrite32options(ring, 0, 0); ring_iowrite64desc(ring, 0, 0); - ring_iowrite16desc(ring, 0, ring->is_tx ? 10 : 8); + ring_iowrite32desc(ring, 0, 8); ring_iowrite32desc(ring, 0, 12); ring->head = 0; ring->tail = 0; -- 2.20.1