All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Saeed Mahameed <saeed@kernel.org>
Cc: Jason Gunthorpe <jgg@nvidia.com>,
	Or Har-Toov <ohartoov@nvidia.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	linux-rdma@vger.kernel.org,
	Michael Guralnik <michaelgur@nvidia.com>,
	netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
	Saeed Mahameed <saeedm@nvidia.com>
Subject: Re: [PATCH rdma-next 4/4] RDMA/mlx5: Use query_special_contexts for mkeys
Date: Tue, 10 Jan 2023 10:45:49 +0200	[thread overview]
Message-ID: <Y70lvUCHeHhNnneq@unreal> (raw)
In-Reply-To: <Y7yUHJukwiIcL5BJ@x130>

On Mon, Jan 09, 2023 at 02:24:28PM -0800, Saeed Mahameed wrote:
> On 08 Jan 12:21, Leon Romanovsky wrote:
> > On Thu, Jan 05, 2023 at 05:04:03PM -0800, Saeed Mahameed wrote:
> > > On 04 Jan 16:03, Leon Romanovsky wrote:
> > > > On Wed, Jan 04, 2023 at 09:56:21AM -0400, Jason Gunthorpe wrote:
> > > > > On Wed, Jan 04, 2023 at 03:55:25PM +0200, Leon Romanovsky wrote:
> > > > > > On Wed, Jan 04, 2023 at 09:13:10AM -0400, Jason Gunthorpe wrote:
> > > > > > > On Wed, Jan 04, 2023 at 03:09:54PM +0200, Leon Romanovsky wrote:
> > > > > > > > On Wed, Jan 04, 2023 at 09:03:06AM -0400, Jason Gunthorpe wrote:
> > > > > > > > > On Wed, Jan 04, 2023 at 10:11:25AM +0200, Leon Romanovsky wrote:
> > > > > > > > > > -int mlx5_cmd_null_mkey(struct mlx5_core_dev *dev, u32 *null_mkey)
> > > > > > > > > > -{
> > > > > > > > > > -	u32 out[MLX5_ST_SZ_DW(query_special_contexts_out)] = {};
> > > > > > > > > > -	u32 in[MLX5_ST_SZ_DW(query_special_contexts_in)] = {};
> > > > > > > > > > -	int err;
> > > > > > > > > > +	err = mlx5_cmd_exec_inout(dev->mdev, query_special_contexts, in, out);
> > > > > > > > > > +	if (err)
> > > > > > > > > > +		return err;
> > > > > > > > > >
> > > > > > > > > > -	MLX5_SET(query_special_contexts_in, in, opcode,
> > > > > > > > > > -		 MLX5_CMD_OP_QUERY_SPECIAL_CONTEXTS);
> > > > > > > > > > -	err = mlx5_cmd_exec_inout(dev, query_special_contexts, in, out);
> > > > > > > > > > -	if (!err)
> > > > > > > > > > -		*null_mkey = MLX5_GET(query_special_contexts_out, out,
> > > > > > > > > > -				      null_mkey);
> > > > > > > > > > -	return err;
> > > > > > > > > > +	if (MLX5_CAP_GEN(dev->mdev, dump_fill_mkey))
> > > > > > > > > > +		dev->mkeys.dump_fill_mkey = MLX5_GET(query_special_contexts_out,
> > > > > > > > > > +						     out, dump_fill_mkey);
> > > > > > > > > > +
> > > > > > > > > > +	if (MLX5_CAP_GEN(dev->mdev, null_mkey))
> > > > > > > > > > +		dev->mkeys.null_mkey = cpu_to_be32(
> > > > > > > > > > +			MLX5_GET(query_special_contexts_out, out, null_mkey));
> > > > > > > > > > +
> > > > > > > > > > +	if (MLX5_CAP_GEN(dev->mdev, terminate_scatter_list_mkey)) {
> > > > > > > > > > +		dev->mkeys.terminate_scatter_list_mkey =
> > > > > > > > > > +			cpu_to_be32(MLX5_GET(query_special_contexts_out, out,
> > > > > > > > > > +					     terminate_scatter_list_mkey));
> > > > > > > > > > +		return 0;
> > > > > > > > > > +	}
> > > > > > > > > > +	dev->mkeys.terminate_scatter_list_mkey =
> > > > > > > > > > +		MLX5_TERMINATE_SCATTER_LIST_LKEY;
> > > > > > > > >
> > > > > > > > > This is already stored in the core dev, why are you recalculating it
> > > > > > > > > here?
> > > > > > > >
> > > > > > > > It is not recalculating but setting default value. In core dev, we will
> > > > > > > > have value only if MLX5_CAP_GEN(dev->mdev, terminate_scatter_list_mkey)
> > > > > > > > is true.
> > > > > > >
> > > > > > > No, it has the identical code:
> > > > > > >
> > > > > > > +static int mlx5_get_terminate_scatter_list_mkey(struct mlx5_core_dev *dev)
> > > > > > > +{
> > > > > > > +       if (MLX5_CAP_GEN(dev, terminate_scatter_list_mkey)) {
> > > > > > > +               dev->terminate_scatter_list_mkey =
> > > > > > > +                       cpu_to_be32(MLX5_GET(query_special_contexts_out, out,
> > > > > > > +                                            terminate_scatter_list_mkey));
> > > > > > > +               return 0;
> > > > > > > +       }
> > > > > > > +       dev->terminate_scatter_list_mkey = MLX5_TERMINATE_SCATTER_LIST_LKEY;
> > > > > >
> > > > > > Ahh, you are talking about that.
> > > > > > terminate_scatter_list_mkey is part of an output from MLX5_CMD_OP_QUERY_SPECIAL_CONTEXTS,
> > > > > > which is needed to get other mkeys. So instead of doing special logic
> > > > > > for the terminate_scatter_list_mkey, we decided to use same pattern as
> > > > > > for other mkeys, which don't belong to core.
> > > > >
> > > > > Regardless, don't duplicate the code and maybe don't even duplicate
> > > > > the storage of the terminate_scatter_list_mkey
> > > >
> > > > ok, will update and resend.
> > > >
> > > 
> > > Please provide a helper mlx5_get_xyz function, avoid assuming mlx5_core will store
> > > it in dev->xyz.
> > 
> > This helper was used in this version of patch and it is:
> > MLX5_GET(query_special_contexts_out, out, terminate_scatter_list_mkey))
> > Which was dropped in favor of Jason's request to rely on mlx5_core_dev
> > as this value already known:
> > https://lore.kernel.org/all/cover.1672917578.git.leonro@nvidia.com
> > 
> > I don't like the idea to add obfuscation function just for the sake of
> > obfuscation. If you don't want access to mlx5_core_dev, please argue with
> > Jason to accept first variant.
> 
> I think you are confused, 1st version duplicated the logic that already
> existed in mlx5 core, didn't just access with MLX5_GET.

No, the end result is the same: call to the memory to get terminate_scatter_list_mkey
value. MLX5_GET(..) will return exactly the same value as dev->terminate_scatter_list_mkey
or some other function call:

int mlx5_get_terminate_scatter_list_mkey() {
 return dev->terminate_scatter_list_mkey;
}

> 
> 

      reply	other threads:[~2023-01-10  8:47 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04  8:11 [PATCH rdma-next 0/4] Rely on firmware to get special mkeys Leon Romanovsky
2023-01-04  8:11 ` [PATCH mlx5-next 1/4] net/mlx5: Expose bits for querying " Leon Romanovsky
2023-01-04  8:11 ` [PATCH mlx5-next 2/4] net/mlx5: Change define name for 0x100 lkey value Leon Romanovsky
2023-01-04  8:11 ` [PATCH mlx5-next 3/4] net/mlx5: Use query_special_contexts for mkeys Leon Romanovsky
2023-01-06  0:58   ` Saeed Mahameed
2023-01-08 10:32     ` Leon Romanovsky
2023-01-09 22:31       ` Saeed Mahameed
2023-01-04  8:11 ` [PATCH rdma-next 4/4] RDMA/mlx5: " Leon Romanovsky
2023-01-04 13:03   ` Jason Gunthorpe
2023-01-04 13:09     ` Leon Romanovsky
2023-01-04 13:13       ` Jason Gunthorpe
2023-01-04 13:55         ` Leon Romanovsky
2023-01-04 13:56           ` Jason Gunthorpe
2023-01-04 14:03             ` Leon Romanovsky
2023-01-06  1:04               ` Saeed Mahameed
2023-01-08 10:21                 ` Leon Romanovsky
2023-01-09 22:24                   ` Saeed Mahameed
2023-01-10  8:45                     ` Leon Romanovsky [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y70lvUCHeHhNnneq@unreal \
    --to=leon@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jgg@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=michaelgur@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=ohartoov@nvidia.com \
    --cc=pabeni@redhat.com \
    --cc=saeed@kernel.org \
    --cc=saeedm@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.