Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp2568rbe; Wed, 28 Feb 2024 10:10:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU1iGlgZVkJqU0YJhs727hoe5bqTmMNM586e+MWUWchBBG3S3O4UMjGgvFHT1ZlK+L9544xITOBB0Tq48p4j219hnkb+POYJNqnQDBAXA== X-Google-Smtp-Source: AGHT+IHNhaKsdqizslic3do4Mf2CBfRSAyznxrm54Xqj5bdkAk/Um2f7yQ1JQ1aVNgBAT9+wy8Ss X-Received: by 2002:a05:6808:bd4:b0:3c0:3189:d9e2 with SMTP id o20-20020a0568080bd400b003c03189d9e2mr6681512oik.20.1709143827789; Wed, 28 Feb 2024 10:10:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709143827; cv=pass; d=google.com; s=arc-20160816; b=EDPZ//WhFaUzRyx9sEtyB9e6Qr56V3nJAdH/bLTiV2fCHF/6/27lhVPCV8ElP/dvb7 Y0Qd0OktnGQHQCZPJr14RJV42HoXIVAUqCIHJTQlpoA8ih1EzXWxE6cQJf1Oo8uCBR3H /pXwt+sLEACrwV+w1emXU3kg/F3P1E0bhrSXqLeW0eGdfVXP+GPTZcG+iM/kQRbytOCR aNMGaFpTLFyInRNWpi/UR9VqtWBAFtsEAPqNyg+Fy3t6zP/VMTOmpWPmxlA6I2ZxinJV xOYULKdF/bh9BANRrseufoMslnQZ32zl60RJBcsKipVUvPEMH3OMhnn2gb6Cergepxe9 vhVw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:organization:autocrypt :references:in-reply-to:date:to:reply-to:from:subject:message-id :dkim-signature; bh=xc4LGkLvVaVJhJXOTj5T8Fde54NZaiMVvKAFIUI+VXo=; fh=QC9YcPh8NIUANQEpVxZxAZTL42GzMqvlyPx8TUvLVUU=; b=WFM04EQsMSig9hwrVIPsNF04rG/u2HVQEwBDBjjFVBr3Upmj/qFIlku/snbpQj4ojr F7WQDpmMvHHpShJdouoHbELZmS+NNG8bC9as1s81Iaf7RLE9aY6dO320+HDpNo7/Q7qa POYd/+iPIVhk1eiop+eFLiTPR1xIdnzORinit+YR/B2lo5u2ZKfVio3rR7FQGQuC+iW8 Htfhjh68ldEtKUijZO/6xZl2gk4e7qeh7KNHynY/JVGbzu58MKawxGNHSuU9XWRy+NoY F+ZxlJKpnd58zYeo4gXKjSPJwk1c/RlY4HPKRtgZKEKPgCazLLPhcK9YzK+d2XLa4dXu VVHg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l2tlfq6O; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-85510-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85510-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b21-20020a63eb55000000b005d7bf204e22si22964pgk.859.2024.02.28.10.10.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 10:10:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85510-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l2tlfq6O; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-85510-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85510-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 712E5289A84 for ; Wed, 28 Feb 2024 18:10:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 048C079B94; Wed, 28 Feb 2024 18:10:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="l2tlfq6O" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DF2E79B83; Wed, 28 Feb 2024 18:10:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709143814; cv=none; b=omySp02xDQlJ/25lwNmApFE6ftBs+OieH1tK9ipTzVXG2N5H2fQBJbIeJJzYwCz551vutkmAV8MIGIrPdn7ksLZHUggrisY6DuNgQPJzKNhpku8QbhSMgs3xhV5cBagcPYkHF+3Hm2j6qQBe+fLFZ3cY4/vfJJVPxu/K0FaCTlI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709143814; c=relaxed/simple; bh=7nVt3hJRNv8Y1TTfxyAmSPl7PgcYwNa0Ckx272J3/3c=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References: Content-Type:MIME-Version; b=nXZF1Zga70URt3hOfCQKJ3JUUSpn5gz0HrFbXBApsn2TyzaZfAc/z8dMWTs0JDrCRNVLFzQe2mdM8rB6F44wfWPY0aa/nJR59qzZ/Q463/wPPZm4vBu7DNEoCg6daqKENOEee144TEAood2YKffYe9JXL81AptL84RIoJzCc5XI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=l2tlfq6O; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709143812; x=1740679812; h=message-id:subject:from:reply-to:to:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=7nVt3hJRNv8Y1TTfxyAmSPl7PgcYwNa0Ckx272J3/3c=; b=l2tlfq6O+FHzYszTPdPEezEBhHhegL+BY6snC1MuEyzNVQ5puLkgBuC9 tyESXMHoRaoybFzg6uIkeY+G16bErNxWvSPXEP4ieMkkaIuGwmeTo+BBL DwVZQrjzhS/BxVusyHhmSITjM+A7SWyp3J5iscueGBCJKw8JqWiaWAQSo ZWXOQeDwdqM9HJHl6UU2/nxcw0b4UZt9yPONDbjTRk9sRvIHhJeyTfxyu xH4AGG0iGrzSJizripBvkeHMp+cBTiY+v3DuaoeakIRRCHmglsuxU+u5W FeO6vkY2VmNP/oIg6TuD/N3g28fvCn5okvUZX8PF0rfU3MnjRvd9O/bW6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14274255" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="14274255" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 10:10:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12230615" Received: from linux.intel.com ([10.54.29.200]) by orviesa005.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 10:10:11 -0800 Received: from [10.54.75.156] (debox1-desk1.jf.intel.com [10.54.75.156]) by linux.intel.com (Postfix) with ESMTP id 1EB48580B99; Wed, 28 Feb 2024 10:10:11 -0800 (PST) Message-ID: <2dba47561b467c483263b65606aa3e79c05c91a3.camel@linux.intel.com> Subject: Re: [PATCH V2 2/9] platform/x86/intel/sdsi: Combine read and write mailbox flows From: "David E. Box" Reply-To: david.e.box@linux.intel.com To: Kuppuswamy Sathyanarayanan , rajvi.jingar@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com Date: Wed, 28 Feb 2024 10:10:11 -0800 In-Reply-To: References: <20240228000016.1685518-1-david.e.box@linux.intel.com> <20240228000016.1685518-3-david.e.box@linux.intel.com> Autocrypt: addr=david.e.box@linux.intel.com; prefer-encrypt=mutual; keydata=mQENBF2w2YABCACw5TpqmFTR6SgsrNqZE8ro1q2lUgVZda26qIi8GeHmVBmu572RfPydisEpCK246rYM5YY9XAps810ZxgFlLyBqpE/rxB4Dqvh04QePD6fQNui/QCSpyZ6j9F8zl0zutOjfNTIQBkcar28hazL9I8CGnnMko21QDl4pkrq1dgLSgl2r2N1a6LJ2l8lLnQ1NJgPAev4BWo4WAwH2rZ94aukzAlkFizjZXmB/6em+lhinTR9hUeXpTwcaAvmCHmrUMxeOyhx+csO1uAPUjxL7olj2J83dv297RrpjMkDyuUOv8EJlPjvVogJF1QOd5MlkWdj+6vnVDRfO8zUwm2pqg25DABEBAAG0KkRhdmlkIEUuIEJveCA8ZGF2aWQuZS5ib3hAbGludXguaW50ZWwuY29tPokBTgQTAQgAOBYhBBFoZ8DYRC+DyeuV6X7Mry1gl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xSfoLZvtoj2MR+2PW1zBALWYUKHOzhfFKs3cMufwIIoQUPVqGVeH+u6Asun6ZpNRxdDONop+uEXHe6q6LzI/NnczqoZQLhM8d1XqokYax/IZ4= Organization: David E. Box Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.2 (3.50.2-1.fc39) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Tue, 2024-02-27 at 18:38 -0800, Kuppuswamy Sathyanarayanan wrote: >=20 > On 2/27/24 4:00 PM, David E. Box wrote: > > The current mailbox commands are either read-only or write-only and the > > flow is different for each. New commands will need to send and receive > > data. In preparation for these commands, create a common polling functi= on > > to handle sending data and receiving in the same transaction. > >=20 > > Signed-off-by: David E. Box > > --- > >=20 > > V2 - In sdsi_cmd_read() remove unnecessary check for non-zero packet_si= ze > > =C2=A0=C2=A0=C2=A0=C2=A0 in do loop since the loop is exited earlier wh= en packet_size is > > =C2=A0=C2=A0=C2=A0=C2=A0 zero. > >=20 > > =C2=A0drivers/platform/x86/intel/sdsi.c | 79 +++++++++++++++++---------= ----- > > =C2=A01 file changed, 44 insertions(+), 35 deletions(-) > >=20 > > diff --git a/drivers/platform/x86/intel/sdsi.c > > b/drivers/platform/x86/intel/sdsi.c > > index a70c071de6e2..d80c2dc0ce71 100644 > > --- a/drivers/platform/x86/intel/sdsi.c > > +++ b/drivers/platform/x86/intel/sdsi.c > > @@ -15,6 +15,7 @@ > > =C2=A0#include > > =C2=A0#include > > =C2=A0#include > > +#include > > =C2=A0#include > > =C2=A0#include > > =C2=A0#include > > @@ -156,8 +157,8 @@ static int sdsi_status_to_errno(u32 status) > > =C2=A0 } > > =C2=A0} > > =C2=A0 > > -static int sdsi_mbox_cmd_read(struct sdsi_priv *priv, struct sdsi_mbox= _info > > *info, > > - =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 size_t *data_size) > > +static int sdsi_mbox_poll(struct sdsi_priv *priv, struct sdsi_mbox_inf= o > > *info, > > + =C2=A0 size_t *data_size) > > =C2=A0{ > > =C2=A0 struct device *dev =3D priv->dev; > > =C2=A0 u32 total, loop, eom, status, message_size; > > @@ -166,18 +167,10 @@ static int sdsi_mbox_cmd_read(struct sdsi_priv *p= riv, > > struct sdsi_mbox_info *inf > > =C2=A0 > > =C2=A0 lockdep_assert_held(&priv->mb_lock); > > =C2=A0 > > - /* Format and send the read command */ > > - control =3D FIELD_PREP(CTRL_EOM, 1) | > > - =C2=A0 FIELD_PREP(CTRL_SOM, 1) | > > - =C2=A0 FIELD_PREP(CTRL_RUN_BUSY, 1) | > > - =C2=A0 FIELD_PREP(CTRL_PACKET_SIZE, info->size); > > - writeq(control, priv->control_addr); > > - > > =C2=A0 /* For reads, data sizes that are larger than the mailbox size a= re > > read in packets. */ > > =C2=A0 total =3D 0; > > =C2=A0 loop =3D 0; > > =C2=A0 do { > > - void *buf =3D info->buffer + (SDSI_SIZE_MAILBOX * loop); > > =C2=A0 u32 packet_size; > > =C2=A0 > > =C2=A0 /* Poll on ready bit */ > > @@ -195,6 +188,11 @@ static int sdsi_mbox_cmd_read(struct sdsi_priv *pr= iv, > > struct sdsi_mbox_info *inf > > =C2=A0 if (ret) > > =C2=A0 break; > > =C2=A0 > > + if (!packet_size) { > > + sdsi_complete_transaction(priv); > > + break; > > + } > > + > > =C2=A0 /* Only the last packet can be less than the mailbox size. > > */ > > =C2=A0 if (!eom && packet_size !=3D SDSI_SIZE_MAILBOX) { > > =C2=A0 dev_err(dev, "Invalid packet size\n"); > > @@ -208,9 +206,13 @@ static int sdsi_mbox_cmd_read(struct sdsi_priv *pr= iv, > > struct sdsi_mbox_info *inf > > =C2=A0 break; > > =C2=A0 } > > =C2=A0 > > - sdsi_memcpy64_fromio(buf, priv->mbox_addr, > > round_up(packet_size, SDSI_SIZE_CMD)); > > + if (info->buffer) { > > + void *buf =3D info->buffer + > > array_size(SDSI_SIZE_MAILBOX, loop); > > =C2=A0 > > - total +=3D packet_size; > > + sdsi_memcpy64_fromio(buf, priv->mbox_addr, > > + =C2=A0=C2=A0=C2=A0=C2=A0 round_up(packet_size, > > SDSI_SIZE_CMD)); > > + total +=3D packet_size; > > + } > > =C2=A0 > > =C2=A0 sdsi_complete_transaction(priv); > > =C2=A0 } while (!eom && ++loop < MBOX_MAX_PACKETS); > > @@ -230,16 +232,33 @@ static int sdsi_mbox_cmd_read(struct sdsi_priv *p= riv, > > struct sdsi_mbox_info *inf > > =C2=A0 dev_warn(dev, "Read count %u differs from expected count > > %u\n", > > =C2=A0 total, message_size); > > =C2=A0 > > - *data_size =3D total; > > + if (data_size) > > + *data_size =3D total; > > =C2=A0 >=20 > Is there a chance for it to be NULL with current callers? Yes. Write only callers set this to NULL. David