Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5886960imb; Fri, 8 Mar 2019 04:46:23 -0800 (PST) X-Google-Smtp-Source: APXvYqyGYD9MA8EqBTSBM+Dv351zXEG+kEK+b1zgcbr614nS1kXY31inIKQYM8jM4igEXdjP8wiR X-Received: by 2002:a63:4a62:: with SMTP id j34mr15485843pgl.97.1552049183066; Fri, 08 Mar 2019 04:46:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552049183; cv=none; d=google.com; s=arc-20160816; b=Uctnbv/Aod05Pfo8I0Ydr4UY+XfrbPdHFv/YupsS7mjY3CmLPqjN5Zh4fTyoUpl27J iKPU5vcJF89OXpBB8mKL3+Agi1eOc/uWxZzKlk1tlXXfGPKfL1fnwDHp7FseSEcqlSDG k5OjcMTOp7IUIs9RwJcLG5UoUGkU3jegM2Dq6y7+MCWFWUJZqeDOcPobv/VMrxsct6fe XJhqtVxqqE0gdNWMmtaUkCLnHNKG1VQ+xyOqH5J3yw5xMrwl7UtAwMMfD9lvMFARLPRA PM74rwefz1zrIMPrvFBGJOxbSzyRWT0BWe+kTOpbTAvVOI59DHNsVPFiQk+MmIJAW+43 SiBA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=PMof77t6o9E6zVbLjhxvFBLyPAZHteSP11zl8GnIyI8=; b=A56i5rhxzf9h0aZF0wGFvScS6ysbnGhlEi+eMHrOSByotUW8zuOAMXnUlNoe3A4CgJ Vtf7vtG5UMQeyNnpYh3vmO3AW7d0nNIKxgg3XHJrx93Gn85MJyQU4dfi+E6NEMFuRpat pfVtJOitEbCrF+W56oy8uLiwuNdMsXDXjBhOgtMrwzQtKhiwnLnzL64JCdUzZ/1wOSva 98kcFhDeCOb1XkbEHvc2s2IE2JNK+r1yPK4GPWX3sP/jSM78BKXnkP10/zzWAvxhpYma VLNBol3ae2jWxOcfQU0kPkmU4xCfymxWj6Eo4rT/p6039cLr4loKfhhF/lxoYwlvlG3T gH2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=NVUuPpiW; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 186si7127753pfe.262.2019.03.08.04.46.07; Fri, 08 Mar 2019 04:46:23 -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=@ti.com header.s=ti-com-17Q1 header.b=NVUuPpiW; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726514AbfCHMoW (ORCPT + 99 others); Fri, 8 Mar 2019 07:44:22 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:50096 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726364AbfCHMoW (ORCPT ); Fri, 8 Mar 2019 07:44:22 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id x28CiFen010173; Fri, 8 Mar 2019 06:44:15 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1552049055; bh=PMof77t6o9E6zVbLjhxvFBLyPAZHteSP11zl8GnIyI8=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=NVUuPpiW1TKg7OsMG06Nm20sMFZzexKFhWxAl9DfcfhQkAupIGuH4doqcx9eHyu/f vKzYdQ3kgO8msLs7LhwTXDtVeVOv3X7mSLzUZuwhADuHDHnd7HyjX+TCr0DW4L+cUA OwrSL/zdURYCoEYz75oTHWgKOFoDabCveSXHYFFA= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x28CiF2b130352 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 8 Mar 2019 06:44:15 -0600 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Fri, 8 Mar 2019 06:44:15 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Fri, 8 Mar 2019 06:44:15 -0600 Received: from [172.22.83.167] (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id x28CiEbT016215; Fri, 8 Mar 2019 06:44:14 -0600 Subject: Re: [PATCH v7 1/4] can: m_can: Create a m_can platform framework To: Wolfgang Grandegger , , CC: , , References: <20190305155220.14037-1-dmurphy@ti.com> <5065d6ba-f195-a695-77b1-b837cac1a199@grandegger.com> From: Dan Murphy Message-ID: Date: Fri, 8 Mar 2019 06:44:01 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.3 MIME-Version: 1.0 In-Reply-To: <5065d6ba-f195-a695-77b1-b837cac1a199@grandegger.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wolfgang On 3/8/19 4:10 AM, Wolfgang Grandegger wrote: > Hallo Dan, > > Am 05.03.19 um 16:52 schrieb Dan Murphy: >> Create a m_can platform framework that peripherial >> devices can register to and use common code and register sets. >> The peripherial devices may provide read/write and configuration >> support of the IP. >> >> Signed-off-by: Dan Murphy >> --- >> >> >> v7 - Fixed remaining new checkpatch issues, removed CSR setting, fixed tx hard >> start function to return tx_busy, and renamed device callbacks - https://lore.kernel.org/patchwork/patch/1047220/ >> >> v6 - Squashed platform patch to this patch for bissectablity, fixed coding style >> issues, updated Kconfig help, placed mcan reg offsets back into c file, renamed >> priv->skb to priv->tx_skb and cleared perp interrupts at ISR start - >> Patch 1 comments - https://lore.kernel.org/patchwork/patch/1042446/ >> Patch 2 comments - https://lore.kernel.org/patchwork/patch/1042442/ >> >> drivers/net/can/m_can/Kconfig | 13 +- >> drivers/net/can/m_can/Makefile | 1 + >> drivers/net/can/m_can/m_can.c | 700 +++++++++++++------------ >> drivers/net/can/m_can/m_can.h | 110 ++++ >> drivers/net/can/m_can/m_can_platform.c | 202 +++++++ >> 5 files changed, 682 insertions(+), 344 deletions(-) >> create mode 100644 drivers/net/can/m_can/m_can.h >> create mode 100644 drivers/net/can/m_can/m_can_platform.c >> >> diff --git a/drivers/net/can/m_can/Kconfig b/drivers/net/can/m_can/Kconfig >> index 04f20dd39007..f7119fd72df4 100644 >> --- a/drivers/net/can/m_can/Kconfig >> +++ b/drivers/net/can/m_can/Kconfig >> @@ -1,5 +1,14 @@ >> config CAN_M_CAN >> + tristate "Bosch M_CAN support" >> + ---help--- >> + Say Y here if you want support for Bosch M_CAN controller framework. >> + This is common support for devices that embed the Bosch M_CAN IP. >> + >> +config CAN_M_CAN_PLATFORM >> + tristate "Bosch M_CAN support for io-mapped devices" >> depends on HAS_IOMEM >> - tristate "Bosch M_CAN devices" >> + depends on CAN_M_CAN >> ---help--- >> - Say Y here if you want to support for Bosch M_CAN controller. >> + Say Y here if you want support for IO Mapped Bosch M_CAN controller. >> + This support is for devices that have the Bosch M_CAN controller >> + IP embedded into the device and the IP is IO Mapped to the processor. >> diff --git a/drivers/net/can/m_can/Makefile b/drivers/net/can/m_can/Makefile >> index 8bbd7f24f5be..057bbcdb3c74 100644 >> --- a/drivers/net/can/m_can/Makefile >> +++ b/drivers/net/can/m_can/Makefile >> @@ -3,3 +3,4 @@ >> # >> >> obj-$(CONFIG_CAN_M_CAN) += m_can.o >> +obj-$(CONFIG_CAN_M_CAN_PLATFORM) += m_can_platform.o >> diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c >> index 9b449400376b..a60278d94126 100644 >> --- a/drivers/net/can/m_can/m_can.c >> +++ b/drivers/net/can/m_can/m_can.c > > ... snip... > >> +static netdev_tx_t m_can_start_xmit(struct sk_buff *skb, >> + struct net_device *dev) >> +{ >> + struct m_can_priv *priv = netdev_priv(dev); >> + >> + if (can_dropped_invalid_skb(dev, skb)) >> + return NETDEV_TX_OK; >> + >> + if (priv->is_peripherial) { >> + if (priv->tx_skb) { >> + netdev_err(dev, "hard_xmit called while tx busy\n"); >> + return NETDEV_TX_BUSY; >> + } > > The problem with that approach is, that the upper layer will try to > resubmit the current "skb" but not the previous "tx_skb". And the > previous "tx_skb" has not been freed yet. I would just drop and free the > skb and return NETDEV_TX_OK in m_can_tx_handler() for peripheral devices > (like can_dropped_invalid_skb() does). > OK. So would this also be a bug in the hi3110 and mcp251x drivers (line 521) as well because besides checking tx_length this is how these drivers are written. In addition in the peripheral context the work queue does not report up to the upper layer the status. Again the hi3110 and mcp251x drivers are written this way. The only issue I see here is that the dropped and invalid check needs to come after the tx_skb check. Dan >> + >> + priv->tx_skb = skb; >> + netif_stop_queue(priv->net); >> + queue_work(priv->tx_wq, &priv->tx_work); >> + } else { >> + priv->tx_skb = skb; >> + return m_can_tx_handler(priv); >> } >> >> return NETDEV_TX_OK; >> } > > Wolfgang. > -- ------------------ Dan Murphy