Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp79144ybk; Thu, 14 May 2020 16:51:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDS5olvxk049alsnhE2MCsZwjrOOVzEU9jBZ+51e56lim58HyhQ8bEal1QHtAS4sLjecIt X-Received: by 2002:a50:fa8d:: with SMTP id w13mr466298edr.280.1589500265717; Thu, 14 May 2020 16:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589500265; cv=none; d=google.com; s=arc-20160816; b=xihTGkFm8VALC9JbTs4zRxS1s27F6t0dXs7kFgnTMpdNpyf4MjyFsMRJpkEaEYOqSZ p1+q9p/mpK98ju4MboSkFJdPnMrOaqK06eEEc/mEF5XYXKDd7q/0Zb4NJgiKTAM1U/oC LNFHmaRM+vQAxiltvn3r2wKg2+ghJTcX9gmfadHKzRyk2FK1nIjAOacFeqrlmbBiihYq qHkDHNvAmtyI5kU7CymycTv7CMItha2rs4WhLmIQJTI+AelNQYooNNF7Wm73QAHXsQTO spxeu5IYGPkPMMH6dFEHDGjapCuHVIwMwvyyRTKW8voTjI2nYGeC7lPnFF/M0HZ+wdkM Ld1g== 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:mime-version :user-agent:organization:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=I/FTFu3Esb5NA/l5xL7ux/92tkQ2JvycVABxeQURrbo=; b=BY9GCIRIMzXwxwArVu/T9njnrCV6px9iuR1+oCVuOYdg/WNJRniNBDME0sldFoTsoS o0NGk5gYosSI4NxIwjTRkuHQLxfVoOyfxN7bCKg3exdvuz2k53YolvZB5XdhG4xfdEUH pMWPKHyo+YTC8d3f+4dlDbZJg6xODWmrScr4EoMkfG1OeJUE3tg03Ijkd3KBmi/NZvRc ENL+rXVROzMuMol4h8xG2V86E0hyru/hLbwyC94Ab1VKDohlbBcNomdHD7jw/d32hT+5 LhMR2M39mq8xfnkQT5/5CzYRVn6YtzLIhDjMrDNcgBcQR8duV+/+Ai/PFU+AyvXe438Q YfWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pAsoCW4t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id l20si237764eji.236.2020.05.14.16.50.41; Thu, 14 May 2020 16:51:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pAsoCW4t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728256AbgENX2l (ORCPT + 99 others); Thu, 14 May 2020 19:28:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbgENX2k (ORCPT ); Thu, 14 May 2020 19:28:40 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24B96C061A0C for ; Thu, 14 May 2020 16:28:39 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id a136so737537qkg.6 for ; Thu, 14 May 2020 16:28:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :organization:user-agent:mime-version:content-transfer-encoding; bh=I/FTFu3Esb5NA/l5xL7ux/92tkQ2JvycVABxeQURrbo=; b=pAsoCW4twMPuMB+CSRxUc0zI1h1/vtfog4+l7wXkwYtyLwBFT2gAmZGs6GulY5TvDJ ovjrxjtG+IlKRkoTqxxV2x0VQLbNK52e+UIYRx9VfbNY9YIdKLb/mqXe1caBEo+oSDu2 oJKVVDQHPf5T9keTXAJEacNAMJoZLnGjxzGfX1+TfgDGict68GRGXksj71lkVfne+NdQ FCaynLyTYju2qp23k25nDo6XyshMaxOBptuyaZb0i3yBQj4X6Aqjn7s1eJM5v5+p8AHC hh9cDQ4A3PI9jPF9rp3aAbUoQnjXO99lNrm11rK3WwvlqMRBEfc7ey//pYGSd+Dayw0R 3SBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:organization:user-agent:mime-version :content-transfer-encoding; bh=I/FTFu3Esb5NA/l5xL7ux/92tkQ2JvycVABxeQURrbo=; b=FzdYOUY3ol0y/tIBUabhWn0Za+xJhToekZWPQTTvAPEfSuOnrx2TcZYt6oUUUAQhRO GLwH7Ve2l9yG84Agns68gkTcFqO3UWaxVbD189JgWue115pCujoJMEcZ7UmXfBicxU0H ShGa3zh+aJ3nB+iSNBfThZX/5LI+7fqZ0Fea+JNF8bPNshVXsHDsura7JfFPvO7z2MW4 2zLC66QEwI24GPoBfPiR/EqthIhbAF3aURo0LatIVRmtPvwiFqsrhZUvMInPCpUs1z7a E05NrS9/9gbcC2ekt/MQc9sWFAkcE8vCK3n04XZqa30cBZruvCjyyYFe9Mce4AyLV3Ij j5Mw== X-Gm-Message-State: AOAM532PHem8BQpioQK6T/Q1TRd/l2ZWH2zBURcPnEmcV9SRZmG4wpcO zN+ioejPAeyDuns8sxw2s70Kprfg X-Received: by 2002:a37:8187:: with SMTP id c129mr806073qkd.211.1589498918382; Thu, 14 May 2020 16:28:38 -0700 (PDT) Received: from LeoBras (179-125-143-209.dynamic.desktop.com.br. [179.125.143.209]) by smtp.gmail.com with ESMTPSA id n20sm290110qkk.53.2020.05.14.16.28.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 May 2020 16:28:37 -0700 (PDT) Message-ID: Subject: Re: [PATCH v3 2/2] powerpc/rtas: Implement reentrant rtas call From: Leonardo Bras To: Nathan Lynch Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Allison Randal , Greg Kroah-Hartman , Thomas Gleixner , Nicholas Piggin , "Gautham R. Shenoy" , Nadav Amit Date: Thu, 14 May 2020 20:28:15 -0300 In-Reply-To: <878shu2vjp.fsf@linux.ibm.com> References: <20200514011245.127174-1-leobras.c@gmail.com> <20200514011245.127174-3-leobras.c@gmail.com> <878shu2vjp.fsf@linux.ibm.com> Organization: IBM Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Nathan, On Thu, 2020-05-14 at 13:58 -0500, Nathan Lynch wrote: > Hi, > > Leonardo Bras writes: > > +/** > > + * rtas_call_reentrant() - Used for reentrant rtas calls > > + * @token: Token for desired reentrant RTAS call > > + * @nargs: Number of Input Parameters > > + * @nret: Number of Output Parameters > > + * @outputs: Array of outputs > > + * @...: Inputs for desired RTAS call > > + * > > + * According to LoPAR documentation, only "ibm,int-on", "ibm,int-off", > > + * "ibm,get-xive" and "ibm,set-xive" are currently reentrant. > > + * Reentrant calls need their own rtas_args buffer, so not using rtas.args, but > > + * PACA one instead. > > + * > > + * Return: -1 on error, > > + * First output value of RTAS call if (nret > 0), > > + * 0 otherwise, > > + */ > > + > > +int rtas_call_reentrant(int token, int nargs, int nret, int *outputs, ...) > > +{ > > + va_list list; > > + struct rtas_args *args; > > + int i; > > + > > + if (!rtas.entry || token == RTAS_UNKNOWN_SERVICE) > > + return -1; > > + > > + /* We use the per-cpu (PACA) rtas args buffer */ > > + args = &local_paca->reentrant_args; > > + > > + va_start(list, outputs); > > + va_rtas_call_unlocked(args, token, nargs, nret, list); > > + va_end(list); > > + > > + if (nret > 1 && outputs) > > + for (i = 0; i < nret - 1; ++i) > > + outputs[i] = be32_to_cpu(args->rets[i + 1]); > > Doesn't this need to be more careful about preemption and exceptions? > I.e. the args structure in the paca needs to be protected from > concurrent use somehow, like any per-cpu data structure. > > local_irq_save/restore while accessing local_paca->reentrant_args here > would be sufficient I think? Yes, you are right. I will also add preempt_{dis,en}able, which in most kernels will compile out, but it will be kind of 'ready' if we ever decide to support PREEMPT. Thanks for the feedback!