From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Vinayak Holikatti <vinayak.kh@samsung.com>
Cc: <qemu-devel@nongnu.org>, <krish.reddy@samsung.com>,
<vishak.g@samsung.com>, <a.manzanares@samsung.com>,
<alok.rathore@samsung.com>, <s5.kumari@samsung.com>,
<linux-cxl@vger.kernel.org>
Subject: Re: [PATCH 2/2] hw/cxl/cxl-mailbox-utils: Add support for Media operations Sanitize and Write Zeros commands (8.2.9.9.5.3)
Date: Thu, 6 Feb 2025 13:45:33 +0000 [thread overview]
Message-ID: <20250206134533.00003e62@huawei.com> (raw)
In-Reply-To: <20250206092714.zdwd6lddw64d5j3b@test-PowerEdge-R740xd>
> >> +static int sanitize_range(CXLType3Dev *ct3d, uint64_t dpa_addr, size_t length,
> >> + uint8_t fill_value)
> >> +{
> >> +
> >> + MemoryRegion *vmr = NULL, *pmr = NULL;
> >> + uint64_t vmr_size = 0, pmr_size = 0;
> >> + AddressSpace *as = NULL;
> >> + MemTxAttrs mem_attrs = {0};
> >> +
> >> + if (ct3d->hostvmem) {
> >> + vmr = host_memory_backend_get_memory(ct3d->hostvmem);
> >> + vmr_size = memory_region_size(vmr);
> >> + }
> >> + if (ct3d->hostpmem) {
> >> + pmr = host_memory_backend_get_memory(ct3d->hostpmem);
> >> + pmr_size = memory_region_size(pmr);
> >> + }
> >> +
> >> + if (dpa_addr < vmr_size) {
> >> + as = &ct3d->hostvmem_as;
> >> + } else if (dpa_addr < vmr_size + pmr_size) {
> >> + as = &ct3d->hostpmem_as;
> >> + } else {
> >> + if (!ct3_test_region_block_backed(ct3d, dpa_addr, length)) {
> >> + return -ENODEV;
> >> + }
> >> + as = &ct3d->dc.host_dc_as;
> >> + }
> >
> >You could factor out everything down to here and then use that
> >for the validate_dpa_addr() as finding an address space means
> >we also checked the address is valid. Otherwise it does not match.
>
> Didnt get what you meant, validate_dpa_addr is meant for
> checking valid dpa address and sanitize_range is
> get the address space handle to do actual sanitize
> of dpa address, so two are different purposes,
Different purposes but the actual checks mostly
overlap. If we can find the address space then there
are only a few extra checks on alignment with granual
size etc needed. I'd just like to avoid that duplication
so factor out the shared code to a helper called in both
functions.
>
> >
> >> +
> >> + return address_space_set(as, dpa_addr,
prev parent reply other threads:[~2025-02-06 13:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250123050903.92336-1-vinayak.kh@samsung.com>
[not found] ` <CGME20250123050912epcas5p2965fd6efa702030802a42c225f11f65b@epcas5p2.samsung.com>
[not found] ` <20250123050903.92336-2-vinayak.kh@samsung.com>
2025-01-24 14:56 ` [PATCH 1/2] hw/cxl/cxl-mailbox-utils: Add support for Media operations discovery commands (8.2.9.9.5.3) Jonathan Cameron
2025-02-11 5:20 ` Vinayak Holikatti
[not found] ` <CGME20250123050913epcas5p45fb9a638e62f436076da283e86e54ea2@epcas5p4.samsung.com>
[not found] ` <20250123050903.92336-3-vinayak.kh@samsung.com>
2025-01-24 15:19 ` [PATCH 2/2] hw/cxl/cxl-mailbox-utils: Add support for Media operations Sanitize and Write Zeros " Jonathan Cameron
2025-01-31 20:48 ` Adam Manzanares
2025-02-03 11:33 ` Jonathan Cameron
2025-02-03 17:02 ` Adam Manzanares
2025-02-06 9:29 ` Vinayak Holikatti
2025-02-06 9:27 ` Vinayak Holikatti
2025-02-06 13:45 ` Jonathan Cameron [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=20250206134533.00003e62@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=a.manzanares@samsung.com \
--cc=alok.rathore@samsung.com \
--cc=krish.reddy@samsung.com \
--cc=linux-cxl@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
--cc=s5.kumari@samsung.com \
--cc=vinayak.kh@samsung.com \
--cc=vishak.g@samsung.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox