Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp776915pxa; Wed, 5 Aug 2020 12:29:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcSKYpgP9tLRZ3/Krb5B6hPsG+Q0L6FJ2rqEI+hrW1NKDlYHpnDULp1dzBb9WL/U1C5dRT X-Received: by 2002:a17:906:f181:: with SMTP id gs1mr826292ejb.293.1596655760013; Wed, 05 Aug 2020 12:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596655760; cv=none; d=google.com; s=arc-20160816; b=VdMeq5QePo2skDClptRQxJPVHAJTfbL8qkl+6kgttP0lr4Ho6vq8k50ZyTLe5rKNG1 0fi0RgNGbVOQHr6ujWv0jDRRszLVuIZrr7ZpqUyWxB91XNmw3QMeN40I7DEp6Wb3Q4NK YWslo2BU4XE2FA6DvI7B/Tsh1C3qanX1jA953ADSoAtmWufz1IR+jLFXrlJplIhVTBPb 2pqsLh9INCzuUFVSxAoeSEnxiDlclO0Ir8t7CnGOPoXypplJPVvgwPDT1zsVP+C7A2PP 1PMz+waXlRuiQMrekQ7Hfieo6Dbd16wManFueD4Z7ix5MmdKVRQsMOZg4eLeHQ6B7Xwv HdJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=7dHJWpRpe+SGCeKRCL7RrX1ymnMkDIH+g5Ri3pUQbvw=; b=p6DQ0RGy/eh1+B9r2MkvDiO+mjQsSuTmUNnvOa7a01ZzLApG9B1QbL1Zh6vqEg9Vqq PeDWISTf1Vv61DHViE3xawLN03B/ZW0+TRPs65IMUKYZa/5GJMF92KnqvelxQ6QRDjek /eAdf/AhtxirwXZoWocO3F4XUiKOGufziKuQr/IehV4nxCRX006KSbMHnpm5/90l1S+5 G0L2M7YXawQpOk4S1aWMQQ3ngQLh1s5UY+Ak/oMeImFhXhIDAJ7asQpc1JDt3y12cOdx 5D+aXXwuW+4q+wCsI3IfSrc9Ae7DJ/CVadnf+XdsWVvbC//0nUi9Bt21HoQcs+CSjLf8 q7NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H3HlkJLA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b17si1769617edy.99.2020.08.05.12.28.57; Wed, 05 Aug 2020 12:29:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H3HlkJLA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728183AbgHET2v (ORCPT + 99 others); Wed, 5 Aug 2020 15:28:51 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:22595 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728401AbgHERL0 (ORCPT ); Wed, 5 Aug 2020 13:11:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596647485; 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: in-reply-to:in-reply-to:references:references; bh=7dHJWpRpe+SGCeKRCL7RrX1ymnMkDIH+g5Ri3pUQbvw=; b=H3HlkJLAUu8Lj6wSmGqSXHK1Z16X0UOdIw6G5//tPXHPiA/SYC2lPKex5611TUcNN8i41J Gq/SmKgA3bw4tjcV4VLfffguIrGEL6c6HidkyuhRyIcHOBjoB6jcrLJJKK9oboLJdi3rH7 tAIs8JNJSIgsS/M2cv0TuMf2qu0dX70= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-492-RB_ERJMfOrmN89RTL3nP2g-1; Wed, 05 Aug 2020 09:44:38 -0400 X-MC-Unique: RB_ERJMfOrmN89RTL3nP2g-1 Received: by mail-wm1-f71.google.com with SMTP id c184so1973887wme.1 for ; Wed, 05 Aug 2020 06:44:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7dHJWpRpe+SGCeKRCL7RrX1ymnMkDIH+g5Ri3pUQbvw=; b=UwneuivqsJqQCNTRKIdODC/cBCSA3Y9zcJS35mowRVCuzdjlkYV3hvydqF1Gulh1I/ sPLnL+SRrxL7/jBzIwjRC+YTRlAzV+rtzOFQ8xJPvhG62ID3eRrqU9bYBm/OmYY8ZBcT MIXnt2h+Nm0mXM+aWWsp1NBC3TakWc4Boy/1Z2NVt1lzPPVBwOhlFpxFofLe1Z1Bb4ag WhgnVvBWpEdk6ig18fyQr6G3ovite1VH0oCnEIT2Kfly7Getr0Ey0b5cir1a1sol29qh mlxPRzVyDaErwKdwXEU9xkcfsdVI3jG9jnqF4QOJ4p2IvoppOieMB7htukS3mD/qKnfz zxlw== X-Gm-Message-State: AOAM530d++m+h80cWq7FR1PWe/nOg2hOEaI3GO33VaCXQF1wiCkgme1i xEev9xjOxL9InPies5Fif1XUhibRjCe8zmyhySQT37YYHqi2EyB0MjGUtsc7ZoMBbelV8qFojWH CHbg5aSPRsZfRwnHKVtOgMhTr X-Received: by 2002:adf:b441:: with SMTP id v1mr2885514wrd.61.1596635076657; Wed, 05 Aug 2020 06:44:36 -0700 (PDT) X-Received: by 2002:adf:b441:: with SMTP id v1mr2885496wrd.61.1596635076408; Wed, 05 Aug 2020 06:44:36 -0700 (PDT) Received: from redhat.com ([192.117.173.58]) by smtp.gmail.com with ESMTPSA id o2sm3136755wrh.70.2020.08.05.06.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 06:44:35 -0700 (PDT) Date: Wed, 5 Aug 2020 09:44:33 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: David Hildenbrand , Jason Wang , virtualization@lists.linux-foundation.org Subject: [PATCH v3 29/38] virtio_balloon: use LE config space accesses Message-ID: <20200805134226.1106164-30-mst@redhat.com> References: <20200805134226.1106164-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200805134226.1106164-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Balloon is LE, it's cleaner to access it as such directly. Signed-off-by: Michael S. Tsirkin --- drivers/virtio/virtio_balloon.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 8bc1704ffdf3..31cc97f2f515 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -398,12 +398,9 @@ static inline s64 towards_target(struct virtio_balloon *vb) s64 target; u32 num_pages; - virtio_cread(vb->vdev, struct virtio_balloon_config, num_pages, - &num_pages); - /* Legacy balloon config space is LE, unlike all other devices. */ - if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1)) - num_pages = le32_to_cpu((__force __le32)num_pages); + virtio_cread_le(vb->vdev, struct virtio_balloon_config, num_pages, + &num_pages); target = num_pages; return target - vb->num_pages; @@ -462,11 +459,8 @@ static void update_balloon_size(struct virtio_balloon *vb) u32 actual = vb->num_pages; /* Legacy balloon config space is LE, unlike all other devices. */ - if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1)) - actual = (__force u32)cpu_to_le32(actual); - - virtio_cwrite(vb->vdev, struct virtio_balloon_config, actual, - &actual); + virtio_cwrite_le(vb->vdev, struct virtio_balloon_config, actual, + &actual); } static void update_balloon_stats_func(struct work_struct *work) @@ -579,12 +573,10 @@ static u32 virtio_balloon_cmd_id_received(struct virtio_balloon *vb) { if (test_and_clear_bit(VIRTIO_BALLOON_CONFIG_READ_CMD_ID, &vb->config_read_bitmap)) { - virtio_cread(vb->vdev, struct virtio_balloon_config, - free_page_hint_cmd_id, - &vb->cmd_id_received_cache); /* Legacy balloon config space is LE, unlike all other devices. */ - if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1)) - vb->cmd_id_received_cache = le32_to_cpu((__force __le32)vb->cmd_id_received_cache); + virtio_cread_le(vb->vdev, struct virtio_balloon_config, + free_page_hint_cmd_id, + &vb->cmd_id_received_cache); } return vb->cmd_id_received_cache; @@ -987,8 +979,8 @@ static int virtballoon_probe(struct virtio_device *vdev) if (!want_init_on_free()) memset(&poison_val, PAGE_POISON, sizeof(poison_val)); - virtio_cwrite(vb->vdev, struct virtio_balloon_config, - poison_val, &poison_val); + virtio_cwrite_le(vb->vdev, struct virtio_balloon_config, + poison_val, &poison_val); } vb->pr_dev_info.report = virtballoon_free_page_report; -- MST