Commit Graph

1065290 Commits

Author SHA1 Message Date
Ulises Mendez Martinez
24886bc4db ANDROID: rockpi4: Add ABI targets & symbol list
* This is the initial symbol list for
rockpi4 target.

Bug: 261782070
Change-Id: I76f8924f5e40c6ecfb91a5291b86a9d4fd9badb0
Signed-off-by: Ulises Mendez Martinez <umendez@google.com>
2023-01-24 20:19:05 +00:00
Keir Fraser
0cd7729ab5 ANDROID: KVM: arm64: Include MMIO guard and memory relinquish in top-level hypercalls doc
This introduces a description of the MEM_RELINQUISH hypercall. MMIO
guard hypercalls are already described in another file, which we now
link to.

Signed-off-by: Keir Fraser <keirf@google.com>
Bug: 265943840
Change-Id: Iaffde3419f6432d76598e48c9bab53f672430b7a
2023-01-24 13:06:07 +00:00
Keir Fraser
7eed5740ff ANDROID: KVM: arm64: Fix MMIO guard documentation
Firstly, the hypercall IDs have been renumbered but that was not
reflected in the documentation. Secondly, the argument registers r1-r3
are checked to be zero when calling
ARM_SMCCC_KVM_FUNC_MMIO_GUARD_INFO.

Signed-off-by: Keir Fraser <keirf@google.com>
Bug: 265943840
Change-Id: I9684d1e71af7d8627d079cfd89d437cfc28be09f
2023-01-24 12:57:30 +00:00
Keir Fraser
9795ec6a60 ANDROID: KVM: arm64: Consistent hypercall naming in documentation
Change a few uses of ARM_SMCCC_VENDOR_HYP_KVM_FOO_FUNC_ID to
ARM_SMCCC_KVM_FUNC_FOO.

Signed-off-by: Keir Fraser <keirf@google.com>
Bug: 265943840
Change-Id: Id1642243ca4105a23e808cf28d13bfb81d9a5ac2
2023-01-24 12:56:21 +00:00
Lee Jones
f632042365 ANDROID: usb: f_accessory: Check buffer size when initialised via composite
When communicating with accessory devices via USBFS, the initialisation
call-stack looks like:

  ConfigFS > Gadget ConfigFS > UDC > Gadget ConfigFS > Composite

Eventually ending up in composite_dev_prepare() where memory for the
data buffer is allocated and initialised.  The default size used for the
allocation is USB_COMP_EP0_BUFSIZ (4k).  When handling bulk transfers,
acc_ctrlrequest() needs to be able to handle buffers up to
BULK_BUFFER_SIZE (16k).  Instead of adding new generic attributes to
'struct usb_request' to track the size of the allocated buffer, we can
simply split off the affected thread of execution to travel via a
knowledgeable abstracted function acc_ctrlrequest_composite() where we
can complete the necessary specific checks.

Bug: 264029575
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Ia1280f85499621d3fa57f7262b4a2c80f4be7773
Signed-off-by: Lee Jones <joneslee@google.com>
2023-01-23 10:32:00 +00:00
Peter Collingbourne
f95873c0e5 Revert "FROMLIST: kasan: allow sampling page_alloc allocations for HW_TAGS"
This reverts commit fe19dff7e6.

Reason for revert:
Observed frequent boot crashes on a device with sampling KASAN enabled.

Bug: 265863271
Change-Id: Ib7860295065ed7aaa36d9e47d8aaa97918c7bc57
Signed-off-by: Peter Collingbourne <pcc@google.com>
2023-01-20 15:11:44 -08:00
Peter Collingbourne
c1ab330840 Revert "ANDROID: gki_defconfig: sample large page_alloc allocations with HW_TAGS KASAN"
This reverts commit 0352e06246.

Reason for revert:
Observed frequent boot crashes on a device with sampling KASAN enabled.

Bug: 265863271
Change-Id: Ie4d9c2ffc39288a9f9a941784bf661eed14503e9
Signed-off-by: Peter Collingbourne <pcc@google.com>
2023-01-20 15:11:40 -08:00
Can Guo
07cd4e0de0 FROMGIT: scsi: ufs: core: mcq: Add Event Specific Interrupt enable and config functions
Add and export two functions to enable ESI and config ESI base addresses.
The calls to these exported functions will be added by the next patch in
this series.

Change-Id: Icccf24b3a0275f76af63c81f1899c48f8c739cbd
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit e02288e0265fe316a16d48ec6dd7b7fd54d66e3e git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-20 13:52:04 -08:00
Ramji Jiyani
0a903fe828 ANDROID: GKI: Header generation fix and improvements
Remove dependency on kleaf intermediate abi_symbollist.raw
and use vendor symbol lists as dependencies for header
generation targets. This prevents the feature to break in
case kleaf path and/or sandboxes changes and rebuilds the
header files if any vendor symbol list changes.

Update the header generation script to process the symbol lists
before generating headers to make sure symbols are in byte order,
any symbol list marker, whitespaces and emptylines are removed
for kernel binary search API.

Bug: 232430739
Test: TH
Change-Id: Ib5783fb21543844dac7faf1fb0fcf3e7bd2bf608
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
2023-01-20 20:42:00 +00:00
Can Guo
d9ffe17d8a FROMGIT: scsi: ufs: core: Add Event Specific Interrupt configuration vendor specific ops
As Event Specific Interrupt message format is not defined in UFSHCI JEDEC
specs, and the ESI handling highly depends on how the format is designed,
hence add a vendor specific ops such that SoC vendors can configure their
own ESI handlers. If ESI vops is not provided or returning error, go with
the legacy (central) interrupt way.

Change-Id: I568e14b01e98868e5149c95cf3f6ee815c72868a
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit edb0db05607ce05a5e0df00518b58a811e9f548e git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-20 08:05:04 +00:00
Asutosh Das
5dc464cf82 FROMGIT: scsi: ufs: core: mcq: Enable multi-circular queue
Enable MCQ in the Host Controller.

Change-Id: I288e4f44416e268ce820219b27f60afbb8f94636
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit eacb139b77ff75b973cb99573b33a7adb1f4ca38 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-20 08:05:04 +00:00
Asutosh Das
67430bf68c FROMGIT: scsi: ufs: core: mcq: Add completion support in poll
Complete CQE requests in poll. Assumption is that several poll completion
may happen in different CPUs for the same completion queue. Hence a spin
lock protection is added.

Co-developed-by: Can Guo <quic_cang@quicinc.com>
Change-Id: I99e7ab96fea562904a572e29f28ecfd10c3ab6cc
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit ed975065c31c2a0372e13c19e8140b69814a98ba git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-20 08:05:04 +00:00
Asutosh Das
31fe4a1621 FROMGIT: scsi: ufs: mcq: Add completion support of a CQE
Add support for completing requests from Completion Queue.  Some host
controllers support vendor specific registers that provide a bitmap of all
CQs which have at least one completed CQE. Add this support.  The MCQ
specification doesn't provide the Task Tag or its equivalent in the
Completion Queue Entry.  So use an indirect method to find the Task Tag
from the Completion Queue Entry.

Co-developed-by: Can Guo <quic_cang@quicinc.com>
Change-Id: Iecd678ef71f5c64925723db198c020fe4cfe36e4
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit f87b2c41822aad09aadac31b8ba22c0c0e639eee git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-20 08:05:04 +00:00
Asutosh Das
ee00e6f120 FROMGIT: scsi: ufs: core: Prepare for completion in MCQ
Modify completion path APIs and add completion queue entry.

Co-developed-by: Can Guo <quic_cang@quicinc.com>
Change-Id: I991ab6052dd0e9278f64d7b8408a9a1fc86108c6
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit c30d8d010b5efd1d526ae94c9fbbfc0f74cec9fe git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-20 08:05:04 +00:00
Asutosh Das
1868449c92 FROMGIT: scsi: ufs: core: mcq: Find hardware queue to queue request
Add support to find the hardware queue on which the request would be
queued.  Since the very first queue is to serve device commands, an offset
of 1 is added to the index of the hardware queue.

Co-developed-by: Can Guo <quic_cang@quicinc.com>
Change-Id: I8ea638482b7c9b9528867284855d142ca9bbeb58
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 854f84e7feebc0c5a63e4c1f29ddf201fd2a57bc git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-20 08:05:04 +00:00
Asutosh Das
0a6fca85d6 BACKPORT: FROMGIT: scsi: ufs: core: Prepare ufshcd_send_command() for MCQ
Add support to send commands using multiple submission queues in MCQ mode.
Modify the functions that use ufshcd_send_command().

Co-developed-by: Can Guo <quic_cang@quicinc.com>
Change-Id: Ib570322ed4456e2328349df4c38f9b46f9f423b6
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 22a2d563de1425ea294e9abfa104dbf20c83a28a git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-20 08:05:04 +00:00
Asutosh Das
4b026bdc91 BACKPORT: FROMGIT: scsi: ufs: core: mcq: Use shared tags for MCQ mode
Enable shared tags for MCQ. For UFS, this should not have a huge
performance impact. It however simplifies the MCQ implementation and reuses
most of the existing code in the issue and completion path.  Also add
multiple queue mapping to map_queue().

Co-developed-by: Can Guo <quic_cang@quicinc.com>
Change-Id: Ida770b88a94957d51f9e564ffa1f4cfe4dfae4ed
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 0d33728fc0e77adeea95de6e53cf26a4f741e594 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-20 08:05:04 +00:00
Paul Lawrence
d1697c9217 ANDROID: incremental fs: Move throttling to outside page lock
Bug: 241479010
Test: incfs_test passes, play confirm behavior in bug is fixed
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ie51f2b76d0873057f54fecf7fcc793c66df20969
2023-01-19 20:57:25 +00:00
Paul Lawrence
35606f6104 ANDROID: incremental fs: Add throttled_read_doesnt_block_read_test
Bug: 261875471
Test: New tests fail initially, pass with aosp/2225243
Change-Id: Ia5f2073dc4710306bd348cb2aab6d2599fd06500
Signed-off-by: Paul Lawrence <paullawrence@google.com>
2023-01-19 20:57:25 +00:00
Paul Lawrence
9e6e86b3ff ANDROID: incremental fs: Fix race between truncate and write last block
Also fix race whereby multiple providers writinig the same block would
actually write out the same block.

Note that multiple_providers_test started failing when incfs was ported
to 5.15, and these fixes are needed to make the test reliable

Bug: 264703896
Test: incfs-test passes, specifically multiple_providers_test. Ran 100
      times
Change-Id: I05ad5b2b2f62cf218256222cecb79bbe9953bd97
Signed-off-by: Paul Lawrence <paullawrence@google.com>
2023-01-19 20:57:25 +00:00
Paul Lawrence
e6c9473f25 ANDROID: incremental fs: Add ability to run ranges of tests to incfs_test
Also fix test build, test memory leaks

Test: run various range options
Change-Id: I747b3c02f0eb7da440c9d2c2a67e19164b8c9908
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Bug: 264703896
2023-01-19 20:57:25 +00:00
Asutosh Das
1d9055b834 FROMGIT: scsi: ufs: core: mcq: Configure operation and runtime interface
Runtime and operation registers are defined per Submission and Completion
queue.  The location of these registers is not defined in the spec; meaning
the offsets and stride may vary for different HC vendors. Establish the
stride, base address, and doorbell address offsets from vendor host driver
and program it.

Co-developed-by: Can Guo <quic_cang@quicinc.com>
Change-Id: I047ebe88dcca27e9ec2ac422b6b9ce28634c595d
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 2468da61ea095162067ed408824298ba9c3661c8 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Asutosh Das
260ac71627 FROMGIT: scsi: ufs: core: mcq: Allocate memory for MCQ mode
To read the bqueuedepth, the device descriptor is fetched in Single
Doorbell Mode. This allocated memory may not be enough for MCQ mode because
the number of tags supported in MCQ mode may be larger than in SDB mode.
Hence, release the memory allocated in SDB mode and allocate memory for MCQ
mode operation.  Define the UFS hardware queue and Completion Queue Entry.

Co-developed-by: Can Guo <quic_cang@quicinc.com>
Change-Id: Ib11a63c7f9014dbd88669c2f3b6675b12e44f528
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 4682abfae2eb3a1c138130cfd6d71411d81aaa00 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Asutosh Das
72999d5802 FROMGIT: scsi: ufs: core: mcq: Calculate queue depth
The UFS device defines the supported queuedepth by bqueuedepth which has a
max value of 256.  The HC defines MAC (Max Active Commands) that defines
the max number of commands that in flight to the UFS device.  Calculate and
configure the nutrs based on both these values.

Co-developed-by: Can Guo <quic_cang@quicinc.com>
Change-Id: I7b1d3d33e14c144129a80f8f46ac29a8e82a0251
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 7224c806876e46cfaf46b1c90da8d5c2e1f2108f git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Asutosh Das
52daaae0bb FROMGIT: scsi: ufs: core: mcq: Configure resource regions
Define the MCQ resources and add support to ioremap the resource regions.

Co-developed-by: Can Guo <quic_cang@quicinc.com>
Change-Id: Ic2076877bf7761a7ca6a4dc85f5394a1faff38cd
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit c263b4ef737e622e2a908c58ca4bb68a89376387 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Asutosh Das
b3b62a7823 FROMGIT: scsi: ufs: core: mcq: Add support to allocate multiple queues
Multi-circular queue (MCQ) has been added in UFSHC v4.0 standard in
addition to the Single Doorbell mode.  The MCQ mode supports multiple
submission and completion queues.  Add support to allocate and configure
the queues.  Add module parameters support to configure the queues.

Co-developed-by: Can Guo <quic_cang@quicinc.com>
Change-Id: I4d8e0f058394d11966f910fe26a84f94bc0340b8
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 57b1c0ef89ac9d9e7475df7843aeb7672ebcd197 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Asutosh Das
0274bd8ea1 FROMGIT: scsi: ufs: core: Defer adding host to SCSI if MCQ is supported
If MCQ support is present, enabling it after MCQ support has been
configured would require reallocating tags and memory.  It would also free
up the already allocated memory in Single Doorbell Mode. So defer invoking
scsi_add_host() until MCQ is configured.

Co-developed-by: Can Guo <quic_cang@quicinc.com>
Change-Id: I87153313994b32a675a9dd0f78ea41bfdaaa0d55
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 0cab4023ec7b49b18145f74ab8389678d6d58878 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Asutosh Das
8bf0539f8b FROMGIT: scsi: ufs: core: Introduce multi-circular queue capability
Add support to check for MCQ capability in the UFSHC.  Add a module
parameter to disable MCQ if needed.

Co-developed-by: Can Guo <quic_cang@quicinc.com>
Change-Id: Ibad0b121314736b6bc6ae6a277b53d34dee0626e
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 305a357d3595d39be7c001f72e135bc94cbd85da git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Asutosh Das
880ec98359 FROMGIT: scsi: ufs: core: Probe for EXT_IID support
Task Tag is limited to 8 bits and this restricts the number of active I/Os
to 255.  In multi-circular queue mode, this may not be enough.  The
specification provides EXT_IID which can be used to increase the number of
I/Os if the UFS device and UFSHC support it.  This patch adds support to
probe for EXT_IID support in UFS device and UFSHC.

Co-developed-by: Can Guo <quic_cang@quicinc.com>
Change-Id: I6ad6c2d4f360626bfa8e9a94373d8a5c6893d9ec
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 6e1d850acff9477ae4c18a73c19ef52841ac2010 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Bean Huo
5ece8d4acf BACKPORT: FROMGIT: scsi: core: Fix invisible definition compilation warning
In 'include/ufs/ufshcd.h' file, 'enum dma_data_direction' will be used,
which is defined in linux/dma-direction.h, however, this header file is not
included in ufshcd.h, thus causing the following compilation warning:

"warning: ‘enum dma_data_direction’ declared inside parameter list will not
be visible outside of this definition or declaration"

Fix this warning by including 'linux/dma-direction.h'.

Fixes: 6ff265fc5ef6 ("scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg")
Reported-by: Xiaosen He <quic_xiaosenh@quicinc.com>
Reported-by: Bart Van Assche <bvanassche@acm.org>
Change-Id: If56d3463377fd4fc157a52807e1a3eccfc5209a2
Signed-off-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit f3e57da528127febae7eb03d9c87408d572b0fd8 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Manivannan Sadhasivam
ac7823b077 FROMGIT: scsi: ufs: ufs-qcom: Add support for finding max gear on new platforms
Starting from Qcom UFS version 4.0, vendor specific REG_UFS_PARAM0 register
can be used to determine the maximum gear supported by the controller.

Suggested-by: Can Guo <quic_cang@quicinc.com>
Reviewed-by: Andrew Halaney <ahalaney@redhat.com>
Tested-by: Andrew Halaney <ahalaney@redhat.com> # Qdrive3/sa8540p-ride
Change-Id: I44a1a54788b77b6072d8514e873515789e60deaf
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 2c407fe97015a063855fa518bd790f024f818277 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Manivannan Sadhasivam
3ce7942d7b FROMGIT: scsi: ufs: ufs-qcom: Add support for reinitializing the UFS device
Starting from Qualcomm UFS version 4, the UFS device needs to be
reinitialized after switching to maximum gear by the UFS core. Hence, add
support for it by enabling the UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH
quirk, implementing reinit_notify() callback and using the agreed gear
speed for setting the PHY mode.

Suggested-by: Can Guo <quic_cang@quicinc.com>
Tested-by: Andrew Halaney <ahalaney@redhat.com> # Qdrive3/sa8540p-ride
Change-Id: I2caf0076bca06385e53e6f6cd4e05e81b1f016ea
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit baf5ddac90dc1983bc376b7ca6fe1afde702ff29 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Manivannan Sadhasivam
022d55f476 FROMGIT: scsi: ufs: ufs-qcom: Factor out the logic finding the HS Gear
In the preparation of adding support for new gears, move the logic that
finds the gear for each platform to a new function. This helps with code
readability and also allows the logic to be used in other places of the
driver in future.

While at it, make it clear that this driver only supports symmetric gear
setting (hs_tx_gear == hs_rx_gear).

Reviewed-by: Andrew Halaney <ahalaney@redhat.com>
Tested-by: Andrew Halaney <ahalaney@redhat.com> # Qdrive3/sa8540p-ride
Change-Id: I518bf29d1c77f2368b922c6c272378cadf2bff98
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit c270986527f9fccb140826cbf3eff2cb1fccf463 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Manivannan Sadhasivam
5452d00c5a FROMGIT: scsi: ufs: core: Add support for reinitializing the UFS device
Some platforms like Qcom, requires the UFS device to be reinitialized after
switching to maximum gear speed. So add support for that in UFS core by
introducing a new quirk (UFSHCD_CAP_REINIT_AFTER_MAX_GEAR_SWITCH) and doing
the reinitialization, if the quirk is enabled by the controller driver.

Suggested-by: Can Guo <quic_cang@quicinc.com>
Tested-by: Andrew Halaney <ahalaney@redhat.com> # Qdrive3/sa8540p-ride
Change-Id: I838fde7f3987257f0611bb37ffc0a1683e8a5c58
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 96a7141da33207672d7a354c885d65af4f0f9b6c git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Manivannan Sadhasivam
58f39c30ec FROMGIT: scsi: ufs: core: Add reinit_notify() callback
reinit_notify() callback can be used by the UFS controller drivers to
perform changes required for UFSHCD reinit that can happen during max gear
switch.

Tested-by: Andrew Halaney <ahalaney@redhat.com> # Qdrive3/sa8540p-ride
Change-Id: Ieafb979fb0006f7bf6e0a4f357822a15d558c181
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit c2c38c573a2e6184f9acd10e98305d3cb5f1c62b git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Manivannan Sadhasivam
1f9d8816a4 FROMGIT: scsi: ufs: ufs-qcom: Fix the Qcom register name for offset 0xD0
On newer UFS revisions, the register at offset 0xD0 is called,
REG_UFS_PARAM0. Since the existing register, RETRY_TIMER_REG is not used
anywhere, it is safe to use the new name.

Reviewed-by: Andrew Halaney <ahalaney@redhat.com>
Reviewed-by: Asutosh Das <quic_asutoshd@quicinc.com>
Tested-by: Andrew Halaney <ahalaney@redhat.com> # Qdrive3/sa8540p-ride
Change-Id: I85d0bb15ef0c1af3be9fd3e8d9aa1e53225a64d7
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 7959587f3284bf163e4f1baff3c6fa71fc6a55b1 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Manivannan Sadhasivam
3257ea90d5 FROMGIT: scsi: ufs: ufs-qcom: Use dev_err_probe() for printing probe error
Make use of dev_err_probe() for printing the probe error.

Reviewed-by: Andrew Halaney <ahalaney@redhat.com>
Reviewed-by: Asutosh Das <quic_asutoshd@quicinc.com>
Tested-by: Andrew Halaney <ahalaney@redhat.com> # Qdrive3/sa8540p-ride
Change-Id: I83853e2aaed1a9f75c5d2ce48790c888451f94b0
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 132b027205ef94a1d933d0f08a4109b1e321bda2 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Manivannan Sadhasivam
5fcbd66ee4 FROMGIT: scsi: ufs: ufs-qcom: Use bitfields where appropriate
Use bitfield macros where appropriate to simplify the driver.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Asutosh Das <quic_asutoshd@quicinc.com>
Tested-by: Andrew Halaney <ahalaney@redhat.com> # Qdrive3/sa8540p-ride
Change-Id: Ie2b73d90c77269654a34b3823b599469b1cb2cb6
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 18fe2ab79bcf00c17d00460ca3f8c179d0aa87a4 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Manivannan Sadhasivam
17fa77a605 FROMGIT: scsi: ufs: ufs-qcom: Remove unnecessary WARN_ON()
In the reset assert and deassert callbacks, the supplied "id" is not used
at all and only the HBA reset is performed all the time. So there is no
reason to use a WARN_ON() on the "id".

Reviewed-by: Andrew Halaney <ahalaney@redhat.com>
Reviewed-by: Asutosh Das <quic_asutoshd@quicinc.com>
Tested-by: Andrew Halaney <ahalaney@redhat.com> # Qdrive3/sa8540p-ride
Change-Id: I498403cd74ca787acc69ec852e4e3e8087f24dc8
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit a98c2183e81d746d8d4d4443359a7c2876a14e3f git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Manivannan Sadhasivam
1a5b9da14f FROMGIT: scsi: ufs: ufs-qcom: Remove unnecessary goto statements
A goto statement in an error path is useful if the function needs to do
cleanup other than returning the error code. But in this driver, goto
statements are used for just returning the error code in many places. This
really makes it hard to read the code.

Get rid of those goto statements and just return the error code directly.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Asutosh Das <quic_asutoshd@quicinc.com>
Tested-by: Andrew Halaney <ahalaney@redhat.com> # Qdrive3/sa8540p-ride
Change-Id: I311b5dc3a38a408c121ef315e39319fb4aea4027
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 031312dbc6950a6a661f2f9ecfbc21fbc2e0e3e3 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Zhe Wang
5794efa0a2 FROMGIT: scsi: ufs: ufs-unisoc: Add support for Unisoc UFS host controller
Add driver code for Unisoc UFS host controller, along with UFS
initialization.

Change-Id: If768bbc760201c1c7f5acbf88d1d765cc8aa9352
Signed-off-by: Zhe Wang <zhe.wang1@unisoc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit df7320bac37e837f43883a51ce879c07c4429180 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 09:34:01 +00:00
Bart Van Assche
329abc0e50 ANDROID: scsi: ufs: Fix locking in ufshcd_queuecommand()
Commit 0fd420005c ("Merge 5.15.89 into android14-5.15") added an
rcu_read_lock() call in ufshcd_queuecommand() that is not present in the
upstream kernel. Since this makes locking in ufshcd_queuecommand()
unbalanced, remove that rcu_read_lock() call again.

Bug: 258234315
Change-Id: I555d91fe0aaabe95c9b762848b05af6c1ffc2be4
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-19 08:52:51 +00:00
Will McVicker
544ef44837 ANDROID: Update the ABI symbol list
Adding the following symbols:
  - android_debug_symbol
  - arch_freq_scale
  - bio_add_page
  - bio_alloc_bioset
  - bio_associate_blkg
  - bio_chain
  - bio_endio
  - bio_end_io_acct_remapped
  - bio_init
  - bio_put
  - bio_start_io_acct
  - __bitmap_andnot
  - bitmap_find_next_zero_area_off
  - __bitmap_or
  - __bitmap_set
  - __bitmap_xor
  - __blk_alloc_disk
  - blk_check_plugged
  - blk_cleanup_disk
  - blkdev_get_by_dev
  - blkdev_put
  - blk_queue_flag_clear
  - blk_queue_flag_set
  - blk_queue_io_min
  - blk_queue_io_opt
  - blk_queue_logical_block_size
  - blk_queue_max_discard_sectors
  - blk_queue_max_write_zeroes_sectors
  - blk_queue_physical_block_size
  - blk_status_to_errno
  - __cfg80211_alloc_event_skb
  - __cfg80211_alloc_reply_skb
  - cfg80211_chandef_create
  - cfg80211_ch_switch_notify
  - cfg80211_connect_done
  - cfg80211_del_sta_sinfo
  - cfg80211_disconnected
  - cfg80211_external_auth_request
  - cfg80211_find_elem_match
  - cfg80211_get_bss
  - cfg80211_ibss_joined
  - cfg80211_inform_bss_frame_data
  - cfg80211_mgmt_tx_status_ext
  - cfg80211_michael_mic_failure
  - cfg80211_new_sta
  - cfg80211_port_authorized
  - cfg80211_put_bss
  - cfg80211_ready_on_channel
  - cfg80211_register_netdevice
  - cfg80211_remain_on_channel_expired
  - cfg80211_roamed
  - cfg80211_rx_mgmt_ext
  - cfg80211_scan_done
  - cfg80211_sched_scan_results
  - cfg80211_sched_scan_stopped_locked
  - __cfg80211_send_event_skb
  - cfg80211_unlink_bss
  - cfg80211_unregister_wdev
  - cfg80211_update_owe_info_event
  - cfg80211_vendor_cmd_reply
  - cpufreq_get_policy
  - cpufreq_table_index_unsorted
  - cpu_hotplug_disable
  - cpu_hotplug_enable
  - cpumask_local_spread
  - crypto_alloc_base
  - crypto_comp_compress
  - crypto_comp_decompress
  - del_gendisk
  - dev_get_stats
  - device_add_disk
  - device_get_child_node_count
  - device_get_match_data
  - device_get_next_child_node
  - devm_input_allocate_device
  - __devm_irq_alloc_descs
  - devm_krealloc
  - __devm_regmap_init_spmi_ext
  - disk_end_io_acct
  - disk_start_io_acct
  - drm_dsc_pps_payload_pack
  - file_path
  - filp_close
  - filp_open_block
  - flush_dcache_page
  - fs_bio_set
  - fsnotify
  - __fsnotify_parent
  - fsync_bdev
  - fwnode_property_read_string
  - fwnode_property_read_u32_array
  - gether_cleanup
  - gether_connect
  - gether_disconnect
  - gether_get_dev_addr
  - gether_get_host_addr
  - gether_get_host_addr_u8
  - gether_get_ifname
  - gether_get_qmult
  - gether_register_netdev
  - gether_set_dev_addr
  - gether_set_gadget
  - gether_set_host_addr
  - gether_set_ifname
  - gether_set_qmult
  - gether_setup_name_default
  - get_task_cred
  - ida_destroy
  - ieee80211_channel_to_freq_khz
  - ieee80211_freq_khz_to_channel
  - ieee80211_get_channel_khz
  - input_alloc_absinfo
  - input_ff_create
  - interval_tree_insert
  - interval_tree_iter_first
  - interval_tree_iter_next
  - interval_tree_remove
  - int_pow
  - iommu_dma_enable_best_fit_algo
  - irq_domain_get_irq_data
  - irq_domain_set_info
  - irq_force_affinity
  - irq_to_desc
  - kfree_skb_reason
  - memchr
  - memset64
  - __memset_io
  - __mmap_lock_do_trace_acquire_returned
  - __mmap_lock_do_trace_released
  - __mmap_lock_do_trace_start_locking
  - ns_capable
  - of_find_node_with_property
  - of_platform_device_create
  - of_platform_device_destroy
  - page_endio
  - pci_msi_mask_irq
  - pci_msi_unmask_irq
  - pkvm_iommu_s2mpu_init
  - pkvm_iommu_s2mpu_register
  - platform_get_irq_optional
  - pm_runtime_get_if_active
  - proc_set_size
  - __put_cred
  - reboot_mode
  - __register_blkdev
  - regulatory_hint
  - regulatory_set_wiphy_regd
  - regulatory_set_wiphy_regd_sync
  - rtnl_trylock
  - sched_set_fifo
  - sched_set_normal
  - set_blocksize
  - set_capacity
  - set_capacity_and_notify
  - set_user_nice
  - spmi_controller_add
  - spmi_controller_alloc
  - spmi_controller_remove
  - __spmi_driver_register
  - submit_bio
  - submit_bio_wait
  - suspend_set_ops
  - __tasklet_hi_schedule
  - __traceiter_android_rvh_arm64_serror_panic
  - __traceiter_android_rvh_cgroup_force_kthread_migration
  - __traceiter_android_rvh_die_kernel_fault
  - __traceiter_android_rvh_do_mem_abort
  - __traceiter_android_rvh_do_ptrauth_fault
  - __traceiter_android_rvh_do_sea
  - __traceiter_android_rvh_do_sp_pc_abort
  - __traceiter_android_rvh_do_undefinstr
  - __traceiter_android_rvh_enqueue_task
  - __traceiter_android_rvh_panic_unhandled
  - __traceiter_android_rvh_select_task_rq_fair
  - __traceiter_android_rvh_set_cpus_allowed_by_task
  - __traceiter_android_rvh_set_task_cpu
  - __traceiter_android_rvh_typec_tcpci_get_vbus
  - __traceiter_android_rvh_ufs_complete_init
  - __traceiter_android_rvh_ufs_reprogram_all_keys
  - __traceiter_android_rvh_update_rt_rq_load_avg
  - __traceiter_android_vh_binder_restore_priority
  - __traceiter_android_vh_binder_set_priority
  - __traceiter_android_vh_dump_throttled_rt_tasks
  - __traceiter_android_vh_dup_task_struct
  - __traceiter_android_vh_enable_thermal_genl_check
  - __traceiter_android_vh_typec_store_partner_src_caps
  - __traceiter_android_vh_typec_tcpci_override_toggling
  - __traceiter_android_vh_typec_tcpm_get_timer
  - __traceiter_android_vh_typec_tcpm_log
  - __traceiter_android_vh_ufs_update_sdev
  - __traceiter_mmap_lock_acquire_returned
  - __traceiter_mmap_lock_released
  - __traceiter_mmap_lock_start_locking
  - __tracepoint_android_rvh_arm64_serror_panic
  - __tracepoint_android_rvh_cgroup_force_kthread_migration
  - __tracepoint_android_rvh_die_kernel_fault
  - __tracepoint_android_rvh_do_mem_abort
  - __tracepoint_android_rvh_do_ptrauth_fault
  - __tracepoint_android_rvh_do_sea
  - __tracepoint_android_rvh_do_sp_pc_abort
  - __tracepoint_android_rvh_do_undefinstr
  - __tracepoint_android_rvh_enqueue_task
  - __tracepoint_android_rvh_panic_unhandled
  - __tracepoint_android_rvh_select_task_rq_fair
  - __tracepoint_android_rvh_set_cpus_allowed_by_task
  - __tracepoint_android_rvh_set_task_cpu
  - __tracepoint_android_rvh_typec_tcpci_get_vbus
  - __tracepoint_android_rvh_ufs_complete_init
  - __tracepoint_android_rvh_ufs_reprogram_all_keys
  - __tracepoint_android_rvh_update_rt_rq_load_avg
  - __tracepoint_android_vh_binder_restore_priority
  - __tracepoint_android_vh_binder_set_priority
  - __tracepoint_android_vh_dump_throttled_rt_tasks
  - __tracepoint_android_vh_dup_task_struct
  - __tracepoint_android_vh_enable_thermal_genl_check
  - __tracepoint_android_vh_typec_store_partner_src_caps
  - __tracepoint_android_vh_typec_tcpci_override_toggling
  - __tracepoint_android_vh_typec_tcpm_get_timer
  - __tracepoint_android_vh_typec_tcpm_log
  - __tracepoint_android_vh_ufs_update_sdev
  - __tracepoint_mmap_lock_acquire_returned
  - __tracepoint_mmap_lock_released
  - __tracepoint_mmap_lock_start_locking
  - ufshcd_auto_hibern8_update
  - unregister_blkdev
  - ___update_load_avg
  - ___update_load_sum
  - usb_assign_descriptors
  - usb_ep_alloc_request
  - usb_ep_disable
  - usb_ep_enable
  - usb_ep_free_request
  - usb_ep_queue
  - usb_free_all_descriptors
  - usb_gadget_activate
  - usb_gadget_deactivate
  - usb_gstrings_attach
  - usb_os_desc_prepare_interf_dir
  - vprintk_emit
  - wiphy_free
  - wiphy_new_nm
  - wiphy_register
  - wiphy_unregister
  - zs_compact
  - zs_create_pool
  - zs_destroy_pool
  - zs_free
  - zs_get_total_pages
  - zs_huge_class_size
  - zs_malloc
  - zs_map_object
  - zs_pool_stats
  - zs_unmap_object

Bug: 259083761
Change-Id: I81e1d7274faaf4f6b8f9d000e353269ee5182ae8
Signed-off-by: Will McVicker <willmcvicker@google.com>
2023-01-18 20:01:08 +00:00
Bart Van Assche
beae65628d BACKPORT: FROMGIT: scsi: ufs: core: Allow UFS host drivers to override the sg entry size
Modify the UFSHCD core to allow 'struct ufshcd_sg_entry' to be
variable-length. The default is the standard length, but variants can
override ufs_hba::sg_entry_size with a larger value if there are
vendor-specific fields following the standard ones.

This is needed to support inline encryption with ufs-exynos (FMP).

Cc: Eric Biggers <ebiggers@google.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Change-Id: I4fa3303b0ed70951ea4ec345bb3d58c6a008917d
Signed-off-by: Eric Biggers <ebiggers@google.com>
[ bvanassche: edited commit message and introduced CONFIG_SCSI_UFS_VARIABLE_SG_ENTRY_SIZE ]
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit ada1e653a5eae7361d95781ed812caa0c8e07dbb git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
[ bvanassche: backported this patch to the Android kernel tree ]
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-18 10:12:49 -08:00
Bart Van Assche
2dffc600ca ANDROID: scsi: core: Delay unaligned write error retries
Host-managed zoned block devices report the sense code 21h/04h
(UNALIGNED WRITE COMMAND) when attempting to write data at another LBA
than the write pointer. Retry unaligned writes after all other pending
commands have completed instead of retrying these immediately. The
change in this patch makes the following function decide to queue the
failed command to the error handler instead of retrying it immediately:

static void scsi_complete(struct request *rq)
{
	[ ... ]
	switch (disposition) {
	case SUCCESS:
		scsi_finish_command(cmd);
		break;
	case NEEDS_RETRY:
		scsi_queue_insert(cmd, SCSI_MLQUEUE_EH_RETRY);
		break;
	case ADD_TO_MLQUEUE:
		scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY);
		break;
	default:
		scsi_eh_scmd_add(cmd);
		break;
	}
}

This patch has not been posted on any Linux kernel mailing list since
there is agreement that another approach will be taken to preserve the
order of WRITE commands for zoned devices. However, the implementation
of that new approach is not yet available.

Bug: 197782466
Change-Id: I3529ce4f01ff166a0c8ac321eb31b0e7771906ac
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-18 17:45:13 +00:00
Treehugger Robot
a27981ad08 Merge "Merge 5.15.89 into android14-5.15" into android14-5.15 2023-01-18 14:40:05 +00:00
Treehugger Robot
6b36a1ab4d Merge "Merge 5.15.88 into android14-5.15" into android14-5.15 2023-01-18 14:33:30 +00:00
Treehugger Robot
989c5fae3b Merge "Merge 5.15.87 into android14-5.15" into android14-5.15 2023-01-18 14:33:30 +00:00
Treehugger Robot
e4c79d18eb Merge "Merge 5.15.86 into android14-5.15" into android14-5.15 2023-01-18 14:33:30 +00:00
Sebastian Ene
fe0be0c1c4 ANDROID: KVM: arm64: Coalesce host stage2 entries on ownership reclaim
This optimization allows us to re-create higher order block mappings in
the host stage2 pagetables after we teardown a guest VM. The coalescing
code is triggered on host_stage2_set_owner_locked path when we annotate
the entries in the host stage2 page-tables with an invalid entry that has
the owner set to PKVM_ID_HOST. This can also be triggered from
page_relinquish when we do page insertion in the ballooning code.

When the host reclaims ownership during guest teardown, the page table
walker drops the refcount of the counted entries and clears out
unreferenced entries (refcount == 1). Clearing out the entry installs a
zero PTE. When the host stage2 receives a data abort because there is no
mapping associated, it will try to create the largest possible block
mapping from the founded leaf entry.
With the current patch, we increase the chances of finding a leaf entry
that has level < 3 if the requested region comes from a reclaimed torned
down VM memory. This has the advantage of reducing the TLB pressure at
host stage2.

To be able to do coalescing, we modify the way we do refcounting by not
counting the following descriptor types at host stage 2:
- non-zero invalid PTEs
- any descriptor that has at least one of the reserved-high bits(58-55)
toogled
- non-default attribute mappings
- page table descriptors

The algorithm works as presented below:

  Is refcount(child(pte_table)) == 1 ?

  Yes -> (because we left only default mappings)
	Zap the table by setting 0 in the pte_table
	and put the page that holds the level 3 entries
	back into the memcache

  level 2
+---------+
|         |
|  ...    |
| pte_table---+      level 3      -> we can now re-create a 2Mb mapping
|  ...    |   +---> +---------+
|         |         |         |
|         |         |         |
|         |         |def entry|
+---------+         |         |
                    |def entry|
                    |         |
                    |  ...    |
                    +---------+

Bug: 222044487
Test: dump the host stage2 pagetables and view the mapping
Change-Id: Ib2bb3d9b5f7d2d89ae67393b59ec8bfa6c1a120c
Signed-off-by: Sebastian Ene <sebastianene@google.com>
2023-01-18 14:01:50 +00:00