From patchwork Tue Jul 23 18:18:50 2024 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: 813967 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2444929wro; Tue, 23 Jul 2024 11:19:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXLdTXDC3OBZ7WcT1o2a/4rNsTNgbixuIFYOrcMNATrXdQWR751fVA+APW0YCULVVxg7iq/nhr5k9GFvI/L2qRS X-Google-Smtp-Source: AGHT+IF9e4K5/kt8mBUntfEZjxXtF8lWKhpnPNKEASljaJZFawK7aD57ucay64i4jKiolv/2jGHy X-Received: by 2002:a05:620a:2552:b0:79e:fed9:795c with SMTP id af79cd13be357-7a1c2f155f7mr551598785a.19.1721758781573; Tue, 23 Jul 2024 11:19:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721758781; cv=none; d=google.com; s=arc-20160816; b=nJG7UjLb2A2PapURtbu/F5z+OMfWTD2+fC8JsIsvsZczsNc5ahmwHtINAA1UCb0d5j R6vb7Pt0CF2LAKG0Kf0/oO1rnjeJLmhJfrTneQHmZvFtwl2NL/y4hzD4nU2R5E8W6XiU YlrLkxXbg4UWtGJ150i0FQO5YGt7D/8mUWfs85aXYak07WhG9gd63mV2GYKhazBiq2Ud 3NlyecHCpX8pp0NM9jiz0hh1uIX8tgE+S9h/IzABq/Fse5J3V4V3Lvbih0hzdW8J3KF+ g1gygaxg8QmmKaqK/CYQYpCp/dJjXhtAvLRXPzVqru4eqHYrcPvW8P61pmHHI3VdbKza DH6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=vG3d6DT4g3RTpV52ZpbZlI+FaEaMRrTOU5HFxUCX76U=; fh=Bvpgva5ky59bvqrewJZk7nRFUPnkfkCdOBznwaq8N94=; b=mWu5sTcGDHo1MkKShB6RI0Fa1cYohsT5HeImhLFQEC9DsUxPt7R9ckQxFz9djeEfBi twf74AWpHwnJtEAJgYHIQg5q3MIpOeEZg5Hty4a4v6vJc/ceXdg4Fq5GIr9JxCIgG/RR NtLvKg7vKbCvy5qKQKsdZ07utzd/4OKqInwfTITgHa9gtbgduNE1CWxbycJEyhecHcjm dE/yTQwbwDsbwD/WI/dycXJNagEdWacqqOPPpwnqE9l0gKfKMENcACXzgJdcLTHfVoTw OomFUdUFHAUqEFmE0ET8thhOoZKX2laXBygUtYMX+QOrQQ1tLXxZFAdRfXTnyV4PzOmZ JzMA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tMjlGTxy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9cf1961dsi105132601cf.781.2024.07.23.11.19.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jul 2024 11:19:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tMjlGTxy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWK6I-0002M5-E8; Tue, 23 Jul 2024 14:19:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sWK6F-0002BW-O5 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 14:18:59 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sWK6D-0003Py-Mt for qemu-devel@nongnu.org; Tue, 23 Jul 2024 14:18:59 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-368f92df172so2748481f8f.2 for ; Tue, 23 Jul 2024 11:18:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721758734; x=1722363534; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vG3d6DT4g3RTpV52ZpbZlI+FaEaMRrTOU5HFxUCX76U=; b=tMjlGTxyeboy5TTnnJRSldCg3E4nVZKFnTcwKZVv+hfQHDNA9rop/jZpeEegUAe7sZ vle7kA7ZWdQCYfKIIO5uBt/FSZUYYwWUo+Hzj8VsZEKpc5AlesSLmu/+bClzPpPvKy6O 8C3cRCAgX9lOSPPpufgPBLWIm0AksXXU9xWgFvjVEHjo+y41B5ihTNNHLy0FkVyVHWqf NpNMAyfMc2chp9fgKHkUMU8aEB8uVRMEr5Len/SfT5Fx1zuJszIIAy2iVLctD6EnP+nY d6pI5nbFdkcsgyI135ZRrqi/iMIA8z1ok6pMLCK5JE5lA0wPsMkKQRstO04B8uAI2g6h RCaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721758734; x=1722363534; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vG3d6DT4g3RTpV52ZpbZlI+FaEaMRrTOU5HFxUCX76U=; b=rqCy+ZfRX2OsmkOv7naQ4C7fEDr5lUKx9qV9nsjI7IfqwXKz/Nx78kVy/lb7rh9UVg xwz90IOnOi7CpnIE4KyvUDNKUXozYirtnnEGsNRAgMjRHwjv4oDsHq33rny97xdqwE6W 2E53B/P444jlGJvq4q6JfetFT0ryIHJt0IW20TlQ12XYX8EvlMjT/DOd0ZpLYTOkjixV w1ptWi7uYTThu85LWW4lYDqqQZl/krvBiOLb7s6VKw+3Rky91nyA5cSdq3kXQlqpiDjt a98ryKEwbv1g0lA38V0JFFHstCUBM0MlZaWIbhZHM7AxHEPn+rkA1X+nWNreJzCCYkU5 h48g== X-Gm-Message-State: AOJu0YyM/hLmxx5hf4jjtndU4lMgYQ7tlHBIdUJE4Xun1Kk+shE1iEhe 7EwR5v0ZK4ZCXaBaQQFmbsMbpeCTypDcqRe8ZkGOOB1gELn2GHbYA0pV7Bx4owwE3kfTX36kgWH w04c= X-Received: by 2002:a05:6000:2c5:b0:368:665a:4c64 with SMTP id ffacd0b85a97d-369bae30740mr6539755f8f.5.1721758734031; Tue, 23 Jul 2024 11:18:54 -0700 (PDT) Received: from localhost.localdomain ([176.187.208.14]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868ac48sm12216796f8f.29.2024.07.23.11.18.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 Jul 2024 11:18:53 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , Gustavo Bueno Romero , Zhao Liu , Laurent Vivier , Pierrick Bouvier , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= Subject: [PATCH] hw/char/goldfish: Use DMA memory API Date: Tue, 23 Jul 2024 20:18:50 +0200 Message-ID: <20240723181850.46000-1-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=philmd@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Rather than using address_space_rw(..., 0 or 1), use the simpler DMA memory API which expand to the same code. This allows removing a cast on the 'buf' variable which is really const. Since 'buf' is only used in the CMD_READ_BUFFER case, we can reduce its scope. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Xu Reviewed-by: Pierrick Bouvier --- hw/char/goldfish_tty.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/char/goldfish_tty.c b/hw/char/goldfish_tty.c index f8ff043c396..cdff46bc13b 100644 --- a/hw/char/goldfish_tty.c +++ b/hw/char/goldfish_tty.c @@ -16,6 +16,7 @@ #include "qemu/log.h" #include "trace.h" #include "exec/address-spaces.h" +#include "sysemu/dma.h" #include "hw/char/goldfish_tty.h" #define GOLDFISH_TTY_VERSION 1 @@ -69,7 +70,6 @@ static uint64_t goldfish_tty_read(void *opaque, hwaddr addr, static void goldfish_tty_cmd(GoldfishTTYState *s, uint32_t cmd) { uint32_t to_copy; - uint8_t *buf; uint8_t data_out[GOLFISH_TTY_BUFFER_SIZE]; int len; uint64_t ptr; @@ -97,8 +97,8 @@ static void goldfish_tty_cmd(GoldfishTTYState *s, uint32_t cmd) while (len) { to_copy = MIN(GOLFISH_TTY_BUFFER_SIZE, len); - address_space_rw(&address_space_memory, ptr, - MEMTXATTRS_UNSPECIFIED, data_out, to_copy, 0); + dma_memory_read_relaxed(&address_space_memory, ptr, + data_out, to_copy); qemu_chr_fe_write_all(&s->chr, data_out, to_copy); len -= to_copy; @@ -109,9 +109,9 @@ static void goldfish_tty_cmd(GoldfishTTYState *s, uint32_t cmd) len = s->data_len; ptr = s->data_ptr; while (len && !fifo8_is_empty(&s->rx_fifo)) { - buf = (uint8_t *)fifo8_pop_buf(&s->rx_fifo, len, &to_copy); - address_space_rw(&address_space_memory, ptr, - MEMTXATTRS_UNSPECIFIED, buf, to_copy, 1); + const uint8_t *buf = fifo8_pop_buf(&s->rx_fifo, len, &to_copy); + + dma_memory_write_relaxed(&address_space_memory, ptr, buf, to_copy); len -= to_copy; ptr += to_copy;