Received: by 10.213.65.68 with SMTP id h4csp844250imn; Tue, 27 Mar 2018 09:50:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx49i5xhAgv1Pbmw/p8w/Ty8+lMBwGX6Ll5CqQDj2jFtgJT/tpEVpFpPB1JTRz+dig6Cn0yNN X-Received: by 2002:a17:902:102:: with SMTP id 2-v6mr113685plb.48.1522169406216; Tue, 27 Mar 2018 09:50:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522169406; cv=none; d=google.com; s=arc-20160816; b=gvtH+PoQ3xldiomYC19nM7/rZGJ6C4lXK94E1pzAAKXCbndem1jHfQ8ebbJN1K0JXD xIhxxpt7wNO50Y7oD4peBCkz4IXj1VgYodQdGt1i3mcpEcp6cmZmIbJKdrkx3ckjpM4W 9dFlJFwdQpUN64D86agHghtxAibhXh8xp8+VHLug36ScvPbJi2pVkQjgC0EBX/bWQpfm ZTrU2lTcvkR0cI2y/9jGGjhL15crU9zxImBnhwtbdZtr4Ti6U1uGxB4JaStIuZBxNBAc o8RlvECeWek1Vby84WLBNk0WOS3c1RkDqNN0pniSRo1mudy+8W3o75kYE2CBQF18yB90 gfzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=HMkOJDtxNU5nnMeDskalk77LAPtCLZ1TIPUGZF4MKoA=; b=NwHtVkw3lNAvrRsy2vDKnk2xor4gRlyPAE3xAyTmn4k3iZptz3QpcPH25AbsMNH4kS jc6VRtmGpbYSmREoRB5N3XXDAxCfZ9EtvyQTYIysfqG76+WqDiUM55bL3VtsMyK/eEeS 1BGo5RpW3Bqyo2VbXREREJeYQNrP2KYSHx2V9tep/MPGZpRkN5VgilcWxpUzcuwq7JBg ZnS/l0kyLzpkZfn0X7g1Ix/od7lmUWU8dbQo4HPNrxeBv/op3Ebfn5f/g1kuGMCdnwFu UPuqA8MamoiCRByuevDY5Z5nmk7MHvlZvBUNW4An7FLWT256jwP3lJvMZOJ4wTPjJCxz 9y8g== ARC-Authentication-Results: i=1; mx.google.com; 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 i21si1304196pfk.34.2018.03.27.09.49.51; Tue, 27 Mar 2018 09:50:06 -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; 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 S1754407AbeC0QsS (ORCPT + 99 others); Tue, 27 Mar 2018 12:48:18 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:49398 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752113AbeC0QnI (ORCPT ); Tue, 27 Mar 2018 12:43:08 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 851C310B5; Tue, 27 Mar 2018 16:43:07 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Diana Burgess , Stephane Grosjean , Marc Kleine-Budde Subject: [PATCH 4.15 075/105] can: peak/pcie_fd: fix echo_skb is occupied! bug Date: Tue, 27 Mar 2018 18:27:55 +0200 Message-Id: <20180327162802.559928021@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162757.813009222@linuxfoundation.org> References: <20180327162757.813009222@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stephane Grosjean commit e6048a00cfd0863d32f53b226e0b9a3633fc3332 upstream. This patch makes atomic the handling of the linux-can echo_skb array and the network tx queue. This prevents from the "BUG! echo_skb is occupied!" message to be printed by the linux-can core, in SMP environments. Reported-by: Diana Burgess Signed-off-by: Stephane Grosjean Cc: linux-stable Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/peak_canfd/peak_canfd.c | 12 ++++++------ drivers/net/can/peak_canfd/peak_pciefd_main.c | 8 ++++++-- 2 files changed, 12 insertions(+), 8 deletions(-) --- a/drivers/net/can/peak_canfd/peak_canfd.c +++ b/drivers/net/can/peak_canfd/peak_canfd.c @@ -262,7 +262,6 @@ static int pucan_handle_can_rx(struct pe spin_lock_irqsave(&priv->echo_lock, flags); can_get_echo_skb(priv->ndev, msg->client); - spin_unlock_irqrestore(&priv->echo_lock, flags); /* count bytes of the echo instead of skb */ stats->tx_bytes += cf_len; @@ -271,6 +270,7 @@ static int pucan_handle_can_rx(struct pe /* restart tx queue (a slot is free) */ netif_wake_queue(priv->ndev); + spin_unlock_irqrestore(&priv->echo_lock, flags); return 0; } @@ -726,11 +726,6 @@ static netdev_tx_t peak_canfd_start_xmit */ should_stop_tx_queue = !!(priv->can.echo_skb[priv->echo_idx]); - spin_unlock_irqrestore(&priv->echo_lock, flags); - - /* write the skb on the interface */ - priv->write_tx_msg(priv, msg); - /* stop network tx queue if not enough room to save one more msg too */ if (priv->can.ctrlmode & CAN_CTRLMODE_FD) should_stop_tx_queue |= (room_left < @@ -742,6 +737,11 @@ static netdev_tx_t peak_canfd_start_xmit if (should_stop_tx_queue) netif_stop_queue(ndev); + spin_unlock_irqrestore(&priv->echo_lock, flags); + + /* write the skb on the interface */ + priv->write_tx_msg(priv, msg); + return NETDEV_TX_OK; } --- a/drivers/net/can/peak_canfd/peak_pciefd_main.c +++ b/drivers/net/can/peak_canfd/peak_pciefd_main.c @@ -349,8 +349,12 @@ static irqreturn_t pciefd_irq_handler(in priv->tx_pages_free++; spin_unlock_irqrestore(&priv->tx_lock, flags); - /* wake producer up */ - netif_wake_queue(priv->ucan.ndev); + /* wake producer up (only if enough room in echo_skb array) */ + spin_lock_irqsave(&priv->ucan.echo_lock, flags); + if (!priv->ucan.can.echo_skb[priv->ucan.echo_idx]) + netif_wake_queue(priv->ucan.ndev); + + spin_unlock_irqrestore(&priv->ucan.echo_lock, flags); } /* re-enable Rx DMA transfer for this CAN */