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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 CF524C432C3 for ; Thu, 21 Nov 2019 00:27:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AF23E20715 for ; Thu, 21 Nov 2019 00:27:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726574AbfKUA1j (ORCPT ); Wed, 20 Nov 2019 19:27:39 -0500 Received: from mga01.intel.com ([192.55.52.88]:64139 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbfKUA1j (ORCPT ); Wed, 20 Nov 2019 19:27:39 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2019 16:27:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,223,1571727600"; d="scan'208";a="204989376" Received: from djiang5-desk3.ch.intel.com ([143.182.136.137]) by fmsmga007.fm.intel.com with ESMTP; 20 Nov 2019 16:27:37 -0800 Subject: Re: [PATCH RFC 01/14] x86/asm: add iosubmit_cmds512() based on movdir64b CPU instruction To: Thomas Gleixner , "Luck, Tony" Cc: Borislav Petkov , "dmaengine@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "vkoul@kernel.org" , "Williams, Dan J" , "Lin, Jing" , "Raj, Ashok" , "Kumar, Sanjay K" , "Dey, Megha" , "Pan, Jacob jun" , "Liu, Yi L" , "axboe@kernel.dk" , "akpm@linux-foundation.org" , "mingo@redhat.com" , "Yu, Fenghua" , "hpa@zytor.com" References: <157428480574.36836.14057238306923901253.stgit@djiang5-desk3.ch.intel.com> <157428502934.36836.8119026517510193201.stgit@djiang5-desk3.ch.intel.com> <20191120215338.GN2634@zn.tnic> <20191120231923.GA32680@agluck-desk2.amr.corp.intel.com> From: Dave Jiang Message-ID: <9504173f-29b5-40a6-3fa8-4bfd498e2e31@intel.com> Date: Wed, 20 Nov 2019 17:27:37 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/20/19 5:22 PM, Thomas Gleixner wrote: > On Wed, 20 Nov 2019, Luck, Tony wrote: >> On Wed, Nov 20, 2019 at 10:53:39PM +0100, Borislav Petkov wrote: >>> On Wed, Nov 20, 2019 at 02:23:49PM -0700, Dave Jiang wrote: >>>> +static inline void iosubmit_cmds512(void __iomem *dst, const void *src, >>>> + size_t count) >>> >>> An iosubmit function which returns void and doesn't tell its callers >>> whether it succeeded or not? That looks non-optimal to say the least. >> >> That's the underlying functionality of the MOVDIR64B instruction. A >> posted write so no way to know if it succeeded. When using dedicated >> queues the caller must keep count of how many operations are in flight >> and not send more than the depth of the queue. >> >>> Why isn't there a fallback function which to call when the CPU doesn't >>> support movdir64b? >> >> This particular driver has no option for fallback. Descriptors can >> only be submitted with MOVDIR64B (to dedicated queues ... in later >> patch series support for shared queues will be added, but those require >> ENQCMD or ENQCMDS to submit). >> >> The driver bails out at the beginning of the probe routine if the >> necessary instructions are not supported: >> >> + /* >> + * If the CPU does not support write512, there's no point in >> + * enumerating the device. We can not utilize it. >> + */ >> + if (!cpu_has_write512()) >> + return -ENXIO; >> >> Though we should always get past that as this PCI device ID shouldn't >> every appear on a system that doesn't have the support. Device is on >> the die, not a plug-in card. > > Then the condition in the iosubmit function is just prone to silently paper > over any bug in a driver: > >> + if (!cpu_has_write512()) >> + return; > > This should at least issue a WARN_ON_ONCE() Thanks! I'll be adding the WARN_ON_ONCE() for the cap check. Also with the alignment check Borislav mentioned, I'll add a WARN_ON() for failures. > > Thanks, > > tglx >