Received: by 10.213.65.68 with SMTP id h4csp879827imn; Tue, 27 Mar 2018 10:28:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/m8PMPkHf96hqgOz4+TGETE39Hb/JrUwSEUlK3x3zpLP7aVAMqbjbdZOls69sDNfBKA7yL X-Received: by 10.99.60.6 with SMTP id j6mr130925pga.73.1522171685418; Tue, 27 Mar 2018 10:28:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522171685; cv=none; d=google.com; s=arc-20160816; b=mqUqiGguMaMTaNPTtYwz5sqqn2yApGxMDto5zvv8Rc2uu2SIPb7iH9TqSJI9ImsOXs g1dFowdVu6r58KCpJm3Upo0qZa3N8UI3gXf25UtvHGBxFxco8XNmZ+7eO8pr8+s7cZTm jdbI7dc+qMBamAkv7jPL/wqaOYFwsrgKA3BaCaQNYN7ff6Xebt2amIa040SWvEHI0iCy GhKLKtNRpLfBYheajXNwbVMcWJOJ3dcboXXCr9obiGlCzy7h300ez78WJtGpgNA6G0or NOcllBUAR55oXOGRy35CMxfFnMFzuUqVoeZEYPqWbH7+bT5/bSazZGisfuyc8NHmjozW A2hA== 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=nhnUAiLTYSkCaPrOv1mvBS8RfjJrTcG9uyU1O4BJdTc=; b=Iqu+MetiChTCv/5WbLHD1U6lWixFJPKhImq13gOwLaFopoi3Dy3DxV2KN32meXDz2d c2vrTr0NfS/9FGiOJKyBKHwAaM/aQw9KLLTwomPyjB0oWFsqcSpA5bdRycAKTQ3Gg++o 3645ftTsfK7FZ0TaLtLoj4MPCvhEYV+FIsLF9YbVlBtMZwVgYfoWdoTgWgsZGH1TfBvW 04OzomH++rNom37j0hv7pbb128npM+mV2eQISTZcxZ0U+IKo862Mv8uFmYnOfWyijwXU yBKpFNeLdFZtm+//C/HYdbi8qobQEVyTAx9To543YAU/tvHD53QaxXMJPbctR1xAH9Nx FATA== 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 y1-v6si1780855pli.586.2018.03.27.10.27.51; Tue, 27 Mar 2018 10:28:05 -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 S1754786AbeC0Qgw (ORCPT + 99 others); Tue, 27 Mar 2018 12:36:52 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45904 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754773AbeC0Qgt (ORCPT ); Tue, 27 Mar 2018 12:36:49 -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 97515EFE; Tue, 27 Mar 2018 16:36:48 +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.14 070/101] can: peak/pcie_fd: fix echo_skb is occupied! bug Date: Tue, 27 Mar 2018 18:27:42 +0200 Message-Id: <20180327162754.363213582@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162749.993880276@linuxfoundation.org> References: <20180327162749.993880276@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.14-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 */