Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1639137imu; Wed, 9 Jan 2019 23:56:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN6SNFOcrJnf1/zaqeHaAVjZisdWZR/QGTzvUns7LIvmMAfa0q7NNBPMgS3ebT86ya8dQrXI X-Received: by 2002:a62:f54f:: with SMTP id n76mr9238429pfh.59.1547106962557; Wed, 09 Jan 2019 23:56:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547106962; cv=none; d=google.com; s=arc-20160816; b=zD8PSIW+aL60IU1jf/FS7CAQ/2zKTlAMBS+fMvonGhkROniYBfYhKj/KrtjoXh55oG gu39Rzh4iAbu2pYB5Ixb0VDzZDhVWyov+plF4EwfqGTI8Xw+AAvLCFxhE2TzvAy8+Kjt sOA5u4rrQfUR6UZcmeq2ZBBRLvMNRbEsCZk7AJEo3gtfK8peUMMNeCKfq5XN9KVmDOdD s+Z8p4+2xmBoKG7zS0f9VWOgxBk+PpmznzLtr/1Wu0MwnZ3vkdmJgfwdVMLlVFEJbYRH JwXXy7IYanCyW0Srhn6uWHComg+98dzk4svzKbiLp9LV2HiDa1rxHkLGfhOYC1epQxYg fLxg== 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:autocrypt:openpgp:from:references:cc:to:subject; bh=vERmLybamKXUbfaWjFg6x/8x4DjmXQPrURupLrqe/U0=; b=YOfZNZuHZKEkgtCfR0x6z4vkSYAiX+ofdh5VNd3gJLsfz3fXqQABCxwyZbcXfcLXvR ZXxj+Ix9EDFS/DnAnwQBQyqG4oCkHOgyaX8VlMExoYopcxtSKFJ2aqUng5tZ/evxTJnf ZjRKRUNLf/fg3w32RCU3S26dZ610iKURw8RZ2enc/z98CtzyEzhTHQHQsKp5sh33+b11 BFHa4eDYhuuBT9eGOdqMunI36B3HA6w9rI1+Ek0jFoL+Lcl4yF3b2KZq8nPsWV8WDcDe Njdcuzo8wgt3qMwXx5nAFILr4cvTf4MG19Xz7qKUFchjUy83bHi2f6d5lUzusr0JowbG LXFw== 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 b6si26998407pgd.292.2019.01.09.23.55.47; Wed, 09 Jan 2019 23:56:02 -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; 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 S1727391AbfAJHxi (ORCPT + 99 others); Thu, 10 Jan 2019 02:53:38 -0500 Received: from mailproxy07.manitu.net ([217.11.48.71]:59290 "EHLO mailproxy07.manitu.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726369AbfAJHxi (ORCPT ); Thu, 10 Jan 2019 02:53:38 -0500 X-Greylist: delayed 562 seconds by postgrey-1.27 at vger.kernel.org; Thu, 10 Jan 2019 02:53:37 EST Received: from [192.168.178.20] (aftr-88-217-180-208.dynamic.mnet-online.de [88.217.180.208]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: wg@grandegger.com) by mailproxy07.manitu.net (Postfix) with ESMTPSA id CF20BC810D; Thu, 10 Jan 2019 08:47:23 +0100 (CET) Subject: Re: [RFC PATCH 1/3] can: m_can: Create m_can core to leverage common code To: Dan Murphy , mkl@pengutronix.de, davem@davemloft.net Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20181010142055.25271-1-dmurphy@ti.com> <20181010142055.25271-2-dmurphy@ti.com> <52811b27-00c0-f5e2-2b18-608ccf846723@grandegger.com> <349ef8be-f4c7-25cc-2c33-7ce1fd0b0f40@ti.com> <9003a544-83cf-7dce-7f14-4abd292d470e@grandegger.com> From: Wolfgang Grandegger Openpgp: preference=signencrypt Autocrypt: addr=wg@grandegger.com; prefer-encrypt=mutual; keydata= mQINBFtEb5MBEAC5aRjs5jLwjbOaEE6rczZSqck7B3iGK8ldrV8HGSjxb1MAf4VbvDWrzXfA phEgX3e54AnYhnKcf6BA3J9TlSDdUAW7r/ijOFl+TehMz7holgjhlDK41acJ/klwXJotIqby bWqFgFw6o7b8hfbVzPi8Pz/+WOIKaDOb1Keb989mn253RF1yFakgvoQfCyAeVcnO5kcByW17 zbTEHsSduYi0Zir26Oedb2Vtas4SovrEXVh4e2dRdbEbHlI8po3Ih117CuGIPAe2RSfZKY88 8c9m+WsJKtrIDIMY+f5kcHG5mib++u1oTg7wjfFgTr925g2WjzT63YRibW8Vazot9yXquMo2 HYQStmnN9MuAkL/jslnxhGKNwTzpXv6FD2g/9hcLfSjaaCwGzj2j2ucJglJnO1n+ibVB14l2 JLVe+IKJaE1gvm2v9HPsE+o1P4O8I9iCiAbQ6BGUszHADOg7r8CeTQ+AOCypfEZ5l1Hwa3gw V+TtqyCU70U9LA0AKaDZ02vf0hFRWeXV/ErFq878GOXbbVMZu8G5aO0EcCBC75/KQnyi0WEl KVIcyTyxKel/Ext7vUFIkiA16JNWRpS85YDfe9CoEZcZK+nUU268j6Bp5a7MYaF/dZaLT+Du hLA82ry8IkPQvyV5yV+B0PwDM/w7de8zIzMy9YBXU8KGGDmgYQARAQABtCdXb2xmZ2FuZyBH cmFuZGVnZ2VyIDx3Z0BncmFuZGVnZ2VyLmNvbT6JAj8EEwECACkFAltEb5MCGyMFCQlmAYAH CwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIXgAAKCRDwuz7LbZzI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3a046-2d55-06e0-fba7-c9a0d20e6daa@grandegger.com> Date: Thu, 10 Jan 2019 08:44:13 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Dan, sorry for my late response on that topic... Am 09.01.19 um 21:58 schrieb Dan Murphy: > Wolfgang > > On 11/3/18 5:45 AM, Wolfgang Grandegger wrote: >> Hello Dan, >> >> Am 31.10.2018 um 21:15 schrieb Dan Murphy: >>> Wolfgang >>> >>> Thanks for the review >>> >>> On 10/27/2018 09:19 AM, Wolfgang Grandegger wrote: >>>> Hello Dan, >>>> >>>> for the RFC, could you please just do the necessary changes to the >>>> existing code. We can discuss about better names, etc. later. For >>>> the review if the common code I quickly did: >>>> >>>> mv m_can.c m_can_platform.c >>>> mv m_can_core.c m_can.c >>>> >>>> The file names are similar to what we have for the C_CAN driver. >>>> >>>> s/classdev/priv/ >>>> variable name s/m_can_dev/priv/ >>>> >>>> Then your patch 1/3 looks as shown below. I'm going to comment on that >>>> one. The comments start with "***".... >>>> >>> >>> So you would like me to align the names with the c_can driver? >> >> That would be the obvious choice. >>> >>>> >>>> *** I didn't review the rest of the patch for now. >>>> >>> >>> snipped the code to reply to the comment. >>> >>>> Looking to the generic code, you didn't really change the way >>>> the driver is accessing the registers. Also the interrupt handling >>>> and rx polling is as it was before. Does that work properly using >>>> the SPI interface of the TCAN4x5x? >>> >>> I don't want to change any of that yet. Maybe my cover letter was not clear >>> or did not go through. >>> >>> But the intention was just to break out the functionality to create a MCAN framework >>> that can be used by devices that contain the Bosch MCAN core and provider their own protocal to access >>> the registers in the device. >>> >>> I don't want to do any functional changes at this time on the IP code itself until we have a framework. >>> There should be no regression in the io mapped code. >>> >>> I did comment on the interrupt handling and asked if a threaded work queue would affect CAN timing. >>> For the original TCAN driver this was the way it was implemented. >> >> Do threaded interrupts with RX polling make sense? I think we need a >> common interface allowing to select hard-irqs+napi or threaded-irqs. >> > > I have been working on this code for about a month now and I am *not happy* with the amount of change that needs > to be done to make the m_can a framework. > > I can tx/rx frames from another CAN device to the TCAN part but I have not even touched the iomapped code. > > The challenging part is that the m_can code that is currently available does not have to worry about atomic context because > there is no peripheral waiting. Since the TCAN is a peripheral device we need to take into about the hard waits in IRQ context > as well as the atomic context. Doing this creates many deltas in the base code that may break iomapped devices. I have had to > add the thread_irqs and now I am in the midst of the issue you brought up with napi. I would have to schedule a queue for perp devices > and leave the non-threaded iomapped irq. > > At this point I think it may be wise to leave the m_can code alone as it is working and stable and just work on the TCAN driver as > a standalone driver. A framework would be nice but I think it would destablize the m_can driver which is embedded in many SoC's and > we cannot possibly test everyone of them. Unfortunately, I do not have m_can hardware at hand. > What are your thoughts? What we need is a common set of functions doing tx, rx, error and state handling. This will requires substantial changes to the existing io-mapped m_can driver, of course. I still believe it's worth the effort, but I agree that it's difficult for you to re-write and test the existing m_can driver. What about implementing such a set of common functions plus the SPI specific part for your TCAN device. What do you/others think? Wolfgang.