From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3940DC4727F for ; Wed, 23 Sep 2020 11:08:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B133820725 for ; Wed, 23 Sep 2020 11:08:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alien8.de header.i=@alien8.de header.b="Vz2sK9dO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726504AbgIWLIq (ORCPT ); Wed, 23 Sep 2020 07:08:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726332AbgIWLIp (ORCPT ); Wed, 23 Sep 2020 07:08:45 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 909BFC0613CE; Wed, 23 Sep 2020 04:08:45 -0700 (PDT) Received: from zn.tnic (p200300ec2f0d13006bfbbaac21a5376c.dip0.t-ipconnect.de [IPv6:2003:ec:2f0d:1300:6bfb:baac:21a5:376c]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id DBF6C1EC0445; Wed, 23 Sep 2020 13:08:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1600859324; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v8IZo3CWRXJtiTiLfrNSgkG9waQamx4FDxHZUEDGYM8=; b=Vz2sK9dO9MXnh7NRaaeCAITabzPj8R505yEKcROShGBtiARdVsSwwW3dAGYhGDD6gXqcY0 aRxFYByKrTAWcwOGM8rur0sqoMNQwDqoJEpyodRqRsE+X6kFHZydPkkI28Ej0kD3PvNads k6/KOxg37lv62T7IZFbAEDvjq3O5DEE= Date: Wed, 23 Sep 2020 13:08:37 +0200 From: Borislav Petkov To: Dave Jiang Cc: vkoul@kernel.org, tglx@linutronix.de, mingo@redhat.com, dan.j.williams@intel.com, tony.luck@intel.com, jing.lin@intel.com, ashok.raj@intel.com, sanjay.k.kumar@intel.com, fenghua.yu@intel.com, kevin.tian@intel.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 2/5] x86/asm: add enqcmds() to support ENQCMDS instruction Message-ID: <20200923110837.GH28545@zn.tnic> References: <160037680630.3777.16356270178889649944.stgit@djiang5-desk3.ch.intel.com> <160037732334.3777.8083106831110728138.stgit@djiang5-desk3.ch.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <160037732334.3777.8083106831110728138.stgit@djiang5-desk3.ch.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 17, 2020 at 02:15:23PM -0700, Dave Jiang wrote: > Add enqcmds() in x86 io.h instead of special_insns.h. Why? It is an asm wrapper for a special instruction. > MOVDIR64B > instruction can be used for other purposes. A wrapper was introduced > in io.h for its command submission usage. ENQCMDS has a single > purpose of submit 64-byte commands to supported devices and should > be called directly. > > Signed-off-by: Dave Jiang > Reviewed-by: Tony Luck > --- > arch/x86/include/asm/io.h | 29 +++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) > > diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h > index d726459d08e5..b7af0bf8a018 100644 > --- a/arch/x86/include/asm/io.h > +++ b/arch/x86/include/asm/io.h > @@ -424,4 +424,33 @@ static inline void iosubmit_cmds512(void __iomem *dst, const void *src, > } > } > > +/** > + * enqcmds - copy a 512 bits data unit to single MMIO location Your #319433 doc says "ENQCMDS — Enqueue Command Supervisor" Now *how* that enqueueing is done you can explain in the comment below. > + * @dst: destination, in MMIO space (must be 512-bit aligned) > + * @src: source > + * > + * Submit data from kernel space to MMIO space, in a unit of 512 bits. > + * Order of data access is not guaranteed, nor is a memory barrier > + * performed afterwards. The command returns false (0) on failure, and true (1) > + * on success. The command or the function? >From what I see below, the instruction sets ZF=1 to denote that it needs to be retried and ZF=0 means success, as the doc says. And in good UNIX tradition, 0 means usually success and !0 failure. So why are you flipping that? > + * Warning: Do not use this helper unless your driver has checked that the CPU > + * instruction is supported on the platform. > + */ > +static inline bool enqcmds(void __iomem *dst, const void *src) > +{ > + bool retry; > + > + /* ENQCMDS [rdx], rax */ > + asm volatile(".byte 0xf3, 0x0f, 0x38, 0xf8, 0x02, 0x66, 0x90\t\n" ^^^^ No need for those last two chars. > + CC_SET(z) > + : CC_OUT(z) (retry) > + : "a" (dst), "d" (src)); <---- newline here. > + /* Submission failure is indicated via EFLAGS.ZF=1 */ > + if (retry) > + return false; > + > + return true; > +} > + > #endif /* _ASM_X86_IO_H */ Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette