Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1136787img; Thu, 28 Feb 2019 13:43:38 -0800 (PST) X-Google-Smtp-Source: APXvYqx6nhPiHQA3AcSYRLxdpE4NutJOq9Z41WVpwDzVAWfs/Op6zteoH9HOnPWtxT30sHOsTX02 X-Received: by 2002:a17:902:ea8c:: with SMTP id cv12mr1583385plb.123.1551390218197; Thu, 28 Feb 2019 13:43:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551390218; cv=none; d=google.com; s=arc-20160816; b=MkFIjIjHyBHcbmiyYH0m7nnT6Cf9WPkj/JpIilYgdizz18Z4MGqJikK7pl5oJ2AJfv av4IWYEf6TPG83RGeNM+mxj9U5WAQVLSfSZbE6fUJxZEDWhw9fPWhyeGUQASUgxYSSx8 8xzgC9/vVREMg/MNtiMljozv1vRnD/1x+LuFnRE3GBHDm1S9s45C27y9IZZOcLmnEQox i/1SMaeYtE5Zv/fh0kwB/sgOpr0wUIrvZpx4HPZRlMkAIWN8uTvJTyHUn3gl7XapBbWm DlQ0/wnRrYOb6SUL6lI+57nh3/YZIryL4PY6374PsAdV7R3Mqoc9OAwJ26ratoR6S9Q0 ORkQ== 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=2nUITFR4oG1S+nsThzaESAFeJG0Gjr0/zkxQ8sCoK+E=; b=xaaSWIoKom97erLVFd+QxpnTrQssH6OROCzOm6OMURxUv3j0zCESemMZemvBCWTheb AaP6WTxXJS1BQG7fRWIudOKDQ/SrMNRk4bFNSs2ePKvxp65i3Fn7vXlR10gnXlEr90Kd rUkiFstS4EAksLZTgkcua5DdJSE/VmC6StzikpVIB8grZn4M+tuin2OENrwqMPs4iJVk Tl7sSsqbOmt2YrxZL4MRk1quFy/vZG7JclBo98NpdsKJr326TWxaTo9q1glntBs1Cvwx H61R1wKT3bXjerIxld05XBoe7WyG/cmckSqLOSKVqaCyUuq5JnHAjZeJbGQHzsB19LsV eNAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=y4et5SWn; 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 h7si18762830plr.178.2019.02.28.13.43.23; Thu, 28 Feb 2019 13:43:38 -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=y4et5SWn; 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 S2388057AbfB1T7r (ORCPT + 99 others); Thu, 28 Feb 2019 14:59:47 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:37732 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726231AbfB1T7r (ORCPT ); Thu, 28 Feb 2019 14:59:47 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x1SJxb2N048347; Thu, 28 Feb 2019 13:59:37 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1551383977; bh=2nUITFR4oG1S+nsThzaESAFeJG0Gjr0/zkxQ8sCoK+E=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=y4et5SWnwpCNGG1I2jEQIwaVEFwZAeAK0ASot1db9rCKrC1383NqAzprMVjwYdTBb veXOpt6lyjtkPA3p1Ga+T/Xkg2nJw8y2KpUVeOjelcfmgve1mMZC+5HhLkWgv2d5kR haa/ogZZ/IYl9fqwmZ9O7qPbIixcPLNTRq+TWtg4= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x1SJxbTA069590 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 28 Feb 2019 13:59:37 -0600 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Thu, 28 Feb 2019 13:59:37 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Thu, 28 Feb 2019 13:59:37 -0600 Received: from [172.22.64.21] (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id x1SJxajm015860; Thu, 28 Feb 2019 13:59:36 -0600 Subject: Re: [PATCH v5 2/5] can: m_can: Migrate the m_can code to use the framework To: Wolfgang Grandegger , , CC: , , References: <20190214182754.30721-1-dmurphy@ti.com> <20190214182754.30721-3-dmurphy@ti.com> <0f5f732a-945c-da56-1086-00fb2c621331@grandegger.com> <639f316a-1190-1e0e-0a1d-6008a1c332d7@ti.com> From: Dan Murphy Message-ID: Date: Thu, 28 Feb 2019 13:59:29 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.2 MIME-Version: 1.0 In-Reply-To: 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 Hello On 2/28/19 1:41 PM, Wolfgang Grandegger wrote: > Hello Dan, > > Am 28.02.19 um 18:57 schrieb Dan Murphy: >> Wolfgang >> >> On 2/28/19 11:33 AM, Wolfgang Grandegger wrote: >>> Am 14.02.19 um 19:27 schrieb Dan Murphy: >>>> Migrate the m_can code to use the m_can_platform framework >>>> code. >>>> >>>> Signed-off-by: Dan Murphy >>>> --- >>>> >>>> v5 - Updated copyright, change m_can_classdev to m_can_priv, removed extra >>>> KCONFIG flag - https://lore.kernel.org/patchwork/patch/1033095/ >>>> >>>> drivers/net/can/m_can/Kconfig | 8 +- >>>> drivers/net/can/m_can/Makefile | 1 + >>>> drivers/net/can/m_can/m_can.c | 745 ++++++++++++++++----------------- >>>> 3 files changed, 367 insertions(+), 387 deletions(-) >>>> >>>> diff --git a/drivers/net/can/m_can/Kconfig b/drivers/net/can/m_can/Kconfig >>>> index 04f20dd39007..66e31022a5fa 100644 >>>> --- a/drivers/net/can/m_can/Kconfig >>>> +++ b/drivers/net/can/m_can/Kconfig >>>> @@ -1,5 +1,11 @@ >>>> config CAN_M_CAN >>>> + tristate "Bosch M_CAN support" >>>> + ---help--- >>>> + Say Y here if you want to support for Bosch M_CAN controller. >>> >>> Typo? >>> >> >> Maybe like you pointed out to update the help. > > I was just not sure if it's correct English... but you know better! > I actually added some additional content explaining what the flag was for and remove the "to" >> >>>> + >>>> +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. >>> >>> Please update the help. >> >> Ack >>> >>>> 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..2ceccb870557 100644 >>>> --- a/drivers/net/can/m_can/m_can.c >>>> +++ b/drivers/net/can/m_can/m_can.c > ... snip ... >>>> @@ -924,6 +885,9 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) >>>> } >>>> } >>>> >>>> + if (priv->ops->clr_dev_interrupts) >>>> + priv->ops->clr_dev_interrupts(priv); >>> >>> post_irq _handler? >>> >> >> I can clear them on entry as well > > OK! > > ...snip... > >>>> - niso_timeout = readl_poll_timeout((priv->base + M_CAN_CCCR), cccr_poll, >>>> - (cccr_poll == cccr_reg), 0, 10); >>>> + for (i = 0; i <= 10; i++) { >>>> + cccr_poll = m_can_read(priv, M_CAN_CCCR); >>>> + if (cccr_poll == cccr_reg) >>>> + niso_timeout = 0; >>>> + } >>> >>> There is no break and delay in the loop? What was the reason why you >>> can't use readl_poll_timeout()? >>> >> >> OK a break if NISO is supported then and probably could add a 1us delay original code on >> line 1232 had no delay but timeout at 10us. >> >> readl_poll_timeout is for iomapped devices. How would this work for peripherial devices? > > Well, it takes much more time to read the register via SPI... maybe using > > if (priv->is_peripherial) ... > > to handle the different timings would make sense here. > We really should isolate IO access calls away from the framework and have the registrars perform all IO calls. It may be better to create a call back to check for NISO support but I would think only IO mapped code is the only special case. Also a call back may be a bit much since this NISO function is only called in setup which is a one and done function during registration. >>>> >>>> /* Clear NISO */ >>>> cccr_reg &= ~(CCCR_NISO); >>>> @@ -1242,107 +1210,95 @@ static bool m_can_niso_supported(const struct m_can_priv *priv) >>>> return !niso_timeout; >>>> } > ... snip... > >>>> -static netdev_tx_t m_can_start_xmit(struct sk_buff *skb, >>>> - struct net_device *dev) >>>> +static void m_can_tx_handler(struct m_can_priv *priv) >>>> { >>>> - struct m_can_priv *priv = netdev_priv(dev); >>>> - struct canfd_frame *cf = (struct canfd_frame *)skb->data; >>>> + struct canfd_frame *cf = (struct canfd_frame *)priv->skb->data; >>>> + struct net_device *dev = priv->net; >>>> + struct sk_buff *skb = priv->skb; >>> >>> Maybe "tx_skb" is a clearer member name.. >> >> Again this was named skb to minimize deltas from original code. > > I mean "priv->tx_skb"! > Ack. Changed for clarity I guess your point was made in my own confusion (heh). Dan >> skb was passed into the start_xmit function and used throughout the function. >> >> Since there was little delta in this function I opt'd to keep the names as is. >> > > Wolfgang. > -- ------------------ Dan Murphy