Received: by 10.213.65.68 with SMTP id h4csp2429992imn; Mon, 9 Apr 2018 03:30:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx49nNSSVuJoPz71Myulbm1D8vNa4Nm7zHCUmaCTG8t07x1yNE1ENoEH0bFccMuzoIY5J1X1r X-Received: by 10.101.91.67 with SMTP id y3mr22843738pgr.264.1523269803526; Mon, 09 Apr 2018 03:30:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523269803; cv=none; d=google.com; s=arc-20160816; b=ZBYThmrtGAJhY0BYH8vmXpegoOAUdNfyCqHJ+2PpB1Gfl3Ps46vE1VtwZ/L0GH8vIc TM+0S1Wc0YkIArxoSHt6awq3htoCyrNL/MuMzRl4Z+UR2kycnMp+SImbAcFKlX9ma1eM 7Rdh2gkYDWed4i0EBGxCGnamNC7u+DOiLuj+dzF5Z42OjU2Q20wLm5KPPaAuhhDliIxE 88+rzFagEaCWQ72qQK1HnsOiAB1+joR8118fBVy479Idld/8wO3hM4Zwe/7nq76EIU1k TV+G+1JFkcH2l0i31xrTMkC+LUyiFlHrL6GMj5+++auhAGAnfhaOhv0wdvasnOalR05E IGew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=5Vxrs9HLgUK7nQkY4kMA+1mkWnlxO2bgpHs2ZqupLCI=; b=U6I4DLGDg+5VPuatJpfa9lbMCmn7g9pvKWKQ2tpV3SRN6A/JN6QbQkMbKyNqkAxjWg Pn9EfVNeLiIXITiFfP27NP5mu8Hrbnx33WJmwv02xGDjZM0Zay10ZUSp7QKCthcm+j2h l9vg9qA8pI4BupOimZ1BuNNXYSUp9ld8VdPf1JGETzImH2KVE1WTYP/6W4DlBz122t19 uqiMB+HTxE/HBZRry+M74Uv9cB2F7Q7dWOD4ykS/LbmBlZrLRMHVZmlLcf72nLp7j7tL NlTmavuK0ImfXjqeL/HnnO+7JKjcCNsXIk5l4Fz1EQZJlqwqHEBDL35axdsgOYZkl0CZ TKcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cojsVXiX; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d13si15144pfl.206.2018.04.09.03.29.26; Mon, 09 Apr 2018 03:30:03 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cojsVXiX; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752099AbeDIKKQ (ORCPT + 99 others); Mon, 9 Apr 2018 06:10:16 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:37285 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751455AbeDIKKM (ORCPT ); Mon, 9 Apr 2018 06:10:12 -0400 Received: by mail-wm0-f48.google.com with SMTP id r131so15607775wmb.2; Mon, 09 Apr 2018 03:10:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=5Vxrs9HLgUK7nQkY4kMA+1mkWnlxO2bgpHs2ZqupLCI=; b=cojsVXiXzeD+LIDeWHMfXfQzYguu5ROIDPhK2k7TPeeU0aK5hZlMeSzycgMEvIoA/3 NhYOz2ddhrar7oe0/SZrGuBnZzSnkoatBt0FK4nikJZ5NNLtehtiAQWrzjvigvKLid1+ 5LF7REQhkamBwAoC3UobGewj4p0HCA7lBDlVVTGSj9BIWSc8IcD03Z25A16bIehDE5d4 ENw7tQachQDZV6PsgvxAaNHz5zYPl+x5zWD0/VSRAVUqyvtA4o77w9F07RLF8IA8DfSj lj7zIHAlyHainnXKHO9OG0X38aP1AHtQONb8npRXtO94G1+FTLHwg5+mgAvEJGBwY9Ov KN5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=5Vxrs9HLgUK7nQkY4kMA+1mkWnlxO2bgpHs2ZqupLCI=; b=klQpBCoZmHqK/YJvYsiH6zh3lN8EC8MLfcmi38vLKrRZhUjcjwCy/5ZC2IcHQpVan+ WpGWOL4+hqlxGsIEwxeI95CoII3Q/TbM/yjRyLOUsw2mMbOPMG9AYd04NO0euOwtyQKf dMQQlMLaNh/5HAT7PU0AMbGzKYtirbFhEDLId5q3MMETHwPZBGd+1dlBSU3MHstIp69q fYjMmBjLLN5FDKMdoghA7f3rt18eEK3M2/2Ahqjw1TwDghTkK3KHDgXlWyYH9/mfroxH NaAYOD6A9yB/AO78g3rQ1/oU/+D+Ovy4ptQ3rhRR+lbjhSvfot0w7L2glE8BQmA5LJJE VZUQ== X-Gm-Message-State: ALQs6tCP/s607eJastDL7D8YMnPguOoVXcCQTiGWqogv9bittbk+WEEG G715DKNkz+CjUGUesQU8ZM0PRl5zQhWLE6BEzNg= X-Received: by 10.80.139.184 with SMTP id m53mr21600888edm.6.1523268611340; Mon, 09 Apr 2018 03:10:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.80.134.132 with HTTP; Mon, 9 Apr 2018 03:10:10 -0700 (PDT) In-Reply-To: References: <1520852307-26659-1-git-send-email-fabien.dessenne@st.com> <1520852307-26659-3-git-send-email-fabien.dessenne@st.com> <4a2170b7-e5e9-4f5c-8ff7-79e102a658c1@st.com> From: Jassi Brar Date: Mon, 9 Apr 2018 15:40:10 +0530 Message-ID: Subject: Re: [PATCH v2 2/2] mailbox: add STMicroelectronics STM32 IPCC driver To: Fabien DESSENNE Cc: Rob Herring , Mark Rutland , Maxime Coquelin , Alexandre TORGUE , Ludovic BARRE , Devicetree List , "linux-mediatek@lists.infradead.org" , srv_heupstream , Linux Kernel Mailing List , Benjamin Gaignard , Loic PALLARDY , Arnaud POULIQUEN , Bjorn Andersson 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 On Mon, Apr 9, 2018 at 2:33 PM, Fabien DESSENNE wrote: > > > On 06/04/18 18:20, Jassi Brar wrote: >> On Fri, Apr 6, 2018 at 8:35 PM, Fabien DESSENNE wrote: >>> On 06/04/18 14:56, Jassi Brar wrote: >>>> On Fri, Apr 6, 2018 at 5:59 PM, Fabien DESSENNE wrote: >>>>> Hi >>>>> >>>>> >>>>> On 05/04/18 11:38, Jassi Brar wrote: >>>>>> On Mon, Mar 12, 2018 at 4:28 PM, Fabien Dessenne wrote: >>>>>> .... >>>>>>> + >>>>>>> + /* irq */ >>>>>>> + for (i = 0; i < IPCC_IRQ_NUM; i++) { >>>>>>> + ipcc->irqs[i] = of_irq_get_byname(dev->of_node, irq_name[i]); >>>>>>> + if (ipcc->irqs[i] < 0) { >>>>>>> + dev_err(dev, "no IRQ specified %s\n", irq_name[i]); >>>>>>> + ret = ipcc->irqs[i]; >>>>>>> + goto err_clk; >>>>>>> + } >>>>>>> + >>>>>>> + ret = devm_request_threaded_irq(dev, ipcc->irqs[i], NULL, >>>>>>> + irq_thread[i], IRQF_ONESHOT, >>>>>>> + dev_name(dev), ipcc); >>>>>>> >>>>>> In your interrupt handlers you don't do anything that could block. >>>>>> Threads only adds some delay to your message handling. >>>>>> So maybe use devm_request_irq() ? >>>>> The interrupt handlers call mbox_chan_received_data() / >>>>> mbox_chan_txdone(), which call in turn client's rx_callback() / >>>>> tx_done() / tx_prepare() which behavior may be unsafe. Hence, using a >>>>> threaded irq here seems to be a good choice. >>>>> >>>> rx_callback() is supposed to be atomic. >>> I am worried with this atomic part (and honestly I did not note that the >>> callbacks were expected to be) >>> >>> In my case, remoteproc->virtio->rpmsg is the mailbox client defining the >>> rx_callback. >>> If I follow your suggestion, I shall make this rx_callback Atomic in >>> remoteproc (or in virtio or rpmsg). And this does not seem to be so >>> simple (add a worker in the middle of somewhere?). Bjorn, feel free to >>> comment this part. >>> >>> An alternate implementation consists in using a threaded IRQ for the >>> mailbox interrupt. >>> This option is not only simple, but also ensures to split bottom & half >>> parts at the irq level which is IMHO a general good practice. >>> >>> I can see that some mailbox clients implement callbacks that are NOT >>> atomic and I suspect this is the reason why some mailbox drivers use >>> threaded_irq (rockchip mailbox splits the bottom & half parts). >>> >>> Would it be acceptable to consider the "atomic client callback" as a >>> non-strict rule ? >>> >> Of course you can traverse atomic path from sleepable context (but not >> vice-versa). > > So, to be sure we understand each other, I can use threaded_irq, right? > Yes. Its platform specific driver, I can't dictate the features you want :)