Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3729321imm; Mon, 8 Oct 2018 08:36:52 -0700 (PDT) X-Google-Smtp-Source: ACcGV60KJ+55znvFKb/yEUnGIIhhl1skTqMPAcygDaLdQK+7/ysDxLU5f4ul74baKqgev+2dXWfK X-Received: by 2002:a63:34c7:: with SMTP id b190-v6mr21112454pga.184.1539013012573; Mon, 08 Oct 2018 08:36:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539013012; cv=none; d=google.com; s=arc-20160816; b=yX78QjFK191xydB79VwPGUDiUcfQ0OCrL7zJN6ie0AAXN9GQ/RaQT/cS0zRG8M7efi OXPQZeByW3+lmiwMI9Yd/LT8bRUoZWtSCwzdWGpwdPvqKtvyeTMqz8DP2BhOqbC6DAwP NY74NKbrrO1iasONdwYGpFp+VkX0apoFRWxAci2GY1m5uE2pPjFRlEkhEHBcum9r/tET Fl6q9XTn1SC5gZn/uW8vG809il7RNHIBiUi8qsIqE1d2IHmOY4RBPAXwgioKijq3R8Je 7Cg1Z5wtKnjHTGU5mKJTgNQlhGH3I8Wrtv2l/kybe2G2QXqehtS4ErU76zbajKobweJJ UCHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Pzgsd/h/6fY2rvIrceq6qfBAyw8c1LElHwB8KXh78Z8=; b=SKT8i1wL2E/QS6qj7oE5MFtA6iKo/Zqs9Jy3hB9ZJ3I6jy0Ph0pbxOIMUTjRIP057/ AztC/yLQ5uijZxxKJ0Dm4vV+zzGakKDK5P5R+5KBVu9+UaoQDlXHyFrO02D4tsIhORZx YKm4H2weKD4PkLLewH2M3cFsV4y804LZ6m4uP8NBJJYxnAKU8rj9z1qqII87GUNygKra WWMQMy9W8Z8xIUei+CLnZfzlYGqqX64dfPsFNmhoZvz0+12hVO6XxtDybR0mKe6emGjZ a+njOyu5fe/Xs7bfsxRRd9xpmOZ5zQMOizBfyr7Cqb43e0qlQygBA2qcbUP0ptAiulBp scfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GIiQpX3A; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b27-v6si14607454pgb.156.2018.10.08.08.36.37; Mon, 08 Oct 2018 08:36:52 -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=GIiQpX3A; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727537AbeJHWiM (ORCPT + 99 others); Mon, 8 Oct 2018 18:38:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:56476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727451AbeJHWiK (ORCPT ); Mon, 8 Oct 2018 18:38:10 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7A00921479; Mon, 8 Oct 2018 15:25:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539012355; bh=o1DHp62sSM1TQLsAAwi463e4uDDDeXJ13PfiSZjq6ZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GIiQpX3AZuu0+6Kaxee7qsFBXf+br+Pof3rooOWdiTZffjlIxWiNQF6IfmcaT/0ys y3g1f0KpGetyqrTUWpAeOoj/5jGju7TiiiCXydqmeU7adELvyjdkSgRgzBUzYAd31o HW87d/X3VqohYOLL20LH9ZmOKDhJL4HkyBNnJCYY= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Kazuya Mizuguchi , Simon Horman , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.18 29/58] ravb: do not write 1 to reserved bits Date: Mon, 8 Oct 2018 11:24:54 -0400 Message-Id: <20181008152523.70705-29-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181008152523.70705-1-sashal@kernel.org> References: <20181008152523.70705-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kazuya Mizuguchi [ Upstream commit 2fe397a3959de8a472f165e6d152f64cb77fa2cc ] EtherAVB hardware requires 0 to be written to status register bits in order to clear them, however, care must be taken not to: 1. Clear other bits, by writing zero to them 2. Write one to reserved bits This patch corrects the ravb driver with respect to the second point above. This is done by defining reserved bit masks for the affected registers and, after auditing the code, ensure all sites that may write a one to a reserved bit use are suitably masked. Signed-off-by: Kazuya Mizuguchi Signed-off-by: Simon Horman Reviewed-by: Sergei Shtylyov Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/renesas/ravb.h | 5 +++++ drivers/net/ethernet/renesas/ravb_main.c | 11 ++++++----- drivers/net/ethernet/renesas/ravb_ptp.c | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index b81f4faf7b10..1c40989479bd 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -431,6 +431,7 @@ enum EIS_BIT { EIS_CULF1 = 0x00000080, EIS_TFFF = 0x00000100, EIS_QFS = 0x00010000, + EIS_RESERVED = (GENMASK(31, 17) | GENMASK(15, 11)), }; /* RIC0 */ @@ -475,6 +476,7 @@ enum RIS0_BIT { RIS0_FRF15 = 0x00008000, RIS0_FRF16 = 0x00010000, RIS0_FRF17 = 0x00020000, + RIS0_RESERVED = GENMASK(31, 18), }; /* RIC1 */ @@ -531,6 +533,7 @@ enum RIS2_BIT { RIS2_QFF16 = 0x00010000, RIS2_QFF17 = 0x00020000, RIS2_RFFF = 0x80000000, + RIS2_RESERVED = GENMASK(30, 18), }; /* TIC */ @@ -547,6 +550,7 @@ enum TIS_BIT { TIS_FTF1 = 0x00000002, /* Undocumented? */ TIS_TFUF = 0x00000100, TIS_TFWF = 0x00000200, + TIS_RESERVED = (GENMASK(31, 20) | GENMASK(15, 12) | GENMASK(7, 4)) }; /* ISS */ @@ -620,6 +624,7 @@ enum GIC_BIT { enum GIS_BIT { GIS_PTCF = 0x00000001, /* Undocumented? */ GIS_PTMF = 0x00000004, + GIS_RESERVED = GENMASK(15, 10), }; /* GIE (R-Car Gen3 only) */ diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 0d811c02ff34..db4e306ca996 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -742,10 +742,11 @@ static void ravb_error_interrupt(struct net_device *ndev) u32 eis, ris2; eis = ravb_read(ndev, EIS); - ravb_write(ndev, ~EIS_QFS, EIS); + ravb_write(ndev, ~(EIS_QFS | EIS_RESERVED), EIS); if (eis & EIS_QFS) { ris2 = ravb_read(ndev, RIS2); - ravb_write(ndev, ~(RIS2_QFF0 | RIS2_RFFF), RIS2); + ravb_write(ndev, ~(RIS2_QFF0 | RIS2_RFFF | RIS2_RESERVED), + RIS2); /* Receive Descriptor Empty int */ if (ris2 & RIS2_QFF0) @@ -798,7 +799,7 @@ static bool ravb_timestamp_interrupt(struct net_device *ndev) u32 tis = ravb_read(ndev, TIS); if (tis & TIS_TFUF) { - ravb_write(ndev, ~TIS_TFUF, TIS); + ravb_write(ndev, ~(TIS_TFUF | TIS_RESERVED), TIS); ravb_get_tx_tstamp(ndev); return true; } @@ -933,7 +934,7 @@ static int ravb_poll(struct napi_struct *napi, int budget) /* Processing RX Descriptor Ring */ if (ris0 & mask) { /* Clear RX interrupt */ - ravb_write(ndev, ~mask, RIS0); + ravb_write(ndev, ~(mask | RIS0_RESERVED), RIS0); if (ravb_rx(ndev, "a, q)) goto out; } @@ -941,7 +942,7 @@ static int ravb_poll(struct napi_struct *napi, int budget) if (tis & mask) { spin_lock_irqsave(&priv->lock, flags); /* Clear TX interrupt */ - ravb_write(ndev, ~mask, TIS); + ravb_write(ndev, ~(mask | TIS_RESERVED), TIS); ravb_tx_free(ndev, q, true); netif_wake_subqueue(ndev, q); mmiowb(); diff --git a/drivers/net/ethernet/renesas/ravb_ptp.c b/drivers/net/ethernet/renesas/ravb_ptp.c index eede70ec37f8..9e3222fd69f9 100644 --- a/drivers/net/ethernet/renesas/ravb_ptp.c +++ b/drivers/net/ethernet/renesas/ravb_ptp.c @@ -319,7 +319,7 @@ void ravb_ptp_interrupt(struct net_device *ndev) } } - ravb_write(ndev, ~gis, GIS); + ravb_write(ndev, ~(gis | GIS_RESERVED), GIS); } void ravb_ptp_init(struct net_device *ndev, struct platform_device *pdev) -- 2.17.1