From patchwork Fri Dec 31 11:48:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12701926 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DBDFCC433F5 for ; Fri, 31 Dec 2021 11:54:51 +0000 (UTC) Received: from localhost ([::1]:40198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n3GUk-0001Li-Sx for qemu-devel@archiver.kernel.org; Fri, 31 Dec 2021 06:54:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3GPM-0002Zc-25 for qemu-devel@nongnu.org; Fri, 31 Dec 2021 06:49:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29646) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3GPI-0000Ga-59 for qemu-devel@nongnu.org; Fri, 31 Dec 2021 06:49:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640951350; 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=Mzp4W/VQyMxGd5CvQVuwL031robPDmwL00FTI5wH9/Y=; b=ijrxFiQCS49Tjcq8K1XAFKzaY8nTN5fLxufnFj/E04Q9WHl+b3raDOjd0UoVNaR5KwirTn KdplsMApr0xFis1cZv7uMRHf48TBdJIWUUHYV769Th8SN8qgzkixkzJ4IhI5FzBtnANjy+ eNc9IVN1puPZ0ZhTU15VzksbTEWvecU= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-569-McktxPFfM1uoBe70K34K0Q-1; Fri, 31 Dec 2021 06:49:09 -0500 X-MC-Unique: McktxPFfM1uoBe70K34K0Q-1 Received: by mail-wr1-f72.google.com with SMTP id v6-20020adfa1c6000000b001a26d0c3e32so7426097wrv.14 for ; Fri, 31 Dec 2021 03:49:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mzp4W/VQyMxGd5CvQVuwL031robPDmwL00FTI5wH9/Y=; b=wrxKqfNwMkwFfYAeWFND9yFuNkdFqns8Q4COz40wjf2rJKJRdagQfIysMK2OwQrreU 3XE5g5cnaZKTr4HaBrI8Xwflp5uoY691GXvX/VT8fyZkL8BneCgu0Xu7VdoxLqohUHqq YsET7RAoqCZPw7tqQyWu9bp0aP1STXGVs+QsBP5sozOawbEDAWee393XUSItm20IJytY 8tCbLSyyYfIjfJ+UHLC2rKXdDUACeiuzYBZfjjJzzqGGJcSvF3/AAGqL1rpqbrGBX5gS vCt5JEJ1r3vYBJjTnDcz040tEVh8neFFmtYovu1ON39c+TuF2tj+QTY+6HCz2T3ySrSC vJdg== X-Gm-Message-State: AOAM533N3q5VYjY/yvNiRsy/hg33XJx2WEyQesIPom65Ta97Copw5GnZ 6B1s1j54HrRH3ZmJbOIJF5Y7TsdzW45NchNUCk9iJzml0UFODv/T2wytyRSuInp6aP1AanTqOiB KJtvJiegF/wQ3F8tCT3qcSeMrSRKpY5gvUsWXkvcm/MMKgGp2iYmFgbTjUevrb4hm X-Received: by 2002:adf:9c85:: with SMTP id d5mr28584587wre.374.1640951348053; Fri, 31 Dec 2021 03:49:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOSGEuDRp2HNybF3MVJgPfgxFxNFANVmmtSwHonmlbykW9rRWMFORYSBDtBN1+3dkgCGjZ6Q== X-Received: by 2002:adf:9c85:: with SMTP id d5mr28584572wre.374.1640951347875; Fri, 31 Dec 2021 03:49:07 -0800 (PST) Received: from x1w.redhat.com (26.red-83-50-86.dynamicip.rima-tde.net. [83.50.86.26]) by smtp.gmail.com with ESMTPSA id l4sm26395582wrm.62.2021.12.31.03.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Dec 2021 03:49:07 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/8] hw/nvram: Restrict stub to sysemu and tools Date: Fri, 31 Dec 2021 12:48:54 +0100 Message-Id: <20211231114901.976937-2-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211231114901.976937-1-philmd@redhat.com> References: <20211231114901.976937-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) DKIMWL_WL_HIGH=-0.573, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , David Hildenbrand , Peter Xu , Gerd Hoffmann , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" User-mode emulation doesn't need the fw_cfg stub. Signed-off-by: Philippe Mathieu-Daudé --- hw/nvram/meson.build | 6 ++++-- stubs/meson.build | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/nvram/meson.build b/hw/nvram/meson.build index 202a5466e63..f5ee9f6b88c 100644 --- a/hw/nvram/meson.build +++ b/hw/nvram/meson.build @@ -1,5 +1,7 @@ -# QOM interfaces must be available anytime QOM is used. -qom_ss.add(files('fw_cfg-interface.c')) +if have_system or have_tools + # QOM interfaces must be available anytime QOM is used. + qom_ss.add(files('fw_cfg-interface.c')) +endif softmmu_ss.add(files('fw_cfg.c')) softmmu_ss.add(when: 'CONFIG_CHRP_NVRAM', if_true: files('chrp_nvram.c')) diff --git a/stubs/meson.build b/stubs/meson.build index 71469c1d50a..363f6fa785d 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -11,7 +11,6 @@ stub_ss.add(files('dump.c')) stub_ss.add(files('error-printf.c')) stub_ss.add(files('fdset.c')) -stub_ss.add(files('fw_cfg.c')) stub_ss.add(files('gdbstub.c')) stub_ss.add(files('get-vm-name.c')) if linux_io_uring.found() @@ -51,6 +50,7 @@ stub_ss.add(files('replay-tools.c')) endif if have_system + stub_ss.add(files('fw_cfg.c')) stub_ss.add(files('semihost.c')) stub_ss.add(files('usb-dev-stub.c')) stub_ss.add(files('xen-hw-stub.c')) From patchwork Fri Dec 31 11:48:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12701930 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 56B10C433F5 for ; Fri, 31 Dec 2021 11:58:10 +0000 (UTC) Received: from localhost ([::1]:47230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n3GXx-0006J8-Am for qemu-devel@archiver.kernel.org; Fri, 31 Dec 2021 06:58:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3GPR-0002Zy-9R for qemu-devel@nongnu.org; Fri, 31 Dec 2021 06:49:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28687) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3GPL-0000IP-Np for qemu-devel@nongnu.org; Fri, 31 Dec 2021 06:49:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640951354; 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=3SyegUav7Y4rfG22z5S0cm0XRrlspgF1hM8sq9A6HmQ=; b=X/8hKWl4RdBR95amu7mCwIJCxlAbFiVvSuwyE6g5dly1alGB5wFI5ze/59XBgS+bapda9B OTdjnPo1d0IVToKhV+jN9wnqqy2lYO69XRssTjlIwB2PN/AdOSuXsxvVeixDUsRV9v/oiT uOldwiDSMqF2GEsw4GoIodqmoWPoqYQ= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-262-jVOvh2RRPD64G1ppJbcc2g-1; Fri, 31 Dec 2021 06:49:13 -0500 X-MC-Unique: jVOvh2RRPD64G1ppJbcc2g-1 Received: by mail-wr1-f72.google.com with SMTP id r7-20020adfbb07000000b001a254645f13so7528939wrg.7 for ; Fri, 31 Dec 2021 03:49:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3SyegUav7Y4rfG22z5S0cm0XRrlspgF1hM8sq9A6HmQ=; b=oQVKCmHRA+Wub3tG+GYkRNN/A0iupEwYtOOSzareFBjLJV1Z241w54omfssYPBoY1F GfZ6ll0V1pQ/0t5nWfyhqf4HQKcS117Txm75yEhifgz481Z8KkPTUvF1JRTl495BZZwl HSYxi6FxS/ykWj3M1QW9E7nwFekncjzcpcvIMQuhEpVDLrrJ5ouBfLd0I3+eWpyBkiVY eP5He2JdyzIOPCaA4c8EQ0WCTqUD8tupx5e2kKtucaFy+OTnJVlj1ZwoKYFPa2K7/HJt duwRwBfGxEDShK5xSnLe96CqIpEVrR6HpHAVan5rrbb3fQ3FlMJejSCw2bLyoStwc5Iw /Azg== X-Gm-Message-State: AOAM530MWXuEgpI9xw6QZfQWGVNd/xaDxHiSnaqgPbFiNGlQ/zLf9CAf TsEyzAQW7cFlzJyqv79h9UtLIx/NAAOzLH8JO+W3AHF0+gg0t+aGyk1A3drNvds83h2E+6DJw1b t+MideRPQ7WE2danSqS4weotYYLT40cnsZpTTtZ+mPGOV3GmUshi+dBFAO+dH9l84 X-Received: by 2002:adf:d1e5:: with SMTP id g5mr28819452wrd.94.1640951352411; Fri, 31 Dec 2021 03:49:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZuvmwQBmcyP5Iini/Kdf7lPa55OIBxKp8Z4wbQBcBNLjJNM2vSXfxFZbF8YsVxbsifrcAZQ== X-Received: by 2002:adf:d1e5:: with SMTP id g5mr28819430wrd.94.1640951352192; Fri, 31 Dec 2021 03:49:12 -0800 (PST) Received: from x1w.redhat.com (26.red-83-50-86.dynamicip.rima-tde.net. [83.50.86.26]) by smtp.gmail.com with ESMTPSA id m21sm25219027wrb.2.2021.12.31.03.49.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Dec 2021 03:49:11 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 2/8] hw/pci: Restrict pci-bus stub to sysemu Date: Fri, 31 Dec 2021 12:48:55 +0100 Message-Id: <20211231114901.976937-3-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211231114901.976937-1-philmd@redhat.com> References: <20211231114901.976937-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) DKIMWL_WL_HIGH=-0.573, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , David Hildenbrand , Peter Xu , Gerd Hoffmann , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Neither tools nor user-mode emulation require the PCI bus stub. Signed-off-by: Philippe Mathieu-Daudé --- stubs/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/meson.build b/stubs/meson.build index 363f6fa785d..d359cbe1ad7 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -26,7 +26,6 @@ stub_ss.add(files('module-opts.c')) stub_ss.add(files('monitor.c')) stub_ss.add(files('monitor-core.c')) -stub_ss.add(files('pci-bus.c')) stub_ss.add(files('qemu-timer-notify-cb.c')) stub_ss.add(files('qmp_memory_device.c')) stub_ss.add(files('qmp-command-available.c')) @@ -51,6 +50,7 @@ endif if have_system stub_ss.add(files('fw_cfg.c')) + stub_ss.add(files('pci-bus.c')) stub_ss.add(files('semihost.c')) stub_ss.add(files('usb-dev-stub.c')) stub_ss.add(files('xen-hw-stub.c')) From patchwork Fri Dec 31 11:48:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12701922 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E3619C433EF for ; Fri, 31 Dec 2021 11:51:31 +0000 (UTC) Received: from localhost ([::1]:60894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n3GRW-0004i4-MQ for qemu-devel@archiver.kernel.org; Fri, 31 Dec 2021 06:51:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3GPT-0002cg-5T for qemu-devel@nongnu.org; Fri, 31 Dec 2021 06:49:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37968) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3GPR-0000Im-0C for qemu-devel@nongnu.org; Fri, 31 Dec 2021 06:49:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640951359; 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=/KXeNIFUnY1pUcNuTPWkGRZ5r1qlFjH4izW6QJgPWUg=; b=Wjpc7D1sLGhLo6b2hgwVi+9y+C6EMYuNRqreOynpirAWxh90XCNEv8BniMnBZHf/4gphwJ 9OmdpO+t1P5y82lKj9J3o6rm2ap7LBXJ0Za4rNbZ3yAMaVylCI6fftwNbwIBi25HzFq39u OHHJ1caUqUzQ6DrManqh6T9us0Xnzec= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-1eSpgmkPPp-RxToZ7G4hAA-1; Fri, 31 Dec 2021 06:49:18 -0500 X-MC-Unique: 1eSpgmkPPp-RxToZ7G4hAA-1 Received: by mail-wm1-f72.google.com with SMTP id b83-20020a1c1b56000000b0033283ea5facso4544802wmb.1 for ; Fri, 31 Dec 2021 03:49:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/KXeNIFUnY1pUcNuTPWkGRZ5r1qlFjH4izW6QJgPWUg=; b=7/YXKnGTmUH8eYx9xaztFtztd+WMJWPcjGpDgOwL6Xomh/U3CrnrDFfKA1BN/sFObw VDr4GeTxO8U6rhNOl6NeUg/DQPH4v+GVqhaS7VNOEtAPO3L9O2OWOR5TC1PKkRGVfIqK +O71Ssw+TQRpqoDP4iuU3wSLUiglFYfwQmL8QMtWo42iJsUL/Z/h0Bz5qsKSqvymmx/W 5mXRCC1+Z+Uz0Ky6PT5dxXxRcIkDUgjYV2VkV9/aJvKAg6/lJX9muf0D4/GQlz1iOleH Yl4Nx3s7dC6BSHw0U0ZV2i5yKZfIDiL6M4rDcipHVxZJVn4DoB4UwygSlR1RSq1fflZu SawQ== X-Gm-Message-State: AOAM530hHfdz+9KVPlOQEGY1h8WiLAb2vilLsg96GMVMqDMhLcSnvCSO WqG7eQW/8l4S0eWhpH6+4QJ++n9mQyUUMYkUA9UAewObNm0U43XaJbeIWbll7WT/jAPLvsnf+SH SK6xsgKMRfc5jbVZRPdHNtt3zxDS9qg00AEyoFk9LDUjZOIK0bL+49hZg6JQy5cNQ X-Received: by 2002:a05:6000:1085:: with SMTP id y5mr29841588wrw.696.1640951356784; Fri, 31 Dec 2021 03:49:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJ0MH1adbramq6Rx/LSJHzXDf5WIu2+OFf7IbTHinEeLWq3jsFk+YmaSZE0hFzSmOw/pqLlA== X-Received: by 2002:a05:6000:1085:: with SMTP id y5mr29841565wrw.696.1640951356595; Fri, 31 Dec 2021 03:49:16 -0800 (PST) Received: from x1w.redhat.com (26.red-83-50-86.dynamicip.rima-tde.net. [83.50.86.26]) by smtp.gmail.com with ESMTPSA id p21sm27122889wmq.20.2021.12.31.03.49.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Dec 2021 03:49:16 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 3/8] hw/pci: Document pci_dma_map() Date: Fri, 31 Dec 2021 12:48:56 +0100 Message-Id: <20211231114901.976937-4-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211231114901.976937-1-philmd@redhat.com> References: <20211231114901.976937-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) DKIMWL_WL_HIGH=-0.573, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , David Hildenbrand , Peter Xu , Gerd Hoffmann , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 5b36334a28a..f0d707efb8c 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -876,6 +876,18 @@ PCI_DMA_DEFINE_LDST(q_be, q_be, 64); #undef PCI_DMA_DEFINE_LDST +/** + * pci_dma_map: Map a physical memory region into a device PCI address space. + * + * May map a subset of the requested range, given by and returned in @plen. + * May return %NULL and set *@plen to zero(0), if resources needed to perform + * the mapping are exhausted. + * + * @dev: #PCIDevice to be accessed + * @addr: address within that device's address space + * @plen: pointer to length of buffer; updated on return + * @dir: indicates the transfer direction + */ static inline void *pci_dma_map(PCIDevice *dev, dma_addr_t addr, dma_addr_t *plen, DMADirection dir) { From patchwork Fri Dec 31 11:48:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12701923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37DCEC433FE for ; Fri, 31 Dec 2021 11:51:32 +0000 (UTC) Received: from localhost ([::1]:32782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n3GRX-0004op-9g for qemu-devel@archiver.kernel.org; Fri, 31 Dec 2021 06:51:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3GPW-0002eA-CW for qemu-devel@nongnu.org; Fri, 31 Dec 2021 06:49:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24824) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3GPU-0000JF-Qk for qemu-devel@nongnu.org; Fri, 31 Dec 2021 06:49:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640951363; 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=wE876U4co5d7p9CIe8hQXrALAIoZI1O45edviYMOfa0=; b=anw+/YjFY0lFKqoil5uZFhlmvAzHtaa+ZMjfklu3cWiZp1Fkd3qzGkDOY4jXEyyzQPCpvN KVXnuKHt1LFnvMxW3eHnOe6q64MB/bZdwFxKryZGof8EG9Ojy2PUNFS7sWxXboiIFtaXyQ lBTxa5z6pc36heGnhlZKgRJPAq7U/48= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-453-2mn_A6UNM5SIfpUdsj3lMQ-1; Fri, 31 Dec 2021 06:49:22 -0500 X-MC-Unique: 2mn_A6UNM5SIfpUdsj3lMQ-1 Received: by mail-wr1-f71.google.com with SMTP id q21-20020adfab15000000b001a24b36e47eso7438641wrc.2 for ; Fri, 31 Dec 2021 03:49:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wE876U4co5d7p9CIe8hQXrALAIoZI1O45edviYMOfa0=; b=VDYER4X0q7xYUBJe3gqp/ML+e+ZLMcwOGKTjQN005si1cD4yFrLKp+0lVeQOA8RWJG NJJ/zkL+fxomtQ9bWjamayySfKRklFWxoN5VxVbOV3OzgJxTvu2M/CbA37PCssnyrrp7 /7z4Pj0KOaPRHjoc2a+tMECaZzaOAKeA5oYOpQc+mDvGotNQJgDvY4NEoVNhvjiFfYwz zRN85CO75bhKcRq7h3Z8HAAfx18x8/i0+BqH4WCGrqk3trvhAbYBtSmtsb8xQiLt7uRi Jfy2Ei5WoqUUkpy2yvSxNVQUleOV/v+NSWVpN51hNT5c6KGcJKodtDKnxW/eE+MntO7L KyTA== X-Gm-Message-State: AOAM530BKqfJ8D21vXSognNCya9NDwWiv2JZZ9OMv2PtU1RyA79t730k GXBsaLEFTNNW93QA6inuPQgNnjdMbJG23KuWEiwI0KkmxJFf02rF6GU8ODN4SIXIYBoJXwIcA5V idz15+B9kBnyEk5ftxys0KgZ6epr53SS/9K1EggH2bwmT1jfac1H437Pcwol545T+ X-Received: by 2002:a5d:59a7:: with SMTP id p7mr28725175wrr.258.1640951361314; Fri, 31 Dec 2021 03:49:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVhucnXHOV0IsRs6rCE30ye6CzRZ+G0PvrOs/WcOL/mG4e5/HH8kMeMAmq+JlOxXCqJwdyDA== X-Received: by 2002:a5d:59a7:: with SMTP id p7mr28725150wrr.258.1640951361047; Fri, 31 Dec 2021 03:49:21 -0800 (PST) Received: from x1w.redhat.com (26.red-83-50-86.dynamicip.rima-tde.net. [83.50.86.26]) by smtp.gmail.com with ESMTPSA id b19sm31281895wmb.38.2021.12.31.03.49.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Dec 2021 03:49:20 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 4/8] hw/dma: Remove CONFIG_USER_ONLY check Date: Fri, 31 Dec 2021 12:48:57 +0100 Message-Id: <20211231114901.976937-5-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211231114901.976937-1-philmd@redhat.com> References: <20211231114901.976937-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) DKIMWL_WL_HIGH=-0.573, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , David Hildenbrand , Peter Xu , Gerd Hoffmann , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" DMA API should not be included in user-mode emulation. If so, build should fail. Remove the CONFIG_USER_ONLY check. Signed-off-by: Philippe Mathieu-Daudé --- include/sysemu/dma.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index b3faef41b2f..0db2478a506 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -31,8 +31,6 @@ struct QEMUSGList { AddressSpace *as; }; -#ifndef CONFIG_USER_ONLY - /* * When an IOMMU is present, bus addresses become distinct from * CPU/memory physical addresses and may be a different size. Because @@ -288,7 +286,6 @@ void qemu_sglist_init(QEMUSGList *qsg, DeviceState *dev, int alloc_hint, AddressSpace *as); void qemu_sglist_add(QEMUSGList *qsg, dma_addr_t base, dma_addr_t len); void qemu_sglist_destroy(QEMUSGList *qsg); -#endif typedef BlockAIOCB *DMAIOFunc(int64_t offset, QEMUIOVector *iov, BlockCompletionFunc *cb, void *cb_opaque, From patchwork Fri Dec 31 11:48:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12701927 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 275F4C433F5 for ; Fri, 31 Dec 2021 11:54:55 +0000 (UTC) Received: from localhost ([::1]:40540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n3GUo-0001aE-5x for qemu-devel@archiver.kernel.org; Fri, 31 Dec 2021 06:54:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3GPZ-0002gb-RS for qemu-devel@nongnu.org; Fri, 31 Dec 2021 06:49:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:26928) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3GPY-0000Jp-DJ for qemu-devel@nongnu.org; Fri, 31 Dec 2021 06:49:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640951367; 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=s1gWXzHHA08XyBDnum+yCmIoN801ZHiVaEGOwmKagUU=; b=ABH04GNglu3j6Lq4pGtyi5DMAD+CPh6ehvvfAK/YQpNNWVBDJA0FQd79WKAD9lm/+66sz8 1QFSYhI7yFoLLQBRMSZE6J7nyqXBeOvxYdBRAOVlQZCKGWMORkdUZyMHM1bCk/EWR9BJqR edwtU9oz6PXHihCvipSHTRVrtTLwRx0= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-193-PrDHAPf6Ofac7ZZ728YxpQ-1; Fri, 31 Dec 2021 06:49:26 -0500 X-MC-Unique: PrDHAPf6Ofac7ZZ728YxpQ-1 Received: by mail-wr1-f69.google.com with SMTP id f13-20020adfe90d000000b001a15c110077so7446593wrm.8 for ; Fri, 31 Dec 2021 03:49:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s1gWXzHHA08XyBDnum+yCmIoN801ZHiVaEGOwmKagUU=; b=UX9+mrB3ZwDqSqB+1TYX9KEDNJxJ1VNhjSM5FCpecucvf2G8gAhyhUwZXrVKzHkP4/ XL/rnwX/4Jpt6tk5rWMsxLLkWnaTHAbNxYVFWMpIcoEIci8v6JTgYUsLr934VCJpbbOZ 7RwrlAVjkGgkrZCCymJbpN0CCieB+k596g1/wXz8oMGFjI8l71m5asyD96m72216iY0N bXcA7djPMhmoqnQO+xVythafK2CmdAsmnSg8YxtmmCxosk/6O4a9h7i1x1oRNjLARbGx 02Wy4wYXPRK8e6gTW8HNhRqRZnQ9NSXOiTaGbAWBdIH5E2mZL3OsgDf0hJmPM409wMxd QQIw== X-Gm-Message-State: AOAM531f/qHTXB5wxFYYYuanx8Ik1diMTy4Vpgl/Ipa+mrWVG0CVWJ65 JVBLRyst+eqIffFjjCQhowSmBrnYCEx4LjI3/9lirzJaPsxxgiFuF5wZsCbV2vaAkjOn8e2hngl iF1YZVAtvdrT4dU8qJLPdzyS44BFRDTrNkSXE0Z6O1DFJWZjApzSO3eIx/1I2/2pd X-Received: by 2002:a5d:6c67:: with SMTP id r7mr30217561wrz.350.1640951365627; Fri, 31 Dec 2021 03:49:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJzk1PB0CJ5V9w98GPEgQGppaZfUg+L1brKLinrifqfcLoq4u//4eSk3Tj3jBGG9MHrHO+v/9Q== X-Received: by 2002:a5d:6c67:: with SMTP id r7mr30217546wrz.350.1640951365458; Fri, 31 Dec 2021 03:49:25 -0800 (PST) Received: from x1w.redhat.com (26.red-83-50-86.dynamicip.rima-tde.net. [83.50.86.26]) by smtp.gmail.com with ESMTPSA id p18sm37592945wmq.0.2021.12.31.03.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Dec 2021 03:49:25 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 5/8] hw/rdma/rdma_utils: Rename rdma_pci_dma_map 'len' argument Date: Fri, 31 Dec 2021 12:48:58 +0100 Message-Id: <20211231114901.976937-6-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211231114901.976937-1-philmd@redhat.com> References: <20211231114901.976937-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) DKIMWL_WL_HIGH=-0.573, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , David Hildenbrand , Peter Xu , Gerd Hoffmann , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Various APIs use 'pval' naming for 'pointer to val'. rdma_pci_dma_map() uses 'plen' for 'PCI length', but since 'PCI' is already explicit in the function name, simplify and rename the argument 'len'. No logical change. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Yuval Shaia Tested-by: Yuval Shaia --- hw/rdma/rdma_utils.h | 2 +- hw/rdma/rdma_utils.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/rdma/rdma_utils.h b/hw/rdma/rdma_utils.h index 9fd0efd940b..0c6414e7e0a 100644 --- a/hw/rdma/rdma_utils.h +++ b/hw/rdma/rdma_utils.h @@ -38,7 +38,7 @@ typedef struct RdmaProtectedGSList { GSList *list; } RdmaProtectedGSList; -void *rdma_pci_dma_map(PCIDevice *dev, dma_addr_t addr, dma_addr_t plen); +void *rdma_pci_dma_map(PCIDevice *dev, dma_addr_t addr, dma_addr_t len); void rdma_pci_dma_unmap(PCIDevice *dev, void *buffer, dma_addr_t len); void rdma_protected_gqueue_init(RdmaProtectedGQueue *list); void rdma_protected_gqueue_destroy(RdmaProtectedGQueue *list); diff --git a/hw/rdma/rdma_utils.c b/hw/rdma/rdma_utils.c index 98df58f6897..61cb8ede0fd 100644 --- a/hw/rdma/rdma_utils.c +++ b/hw/rdma/rdma_utils.c @@ -17,29 +17,29 @@ #include "trace.h" #include "rdma_utils.h" -void *rdma_pci_dma_map(PCIDevice *dev, dma_addr_t addr, dma_addr_t plen) +void *rdma_pci_dma_map(PCIDevice *dev, dma_addr_t addr, dma_addr_t len) { void *p; - hwaddr len = plen; + hwaddr pci_len = len; if (!addr) { rdma_error_report("addr is NULL"); return NULL; } - p = pci_dma_map(dev, addr, &len, DMA_DIRECTION_TO_DEVICE); + p = pci_dma_map(dev, addr, &pci_len, DMA_DIRECTION_TO_DEVICE); if (!p) { rdma_error_report("pci_dma_map fail, addr=0x%"PRIx64", len=%"PRId64, - addr, len); + addr, pci_len); return NULL; } - if (len != plen) { - rdma_pci_dma_unmap(dev, p, len); + if (pci_len != len) { + rdma_pci_dma_unmap(dev, p, pci_len); return NULL; } - trace_rdma_pci_dma_map(addr, p, len); + trace_rdma_pci_dma_map(addr, p, pci_len); return p; } From patchwork Fri Dec 31 11:48:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12701932 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E5F13C433F5 for ; Fri, 31 Dec 2021 12:02:27 +0000 (UTC) Received: from localhost ([::1]:53234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n3Gc6-0002Cf-Ap for qemu-devel@archiver.kernel.org; Fri, 31 Dec 2021 07:02:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3GPy-000357-G4 for qemu-devel@nongnu.org; Fri, 31 Dec 2021 06:49:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37846) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3GPv-0000LB-2a for qemu-devel@nongnu.org; Fri, 31 Dec 2021 06:49:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640951390; 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=zc7qbwDFORfvzaOFgdWHz84wTbYxgE4ItWWUjM2vJzI=; b=Rh9dzfnBKPx1YxLpE5Ax887lAOfXg5d8Cpjwd1MJmE6SNPYtUMKRjdsqI7aQjDRWqNVYJD qUzFELR1hGJcNDG/r+k6ZeCUpeDlKdNMHeZszmwlfzVItg+MWunT2jJh535FNEZ1FSoKTM gmBFclw6RP/C7kC0J8mEI1JlpHf3eaI= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-394-7yhs7o33N8e57s5Roo2iXw-1; Fri, 31 Dec 2021 06:49:33 -0500 X-MC-Unique: 7yhs7o33N8e57s5Roo2iXw-1 Received: by mail-wr1-f72.google.com with SMTP id r7-20020adfbb07000000b001a254645f13so7529183wrg.7 for ; Fri, 31 Dec 2021 03:49:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zc7qbwDFORfvzaOFgdWHz84wTbYxgE4ItWWUjM2vJzI=; b=btpSJHnozcgCMMEYwF+RYU8ZmSIkBR6aZU7CTHyLrZ3ArmdOvD87pmLZU4wo0B+cyM GvvwOh5/J6/N+YgL2lWI6XKbOe1/085MoOw6WbBv7HXkTR7H7GAMuXNGxHHeT9TtlUM8 paasiUOVhHPQIV+5RnWSJM/Pa/qI7eWJzdTHQxnVWt6yuBKag8o8L+ImU/aA8yGKRnIQ 8Rih6UBQaieY6G9WR8r7AB8Gq1liUEibPGhaz8AS8GuTMs0WmtwgJyC3klUNHjW3gEaK uPtDULNr/O9OPAiYvD4Ls5kxLyqluwiGLf3qHaWCoFDoAjoE/Snxngy3cdDSqljsysEZ zpwA== X-Gm-Message-State: AOAM5330UuW4vpSgRf/hKdLEel80rDdbJGQ9eYl1+rt2tqZP7cO8oc+a bFyQKHlo/libNEDVpq9oh/H1Tj9pWXUU8hYm7nNDJCI6ijZTOTumxnVuWMISVA31C/x8w608ona /7wwMOunOJDji0e/QjMHnMB8IBrUa951wJ8eycuGDuw0z9dDW4vB/CJKYgQij+YSo X-Received: by 2002:a1c:1dc9:: with SMTP id d192mr29894733wmd.95.1640951371006; Fri, 31 Dec 2021 03:49:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwh0MshaBZaWtcRc6fHWdv+TupxL0BpQwFByB51qvYil02BDqRkWkTGpzjhkcV6D+CEgQQLg== X-Received: by 2002:a1c:1dc9:: with SMTP id d192mr29894672wmd.95.1640951369819; Fri, 31 Dec 2021 03:49:29 -0800 (PST) Received: from x1w.redhat.com (26.red-83-50-86.dynamicip.rima-tde.net. [83.50.86.26]) by smtp.gmail.com with ESMTPSA id o38sm24808178wms.11.2021.12.31.03.49.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Dec 2021 03:49:29 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 6/8] hw/scsi: Rename SCSIRequest::resid as 'residual' Date: Fri, 31 Dec 2021 12:48:59 +0100 Message-Id: <20211231114901.976937-7-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211231114901.976937-1-philmd@redhat.com> References: <20211231114901.976937-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) DKIMWL_WL_HIGH=-0.573, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , David Hildenbrand , Peter Xu , Gerd Hoffmann , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The 'resid' field is slightly confusing and could be interpreted as some ID. Rename it as 'residual' which is clearer to review. No logical change. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/scsi/scsi.h | 4 ++-- hw/scsi/megasas.c | 42 +++++++++++++++++++++++++----------------- hw/scsi/scsi-bus.c | 10 +++++----- hw/scsi/scsi-disk.c | 4 ++-- softmmu/dma-helpers.c | 26 +++++++++++++------------- 5 files changed, 47 insertions(+), 39 deletions(-) diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index 2ef80af6dca..b27d133b113 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -30,7 +30,7 @@ struct SCSIRequest { int16_t status; int16_t host_status; void *hba_private; - size_t resid; + size_t residual; SCSICommand cmd; NotifierList cancel_notifiers; @@ -125,7 +125,7 @@ struct SCSIBusInfo { void *hba_private); void (*transfer_data)(SCSIRequest *req, uint32_t arg); void (*fail)(SCSIRequest *req); - void (*complete)(SCSIRequest *req, size_t resid); + void (*complete)(SCSIRequest *req, size_t residual); void (*cancel)(SCSIRequest *req); void (*change)(SCSIBus *bus, SCSIDevice *dev, SCSISense sense); QEMUSGList *(*get_sg_list)(SCSIRequest *req); diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index dc9bbdb740e..cb019549371 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -1045,7 +1045,8 @@ static int megasas_pd_get_info_submit(SCSIDevice *sdev, int lun, uint64_t pd_size; uint16_t pd_id = ((sdev->id & 0xFF) << 8) | (lun & 0xFF); uint8_t cmdbuf[6]; - size_t len, resid; + size_t len; + size_t residual; if (!cmd->iov_buf) { cmd->iov_buf = g_malloc0(dcmd_size); @@ -1112,9 +1113,10 @@ static int megasas_pd_get_info_submit(SCSIDevice *sdev, int lun, info->connected_port_bitmap = 0x1; info->device_speed = 1; info->link_speed = 1; - resid = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + residual = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); g_free(cmd->iov_buf); - cmd->iov_size = dcmd_size - resid; + cmd->iov_size = dcmd_size - residual; cmd->iov_buf = NULL; return MFI_STAT_OK; } @@ -1149,7 +1151,8 @@ static int megasas_dcmd_pd_get_info(MegasasState *s, MegasasCmd *cmd) static int megasas_dcmd_ld_get_list(MegasasState *s, MegasasCmd *cmd) { struct mfi_ld_list info; - size_t dcmd_size = sizeof(info), resid; + size_t dcmd_size = sizeof(info); + size_t residual; uint32_t num_ld_disks = 0, max_ld_disks; uint64_t ld_size; BusChild *kid; @@ -1184,8 +1187,9 @@ static int megasas_dcmd_ld_get_list(MegasasState *s, MegasasCmd *cmd) info.ld_count = cpu_to_le32(num_ld_disks); trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks); - resid = dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); - cmd->iov_size = dcmd_size - resid; + residual = dma_buf_read(&info, dcmd_size, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); + cmd->iov_size = dcmd_size - residual; return MFI_STAT_OK; } @@ -1193,7 +1197,8 @@ static int megasas_dcmd_ld_list_query(MegasasState *s, MegasasCmd *cmd) { uint16_t flags; struct mfi_ld_targetid_list info; - size_t dcmd_size = sizeof(info), resid; + size_t dcmd_size = sizeof(info); + size_t residual; uint32_t num_ld_disks = 0, max_ld_disks = s->fw_luns; BusChild *kid; @@ -1233,8 +1238,9 @@ static int megasas_dcmd_ld_list_query(MegasasState *s, MegasasCmd *cmd) info.size = dcmd_size; trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks); - resid = dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); - cmd->iov_size = dcmd_size - resid; + residual = dma_buf_read(&info, dcmd_size, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); + cmd->iov_size = dcmd_size - residual; return MFI_STAT_OK; } @@ -1244,7 +1250,8 @@ static int megasas_ld_get_info_submit(SCSIDevice *sdev, int lun, struct mfi_ld_info *info = cmd->iov_buf; size_t dcmd_size = sizeof(struct mfi_ld_info); uint8_t cdb[6]; - ssize_t len, resid; + ssize_t len; + size_t residual; uint16_t sdev_id = ((sdev->id & 0xFF) << 8) | (lun & 0xFF); uint64_t ld_size; @@ -1283,9 +1290,10 @@ static int megasas_ld_get_info_submit(SCSIDevice *sdev, int lun, info->ld_config.span[0].num_blocks = info->size; info->ld_config.span[0].array_ref = cpu_to_le16(sdev_id); - resid = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + residual = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); g_free(cmd->iov_buf); - cmd->iov_size = dcmd_size - resid; + cmd->iov_size = dcmd_size - residual; cmd->iov_buf = NULL; return MFI_STAT_OK; } @@ -1617,13 +1625,13 @@ static int megasas_handle_dcmd(MegasasState *s, MegasasCmd *cmd) } static int megasas_finish_internal_dcmd(MegasasCmd *cmd, - SCSIRequest *req, size_t resid) + SCSIRequest *req, size_t residual) { int retval = MFI_STAT_OK; int lun = req->lun; trace_megasas_dcmd_internal_finish(cmd->index, cmd->dcmd_opcode, lun); - cmd->iov_size -= resid; + cmd->iov_size -= residual; switch (cmd->dcmd_opcode) { case MFI_DCMD_PD_GET_INFO: retval = megasas_pd_get_info_submit(req->dev, lun, cmd); @@ -1865,12 +1873,12 @@ static void megasas_xfer_complete(SCSIRequest *req, uint32_t len) } } -static void megasas_command_complete(SCSIRequest *req, size_t resid) +static void megasas_command_complete(SCSIRequest *req, size_t residual) { MegasasCmd *cmd = req->hba_private; uint8_t cmd_status = MFI_STAT_OK; - trace_megasas_command_complete(cmd->index, req->status, resid); + trace_megasas_command_complete(cmd->index, req->status, residual); if (req->io_canceled) { return; @@ -1880,7 +1888,7 @@ static void megasas_command_complete(SCSIRequest *req, size_t resid) /* * Internal command complete */ - cmd_status = megasas_finish_internal_dcmd(cmd, req, resid); + cmd_status = megasas_finish_internal_dcmd(cmd, req, residual); if (cmd_status == MFI_STAT_INVALID_STATUS) { return; } diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 2b5e9dca311..3466e680ac7 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -760,7 +760,7 @@ SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun, } req->cmd = cmd; - req->resid = req->cmd.xfer; + req->residual = req->cmd.xfer; switch (buf[0]) { case INQUIRY: @@ -1408,7 +1408,7 @@ void scsi_req_data(SCSIRequest *req, int len) trace_scsi_req_data(req->dev->id, req->lun, req->tag, len); assert(req->cmd.mode != SCSI_XFER_NONE); if (!req->sg) { - req->resid -= len; + req->residual -= len; req->bus->info->transfer_data(req, len); return; } @@ -1421,9 +1421,9 @@ void scsi_req_data(SCSIRequest *req, int len) buf = scsi_req_get_buf(req); if (req->cmd.mode == SCSI_XFER_FROM_DEV) { - req->resid = dma_buf_read(buf, len, req->sg, MEMTXATTRS_UNSPECIFIED); + req->residual = dma_buf_read(buf, len, req->sg, MEMTXATTRS_UNSPECIFIED); } else { - req->resid = dma_buf_write(buf, len, req->sg, MEMTXATTRS_UNSPECIFIED); + req->residual = dma_buf_write(buf, len, req->sg, MEMTXATTRS_UNSPECIFIED); } scsi_req_continue(req); } @@ -1512,7 +1512,7 @@ void scsi_req_complete(SCSIRequest *req, int status) scsi_req_ref(req); scsi_req_dequeue(req); - req->bus->info->complete(req, req->resid); + req->bus->info->complete(req, req->residual); /* Cancelled requests might end up being completed instead of cancelled */ notifier_list_notify(&req->cancel_notifiers, req); diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index d4914178ea0..9c0dc7b9468 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -420,7 +420,7 @@ static void scsi_do_read(SCSIDiskReq *r, int ret) if (r->req.sg) { dma_acct_start(s->qdev.conf.blk, &r->acct, r->req.sg, BLOCK_ACCT_READ); - r->req.resid -= r->req.sg->size; + r->req.residual -= r->req.sg->size; r->req.aiocb = dma_blk_io(blk_get_aio_context(s->qdev.conf.blk), r->req.sg, r->sector << BDRV_SECTOR_BITS, BDRV_SECTOR_SIZE, @@ -580,7 +580,7 @@ static void scsi_write_data(SCSIRequest *req) if (r->req.sg) { dma_acct_start(s->qdev.conf.blk, &r->acct, r->req.sg, BLOCK_ACCT_WRITE); - r->req.resid -= r->req.sg->size; + r->req.residual -= r->req.sg->size; r->req.aiocb = dma_blk_io(blk_get_aio_context(s->qdev.conf.blk), r->req.sg, r->sector << BDRV_SECTOR_BITS, BDRV_SECTOR_SIZE, diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c index b0be1564797..4563a775aa7 100644 --- a/softmmu/dma-helpers.c +++ b/softmmu/dma-helpers.c @@ -294,49 +294,49 @@ BlockAIOCB *dma_blk_write(BlockBackend *blk, } -static MemTxResult dma_buf_rw(void *buf, int32_t len, uint64_t *residp, +static MemTxResult dma_buf_rw(void *buf, int32_t len, uint64_t *residual, QEMUSGList *sg, DMADirection dir, MemTxAttrs attrs) { uint8_t *ptr = buf; - uint64_t resid; + uint64_t xresidual; int sg_cur_index; MemTxResult res = MEMTX_OK; - resid = sg->size; + xresidual = sg->size; sg_cur_index = 0; - len = MIN(len, resid); + len = MIN(len, xresidual); while (len > 0) { ScatterGatherEntry entry = sg->sg[sg_cur_index++]; int32_t xfer = MIN(len, entry.len); res |= dma_memory_rw(sg->as, entry.base, ptr, xfer, dir, attrs); ptr += xfer; len -= xfer; - resid -= xfer; + xresidual -= xfer; } - if (residp) { - *residp = resid; + if (residual) { + *residual = xresidual; } return res; } uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs) { - uint64_t resid; + uint64_t residual; - dma_buf_rw(ptr, len, &resid, sg, DMA_DIRECTION_FROM_DEVICE, attrs); + dma_buf_rw(ptr, len, &residual, sg, DMA_DIRECTION_FROM_DEVICE, attrs); - return resid; + return residual; } uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs) { - uint64_t resid; + uint64_t residual; - dma_buf_rw(ptr, len, &resid, sg, DMA_DIRECTION_TO_DEVICE, attrs); + dma_buf_rw(ptr, len, &residual, sg, DMA_DIRECTION_TO_DEVICE, attrs); - return resid; + return residual; } void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie, From patchwork Fri Dec 31 11:49:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12701931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1780FC433F5 for ; Fri, 31 Dec 2021 11:58:23 +0000 (UTC) Received: from localhost ([::1]:47666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n3GYA-0006bo-Qh for qemu-devel@archiver.kernel.org; Fri, 31 Dec 2021 06:58:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3GPl-0002xh-R9 for qemu-devel@nongnu.org; Fri, 31 Dec 2021 06:49:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43955) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3GPj-0000KN-3S for qemu-devel@nongnu.org; Fri, 31 Dec 2021 06:49:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640951378; 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=VWOQCoOQErbEn0u8LJsn620oYxNKcQdFiEhqtenCnB4=; b=aMZrLbu2STCz6WnO8fyfiOvb4toTx8kgBVNrMratsaDQNyG0hxQ+p2h1SyWZHm7UJEpRpv f3J63e3/tPX7e64Xn7gdarwiF3uKXrU0pJfvzvSjxNJAz62paLCmCn2PD1bv9EwlA7CZFY rZmByMAP0WM9dZ6My1bEzSwpH7ls03Q= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-31-V3_WAHklMRepBSojx4Aldg-1; Fri, 31 Dec 2021 06:49:37 -0500 X-MC-Unique: V3_WAHklMRepBSojx4Aldg-1 Received: by mail-wr1-f69.google.com with SMTP id r7-20020adfbb07000000b001a254645f13so7529238wrg.7 for ; Fri, 31 Dec 2021 03:49:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VWOQCoOQErbEn0u8LJsn620oYxNKcQdFiEhqtenCnB4=; b=4SGmC+kVQsaldTKNblBBXsiiV7byvyG82zUsaAytQRaU4XSmBvMYrUrv98reQdjktc FMc356Wk98MU99XQnqsxzoMiv//dSNSsH0zjA7lPjZE7EafpRKfKYq73EHuw4LpR1L3i uW7rCxK0SX4GRklSxUY7lsYJ5W05nIKGxEcq0cdZ/eiCxhlDHJGzpS53UdIYT3NJXgIh mSxJzOCFi68WP44xHXq2csd9R4DT1mXiipX9fbSrKQ8lwrPdZFhlUwn+jXnoAn2W0usz qOM5AjhTw1TXjS9DZbS0qdoP4X3necq7OiUT69FvIacTAXKKEgYdY+r8zLU5DQBbI9cz 5MZg== X-Gm-Message-State: AOAM530E39aYYsz8Q4Y6NCPZzBHilqXALWuF3+3LSKe4/DX9JzNimuxr L58ujIMe84BPP0WI9Wd1n3r3EPxijUQqxwOmfkkirmS/XNEtbSbAAXQPXmjqvuLUgPK76bdKy9u nAt4gctnab3eONJFtF4S0zAnSVj/UxYJxRJZzy6euAdFLY9MQyyhQbBG5L+okP291 X-Received: by 2002:adf:cd8a:: with SMTP id q10mr28918186wrj.164.1640951374782; Fri, 31 Dec 2021 03:49:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2dIVmmJjJoWOYkN6QY4oEzQHq2PYPcfJGoUKtxh9GPOzq4G0wqsdDi0lyd+GdbG73VYoPTQ== X-Received: by 2002:adf:cd8a:: with SMTP id q10mr28918156wrj.164.1640951374374; Fri, 31 Dec 2021 03:49:34 -0800 (PST) Received: from x1w.redhat.com (26.red-83-50-86.dynamicip.rima-tde.net. [83.50.86.26]) by smtp.gmail.com with ESMTPSA id p13sm26070464wrr.37.2021.12.31.03.49.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Dec 2021 03:49:34 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 7/8] hw/dma: Introduce dma_size_t type definition Date: Fri, 31 Dec 2021 12:49:00 +0100 Message-Id: <20211231114901.976937-8-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211231114901.976937-1-philmd@redhat.com> References: <20211231114901.976937-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) DKIMWL_WL_HIGH=-0.573, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , David Hildenbrand , Peter Xu , Gerd Hoffmann , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The DMA API defines the dma_addr_t type for DMA addresses. Some sizes related to the API also use this type, which is a bit confusing when reviewing. Add a similar 'dma_size_t' definition (and its format string). Update the obvious places where dma_size_t should be used, and adapt a pair of format strings. Move QEMUSGList declaration after dma_size_t definition so this structure can use the new type. Signed-off-by: Philippe Mathieu-Daudé --- hw/rdma/rdma_utils.h | 4 ++-- include/hw/pci/pci.h | 10 ++++---- include/sysemu/dma.h | 50 ++++++++++++++++++++------------------- hw/ide/ahci.c | 2 +- hw/nvme/ctrl.c | 2 +- hw/nvram/fw_cfg.c | 2 +- hw/rdma/rdma_utils.c | 6 ++--- hw/rdma/vmw/pvrdma_main.c | 2 +- hw/scsi/lsi53c895a.c | 4 ++-- hw/scsi/megasas.c | 10 ++++---- hw/usb/libhw.c | 4 ++-- softmmu/dma-helpers.c | 10 ++++---- hw/rdma/trace-events | 2 +- 13 files changed, 55 insertions(+), 53 deletions(-) diff --git a/hw/rdma/rdma_utils.h b/hw/rdma/rdma_utils.h index 0c6414e7e0a..5446e4e2500 100644 --- a/hw/rdma/rdma_utils.h +++ b/hw/rdma/rdma_utils.h @@ -38,8 +38,8 @@ typedef struct RdmaProtectedGSList { GSList *list; } RdmaProtectedGSList; -void *rdma_pci_dma_map(PCIDevice *dev, dma_addr_t addr, dma_addr_t len); -void rdma_pci_dma_unmap(PCIDevice *dev, void *buffer, dma_addr_t len); +void *rdma_pci_dma_map(PCIDevice *dev, dma_addr_t addr, dma_size_t len); +void rdma_pci_dma_unmap(PCIDevice *dev, void *buffer, dma_size_t len); void rdma_protected_gqueue_init(RdmaProtectedGQueue *list); void rdma_protected_gqueue_destroy(RdmaProtectedGQueue *list); void rdma_protected_gqueue_append_int64(RdmaProtectedGQueue *list, diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index f0d707efb8c..f2257b2cd8c 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -805,7 +805,7 @@ static inline AddressSpace *pci_get_address_space(PCIDevice *dev) * @dir: indicates the transfer direction */ static inline MemTxResult pci_dma_rw(PCIDevice *dev, dma_addr_t addr, - void *buf, dma_addr_t len, + void *buf, dma_size_t len, DMADirection dir, MemTxAttrs attrs) { return dma_memory_rw(pci_get_address_space(dev), addr, buf, len, @@ -825,7 +825,7 @@ static inline MemTxResult pci_dma_rw(PCIDevice *dev, dma_addr_t addr, * @len: length of the data transferred */ static inline MemTxResult pci_dma_read(PCIDevice *dev, dma_addr_t addr, - void *buf, dma_addr_t len) + void *buf, dma_size_t len) { return pci_dma_rw(dev, addr, buf, len, DMA_DIRECTION_TO_DEVICE, MEMTXATTRS_UNSPECIFIED); @@ -844,7 +844,7 @@ static inline MemTxResult pci_dma_read(PCIDevice *dev, dma_addr_t addr, * @len: the number of bytes to write */ static inline MemTxResult pci_dma_write(PCIDevice *dev, dma_addr_t addr, - const void *buf, dma_addr_t len) + const void *buf, dma_size_t len) { return pci_dma_rw(dev, addr, (void *) buf, len, DMA_DIRECTION_FROM_DEVICE, MEMTXATTRS_UNSPECIFIED); @@ -889,7 +889,7 @@ PCI_DMA_DEFINE_LDST(q_be, q_be, 64); * @dir: indicates the transfer direction */ static inline void *pci_dma_map(PCIDevice *dev, dma_addr_t addr, - dma_addr_t *plen, DMADirection dir) + dma_size_t *plen, DMADirection dir) { void *buf; @@ -898,7 +898,7 @@ static inline void *pci_dma_map(PCIDevice *dev, dma_addr_t addr, return buf; } -static inline void pci_dma_unmap(PCIDevice *dev, void *buffer, dma_addr_t len, +static inline void pci_dma_unmap(PCIDevice *dev, void *buffer, dma_size_t len, DMADirection dir, dma_addr_t access_len) { dma_memory_unmap(pci_get_address_space(dev), buffer, len, dir, access_len); diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 0db2478a506..45a2567848c 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -15,22 +15,11 @@ #include "block/block.h" #include "block/accounting.h" -typedef struct ScatterGatherEntry ScatterGatherEntry; - typedef enum { DMA_DIRECTION_TO_DEVICE = 0, DMA_DIRECTION_FROM_DEVICE = 1, } DMADirection; -struct QEMUSGList { - ScatterGatherEntry *sg; - int nsg; - int nalloc; - size_t size; - DeviceState *dev; - AddressSpace *as; -}; - /* * When an IOMMU is present, bus addresses become distinct from * CPU/memory physical addresses and may be a different size. Because @@ -39,9 +28,22 @@ struct QEMUSGList { * least most) cases. */ typedef uint64_t dma_addr_t; +typedef uint64_t dma_size_t; #define DMA_ADDR_BITS 64 #define DMA_ADDR_FMT "%" PRIx64 +#define DMA_SIZE_FMT "%" PRIx64 + +typedef struct ScatterGatherEntry ScatterGatherEntry; + +struct QEMUSGList { + ScatterGatherEntry *sg; + int nsg; + int nalloc; + dma_size_t size; + DeviceState *dev; + AddressSpace *as; +}; static inline void dma_barrier(AddressSpace *as, DMADirection dir) { @@ -70,7 +72,7 @@ static inline void dma_barrier(AddressSpace *as, DMADirection dir) * useful for certain cases, but usually you should just use * dma_memory_{read,write}() and check for errors */ static inline bool dma_memory_valid(AddressSpace *as, - dma_addr_t addr, dma_addr_t len, + dma_addr_t addr, dma_size_t len, DMADirection dir, MemTxAttrs attrs) { return address_space_access_valid(as, addr, len, @@ -80,7 +82,7 @@ static inline bool dma_memory_valid(AddressSpace *as, static inline MemTxResult dma_memory_rw_relaxed(AddressSpace *as, dma_addr_t addr, - void *buf, dma_addr_t len, + void *buf, dma_size_t len, DMADirection dir, MemTxAttrs attrs) { @@ -90,7 +92,7 @@ static inline MemTxResult dma_memory_rw_relaxed(AddressSpace *as, static inline MemTxResult dma_memory_read_relaxed(AddressSpace *as, dma_addr_t addr, - void *buf, dma_addr_t len) + void *buf, dma_size_t len) { return dma_memory_rw_relaxed(as, addr, buf, len, DMA_DIRECTION_TO_DEVICE, @@ -100,7 +102,7 @@ static inline MemTxResult dma_memory_read_relaxed(AddressSpace *as, static inline MemTxResult dma_memory_write_relaxed(AddressSpace *as, dma_addr_t addr, const void *buf, - dma_addr_t len) + dma_size_t len) { return dma_memory_rw_relaxed(as, addr, (void *)buf, len, DMA_DIRECTION_FROM_DEVICE, @@ -122,7 +124,7 @@ static inline MemTxResult dma_memory_write_relaxed(AddressSpace *as, * @attrs: memory transaction attributes */ static inline MemTxResult dma_memory_rw(AddressSpace *as, dma_addr_t addr, - void *buf, dma_addr_t len, + void *buf, dma_size_t len, DMADirection dir, MemTxAttrs attrs) { dma_barrier(as, dir); @@ -144,7 +146,7 @@ static inline MemTxResult dma_memory_rw(AddressSpace *as, dma_addr_t addr, * @attrs: memory transaction attributes */ static inline MemTxResult dma_memory_read(AddressSpace *as, dma_addr_t addr, - void *buf, dma_addr_t len, + void *buf, dma_size_t len, MemTxAttrs attrs) { return dma_memory_rw(as, addr, buf, len, @@ -165,7 +167,7 @@ static inline MemTxResult dma_memory_read(AddressSpace *as, dma_addr_t addr, * @attrs: memory transaction attributes */ static inline MemTxResult dma_memory_write(AddressSpace *as, dma_addr_t addr, - const void *buf, dma_addr_t len, + const void *buf, dma_size_t len, MemTxAttrs attrs) { return dma_memory_rw(as, addr, (void *)buf, len, @@ -186,7 +188,7 @@ static inline MemTxResult dma_memory_write(AddressSpace *as, dma_addr_t addr, * @attrs: memory transaction attributes */ MemTxResult dma_memory_set(AddressSpace *as, dma_addr_t addr, - uint8_t c, dma_addr_t len, MemTxAttrs attrs); + uint8_t c, dma_size_t len, MemTxAttrs attrs); /** * address_space_map: Map a physical memory region into a host virtual address. @@ -203,7 +205,7 @@ MemTxResult dma_memory_set(AddressSpace *as, dma_addr_t addr, * @attrs: memory attributes */ static inline void *dma_memory_map(AddressSpace *as, - dma_addr_t addr, dma_addr_t *len, + dma_addr_t addr, dma_size_t *len, DMADirection dir, MemTxAttrs attrs) { hwaddr xlen = *len; @@ -230,8 +232,8 @@ static inline void *dma_memory_map(AddressSpace *as, * @access_len: amount of data actually transferred */ static inline void dma_memory_unmap(AddressSpace *as, - void *buffer, dma_addr_t len, - DMADirection dir, dma_addr_t access_len) + void *buffer, dma_size_t len, + DMADirection dir, dma_size_t access_len) { address_space_unmap(as, buffer, (hwaddr)len, dir == DMA_DIRECTION_FROM_DEVICE, access_len); @@ -279,12 +281,12 @@ DEFINE_LDST_DMA(q, q, 64, be); struct ScatterGatherEntry { dma_addr_t base; - dma_addr_t len; + dma_size_t len; }; void qemu_sglist_init(QEMUSGList *qsg, DeviceState *dev, int alloc_hint, AddressSpace *as); -void qemu_sglist_add(QEMUSGList *qsg, dma_addr_t base, dma_addr_t len); +void qemu_sglist_add(QEMUSGList *qsg, dma_addr_t base, dma_size_t len); void qemu_sglist_destroy(QEMUSGList *qsg); typedef BlockAIOCB *DMAIOFunc(int64_t offset, QEMUIOVector *iov, diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 205dfdc6622..256bbc377ce 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1159,7 +1159,7 @@ static void process_ncq_command(AHCIState *s, int port, const uint8_t *cmd_fis, ahci_populate_sglist(ad, &ncq_tfs->sglist, ncq_tfs->cmdh, size, 0); if (ncq_tfs->sglist.size < size) { - error_report("ahci: PRDT length for NCQ command (0x%zx) " + error_report("ahci: PRDT length for NCQ command (0x" DMA_SIZE_FMT ") " "is smaller than the requested size (0x%zx)", ncq_tfs->sglist.size, size); ncq_err(ncq_tfs); diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 462f79a1f60..4620e662fc9 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -1147,7 +1147,7 @@ static uint16_t nvme_tx(NvmeCtrl *n, NvmeSg *sg, uint8_t *ptr, uint32_t len, if (sg->flags & NVME_SG_DMA) { const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; - uint64_t residual; + dma_size_t residual; if (dir == NVME_TX_DIRECTION_TO_DEVICE) { residual = dma_buf_write(ptr, len, &sg->qsg, attrs); diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index e5f3c981841..a30bff8a14a 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -346,12 +346,12 @@ static void fw_cfg_data_mem_write(void *opaque, hwaddr addr, static void fw_cfg_dma_transfer(FWCfgState *s) { - dma_addr_t len; FWCfgDmaAccess dma; int arch; FWCfgEntry *e; int read = 0, write = 0; dma_addr_t dma_addr; + dma_size_t len; /* Reset the address before the next access */ dma_addr = s->dma_addr; diff --git a/hw/rdma/rdma_utils.c b/hw/rdma/rdma_utils.c index 61cb8ede0fd..677d7ffba53 100644 --- a/hw/rdma/rdma_utils.c +++ b/hw/rdma/rdma_utils.c @@ -17,10 +17,10 @@ #include "trace.h" #include "rdma_utils.h" -void *rdma_pci_dma_map(PCIDevice *dev, dma_addr_t addr, dma_addr_t len) +void *rdma_pci_dma_map(PCIDevice *dev, dma_addr_t addr, dma_size_t len) { void *p; - hwaddr pci_len = len; + dma_size_t pci_len = len; if (!addr) { rdma_error_report("addr is NULL"); @@ -44,7 +44,7 @@ void *rdma_pci_dma_map(PCIDevice *dev, dma_addr_t addr, dma_addr_t len) return p; } -void rdma_pci_dma_unmap(PCIDevice *dev, void *buffer, dma_addr_t len) +void rdma_pci_dma_unmap(PCIDevice *dev, void *buffer, dma_size_t len) { trace_rdma_pci_dma_unmap(buffer); if (buffer) { diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c index 91206dbb8eb..bf3d542302e 100644 --- a/hw/rdma/vmw/pvrdma_main.c +++ b/hw/rdma/vmw/pvrdma_main.c @@ -124,7 +124,7 @@ static int init_dev_ring(PvrdmaRing *ring, PvrdmaRingState **ring_state, (num_pages - 1) * TARGET_PAGE_SIZE / sizeof(struct pvrdma_cqne), sizeof(struct pvrdma_cqne), - (dma_addr_t *)&tbl[1], (dma_addr_t)num_pages - 1); + (dma_addr_t *)&tbl[1], (dma_size_t)num_pages - 1); if (rc) { rc = -ENOMEM; goto out_free_ring_state; diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index 4c431adb774..6d63bffc804 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -444,7 +444,7 @@ static void lsi_execute_script(LSIState *s); static void lsi_reselect(LSIState *s, lsi_request *p); static inline void lsi_mem_read(LSIState *s, dma_addr_t addr, - void *buf, dma_addr_t len) + void *buf, dma_size_t len) { if (s->dmode & LSI_DMODE_SIOM) { address_space_read(&s->pci_io_as, addr, MEMTXATTRS_UNSPECIFIED, @@ -455,7 +455,7 @@ static inline void lsi_mem_read(LSIState *s, dma_addr_t addr, } static inline void lsi_mem_write(LSIState *s, dma_addr_t addr, - const void *buf, dma_addr_t len) + const void *buf, dma_size_t len) { if (s->dmode & LSI_DMODE_DIOM) { address_space_write(&s->pci_io_as, addr, MEMTXATTRS_UNSPECIFIED, diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index cb019549371..7456a25970a 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -1046,7 +1046,7 @@ static int megasas_pd_get_info_submit(SCSIDevice *sdev, int lun, uint16_t pd_id = ((sdev->id & 0xFF) << 8) | (lun & 0xFF); uint8_t cmdbuf[6]; size_t len; - size_t residual; + dma_size_t residual; if (!cmd->iov_buf) { cmd->iov_buf = g_malloc0(dcmd_size); @@ -1152,7 +1152,7 @@ static int megasas_dcmd_ld_get_list(MegasasState *s, MegasasCmd *cmd) { struct mfi_ld_list info; size_t dcmd_size = sizeof(info); - size_t residual; + dma_size_t residual; uint32_t num_ld_disks = 0, max_ld_disks; uint64_t ld_size; BusChild *kid; @@ -1198,7 +1198,7 @@ static int megasas_dcmd_ld_list_query(MegasasState *s, MegasasCmd *cmd) uint16_t flags; struct mfi_ld_targetid_list info; size_t dcmd_size = sizeof(info); - size_t residual; + dma_size_t residual; uint32_t num_ld_disks = 0, max_ld_disks = s->fw_luns; BusChild *kid; @@ -1251,7 +1251,7 @@ static int megasas_ld_get_info_submit(SCSIDevice *sdev, int lun, size_t dcmd_size = sizeof(struct mfi_ld_info); uint8_t cdb[6]; ssize_t len; - size_t residual; + dma_size_t residual; uint16_t sdev_id = ((sdev->id & 0xFF) << 8) | (lun & 0xFF); uint64_t ld_size; @@ -1625,7 +1625,7 @@ static int megasas_handle_dcmd(MegasasState *s, MegasasCmd *cmd) } static int megasas_finish_internal_dcmd(MegasasCmd *cmd, - SCSIRequest *req, size_t residual) + SCSIRequest *req, dma_size_t residual) { int retval = MFI_STAT_OK; int lun = req->lun; diff --git a/hw/usb/libhw.c b/hw/usb/libhw.c index f350eae443d..f632258459a 100644 --- a/hw/usb/libhw.c +++ b/hw/usb/libhw.c @@ -32,10 +32,10 @@ int usb_packet_map(USBPacket *p, QEMUSGList *sgl) for (i = 0; i < sgl->nsg; i++) { dma_addr_t base = sgl->sg[i].base; - dma_addr_t len = sgl->sg[i].len; + dma_size_t len = sgl->sg[i].len; while (len) { - dma_addr_t xlen = len; + dma_size_t xlen = len; mem = dma_memory_map(sgl->as, base, &xlen, dir, MEMTXATTRS_UNSPECIFIED); if (!mem) { diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c index 4563a775aa7..66ba0b2c361 100644 --- a/softmmu/dma-helpers.c +++ b/softmmu/dma-helpers.c @@ -19,7 +19,7 @@ /* #define DEBUG_IOMMU */ MemTxResult dma_memory_set(AddressSpace *as, dma_addr_t addr, - uint8_t c, dma_addr_t len, MemTxAttrs attrs) + uint8_t c, dma_size_t len, MemTxAttrs attrs) { dma_barrier(as, DMA_DIRECTION_FROM_DEVICE); @@ -51,7 +51,7 @@ void qemu_sglist_init(QEMUSGList *qsg, DeviceState *dev, int alloc_hint, object_ref(OBJECT(dev)); } -void qemu_sglist_add(QEMUSGList *qsg, dma_addr_t base, dma_addr_t len) +void qemu_sglist_add(QEMUSGList *qsg, dma_addr_t base, dma_size_t len) { if (qsg->nsg == qsg->nalloc) { qsg->nalloc = 2 * qsg->nalloc + 1; @@ -294,12 +294,12 @@ BlockAIOCB *dma_blk_write(BlockBackend *blk, } -static MemTxResult dma_buf_rw(void *buf, int32_t len, uint64_t *residual, +static MemTxResult dma_buf_rw(void *buf, dma_size_t len, dma_size_t *residual, QEMUSGList *sg, DMADirection dir, MemTxAttrs attrs) { uint8_t *ptr = buf; - uint64_t xresidual; + dma_size_t xresidual; int sg_cur_index; MemTxResult res = MEMTX_OK; @@ -308,7 +308,7 @@ static MemTxResult dma_buf_rw(void *buf, int32_t len, uint64_t *residual, len = MIN(len, xresidual); while (len > 0) { ScatterGatherEntry entry = sg->sg[sg_cur_index++]; - int32_t xfer = MIN(len, entry.len); + dma_size_t xfer = MIN(len, entry.len); res |= dma_memory_rw(sg->as, entry.base, ptr, xfer, dir, attrs); ptr += xfer; len -= xfer; diff --git a/hw/rdma/trace-events b/hw/rdma/trace-events index 9accb149734..c23175120e1 100644 --- a/hw/rdma/trace-events +++ b/hw/rdma/trace-events @@ -27,5 +27,5 @@ rdma_rm_alloc_qp(uint32_t rm_qpn, uint32_t backend_qpn, uint8_t qp_type) "rm_qpn rdma_rm_modify_qp(uint32_t qpn, uint32_t attr_mask, int qp_state, uint8_t sgid_idx) "qpn=0x%x, attr_mask=0x%x, qp_state=%d, sgid_idx=%d" # rdma_utils.c -rdma_pci_dma_map(uint64_t addr, void *vaddr, uint64_t len) "0x%"PRIx64" -> %p (len=%" PRId64")" +rdma_pci_dma_map(uint64_t addr, void *vaddr, uint64_t len) "0x%"PRIx64" -> %p (len=%" PRIu64")" rdma_pci_dma_unmap(void *vaddr) "%p" From patchwork Fri Dec 31 11:49:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12701928 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DA0A0C433EF for ; Fri, 31 Dec 2021 11:54:55 +0000 (UTC) Received: from localhost ([::1]:40478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n3GUo-0001Y1-Sg for qemu-devel@archiver.kernel.org; Fri, 31 Dec 2021 06:54:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3GPp-00031L-25 for qemu-devel@nongnu.org; Fri, 31 Dec 2021 06:49:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36992) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3GPm-0000Km-S3 for qemu-devel@nongnu.org; Fri, 31 Dec 2021 06:49:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640951381; 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=sVbqGuL5i4KG9wiyUQdUi9FXx9GY+w1Tl1XX5hguON4=; b=a7gFxwuKt5bXpO1mEvnfj/sDkDZafca7cthZ8wuUoUejT+PF7KAAu6xKJz2c9ncXjgoJGM XbThsK5rR0iqlgYJUhczkdhDFJFistaLmmHC/uk7Mwn5ZkEFljdTXIV0brWSfAA3G0DHMg Wn6y9lf7dHXQ6MfTGfA7Kr3geLt6sSo= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-623-HZIsEwYYMvKu9d7rOsl9CA-1; Fri, 31 Dec 2021 06:49:40 -0500 X-MC-Unique: HZIsEwYYMvKu9d7rOsl9CA-1 Received: by mail-wm1-f70.google.com with SMTP id f202-20020a1c1fd3000000b00344f1cae317so4561548wmf.0 for ; Fri, 31 Dec 2021 03:49:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sVbqGuL5i4KG9wiyUQdUi9FXx9GY+w1Tl1XX5hguON4=; b=itFKWUfmcUyNaTvqQe5cA9AU2C9exhz8LlxEpZ/tHfAi3ZWu36Be7tTNNvvgZlj/W1 xRTuwJBpn+o1IR7WaTHvTgatGBtVGYzrb7Rtryk1b/TjQ8eQ+0rb4heuNCPP7GEjlzWg vUpcZhSzZHl4sgzvfwesQtLJgbmArMLtnniYShxcvMv0PlpfTEmCf1gluMZwpCWU0h03 M22wDCyfAIWAmgcZhZ+NhEOreG9UwKxdM7ebAaogGjWXQUBBtUIgbmjGNa4/d5Hqxlre 1bBYBIH0gTflBr/cyuUo8Z7qNbT8bL0YD3PwfRQazxbZNw8/ITLKUMzpRN5PcDmUm+SZ yR1Q== X-Gm-Message-State: AOAM533yqQsteTRN3RFngsteSf4+yd5s/1rRnc9SZczc4ZZZate2MhJY paq+4Wqtf8JqZEyHmKRqOxgWexc3tqNkqzq1O4ZIk1XgSNKpqmSaCo3w8JJtIqlRchSL3b+GPZE GdtT7tRfE4wwPhDrYY99guWqWRsnVCJPvP6tmcOPAPvxKROsJlAo8wS7NaJiFnbEr X-Received: by 2002:a05:6000:c6:: with SMTP id q6mr28844957wrx.181.1640951378964; Fri, 31 Dec 2021 03:49:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJze40y+FDpdvAVYk73CGv/wGhHSTGgdTSeJfcfRcrkN+CMguXeVW7PqdwukP2iZB0f9tFhPlg== X-Received: by 2002:a05:6000:c6:: with SMTP id q6mr28844937wrx.181.1640951378689; Fri, 31 Dec 2021 03:49:38 -0800 (PST) Received: from x1w.redhat.com (26.red-83-50-86.dynamicip.rima-tde.net. [83.50.86.26]) by smtp.gmail.com with ESMTPSA id n17sm24984705wmc.32.2021.12.31.03.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Dec 2021 03:49:38 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 8/8] hw/dma: Let dma_buf_read() / dma_buf_write() propagate MemTxResult Date: Fri, 31 Dec 2021 12:49:01 +0100 Message-Id: <20211231114901.976937-9-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211231114901.976937-1-philmd@redhat.com> References: <20211231114901.976937-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) DKIMWL_WL_HIGH=-0.573, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Klaus Jensen , David Hildenbrand , Peter Xu , Gerd Hoffmann , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Since the previous commit, dma_buf_rw() returns a MemTxResult type. Do not discard it, return it to the caller. Since both dma_buf_read/dma_buf_write functions were previously returning the QEMUSGList size not consumed, add an extra argument where the unconsummed size can be stored. Update the few callers. Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daudé --- include/hw/scsi/scsi.h | 2 +- include/sysemu/dma.h | 6 +++-- hw/ide/ahci.c | 8 +++--- hw/nvme/ctrl.c | 4 +-- hw/scsi/megasas.c | 59 ++++++++++++++++++++++++++++++------------ hw/scsi/scsi-bus.c | 6 +++-- softmmu/dma-helpers.c | 18 +++++-------- 7 files changed, 63 insertions(+), 40 deletions(-) diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index b27d133b113..1ffb367f94f 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -30,7 +30,7 @@ struct SCSIRequest { int16_t status; int16_t host_status; void *hba_private; - size_t residual; + uint64_t residual; SCSICommand cmd; NotifierList cancel_notifiers; diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 45a2567848c..77a346d5ed1 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -303,8 +303,10 @@ BlockAIOCB *dma_blk_read(BlockBackend *blk, BlockAIOCB *dma_blk_write(BlockBackend *blk, QEMUSGList *sg, uint64_t offset, uint32_t align, BlockCompletionFunc *cb, void *opaque); -uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs); -uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs); +MemTxResult dma_buf_read(void *ptr, dma_size_t len, dma_size_t *residual, + QEMUSGList *sg, MemTxAttrs attrs); +MemTxResult dma_buf_write(void *ptr, dma_size_t len, dma_size_t *residual, + QEMUSGList *sg, MemTxAttrs attrs); void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie, QEMUSGList *sg, enum BlockAcctType type); diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 256bbc377ce..564293fd492 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1384,9 +1384,9 @@ static void ahci_pio_transfer(const IDEDMA *dma) const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; if (is_write) { - dma_buf_write(s->data_ptr, size, &s->sg, attrs); + dma_buf_write(s->data_ptr, size, NULL, &s->sg, attrs); } else { - dma_buf_read(s->data_ptr, size, &s->sg, attrs); + dma_buf_read(s->data_ptr, size, NULL, &s->sg, attrs); } } @@ -1479,9 +1479,9 @@ static int ahci_dma_rw_buf(const IDEDMA *dma, bool is_write) } if (is_write) { - dma_buf_read(p, l, &s->sg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(p, l, NULL, &s->sg, MEMTXATTRS_UNSPECIFIED); } else { - dma_buf_write(p, l, &s->sg, MEMTXATTRS_UNSPECIFIED); + dma_buf_write(p, l, NULL, &s->sg, MEMTXATTRS_UNSPECIFIED); } /* free sglist, update byte count */ diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 4620e662fc9..72faa94a4a3 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -1150,9 +1150,9 @@ static uint16_t nvme_tx(NvmeCtrl *n, NvmeSg *sg, uint8_t *ptr, uint32_t len, dma_size_t residual; if (dir == NVME_TX_DIRECTION_TO_DEVICE) { - residual = dma_buf_write(ptr, len, &sg->qsg, attrs); + dma_buf_write(ptr, len, &residual, &sg->qsg, attrs); } else { - residual = dma_buf_read(ptr, len, &sg->qsg, attrs); + dma_buf_read(ptr, len, &residual, &sg->qsg, attrs); } if (unlikely(residual)) { diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index 7456a25970a..f2daeeb7005 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -750,6 +750,7 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd) size_t dcmd_size = sizeof(info); BusChild *kid; int num_pd_disks = 0; + dma_size_t residual; memset(&info, 0x0, dcmd_size); if (cmd->iov_size < dcmd_size) { @@ -860,7 +861,9 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd) MFI_INFO_PDMIX_SATA | MFI_INFO_PDMIX_LD); - cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&info, dcmd_size, &residual, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= residual; return MFI_STAT_OK; } @@ -868,6 +871,7 @@ static int megasas_mfc_get_defaults(MegasasState *s, MegasasCmd *cmd) { struct mfi_defaults info; size_t dcmd_size = sizeof(struct mfi_defaults); + dma_size_t residual; memset(&info, 0x0, dcmd_size); if (cmd->iov_size < dcmd_size) { @@ -890,7 +894,9 @@ static int megasas_mfc_get_defaults(MegasasState *s, MegasasCmd *cmd) info.disable_preboot_cli = 1; info.cluster_disable = 1; - cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&info, dcmd_size, &residual, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= residual; return MFI_STAT_OK; } @@ -898,6 +904,7 @@ static int megasas_dcmd_get_bios_info(MegasasState *s, MegasasCmd *cmd) { struct mfi_bios_data info; size_t dcmd_size = sizeof(info); + dma_size_t residual; memset(&info, 0x0, dcmd_size); if (cmd->iov_size < dcmd_size) { @@ -911,7 +918,9 @@ static int megasas_dcmd_get_bios_info(MegasasState *s, MegasasCmd *cmd) info.expose_all_drives = 1; } - cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&info, dcmd_size, &residual, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= residual; return MFI_STAT_OK; } @@ -919,10 +928,13 @@ static int megasas_dcmd_get_fw_time(MegasasState *s, MegasasCmd *cmd) { uint64_t fw_time; size_t dcmd_size = sizeof(fw_time); + dma_size_t residual; fw_time = cpu_to_le64(megasas_fw_time()); - cmd->iov_size -= dma_buf_read(&fw_time, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&fw_time, dcmd_size, &residual, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= residual; return MFI_STAT_OK; } @@ -942,6 +954,7 @@ static int megasas_event_info(MegasasState *s, MegasasCmd *cmd) { struct mfi_evt_log_state info; size_t dcmd_size = sizeof(info); + dma_size_t residual; memset(&info, 0, dcmd_size); @@ -949,7 +962,9 @@ static int megasas_event_info(MegasasState *s, MegasasCmd *cmd) info.shutdown_seq_num = cpu_to_le32(s->shutdown_event); info.boot_seq_num = cpu_to_le32(s->boot_event); - cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&info, dcmd_size, &residual, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= residual; return MFI_STAT_OK; } @@ -979,6 +994,7 @@ static int megasas_dcmd_pd_get_list(MegasasState *s, MegasasCmd *cmd) size_t dcmd_size = sizeof(info); BusChild *kid; uint32_t offset, dcmd_limit, num_pd_disks = 0, max_pd_disks; + dma_size_t residual; memset(&info, 0, dcmd_size); offset = 8; @@ -1018,7 +1034,9 @@ static int megasas_dcmd_pd_get_list(MegasasState *s, MegasasCmd *cmd) info.size = cpu_to_le32(offset); info.count = cpu_to_le32(num_pd_disks); - cmd->iov_size -= dma_buf_read(&info, offset, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&info, offset, &residual, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= residual; return MFI_STAT_OK; } @@ -1113,8 +1131,9 @@ static int megasas_pd_get_info_submit(SCSIDevice *sdev, int lun, info->connected_port_bitmap = 0x1; info->device_speed = 1; info->link_speed = 1; - residual = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg, - MEMTXATTRS_UNSPECIFIED); + dma_buf_read(cmd->iov_buf, dcmd_size, &residual, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= residual; g_free(cmd->iov_buf); cmd->iov_size = dcmd_size - residual; cmd->iov_buf = NULL; @@ -1187,8 +1206,8 @@ static int megasas_dcmd_ld_get_list(MegasasState *s, MegasasCmd *cmd) info.ld_count = cpu_to_le32(num_ld_disks); trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks); - residual = dma_buf_read(&info, dcmd_size, &cmd->qsg, - MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&info, dcmd_size, &residual, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); cmd->iov_size = dcmd_size - residual; return MFI_STAT_OK; } @@ -1238,8 +1257,8 @@ static int megasas_dcmd_ld_list_query(MegasasState *s, MegasasCmd *cmd) info.size = dcmd_size; trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks); - residual = dma_buf_read(&info, dcmd_size, &cmd->qsg, - MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&info, dcmd_size, &residual, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); cmd->iov_size = dcmd_size - residual; return MFI_STAT_OK; } @@ -1290,8 +1309,8 @@ static int megasas_ld_get_info_submit(SCSIDevice *sdev, int lun, info->ld_config.span[0].num_blocks = info->size; info->ld_config.span[0].array_ref = cpu_to_le16(sdev_id); - residual = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg, - MEMTXATTRS_UNSPECIFIED); + dma_buf_read(cmd->iov_buf, dcmd_size, &residual, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); g_free(cmd->iov_buf); cmd->iov_size = dcmd_size - residual; cmd->iov_buf = NULL; @@ -1336,6 +1355,7 @@ static int megasas_dcmd_cfg_read(MegasasState *s, MegasasCmd *cmd) struct mfi_config_data *info; int num_pd_disks = 0, array_offset, ld_offset; BusChild *kid; + dma_size_t residual; if (cmd->iov_size > 4096) { return MFI_STAT_INVALID_PARAMETER; @@ -1410,7 +1430,9 @@ static int megasas_dcmd_cfg_read(MegasasState *s, MegasasCmd *cmd) ld_offset += sizeof(struct mfi_ld_config); } - cmd->iov_size -= dma_buf_read(data, info->size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(data, info->size, &residual, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= residual; return MFI_STAT_OK; } @@ -1418,6 +1440,7 @@ static int megasas_dcmd_get_properties(MegasasState *s, MegasasCmd *cmd) { struct mfi_ctrl_props info; size_t dcmd_size = sizeof(info); + dma_size_t residual; memset(&info, 0x0, dcmd_size); if (cmd->iov_size < dcmd_size) { @@ -1440,7 +1463,9 @@ static int megasas_dcmd_get_properties(MegasasState *s, MegasasCmd *cmd) info.ecc_bucket_leak_rate = cpu_to_le16(1440); info.expose_encl_devices = 1; - cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&info, dcmd_size, &residual, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= residual; return MFI_STAT_OK; } @@ -1485,7 +1510,7 @@ static int megasas_dcmd_set_properties(MegasasState *s, MegasasCmd *cmd) dcmd_size); return MFI_STAT_INVALID_PARAMETER; } - dma_buf_write(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_write(&info, dcmd_size, NULL, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); trace_megasas_dcmd_unsupported(cmd->index, cmd->iov_size); return MFI_STAT_OK; } diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 3466e680ac7..4057e04ce89 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -1421,9 +1421,11 @@ void scsi_req_data(SCSIRequest *req, int len) buf = scsi_req_get_buf(req); if (req->cmd.mode == SCSI_XFER_FROM_DEV) { - req->residual = dma_buf_read(buf, len, req->sg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(buf, len, &req->residual, req->sg, + MEMTXATTRS_UNSPECIFIED); } else { - req->residual = dma_buf_write(buf, len, req->sg, MEMTXATTRS_UNSPECIFIED); + dma_buf_write(buf, len, &req->residual, req->sg, + MEMTXATTRS_UNSPECIFIED); } scsi_req_continue(req); } diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c index 66ba0b2c361..25120ea2792 100644 --- a/softmmu/dma-helpers.c +++ b/softmmu/dma-helpers.c @@ -321,22 +321,16 @@ static MemTxResult dma_buf_rw(void *buf, dma_size_t len, dma_size_t *residual, return res; } -uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs) +MemTxResult dma_buf_read(void *ptr, dma_size_t len, dma_size_t *residual, + QEMUSGList *sg, MemTxAttrs attrs) { - uint64_t residual; - - dma_buf_rw(ptr, len, &residual, sg, DMA_DIRECTION_FROM_DEVICE, attrs); - - return residual; + return dma_buf_rw(ptr, len, residual, sg, DMA_DIRECTION_FROM_DEVICE, attrs); } -uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs) +MemTxResult dma_buf_write(void *ptr, dma_size_t len, dma_size_t *residual, + QEMUSGList *sg, MemTxAttrs attrs) { - uint64_t residual; - - dma_buf_rw(ptr, len, &residual, sg, DMA_DIRECTION_TO_DEVICE, attrs); - - return residual; + return dma_buf_rw(ptr, len, residual, sg, DMA_DIRECTION_TO_DEVICE, attrs); } void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie,