Received: by 10.223.185.116 with SMTP id b49csp3754490wrg; Tue, 13 Feb 2018 07:17:01 -0800 (PST) X-Google-Smtp-Source: AH8x224RTjnI+MD5MAvyR3ytGNfX7UCoiboSccG/dGq2WbZaMv4ej5b5fKGDFPN0G8/4pz1WxCTt X-Received: by 2002:a17:902:9898:: with SMTP id s24-v6mr1443383plp.275.1518535021019; Tue, 13 Feb 2018 07:17:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518535020; cv=none; d=google.com; s=arc-20160816; b=Er2JtvP5szywI/jjN7T6452XUuYu3/Mol/W/m+u3ysY4QOTJyZ54mRDHS2gSL5Nnvd sJI989+9cQppcSZ1s90L7Mq7sF2+KpjzX0y11srkzPEaAjshWhpB+lOm0NO0Fv9LBfwz cg4K1hY0XwqdBR3s8E7N/4/vPYLlGe4v1Uc4Iu219Mt9ejw/lPCb4tOW9gf85Lf5BDYJ AjTiZxbczy1j8yz58adU9HP0HAD8VmOO1F4AMWc+jC/e1ieVW4Qn3YZhKXT+PoMxae5C PB2FzmjgHrIWq5KDh/bxugQG/aQES/5S0HGsLxI/eNcUaxYtudu8T+ZgCpw2LRRb4cKa mh6Q== 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:arc-authentication-results; bh=4pLLs+PHfZn4CXFNKVydrYJJa0121JrcXo+pr7GNMU4=; b=cNNaRS7bASv35+cBiD2SMbjbC8EJ/JJJ63Zfnzvb4vrSN39acNEn6xCLnZVWRkCSXi T/Hzq1i+O5D/EkJQKgsgaWcMHKZSwaHuasgzUgDSQ4c8dALxXfG00MiP+IxE7VOGo6SX uSiLVQXimxuICtorOglJV/AYS8Vjf3caS2qJDIHZCEF0Crmc0y04GVU4lpQmkPjFf8xi j13EqiZCE/XXs4eGfVddEgifQDze2cX3iRY/vCVvxNXS3oRznhIdgkjOB0YDgf1P6few RYk3AJJNGjNN1iJLRGHm3NyRlhiPh138764ccpZlY31yhH7U2b5S9VViEMMBgxDzJMgv ATJw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a23si1206948pgd.610.2018.02.13.07.16.46; Tue, 13 Feb 2018 07:17:00 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965188AbeBMPQL (ORCPT + 99 others); Tue, 13 Feb 2018 10:16:11 -0500 Received: from mail-qk0-f173.google.com ([209.85.220.173]:37971 "EHLO mail-qk0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965079AbeBMPQJ (ORCPT ); Tue, 13 Feb 2018 10:16:09 -0500 Received: by mail-qk0-f173.google.com with SMTP id s198so6720390qke.5 for ; Tue, 13 Feb 2018 07:16:09 -0800 (PST) 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=4pLLs+PHfZn4CXFNKVydrYJJa0121JrcXo+pr7GNMU4=; b=N0DN4yjkKMONGhhYyerctTMVDBZdMKhuyNi8UM7AILMxlbx8iL70nMftO/AfV0xkWl qylfrOBzbpSov/qL1Hj0+vIBRErYPJ1HPw/gpq2hE6ScLvReaLKlQ9g5qFVqS4giRMlz cBXsaeP0cAPZpu0CvtjVfJTAK5AhZsxD/PTvkKzCb9jFoatIClXz2tOqn0bqnV+jCLou dot4DecwNF6wv42/LFlAP1nQJUTmOY6q9fxywcDTGJPHuiG4q6Ha7DCdXmE2G50NnztU c3Tk0lnsb2pJsn5AylzKsWzkf3zqEKgj1obxvaKlClTjMPE9JZNnW8bZtb7U6PYAjQCo 0y1A== X-Gm-Message-State: APf1xPDYc8P347kBPEy73HeoEAYmNpwJp9/JO2loNMBxFWroJ45YNT9s 1Mp6mmHRsHulyOkEmorontK3dOE7L30fQDFUP/Y0pwgc X-Received: by 10.55.220.197 with SMTP id v188mr2371994qki.147.1518534969193; Tue, 13 Feb 2018 07:16:09 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.146.213 with HTTP; Tue, 13 Feb 2018 07:16:08 -0800 (PST) In-Reply-To: <20180213162038-mutt-send-email-mst@kernel.org> References: <20180207013525.1634-1-marcandre.lureau@redhat.com> <20180207013525.1634-4-marcandre.lureau@redhat.com> <20180212053104-mutt-send-email-mst@kernel.org> <20180212160849-mutt-send-email-mst@kernel.org> <20180213162038-mutt-send-email-mst@kernel.org> From: Marc-Andre Lureau Date: Tue, 13 Feb 2018 16:16:08 +0100 Message-ID: Subject: Re: [PATCH v13 3/4] fw_cfg: write vmcoreinfo details To: "Michael S. Tsirkin" Cc: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= , Linux Kernel Mailing List , Sergio Lopez Pascual , Baoquan He , "Somlo, Gabriel" , xiaolong.ye@intel.com 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 Hi On Tue, Feb 13, 2018 at 3:27 PM, Michael S. Tsirkin wrote: > On Tue, Feb 13, 2018 at 03:14:03PM +0100, Marc-Andre Lureau wrote: >> Hi >> >> On Mon, Feb 12, 2018 at 10:00 PM, Michael S. Tsirkin wrote: >> > On Mon, Feb 12, 2018 at 11:04:49AM +0100, Marc-Andre Lureau wrote: >> >> >> +} >> >> >> + >> >> >> +/* qemu fw_cfg device is sync today, but spec says it may become async */ >> >> >> +static void fw_cfg_wait_for_control(struct fw_cfg_dma *d) >> >> >> +{ >> >> >> + do { >> >> >> + u32 ctrl = be32_to_cpu(READ_ONCE(d->control)); >> >> >> + >> >> >> + if ((ctrl & ~FW_CFG_DMA_CTL_ERROR) == 0) >> >> >> + return; >> >> >> + >> >> >> + usleep_range(50, 100); >> >> >> + } while (true); >> >> > >> >> > And you need an smp rmb here. >> > >> > I'd just do rmb() in fact. >> > >> >> Could you explain? thanks >> > >> > See Documentation/memory-barriers.txt >> > You know that control is valid, but following read of >> > the structure could be reordered. So you need that barrier there. >> > Same for write: wmb. >> >> Is this ok? >> @@ -103,10 +104,14 @@ static ssize_t fw_cfg_dma_transfer(void >> *address, u32 length, u32 control) >> dma = virt_to_phys(d); >> >> iowrite32be((u64)dma >> 32, fw_cfg_reg_dma); >> + /* force memory to sync before notifying device via MMIO */ >> + wmb(); >> iowrite32be(dma, fw_cfg_reg_dma + 4); >> >> fw_cfg_wait_for_control(d); >> >> + /* do not reorder the read to d->control */ >> + rmb(); >> if (be32_to_cpu(READ_ONCE(d->control)) & FW_CFG_DMA_CTL_ERROR) { >> ret = -EIO; >> } > > I think you need an rmb after the read of d->control. > There are two reads of d->control, one in fw_cfg_wait_for_control() to wait for completion, and the other one here to handle error. Do you mean that for clarity rmb() should be moved at the end of fw_cfg_wait_for_control() instead? thanks