Message ID | 20230116193722.50360-1-ahalaney@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1369158wrn; Mon, 16 Jan 2023 11:45:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXvqgWqS4T6Cda1+dAnB41nyJ9vGkPDGlX4/RCNLc+pZU3z4Or1xTWTJA7qfTQvYzvfFdjov X-Received: by 2002:a05:6402:2408:b0:48e:94ec:b7ac with SMTP id t8-20020a056402240800b0048e94ecb7acmr11301497eda.7.1673898326222; Mon, 16 Jan 2023 11:45:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673898326; cv=none; d=google.com; s=arc-20160816; b=BozowkTMlHkmnl3cU04+QTyqGiom1fGUGogOur3WzTeFJJTacLb3OnpCEFGakPX3Ux 2O4Zm0rIV1LyIo0SZ1qioedUxCjvLZ7pEglhfwcPEksZkJcbyOlIjIAchQT9AgQV4rqF RWbfxSpgJLhdCApFheyI1XB9uX6nHtArebbY3ShaXBgX8cblDtPhvLFbIe0AtNZmupEc vInDCSRUfd43I5zyGgyQDbmOk6rsmxWqhW6q6wZWfnz1o6NBLL5SoMdgefvNmz3oY7A2 CqA2XgaTfTWu+iYDdabHgb3US8rrOiV08soeYKaC2CJxkOiKCKoBfLOXys6Xi/1/56mC zWpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=J03AEUyMs2O4Zc0M/YmOn8FNZhulZOm8FyrWoJOTpuA=; b=E+Mmuh66LAOuWwfGw6LSRWh0nQNyqqb1LQF6fUlDB8vWzRNK3tZStDadtAbiIMDua5 hl7KIZ8Ijmq/rpbGQvxaUu6zdjpJA3hA7ThLNaafmrMyZ5wpqPha53mYKw/yBdsxMv0g kFI69f+VZTt6RyqNPms0w8sYaua5MtfE5HCBbbv5Ogd1V5FVZqQukdfvXzNQBL4RFs5q 3Vz/tO21fqVeWnkVy1YZN7/vqCJwa0t3x7qbX4nRTqrUdmtujaA87bfZ/BV/fDSnP750 AB+ce+24lZ9GIPHOIzqk49XSwtgVbOSFdKZcKE1FF1cCN+nqsEQZGKHl2+wI/NBOLQXp LPGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Bq9Ke7m8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cz3-20020a0564021ca300b0049cfcf42722si9595776edb.449.2023.01.16.11.45.02; Mon, 16 Jan 2023 11:45:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Bq9Ke7m8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232583AbjAPTkB (ORCPT <rfc822;stefanalexe802@gmail.com> + 99 others); Mon, 16 Jan 2023 14:40:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231705AbjAPTkA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 16 Jan 2023 14:40:00 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A97AB2B615 for <linux-kernel@vger.kernel.org>; Mon, 16 Jan 2023 11:39:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673897957; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=J03AEUyMs2O4Zc0M/YmOn8FNZhulZOm8FyrWoJOTpuA=; b=Bq9Ke7m87DaUJVsVj64ewbfQZ934aG8RLucLG/4J3uXvbeXQ40aXp1KyPRFlTZHmwCaFWp ARdBjsAoSe5grlAdBCjKnVdjdd7zPYXABN0UA5Ox3A7BKUnou9vQMGABv3Th0BMWLqR/ox mKxnLZgetNStdp1lTJbkYO8bVHZSomc= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-488-i6m9gviTNOeiklmApjG1xg-1; Mon, 16 Jan 2023 14:39:16 -0500 X-MC-Unique: i6m9gviTNOeiklmApjG1xg-1 Received: by mail-ot1-f69.google.com with SMTP id e25-20020a05683013d900b00684a1d326e5so9995084otq.13 for <linux-kernel@vger.kernel.org>; Mon, 16 Jan 2023 11:39:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=J03AEUyMs2O4Zc0M/YmOn8FNZhulZOm8FyrWoJOTpuA=; b=qoHoUvq2hfXJxPeMQ0hvUCznWQLUWDJ3rsPr/beVSsQn2yg1EonVRAl/vyTZs7x8OT WA0yhQqR1C8JyBXnO+ZkUJk38alfp98uZ7xhQCauzwaDAa9LcCSnVQ4OuaexIRnFPd7t 0NX39ifpjTo1wCxyCMdE7KqUb8suwXdBBlYpT+DMRcNTZnjp/7qdobF7OyGVdMcLwg/s nxOiuTzTYh9g5vUeUOzDiSACRR89R7Cy58E0n81ofPFr91WTyb2DKAAXMrMAMBzC1g1I /Lswsq7/BYwf//qvOYIaeYHJVSQH0jTvk2G/wFPdtyxgO9YHMmUX3dxo2vDRRi8gTzN5 VNJA== X-Gm-Message-State: AFqh2kpYjwmeO7wjmQsLyT6EOvj+jYjRLS5vJQR0uJhqBPguO3xph5z2 vBliFos1tZXQsOXfSw6jlri+lbvWRh0JQnVMogOJCS0swLLQDlo5IXizaD0tTHq03nHlhLe1/GA NrdS9tOu10E+uqObbXCcpopPz X-Received: by 2002:a05:6830:26d2:b0:684:caea:9c31 with SMTP id m18-20020a05683026d200b00684caea9c31mr118630otu.10.1673897955374; Mon, 16 Jan 2023 11:39:15 -0800 (PST) X-Received: by 2002:a05:6830:26d2:b0:684:caea:9c31 with SMTP id m18-20020a05683026d200b00684caea9c31mr118619otu.10.1673897955126; Mon, 16 Jan 2023 11:39:15 -0800 (PST) Received: from halaney-x13s.attlocal.net ([2600:1700:1ff0:d0e0::21]) by smtp.gmail.com with ESMTPSA id o15-20020a9d764f000000b0066b9a6bf3bcsm15234392otl.12.2023.01.16.11.39.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 11:39:14 -0800 (PST) From: Andrew Halaney <ahalaney@redhat.com> To: davem@davemloft.net Cc: peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, richardcochran@gmail.com, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Halaney <ahalaney@redhat.com>, Ning Cai <ncai@quicinc.com> Subject: [PATCH net] net: stmmac: enable all safety features by default Date: Mon, 16 Jan 2023 13:37:23 -0600 Message-Id: <20230116193722.50360-1-ahalaney@redhat.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755209611615154999?= X-GMAIL-MSGID: =?utf-8?q?1755209611615154999?= |
Series |
[net] net: stmmac: enable all safety features by default
|
|
Commit Message
Andrew Halaney
Jan. 16, 2023, 7:37 p.m. UTC
In the original implementation of dwmac5
commit 8bf993a5877e ("net: stmmac: Add support for DWMAC5 and implement Safety Features")
all safety features were enabled by default.
Later it seems some implementations didn't have support for all the
features, so in
commit 5ac712dcdfef ("net: stmmac: enable platform specific safety features")
the safety_feat_cfg structure was added to the callback and defined for
some platforms to selectively enable these safety features.
The problem is that only certain platforms were given that software
support. If the automotive safety package bit is set in the hardware
features register the safety feature callback is called for the platform,
and for platforms that didn't get a safety_feat_cfg defined this results
in the following NULL pointer dereference:
[ 7.933303] Call trace:
[ 7.935812] dwmac5_safety_feat_config+0x20/0x170 [stmmac]
[ 7.941455] __stmmac_open+0x16c/0x474 [stmmac]
[ 7.946117] stmmac_open+0x38/0x70 [stmmac]
[ 7.950414] __dev_open+0x100/0x1dc
[ 7.954006] __dev_change_flags+0x18c/0x204
[ 7.958297] dev_change_flags+0x24/0x6c
[ 7.962237] do_setlink+0x2b8/0xfa4
[ 7.965827] __rtnl_newlink+0x4ec/0x840
[ 7.969766] rtnl_newlink+0x50/0x80
[ 7.973353] rtnetlink_rcv_msg+0x12c/0x374
[ 7.977557] netlink_rcv_skb+0x5c/0x130
[ 7.981500] rtnetlink_rcv+0x18/0x2c
[ 7.985172] netlink_unicast+0x2e8/0x340
[ 7.989197] netlink_sendmsg+0x1a8/0x420
[ 7.993222] ____sys_sendmsg+0x218/0x280
[ 7.997249] ___sys_sendmsg+0xac/0x100
[ 8.001103] __sys_sendmsg+0x84/0xe0
[ 8.004776] __arm64_sys_sendmsg+0x24/0x30
[ 8.008983] invoke_syscall+0x48/0x114
[ 8.012840] el0_svc_common.constprop.0+0xcc/0xec
[ 8.017665] do_el0_svc+0x38/0xb0
[ 8.021071] el0_svc+0x2c/0x84
[ 8.024212] el0t_64_sync_handler+0xf4/0x120
[ 8.028598] el0t_64_sync+0x190/0x194
Go back to the original behavior, if the automotive safety package
is found to be supported in hardware enable all the features unless
safety_feat_cfg is passed in saying this particular platform only
supports a subset of the features.
Fixes: 5ac712dcdfef ("net: stmmac: enable platform specific safety features")
Reported-by: Ning Cai <ncai@quicinc.com>
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
---
I've been working on a newer Qualcomm platform (sa8540p-ride) which has
a variant of dwmac5 in it. This patch is something Ning stumbled on when
adding some support for it downstream, and has been in my queue as I try
and get some support ready for review on list upstream.
Since it isn't really related to the particular hardware I decided to
pop it on list now. Please let me know if instead of enabling by default
(which the original implementation did and is why I went that route) a
message like "Safety features detected but not enabled in software" is
preferred and platforms are skipped unless they opt-in for enablement.
Thanks,
Andrew
drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
Comments
On Mon, 16 Jan 2023 13:37:23 -0600 Andrew Halaney wrote: > I've been working on a newer Qualcomm platform (sa8540p-ride) which has > a variant of dwmac5 in it. This patch is something Ning stumbled on when > adding some support for it downstream, and has been in my queue as I try > and get some support ready for review on list upstream. > > Since it isn't really related to the particular hardware I decided to > pop it on list now. Please let me know if instead of enabling by default > (which the original implementation did and is why I went that route) a > message like "Safety features detected but not enabled in software" is > preferred and platforms are skipped unless they opt-in for enablement. Could you repost and CC Wong Vee Khee, and maybe some other Intel folks who have been touching stmmac recently? They are probably the best to comment / review.
On Tue, Jan 17, 2023 at 07:43:48PM -0800, Jakub Kicinski wrote: > On Mon, 16 Jan 2023 13:37:23 -0600 Andrew Halaney wrote: > > I've been working on a newer Qualcomm platform (sa8540p-ride) which has > > a variant of dwmac5 in it. This patch is something Ning stumbled on when > > adding some support for it downstream, and has been in my queue as I try > > and get some support ready for review on list upstream. > > > > Since it isn't really related to the particular hardware I decided to > > pop it on list now. Please let me know if instead of enabling by default > > (which the original implementation did and is why I went that route) a > > message like "Safety features detected but not enabled in software" is > > preferred and platforms are skipped unless they opt-in for enablement. > > Could you repost and CC Wong Vee Khee, and maybe some other Intel folks > who have been touching stmmac recently? They are probably the best to > comment / review. > Shoot, yes thank you I intended to do! Will resend. - Andrew
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c index 9c2d40f853ed..413f66017219 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c @@ -186,11 +186,25 @@ static void dwmac5_handle_dma_err(struct net_device *ndev, int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp, struct stmmac_safety_feature_cfg *safety_feat_cfg) { + struct stmmac_safety_feature_cfg all_safety_feats = { + .tsoee = 1, + .mrxpee = 1, + .mestee = 1, + .mrxee = 1, + .mtxee = 1, + .epsi = 1, + .edpp = 1, + .prtyen = 1, + .tmouten = 1, + }; u32 value; if (!asp) return -EINVAL; + if (!safety_feat_cfg) + safety_feat_cfg = &all_safety_feats; + /* 1. Enable Safety Features */ value = readl(ioaddr + MTL_ECC_CONTROL); value |= MEEAO; /* MTL ECC Error Addr Status Override */