Received: by 10.213.65.68 with SMTP id h4csp816150imn; Fri, 6 Apr 2018 09:22:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx49vX1QfWph/lJND+fnM00OKNQk3gTlbssd4hF4XYzUHiyHG3E7WDrEnf4orD6B9JGaeVrYK X-Received: by 10.99.158.81 with SMTP id r17mr18541066pgo.348.1523031727491; Fri, 06 Apr 2018 09:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523031727; cv=none; d=google.com; s=arc-20160816; b=bSNgeQZBBs4/06iT9ILoq6e5HFHWIn8uUC95PgRjmeONhF1oN5cM9B0XKCkqrnaKkB qo6TxsUmCC3w0Q6Swd1Y3oKEv8R63yWKVqiEAjmhbTB0kK9t8Ht0dVWVW6ROkKR1Iq6y kFfkVF+BRwaQaSM+KAMRP0ZNFK6XWn8+hf8VmLNyRD1D4Pz54fpkVxR7LOI2a9qiwXO4 NUuXflTjNyMSFx5MyWaIlhmO3Iqa4QZ6m67B4ekCA3vmXN0V1/qsFO40qLk91TaBz6Xd pkevXamnifV1DDb1OZzjT/Gv4JmBDaNOywAw2n6A2jg/da5ZhaTbUN3TCfJJCSPPEd8z vk/A== 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=h3H+dxqgZ90ETlcIu2q9MSfJHlkP12uruMvFbamBIv0=; b=sOD1awOmYUnexM8V0QR12at0n9FHIWH5iXXxEGqKBk9h4rSrPC+sRGewH28dVWwsTg 8LRs9gHRR8d6Jn/kzPHtf1L0LMPHLjE15ZdfAvCTgnkgAzgJq5QxvSOfeaxmbf3zOTwn 6zP67P+kJpBKvOzmATiFlgQyXMbNrZpVAu7PDcptbsj11EkvE7njrak4q/MaX1oY9Ajh +/ObseB3STAVbzp2yb5WWdg+hLXc5Sw0S2fjpwjBSIRaIqlca5wQFDzl7hchrY0XgYs7 YprvhIGKMnxaAwfCP1QztHpXyeuuULD9aNO6CQnPj6rk5nWYOA08jCcynI0XoL3S4j8n b9SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uPQls4vp; 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 c23-v6si1074147plk.245.2018.04.06.09.21.53; Fri, 06 Apr 2018 09:22:07 -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=uPQls4vp; 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 S1751638AbeDFQUs (ORCPT + 99 others); Fri, 6 Apr 2018 12:20:48 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:52017 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751089AbeDFQUq (ORCPT ); Fri, 6 Apr 2018 12:20:46 -0400 Received: by mail-wm0-f50.google.com with SMTP id u189so4580470wmd.1; Fri, 06 Apr 2018 09:20:45 -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=h3H+dxqgZ90ETlcIu2q9MSfJHlkP12uruMvFbamBIv0=; b=uPQls4vpanbZyoR/xbwwCagnNV4VDAKgrx5JYb/SPt0yCzYg0lKKtDGpwelaegzaz9 wF8A1G/kJauH5kZj3HaN/FUI3HtdzIvGyzyfpsbQ+K0hfcQJ0T8tCvXenGJ8XUSuqSEa 4/lhpZo9zMtCb+zYMw1IDuYRk8JuJ6Nf28D483yO7r5m8+i2oJiIFhKZYLwBkSX0QXSC 3iLfvsTpnXHxeSapxGwUtiqCL1/WAIQTZ8w/fV7x+DkjMYljP8LGMOWsU6mBCmg0j165 W/6s8THeywmv5O7/Tn64ICh6l92WraXlmS04V1wczehX2EA3wN3L+54zfNi0g08GfnY7 V43Q== 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=h3H+dxqgZ90ETlcIu2q9MSfJHlkP12uruMvFbamBIv0=; b=htbG0/Zwrvc3SmcU9sa/ks0b/Xhg1b/c2JiOO3vSEJTd8gl1jiht0sg9PKCP9pnO8L 8BY2d1ZJe/BRXFBSL5GpUSkgGYCHGpYzH8lwVGQ/4sGfdiGGQxOQnTDPBU+pyhUln6Bd qRvUyBCyydZ3wmhJ7edGk5fCuWbW/hiE7OOeSps0tP5YpLzQrPaklRQLJWBA6/t4H3KH /LGJck65lptC2YW+loyw3y0v0Wecy6cPeuDJatCu6amLveu6VOeEvi4tIw2ka/1jd45G 6HNgzI0IIcIvvsyOp2MHslhjdVPiJEq/1Q5UM8c+bs07y6h8LKzKLoQ9ZIa1jK9FLbBR 3V6Q== X-Gm-Message-State: ALQs6tBJrUEWWR3p1KtVt0J6x++6APvwtDALpdmRsZihz+05mUtnQpxR 6xN4FayGucU4wd2AxJgfIwABqoiZyC5/ILzOfYg= X-Received: by 10.80.137.60 with SMTP id e57mr7348711ede.213.1523031644631; Fri, 06 Apr 2018 09:20:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.80.134.132 with HTTP; Fri, 6 Apr 2018 09:20:44 -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: Fri, 6 Apr 2018 21:50:44 +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 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). Please send in the final revision. Thanks.